954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Jumping on an object

Hey I am making a game and i can make the character jump, but i am trying to make the character land on an object. I am trying to do this with object collision but im not sure how. My code for jumping for an image with a certain height is below. I was trying to do it when the character jumps to a certain height and collides with an object, its new location on the screen will be on top of the object but i am not sure how to add that in. any suggestions would be great.

//METHOD TO JUMP
	public void jump(){
		if(peak == false)
			v--;//character jumping
		if(v == 250)//max height for jump
			peak = true;
		if(peak == true && v <= 300){//returning to ground
			v++;
			if(v == 300){
				done = true;
			}
		}
	}
corby
Junior Poster
118 posts since Feb 2010
Reputation Points: 6
Solved Threads: 5
 

No idea what your code is supposed to do.
Can you explain your problem in terms of x and y values?
You have a character at one x,y location and an object at another x,y location.
Then what do you want to happen?
How are the x,y values changing for the two items in question?

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: