Results 1 to 4 of 4
Thread: Beginner Java Modding Problem...
- 04-13-2011, 02:35 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 7
- Rep Power
- 0
Beginner Java Modding Problem...
Hello im trying to use Keyboard.isKeyDown to create a way to make it so if the button is pressed something will happen and if I press the button again it will stop. I have the basic concept worked out, and I HAD it working with another thing but for some reason this code won't work (im making mods for a Java game using Java Eclipse EE):
whattodo and buttonpress are booleans and moty is a double. moty is the variable for MotionY. Later on in this code I use this (or something like it, its not the exact code) to call itJava Code:if(Keyboard.isKeyDown(36) && buttonpress==false){ buttonpress=true; whattodo=!whattodo; } if(!Keyboard.isKeyDown(36)){ buttonpress=false; } if(whattodo=false){ moty=0.41999998688697815D; } if(whattodo=true){ moty=0.71999998688697815D; }
Im trying to make it so when I press "J" or J = true MotionY is .3 higher (A very noticable difference)Java Code:Public class Jump(){ MotionY = moty; }Last edited by walkineagle; 04-13-2011 at 02:37 AM.
-
Use a Swing Timer. I would also use key binding rather than a key listener to check for key press.
Also, this is messed up:
You are not checking for equality which uses ==, but you don't even want to. To check if a boolean is true you simply doJava Code:if(whattodo=false){ moty=0.41999998688697815D; // ??? what's the D for ??? } if(whattodo=true){ moty=0.71999998688697815D; }
Java Code:if (!whattodo) { moty=0.41999998688697815; } else { moty=0.71999998688697815; }
- 04-13-2011, 03:33 AM #3
Member
- Join Date
- Apr 2011
- Posts
- 7
- Rep Power
- 0
Okay so I tried this and it doesn't work... MotionY always stays at the .4 one.
Java Code:protected void jump() { if(Keyboard.isKeyDown(36) && !buttonpress){ buttonpress=true; whattodo=!whattodo; } if(!Keyboard.isKeyDown(36)){ buttonpress = false; } if (!whattodo) { moty=0.41999998688697815D; } else { moty=0.71999998688697815D; } motionY = moty; }
- 04-13-2011, 04:20 AM #4
Member
- Join Date
- Apr 2011
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Beginner Problem
By Freakzoyd in forum New To JavaReplies: 6Last Post: 07-20-2010, 01:23 PM -
Beginner in Java - need some help
By ea09530 in forum Advanced JavaReplies: 4Last Post: 04-05-2010, 11:47 PM -
java beginner
By devstarter in forum New To JavaReplies: 4Last Post: 03-03-2010, 08:39 AM -
Java Beginner needs help!!
By Polyy in forum New To JavaReplies: 4Last Post: 11-23-2008, 02:11 AM -
beginner to Java
By notwist in forum New To JavaReplies: 15Last Post: 04-18-2008, 09:41 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks