Game Development Community

Problem Solving Player/npc movement (TGB)

by Boon Cotter · in Technical Issues · 08/19/2008 (5:10 am) · 0 replies

Hi all,

I'm finding myself a bit confused about the best way to structure movement in my game.

The basic premise involves the player being center-locked to camera, in a side-scrolling 2D environment. The environment loops in X (ie. the player can run infinitely in a horizontal direction, within a looping environment). There are also a large number of npc's and pickups scattered throughout the level.

At the moment, I'm thinking that the easiest way to manage it would be to not actually move the player in X, but pass a symbolic X value to all of the npc's/pickups/art in the level, and position them relative to the player.

For example, if my player's symbolic X value is 200, and a pickup's symbolic X value is 400, then given that the player remains at X=0, the pickup will be displayed at X=200. So the player remains stationary, and the level moves around the player.

I'm posting to ask if this would be an okay way to approach this? My coding experience is quite limited, and while I'm a little nervous about a per-tick xpos update on every single scene element minus the player, I have no idea whether the impact would be negligable or significant.

If anyone has some simple tips on the best way to deal with a scrolling/looping environment with 50-60 objects (not including static art) I'd be hugely appreciative.

Thankyou for reading.

About the author

Recent Threads