• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=Gulen;39903731][url]https://developer.valvesoftware.com/wiki/User:Daeval/Weapon_Basics#Functional_Properties[/url] It seems that it's not defined in the C++, but in a txt file. (note, I'm pretty certain that servers have their own copy of that file, and it'll use that to calculate the damage dealt in Multiplayer)[/QUOTE] I know of those text files, but they don't have a "damage" line. When I add one, it doesn't effect the damage of the weapon any. I'm building my source mod on the 2007 engine if that helps to locate the file I need to modify.
So I started doing the KeyPressed and KeyReleased thing, and to test it to make sure it works, I wrote the following: [code] private class Key extends KeyAdapter { public void keyPressed(KeyEvent e, int key) { if(e.getKeyCode() == KeyEvent.VK_W) { nkUpKeyDown=true; System.out.println(nkUpKeyDown); } if(e.getKeyCode() == KeyEvent.VK_S) { nkDownKeyDown=true; System.out.println(nkDownKeyDown); } if(e.getKeyCode() == KeyEvent.VK_UP) { skUpKeyDown=true; System.out.println(skUpKeyDown); } if(e.getKeyCode() == KeyEvent.VK_DOWN) { skDownKeyDown=true; System.out.println(skDownKeyDown); } } public void keyReleased(KeyEvent e, int key) { if(e.getKeyCode() == KeyEvent.VK_W) { nkUpKeyDown=false; System.out.println(nkUpKeyDown); } if(e.getKeyCode() == KeyEvent.VK_S) { nkDownKeyDown=false; System.out.println(nkDownKeyDown); } if(e.getKeyCode() == KeyEvent.VK_UP) { skUpKeyDown=false; System.out.println(skUpKeyDown); } if(e.getKeyCode() == KeyEvent.VK_DOWN) { skDownKeyDown=false; System.out.println(skDownKeyDown); } } } [/code] It compiles with no errors but when I press the up or down keys (or w/s keys) it prints nothing in the console.
I'm thinking of how to solve the physics problem of going through things if you go too fast, is making a ray between your current and next position and seeing if there's anything colliding between it a good solution?
[QUOTE=Shadaez;39909251]I'm thinking of how to solve the physics problem of going through things if you go too fast, is making a ray between your current and next position and seeing if there's anything colliding between it a good solution?[/QUOTE] Isn't it just like normal collision but with a larger step size?
[QUOTE=DoctorSalt;39889398]Hey, so I just got Visual Studio 2012 to cooperate with their git extension. Now I tried to create a new branch, but whenever I do it displays this: [IMG]http://i.imgur.com/L3Wn3zm.png[/IMG] Very cryptic to me, google was useless. Also, I didn't seem to have this problem in my trivial little test program to figure git out. EDIT: Before someone says, "just learn to use git normally", I've tried so hard, but it seems with git there is no abstractions, just a giant semi-consistent mess of commands geared towards experienced devs; I just can't do it. EDITITED: Linus is doing a shit job of making me like him. Also, whoever was talking about VS 2012, if you're a student the professional version is free. Get it, it is awesome.[/QUOTE] Did you install the Update 2 CTP as well? I don't think the Git extension needs it but it's worth a try.
[QUOTE=SteveUK;39910952]Did you install the Update 2 CTP as well? I don't think the Git extension needs it but it's worth a try.[/QUOTE] I did. Anyways, I restarted that project and now it's not having problems, so unless it comes up again I suppose I'm good. My guess is that it's related to how it comes up with Branch ID's or something
[QUOTE=Protocol7;39900183]If I'm filling values into a search three how the hell do I compare something like A123 with 4567? Which value is larger and why?[/QUOTE] split pure numbers and num+letters so if you have 1123, 1345, a345, b345, a123 it should be listed as 1123>1345>a123>a345>b345 for a23, 1a2, and 11a, 11a is the largest one as it has numbers in front and 1a2 is the second then a23 is the third because it has a letter in front of it so its a loser. or reserve it and make letters more important than numbers, basically im saying 1 is the number 1 and a is the number 30. we are in base 10 but disregard that oh shit I just said same thing thrice. well pick your best reading
In that case, couldn't he just compare the characters' ascii value?
[QUOTE=prooboo;39907912]So I started doing the KeyPressed and KeyReleased thing, and to test it to make sure it works, I wrote the following: It compiles with no errors but when I press the up or down keys (or w/s keys) it prints nothing in the console.[/QUOTE] Didja [URL="http://docs.oracle.com/javase/6/docs/api/java/awt/Component.html#addKeyListener(java.awt.event.KeyListener)"]add a key listener[/URL] anywhere? So like in whatever class implements KeyListener add the line [code]this.addKeyListener(this);[/code] in the constructor or something. [editline]14th March 2013[/editline] Or rather in the panel or whatever jcomponent your a running do this: (ignore what is above, your Key class isn't a JComponent). [code]this.addKeyListener(new Key());[/code]
[QUOTE=Gulen;39914669]In that case, couldn't he just compare the characters' ascii value?[/QUOTE] well there is upper-case and lower-case thing but more or less yeah he could do that.
Whenever I try to add something into R.java for my Android app, it gets deleted the minute I save. What am I doing wrong?
[QUOTE=Vault;39917857]Whenever I try to add something into R.java for my Android app, it gets deleted the minute I save. What am I doing wrong?[/QUOTE] r.java is auto matically generated, youre not supposed to add things to it. i think
[QUOTE=egomanyak;39915065]well there is upper-case and lower-case thing but more or less yeah he could do that.[/QUOTE] Yeah, he'd have to do an all-uppercase or all-lowercase first, unless he knows that the input is always lower or always uppercase. [editline]15th March 2013[/editline] [QUOTE=Vault;39917857]Whenever I try to add something into R.java for my Android app, it gets deleted the minute I save. What am I doing wrong?[/QUOTE] [QUOTE=a-k-t-w;39917921]r.java is auto matically generated, youre not supposed to add things to it. i think[/QUOTE] True, it even says so in the file itself. And if you're using Eclipse, it's under the gen category.
Starting to mess with Love and Lua and stuff. After doing some reading and stuff I've started just throwing stuff into a program and seeing what it does. Why does some of the text move with the mouse but not the rest...? Very much confused [code] function love.load() love.physics.setMeter(64) --the height of a meter our worlds will be 64px world = love.physics.newWorld(0, 9.81*64, true) --create a world for the bodies to exist in with horizontal gravity of 0 and vertical gravity of 9.81 objects = {} -- table to hold all our physical objects f = 0 --let's create the ground objects.ground = {} objects.ground.body = love.physics.newBody(world, 650/2, 650-50/2) --remember, the shape (the rectangle we create next) anchors to the body from its center, so we have to move it to (650/2, 650-50/2) objects.ground.shape = love.physics.newRectangleShape(650, 50) --make a rectangle with a width of 650 and a height of 50 objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape); --attach shape to body --let's create a ball objects.ball = {} objects.ball.body = love.physics.newBody(world, 650/2, 650/2, "dynamic") --place the body in the center of the world and make it dynamic, so it can move around objects.ball.shape = love.physics.newCircleShape(20) --the ball's shape has a radius of 20 objects.ball.fixture = love.physics.newFixture(objects.ball.body, objects.ball.shape, 1) -- Attach fixture to body and give it a density of 1. objects.ball.fixture:setRestitution(0.6) --let the ball bounce --let's create a couple blocks to play around with objects.block1 = {} objects.block1.body = love.physics.newBody(world, 200, 550, "dynamic") objects.block1.shape = love.physics.newRectangleShape(0, 0, 50, 100) objects.block1.fixture = love.physics.newFixture(objects.block1.body, objects.block1.shape, 5) -- A higher density gives it more mass. objects.block2 = {} objects.block2.body = love.physics.newBody(world, 200, 400, "dynamic") objects.block2.shape = love.physics.newRectangleShape(0, 0, 100, 50) objects.block2.fixture = love.physics.newFixture(objects.block2.body, objects.block2.shape, 2) --initial graphics setup love.graphics.setBackgroundColor(104, 136, 248) --set the background color to a nice blue love.graphics.setMode(1700, 900, false, true, 0) --set the window dimensions to 650 by 650 end function love.update(dt) world:update(dt) --this puts the world into motion objects.ball.body:applyForce(0, f) --here we are going to create some keyboard events if love.keyboard.isDown("right") then --press the right arrow key to push the ball to the right objects.ball.body:applyForce(400, 0) elseif love.keyboard.isDown("left") then --press the left arrow key to push the ball to the left objects.ball.body:applyForce(-400, 0) end if love.keyboard.isDown("up") then --press the up arrow key to set the ball in the air f = f - 1 elseif love.keyboard.isDown("down") then f = f + 1 end mx, my = love.mouse.getPosition() end function love.draw() love.graphics.setColor(72, 160, 14) -- set the drawing color to green for the ground love.graphics.polygon("fill", objects.ground.body:getWorldPoints(objects.ground.shape:getPoints())) -- draw a "filled in" polygon using the ground's coordinates love.graphics.setColor(193, 47, 14) --set the drawing color to red for the ball love.graphics.circle("fill", objects.ball.body:getX(), objects.ball.body:getY(), objects.ball.shape:getRadius()) love.graphics.setColor(50, 50, 50) -- set the drawing color to grey for the blocks love.graphics.polygon("fill", objects.block1.body:getWorldPoints(objects.block1.shape:getPoints())) love.graphics.polygon("fill", objects.block2.body:getWorldPoints(objects.block2.shape:getPoints())) love.graphics.translate (mx-1700/2, my-900/2) -- Mouse moving thingy love.graphics.print(f, 100,100) love.graphics.print(mx.. " : ".. my, 100,120) -- Moving text in question end [/code] Code in question is right at the bottom more or less. I went back to it and suddenly both text is moving. I don't understand anything.
For some reason, my form doesn't close even after Yes is clicked in the MessageBox. Does anyone have any idea why? [code] protected override void OnClosing(CancelEventArgs e) { if (MessageBox.Show(this, "Are you sure you want to close the form?", "Verify", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No) { e.Cancel = true; } else { // make sure everything is set for the form to close } base.OnClosing(e); } [/code]
Can anyone else help me with this quick question regarding slick? (Might actually be just a Java question) To draw an Image in slick, I need to put it in a render method. I write the line [code]i.draw(x,y)[/code] where i is the image object created previously. I want to make a class that will put together one of these Images and then I want to be able to call it to show up or not show up at a certain place in the render method. I'm really not too sure how I can go about this. Like, for example. I have this fancy looking rectangle. I want to make a class that would throw this image together that consists of that rectangle, plus formatted text on the inside that would fit in the fancy looking rectangle. Would I have to use a different class for that? To maybe help visualize it, I want to make a visual novel lookin' thing just as something to try out, and I want to get be able to make a textbox at the bottom that can have text inside, able to be drawn at will. Also, another issue. In the Update logic method, I have it so if you roll over the mouse onto a button, it plays a ding noise. However, when I keep it on the button, it plays over and over and over again. How would I get it so it only goes ding once while it's moused over? D: This is the code I have now [code] public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException //Logic Portion { Input input = gc.getInput(); if(first) { bgM.play(1f,0.5f); first = false; } if(input.isKeyPressed(Input.KEY_ESCAPE)){ sbg.enterState(0); } if(counter == 3) { counter = 0; } if(input.isKeyPressed(Input.KEY_END)) { if(counter < 3) { herp = script[counter]; counter++; } } } [/code]
for the ding noise. Each time you hit the update method, save the location of mouse as newMouseLocation, and once you do your processing save it as oldMouseLocation. Only play the sound if the oldMouseLocation is NOT within the bounds of the button and newMouseLocation IS within the bounds of the button.
Actual question this time. Say I want to create a program in Love/Lua so that when you press a button (Doesn't matter what really) it draws a line between two points that you previously set (Last two mouse clicks for example) which will stay there indefinitely? How do you do that? Only thought that's come to mind is like, having a function that adds those two coordinates to a table and just have the table drawn constantly as coordinates for the line, except then you'll have a massive line going everywhere instead of separate lines. Any help?
In lisp does a "proper list" have to be explicitly terminated with nil? [code] (defun range (start stop) (if (< start stop) (cons start (range (+ start 1) stop)))) (print (range 0 10)) ==> (0 1 2 3 4 5 6 7 8 9) (defun range (start stop) (if (< start stop) (cons start (range (+ start 1) stop)) '(nil))) (print (range 0 10)) ==> (0 1 2 3 4 5 6 7 8 9 NIL) [/code] In the first is the last cdr implicitly pointing to the nil atom? What is the difference between the two exactly and which one is "better"? [editline]16th March 2013[/editline] I would assume the NIL that is displayed in the second one is actually in the car of the final pair, so it is actually the "data", but I am still confused as to what the cdr of the final element points to.
This either crashes, or when I run the debug exe it gives me this: [IMG]http://i.imgur.com/BlirsMT.png[/IMG] [cpp] //main.cpp #include "MapParser.h" int main() { //sf::RenderWindow wnd(sf::VideoMode(800, 600, 32), "Map Parser"); Parser parser; Map map = parser.ReadMap("map1.txt"); parser.PrintMap(map); /* while(true) { wnd.display(); } */ std::cin.get(); return 0; } [/cpp] [cpp] // MapParser.h #include "incs.h" #include "Map.h" class Parser { public: Map ReadMap(std::string fileName); void PrintMap(Map map); }; Map Parser::ReadMap(std::string fileName) { std::fstream mapFile; Map map; mapFile.open(fileName, std::ios::in); while(!mapFile.eof()) { std::string lineMap; getline(mapFile, lineMap); map.lines.push_back(lineMap); } return map; } void Parser::PrintMap(Map map) { for(int i = 0; i = map.lines.size(); i++) { std::cout << map.lines.at(i) << "\n"; } } [/cpp] [cpp] // Map.h #include "incs.h" struct Map { std::vector<std::string> lines; }; [/cpp] [cpp] // incs.h #pragma once #include <SFML/Graphics.hpp> #include <iostream> #include <Windows.h> #include <fstream> #include <vector> [/cpp] Help
Have you pressed the "retry" button to find out where in the code it happens?
[QUOTE=Guzbone;39928430]Actual question this time. Say I want to create a program in Love/Lua so that when you press a button (Doesn't matter what really) it draws a line between two points that you previously set (Last two mouse clicks for example) which will stay there indefinitely? How do you do that? Only thought that's come to mind is like, having a function that adds those two coordinates to a table and just have the table drawn constantly as coordinates for the line, except then you'll have a massive line going everywhere instead of separate lines. Any help?[/QUOTE] Gonna type up som pseudo code here, to get you on the right track. [cpp]Vector2D firstCord, secondCord; onMouseClick(int MouseX, int MouseY){ if(firstCord.X <= 0 || firstCord.Y <= 0){ // If the first cord is empty, the second is as well firstCord.X = MouseX; firstCord.Y = MouseY; } else if((firstCord.X > 0 || firstCord.Y > 0) && (secondCord.X <= 0 && secondCord.Y <= 0){ // If we have a first coordinate, but not the second secondCord.X = MouseX; secondCord.Y = MouseY; } else { // If we have a first coordinate and a second one firstCord.X = secondCord.X; firstCord.Y = secondCord.Y; secondCord.X = MouseX; secondCord.Y = MouseY; } // We're done! }[/cpp] [editline]16th March 2013[/editline] So basically, you have two coordinates, and when you click the mouse the third time, we move the coordinates up (so the first one disappears, and the second is now the first)
Does anybody know of any API for stocks, which I can query through http? (Preferably not something I need to download, more like an URL API or what it's called)
[QUOTE=Donkie;39931693]Does anybody know of any API for stocks, which I can query through http? (Preferably not something I need to download, more like an URL API or what it's called)[/QUOTE] [url=http://www.blogbyben.com/2009/01/truly-simple-stock-api.html]I had a little look and I found something that may be what you are looking for.[/url]
[QUOTE=MakeR;39931715][url=http://www.blogbyben.com/2009/01/truly-simple-stock-api.html]I had a little look and I found something that may be what you are looking for.[/url][/QUOTE] Looks good, Thanks!
Is this a bug in Python, or am I missing something? Class Child inherits from Class Parent. Class Parent has methods called A and B. Class Child has only a method called A. In Class Parent's constructor, when trying to access both self.A and self.B, both are Child's methods, even if Child.B doesn't even exist. [code] class ParentTest: def __init__(self): print self.a print self.b def a(self): print "Parent function" def b(self): print "Parent function" class ChildTest(ParentTest): def a(self): print "Child function" test = ChildTest() [/code] result: [code] <bound method ChildTest.a of <__main__.ChildTest instance at 0x024ECB48>> <bound method ChildTest.b of <__main__.ChildTest instance at 0x024ECB48>> [/code] Wtf?
Exactly what are you expecting to happen? Parent has a method b. Child inherits parent, therefore child must have a method b as well. If you were to call a and b from the constructor, you would see output like [code]Parent function Child function[/code]
[QUOTE=Robbis_1;39931343]Have you pressed the "retry" button to find out where in the code it happens?[/QUOTE] Yes, it crashes
[QUOTE=raccoon12;39934899]Yes, it crashes[/QUOTE] Have you tried stepping through the program?
[QUOTE=ThePuska;39932002]Exactly what are you expecting to happen? Parent has a method b. Child inherits parent, therefore child must have a method b as well. If you were to call a and b from the constructor, you would see output like [code]Parent function Child function[/code][/QUOTE] Yeah, I ran it and found that out. You're right that it inherits the function, even if it doesn't override it. Thanks.
Sorry, you need to Log In to post a reply to this thread.