Hi I got my little paddle object and player working together to move around, and it does what I want it to except it does it at whatever frame rate the window is going at, (alot I assume). So when I tell my paddle to move up it flies off the screen, how do I make the movement updates time dependent?
My project is based off of Nehe's Lesson 1
Player.h
Paddle.hCode:#include "vector2.h" #include "Paddle.h" class Player { public: vector2 location; Paddle paddle; const vector2 & get_position() const { return location; } Player() { location.x = 0; location.y = 0; } void draw_paddle() { paddle.draw(location); } void move_paddle(vector2 direction) { location += direction; } }; Player player;
Code:#include "vector2.h" class Paddle { public: void draw(vector2 vec) { glTranslatef(vec.x,vec.y,-100.0f); glBegin(GL_QUADS); // Start Drawing Quads glVertex3f(-1.0f, -5.0f, 1.0f); // Bottom Left Of The Texture and Quad glVertex3f( 1.0f, -5.0f, 1.0f); // Bottom Right Of The Texture and Quad glVertex3f( 1.0f, 5.0f, 1.0f); // Top Right Of The Texture and Quad glVertex3f(-1.0f, 5.0f, 1.0f); // Top Left Of The Texture and Quad glEnd(); } };



LinkBack URL
About LinkBacks



