Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » gravity with a vertically moving map?

This thread is locked; no one can reply to it. rss feed Print
gravity with a vertically moving map?
booglebeast
Member #17,138
October 2019

Trying to figure out how to have gravity in a platformer based game, where the map moves in the background simulating vertical movement. however, the current issue is gravity does not match up with the pace of the screen moving down, and the collision is even more buggy.

Edgar Reynaldo
Member #8,592
May 2007
avatar

If you want a good example of gravity in a 'tower' based climbing game, you could take a look at Icy Towers, by Johan Peitz. I'm not sure if source is available though.

Basically, your character's y speed and the pan y speed of the camera will constantly get out of sync. You can limit it to upward movement only, and only move up once the character crosses a vertical threshold. Try a few things and report back your progress.

Audric
Member #907
January 2001

The first thing is to start counting positions and speeds relative to 'game world', and then consider that there is an invisible rectangle, the camera (or 'screen window') that tracks the main character. This kind of system works equally well for side-view platformer and overhead (top down) games.

Anyway, if the character falls through platforms when he's falling fast enough, you must reconsider how you're handling collision. Checking collision after a character movement is too late.

Go to: