This site requires JavaScript, please enable it in your browser!
Greenfoot back
sametguzelgun
sametguzelgun wrote ...

2013/1/5

Gravity

sametguzelgun sametguzelgun

2013/1/5

#
Hi. I would like to add gravity to the game. Issues of gravity and acceleration due to gravity could do. However, the y position of the object falling to control whether or not there is an object I want to add one. How can I do this? Because of that I may be writing to the Turkish errors, forgive me. :)
danpost danpost

2013/1/6

#
Acceleration due to gravity in most scenarios is just adding one (1) to the speed along the y axis each act cycle. The speed should be set to zero at any time an obstacle is encountered. Jump force is a constant subtracted from the speed along the y axis. There can be issues with falling through objects if the speed increases beyond the height of an obstacle. To avoid this either check multiple point along the move each cycle or increase the height of the obstacle (this can be done by drawing the obstacles image on a transparent image of larger height and making this new image the image of the obstacle). For example code, see the 'Wombat' class of my Scrolling SuperWorld.
sametguzelgun sametguzelgun

2013/1/6

#
Thank you.
You need to login to post a reply.