I am making a battle game and need to have a program to make something jump.
This is to general of a question. The answer would be to track the vertical speed of the actor, increase the speed each act cycle for gravity and set the speed to some nominal negative number to initiate a jump. If you have issues with any of these (1) specify which one (2) show what code you tried (3) explain what adverse behavior you are getting -- etc.
I am a beginner so I do not understand what you mean. Do you have a different way of explaining it?
Gravity pulls your character downward -- in the direction where the y-coordinate will increase. When gravity is constantly applied, the speed of the character, if allowed to move freely, will increase as time passes if falling (and decrease if rising). So, if you have a field to track the speed along the vertical axis, you would add a constant to it every act cycle and then move the character according to the new speed value. Normally, if an obstacle or the bottom edge of the world is encountered the vertical location of the character would be adjusted so as to stop the movement at the contact point and the speed value will be zeroed. When jumping, you need the speed value to be some negative number (going upward the coordinate along the vertical decreases) so that the character will rise each act with decreasing speeds as gravity is applied.
So, how would I make a field to track the vertical axis. All I know to do is to make the crab game listed as an example in documentation. BTW. Thanks a lot for your help. I really appreciate it.
So, how would I make a field to track the vertical axis. All I know to do is to make the crab game listed as an example in documentation. BTW. Thanks a lot for your help. I really appreciate it.
Similar to how you make a 'wormsEaten' field. You may have to refer to Mik's blog A first look at variables (the Joy of Code video #14) to see how you work with fields. You could also refer to the Java tutorial's page on variables.
You gave the complete program to The Invinity Scrolling guy (Jaki). Why don't you give me a program. Please just give me the whole Program and I will leave you alone.
He won't give you "the program". Stop begging like that and use the advices that he gave you to make your character jump. Learning by doing! Try to understand what and how you are programming instead of copying other's code.