Sean Panting

Greenhorn
+ Follow
since Oct 13, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Sean Panting

well... i know nothing about physics, but wat i have come up with that will fit your needs perfectly is the set of code below:

basically, it calculates the new x coordinate by taking x and adding it to the x axis speed minus friction. It calculates the new y coordinate by adding the current y to gravity plus y axis speed plus equals to gravity minus friction. you shall get a nice upward spring that gradually will make the object follow a arc... an arc like a really ball or something like that would look. so its realistic. if you need each jump to be successively smaller, this doesnt account for that. it performs the same jump arc every time... so, for wat i think you need, this will work just fine. Also, dont set friction or grav to like 3... it needs to be like 0.25 or 1.11... try it, and, if it does what i think itll do, you know why not to do it. oh, the variables need to be doubles... and yspd MUST be limited to a value below 20... it would do the same thing as setting the gravity and\or the friction to a big number... . variables: Friction(fric), x axis speed(xspd), gravity(grav), y axis speed(yspd). oh, to make the object jump, you need to put in the keylistener this little piece of code: Y*=-1;
13 years ago
Hello... im trying to make a game for my java programming class at school because of an assignment... anyways... its a game where you have to get the bouncing ball thru a hole in the wall, something like pong. well, ive got it all pretty much figured out... the problem im having is the physics on the ball. i did research on this already, and after some testing, created a class Ball that worked well for my other bouncy ball related game, but not this one. here's the code for class ball:

this actually works kinda fine. the ball actually works like a real ball... it starts going sideways, then goes more downward, and bounces off the bottom of the screen, and basically does an arc. it works, except the fact that each successive bounce is the same height as the one before. and there are probably other flaws to. but it still kinda works, for my needs. but its not random enough. the path of the ball is the same, it iterates 3 different paths, then starts over. i need the ball to be much more random. just for clarification, it follows the same arc every time, and the drop angle, thats the same every time, is wats causing the ball to not go thru the hole in the wall. if somebody could help me out, that would be great, thanks.
13 years ago
I'm trying to create an applet of a rain storm. i've already have the program working, pretty much. the only problem that i have is... well let me explain it this way: RainDrop is the class that has the methods to draw the raindrop to the screen, move it down the screen, and destroy it when it reaches the bottom of the frame. (Note: if you want 20 raindrops on the screen, you need 20 instances of RainDrop by the way i have it setup.) each instance of RainDrop implements Runnable. the run methods of each class will paint a blue oval to the screen, move the coordinates down, then call repaint(). this paints to an image, ALL instances of raindrop paint to one image, then the call to paint well paints that image onto the frame, double buffering it. the problem i'm having is the stupid Thread system in java. here's an example of what i mean: 2 instances of raindrop are in the part of the thread sequence where it paints the raindrop to the screen. well, at the same time, another instance of raindrop is executing the command to draw a rectangle the size of the screen, to cover up the other traces of the left behinds raindrop images, making the raindrops look animated. what i'm basically getting at is that because of this system, the final result is that the raindrops flicker all the way down the screen, and i'm pretty sure that sun has created a class or a method that i have not seen yet that will take care of this problem. PLEASE HELP!!!
13 years ago