From 89ca62b2694538f2ca5845b40aed7c2dec5143fe Mon Sep 17 00:00:00 2001 From: Patrik Gornicz Date: Sun, 20 Jul 2008 23:03:47 -0400 Subject: [PATCH] made a ball move --- src/Entities/Ball.cpp | 2 +- src/Entities/PhysicsEntity.cpp | 4 +++- src/entityCreator.cpp | 2 +- src/graphics/graphics.cpp | 4 ++-- src/graphics/graphics.h | 2 +- src/ticks.cpp | 11 ----------- src/ticks.h | 2 -- 7 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/Entities/Ball.cpp b/src/Entities/Ball.cpp index 7b75839..37a37c7 100644 --- a/src/Entities/Ball.cpp +++ b/src/Entities/Ball.cpp @@ -17,5 +17,5 @@ Ball::~Ball() void Ball::draw() const { - glDrawCircle(radius, &position, color); + glDrawCircle(radius, position, color); } diff --git a/src/Entities/PhysicsEntity.cpp b/src/Entities/PhysicsEntity.cpp index 00817b4..225138a 100644 --- a/src/Entities/PhysicsEntity.cpp +++ b/src/Entities/PhysicsEntity.cpp @@ -1,9 +1,11 @@ #include "PhysicsEntity.h" +#include "../debug.h" + #include "../Vector2.h" /// ***** Public Class Methods ***** PhysicsEntity::PhysicsEntity(const Vector2& pos) - : Entity(pos) + : Entity(pos), mass(1) { } diff --git a/src/entityCreator.cpp b/src/entityCreator.cpp index aa5db0e..8ed35f4 100644 --- a/src/entityCreator.cpp +++ b/src/entityCreator.cpp @@ -17,9 +17,9 @@ void creator::init() { Ball* ball; - // needs to be first for the overlap ball = new Ball(Vector2(50, 50), 20, cWhite); + ball->applyImpulse(Vector2(0.01,0.01)), Balls.push(ball); manager::add(ball); diff --git a/src/graphics/graphics.cpp b/src/graphics/graphics.cpp index a719662..ab7f08f 100644 --- a/src/graphics/graphics.cpp +++ b/src/graphics/graphics.cpp @@ -27,11 +27,11 @@ void graphicsCleanUp() } -void glDrawCircle(float radius, const Vector2* vec, const float* color) +void glDrawCircle(float radius, const Vector2& vec, const float* color) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glTranslatef(vec->x, vec->y, -1); + glTranslatef(vec.x, vec.y, -1); glScalef(radius, radius, radius); if(color != NULL) diff --git a/src/graphics/graphics.h b/src/graphics/graphics.h index df3b5c2..b42617c 100644 --- a/src/graphics/graphics.h +++ b/src/graphics/graphics.h @@ -7,6 +7,6 @@ void graphicsInit(); void graphicsCleanUp(); -void glDrawCircle(float radius, const Vector2*, const float* color = 0); +void glDrawCircle(float radius, const Vector2&, const float* color = 0); #endif // GRAPHICS_H diff --git a/src/ticks.cpp b/src/ticks.cpp index 69a8cbf..f3938d4 100644 --- a/src/ticks.cpp +++ b/src/ticks.cpp @@ -25,14 +25,3 @@ long int tickCountSec() { return tickCountMicro() / 1000000; } - -// return after num milliseconds -void wait(int num) -{ - long int start; - int numMicro = num * 1000; - - start = tickCountMicro(); - while(tickCountMicro() - start < numMicro); -} - diff --git a/src/ticks.h b/src/ticks.h index 239ef0c..853f4d7 100644 --- a/src/ticks.h +++ b/src/ticks.h @@ -12,6 +12,4 @@ long int tickCountMilli(); // returns the current microseconds from program start long int tickCountMicro(); -void wait(int); - #endif // TICKS_H -- 2.10.2