PDA

View Full Version : Move an Polygon



Neophyte
03-30-2010, 11:26 AM
Hi guys,
i'm new in this Forum and I have a simple question:
at the moment i'm writing a small "Space Invaders"-clone
using openGl and C++.
Now my Problem:
The ship wich the player has to move is defined in a class wich looks as this (simplified):

class ship
{
public:

void moveRight();
void moveLeft();
void moveForward();
void moveBack();
void shoot();
};

Now my Problem:
I'm using the initialisiation code of NeHe.
In this theres a function called drawScene()
wich draws the scene at the beginning of the Program.

Now I want that the function ship::move() moves the ship.
So i have to actualise the screen and delete the previous polygon and draw the new polygon with another position,
because I don't want to use the translate()-function.

So I want to write an actualiseScreen()-function wich
redraws the whole Scene (including the monsters i didn't implement yet).
This function has to be called everytime when anything on the screen has moved.
Well, how do I delete the polygon I want to actualise?

Aeluned
03-30-2010, 11:57 AM
You erase your entire scene and draw it again with your ship in the new position; you don't normally delete specific polygons and redraw them.

Why don't you want to use glTranslate()? Are you planning on moving your ship by modifying it's vertex data or something?

Neophyte
03-30-2010, 12:03 PM
Thanks, I thought maybe i should delete only one polygone.

I think I will write a function ship::draw(x,y).
So I redraw the ship only with other vertices

Aeluned
03-30-2010, 12:12 PM
It's faster to use glTranslate() than it is to redefine your ship's vertices every frame.

And no, you shouldn't just delete 1 polygon, or even 1 ship.
Redraw the entire scene each frame. It would be more work for
you to compute what has moved and try and selectively delete
those objects for redrawing purposes than it would be to just
scratch the whole scene and draw it again.

Neophyte
04-01-2010, 11:12 AM
Now I have another Question to this topic:
If I want to have multiple nodes in my game (for example the ship, the monsters, and so on) an they all are moving in the game, how must manage the multiple nodes?
Do I have to write a SceneManager classe like in the GameEngines I worked with? This class has to store every Node and its position in the Game and than delete the scene and render every Node again?
Or is there an easier way?

I know that thats a very basic question but by now I only worked with complete engines like Ogre and Irrlicht.