A few Space-related Questions

Hello all, I’m just tinkering with Panda 3D after getting a bit annoyed at pyOgre. I’m looking to do a really basic top-down arcade space game. Similar to asteroids, but with a big map that scrolls with the player’s movements (rather than showing the whole thing at once like classic asteroids does).

I assume what I need to do is position the camera directly above my player’s ship, angle it down, and update its lateral location each time the ship moves (unless there’s a built-in camera follow task).

The big thing I’ve been pondering is how to get the background image to scroll slightly as the player moves. Since the camera will stay directly overhead of the player’s ship as it moves, there needs to be some kind of illusion of movement. Maybe a static background image isn’t the way to go, are there any ideas here? Perhaps some kind of little stationary specs could be rendered dynamically on this map, and the player’s ship would actually be moving around/past them to provide an even better look.

Thanks in advance for any replies for this dumb newbie :slight_smile: I’m still trying to go through a lot of examples and tutorials, so I apologize if some of this stuff is explained in the common ones.

First of all, you might well get away with simply placing a large, flat polygon (the size of your entire play-area) in the background and texturing it appropriately.

If that doesn’t work for you, for whatever reason, you might have success with smaller tiles tessellated together.

Finally, if that doesn’t work either (for example, if you don’t have a set play-area size for a given level), you can either use a set of tiles, offsetting them and wrapping them around as the player moves, or you can use the following technique, which I’ve done elsewhere, but unfortunately do not yet know how to implement in Panda:

Create a large rectangle - large enough, or placed appropriately, that it is larger than the screen when rendered - perhaps two or three times in each of the x- and y- directions (presuming that you use the x-y plane) - and texture that with an appropriate texture (I used Diamond-square noise for my purpose at the time; you could use stars if you prefer). Each frame, set the texture coordinates of this as follows, with px and py being the x- and y- coordinates of the player:

(I think that these start with the bottom-left vertex, and proceed counter-clockwise; you may, of course, want to alter this for your purposes.)

Tex coord 1: (px/1.5, py/1.5)
Tex coord 2: (px/1.5+1.0, py/1.5)
Tex coord 3: (px/1.5+1.0, py/1.5+1.0)
Tex coord 4: (px/1.5, py/1.5+1.0)

This produces a scrolling effect that, as I recall, actually appears to move past faster than the player is moving, resulting in an effect that I rather liked in that game. The value divided by (1.5 in this case) can be altered to change the apparent speed of the background’s scrolling, if I recall correctly.

If you parent the camera to the ship it will stay with the ship and whatever position you give it will be relative to the ship. And the lookat function is useful.

Panda3d is a 3d engine. Instead of moving a flat “background” why not move the ship. Its not necessary to use all 3 dimensions for movement. Your models will be in 3d? Set all their positions with the same Z value so they all stay on a Z plane. Or you could even restrain the ship to a set Y value and just move the ship along the X axis. Load objects (asteroids) and set their position outside the cameras field of view. Then move them through the FOV using a position interval. Use a random function to determine the start and end points’ X value for the interval. The speed of the asteroid is determined by the intervals duration.

Also check out the section on collision detection.

If you are using intervals and collision check out:
panda3d.org/manual/index.php/Rapid … ng_Objects

Thanks for the reply.

Just to clarify, I’m looking to have stationary stuff that sits still that the player runs past in his ship that gives a sense of movement. I’d like to have a starscape background (which I assume would be doable with the Panda equivalent to skyboxes) that would be stationary, but have little specs/space dirt sitting on top of it kind of like EVE online does. The player moves past these specs, and gives the allusion of moving even when the starscape is “still”.

So I guess the question should be, what is the best way to define this space dirt?

The camera stuff was spot on, thanks for that!

I found the particle system was good at making space dirt.