Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Timer based game and physics

Author
Message
Satchmo
18
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 18th Aug 2013 19:53
Could somebody explain how to make the box2d physics play nice with a timer based game? The movement of the character in my game is all force physics based so I was wondering how this could be scaled based on the fps (relying on timers instead of framerate).

3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 18th Aug 2013 19:59 Edited at: 18th Aug 2013 20:02
Use a outline and make it square or circle set the outline to a depth of 50 or so. Physics is harder I check if velocity is positive to make it more positive to make the charactor not float. Cheak velocity if it is greater then .5 I think would do it. Reset timer before the level starts.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 18th Aug 2013 20:05
Physics is timer based anyway???

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Aug 2013 20:06
StepPhysics command?
Satchmo
18
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 18th Aug 2013 20:21
What does step physics do and how would I use it? I don't think physics is timer based as it acts differently depending on what I set the fps to, for example my character jumps higher the lower I put the fps. The code checks for a button press then applies an upward force if the button is pressed, but only once and will not do it again until the player is back on the ground.

Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 18th Aug 2013 20:44 Edited at: 18th Aug 2013 20:45
Satchmo, take a read of this thread...

http://forum.thegamecreators.com/?m=forum_view&t=204311&b=41

Paul provides a solution at the bottom, but it didn't work for me... Made the game too jerky. Let me know if you have any success...
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Aug 2013 21:31
with StepPhysics you tell the physic engine what time steps
will calculated.
StepPhysics 0 means no movement.
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 19th Aug 2013 17:00 Edited at: 19th Aug 2013 17:11
I dont think I like step physics that much only when you pause the game it works effectivly I like a constant force that pushes my charactor down instead and have greater forces that bring the charactor off a plateform. I don't change gravity because that messes up other physics in my app.

Let say you want your charactor jump step physics in the documentation says it might miss collision, and applying a constant force the other direction will make the charactor not float and also it will not miss the collision with certain objects.

agk::SetSpritePhysicsVelocity(numframes2.spriteid,agk::GetSpritePhysicsVelocityX(numframes2.spriteid),agk::GetSpritePhysicsVelocityY(numframes2.spriteid)+5);
will get current velocity and apply a downword force to charactor.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.

Login to post a reply

Server time is: 2024-05-09 08:25:39
Your offset time is: 2024-05-09 08:25:39