Archived

This topic is now archived and is closed to further replies.

Sketchy

Object motion help

Recommended Posts

Hi, I'm trying to make a triangle move around the screen using the keyboard. When drawing the vertices for the triangle, I add a value to each parameter, like glVertex3f((1.0f + xmove),...) Then, in KEYDOWN of the message handler, I have 4 if statements to see if the key pressed was an arrow key, and if so, I increase/decrease xmove & ymove. I'm having a problem: I get a double image of the triangle if the xmove/ymove is small (to simulate less jumpy motion) Whats the difference between moving the coordinate system to the triangle then translating it, and the way im doing it? I'm trying to make a simple scrolling space fighter game, so I thought I should start by making sure I can move an object around the screen. --SK Edited by - Sketchy on June 22, 2001 1:35:12 AM

Share this post


Link to post
Share on other sites
ok, dont change the vertices on the triangle, just create a set of global variables

float x,y,z;

and do this just before you draw your triangle

glTranslatef(x,y,z);

then set your keyboard commands to modify the x,y,z variables

i would reccomend a switch statement in the keyboard function.

home.earthlink.net/~eberkain/

Share this post


Link to post
Share on other sites