From ce336a03cbce9c2f4c6f8de90cdc3f8171c498df Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 18 Jul 2008 17:54:54 +0100 Subject: [PATCH] Make a few more rendering methods const --- src/Asteroid.cpp | 2 +- src/Asteroid.hpp | 2 +- src/Mine.cpp | 12 ++++++------ src/Mine.hpp | 2 +- src/Ship.cpp | 2 +- src/Ship.hpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Asteroid.cpp b/src/Asteroid.cpp index b4c77ee..b182eed 100644 --- a/src/Asteroid.cpp +++ b/src/Asteroid.cpp @@ -183,7 +183,7 @@ LineSegment Asteroid::GetDownBoundary(int poly) (ypos+2)*OBJ_GRID_SIZE + downpolys[poly].points[2].y + OBJ_GRID_TOP); } -void Asteroid::Draw(int viewadjust_x, int viewadjust_y) +void Asteroid::Draw(int viewadjust_x, int viewadjust_y) const { double ix = xpos*OBJ_GRID_SIZE - viewadjust_x; double iy = ypos*OBJ_GRID_SIZE - viewadjust_y + OBJ_GRID_TOP; diff --git a/src/Asteroid.hpp b/src/Asteroid.hpp index 13fc4b5..688cf3b 100644 --- a/src/Asteroid.hpp +++ b/src/Asteroid.hpp @@ -31,7 +31,7 @@ public: ~Asteroid() {} void ConstructAsteroid(int x, int y, int width, int surftex); - void Draw(int viewadjust_x, int viewadjust_y); + void Draw(int viewadjust_x, int viewadjust_y) const; bool CheckCollision(Ship &ship); LineSegment GetUpBoundary(int poly); LineSegment GetDownBoundary(int poly); diff --git a/src/Mine.cpp b/src/Mine.cpp index 06038c4..eeaa27e 100644 --- a/src/Mine.cpp +++ b/src/Mine.cpp @@ -131,6 +131,11 @@ void Mine::Move() } movedelay = MINE_MOVE_SPEED; } + + if (--rotcount == 0) { + current = (current + 1) % MINE_FRAME_COUNT; + rotcount = MINE_ROTATION_SPEED; + } } bool Mine::CheckCollision(Ship &ship) @@ -142,7 +147,7 @@ bool Mine::CheckCollision(Ship &ship) OBJ_GRID_SIZE*2 - 12); } -void Mine::Draw() +void Mine::Draw() const { int draw_x = xpos*OBJ_GRID_SIZE + displace_x - viewport->GetXAdjust(); @@ -150,9 +155,4 @@ void Mine::Draw() - viewport->GetYAdjust() + OBJ_GRID_TOP; image->SetFrame(current); image->Draw(draw_x, draw_y); - - if (--rotcount == 0) { - current = (current + 1) % MINE_FRAME_COUNT; - rotcount = MINE_ROTATION_SPEED; - } } diff --git a/src/Mine.hpp b/src/Mine.hpp index 6c52808..4b2eb9b 100644 --- a/src/Mine.hpp +++ b/src/Mine.hpp @@ -28,7 +28,7 @@ public: Mine(ObjectGrid *o, Viewport *v, int x, int y); void Move(); - void Draw(); + void Draw() const; bool CheckCollision(Ship &ship); static const int MINE_FRAME_COUNT = 18; diff --git a/src/Ship.cpp b/src/Ship.cpp index 395cd3a..827483d 100644 --- a/src/Ship.cpp +++ b/src/Ship.cpp @@ -35,7 +35,7 @@ Ship::Ship(Viewport *v) } -void Ship::Display() +void Ship::Display() const { int dx = (int)xpos - viewport->GetXAdjust(); int dy = (int)ypos - viewport->GetYAdjust(); diff --git a/src/Ship.hpp b/src/Ship.hpp index a4e87a6..0e490c0 100644 --- a/src/Ship.hpp +++ b/src/Ship.hpp @@ -31,7 +31,7 @@ public: void Reset(); - void Display(); + void Display() const; void DrawExhaust(); void DrawExplosion(); void Move(); -- 2.39.2