From ca693623864e00b10f0476a7b0901ad01e02c35b Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 22 Jun 2009 20:46:25 +0100 Subject: [PATCH] Replace some defines with constants --- src/Game.cpp | 18 +++++++++--------- src/Game.hpp | 7 +++++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Game.cpp b/src/Game.cpp index 1ae9b1d..ea236f8 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -29,21 +29,21 @@ // // Constants affecting level generation. // -#define MAX_SURFACE_HEIGHT 300 -#define SHIP_SPEED 0.15f -#define MAX_PAD_SIZE 2 -#define FUELBAR_OFFSET 68 -#define GRAVITY 0.035f +const int Game::MAX_SURFACE_HEIGHT(300); +const float Game::SHIP_SPEED(0.15f); +const int Game::MAX_PAD_SIZE(2); +const int FuelMeter::FUELBAR_OFFSET(68); +const float Game::GRAVITY(0.035f); const int Game::MAX_MISSILES(20); // // Constants affecting state transitions. // const int Game::DEATH_TIMEOUT(50); // Frames to wait for ending level -#define GAME_FADE_IN_SPEED 0.1f // Rate of alpha change at level start -#define GAME_FADE_OUT_SPEED 0.1f // Rate of alpha change at level end -#define LIFE_ALPHA_BASE 2.0f -#define LEVEL_TEXT_TIMEOUT 75 +const float Game::GAME_FADE_IN_SPEED(0.1f); // Rate of alpha change at level start +const float Game::GAME_FADE_OUT_SPEED(0.1f); // Rate of alpha change at level end +const float Game::LIFE_ALPHA_BASE(2.0f); +const int Game::LEVEL_TEXT_TIMEOUT(75); const float Game::TURN_ANGLE(3.0f); const float Game::DEATH_SPIN_RATE(5.0f); diff --git a/src/Game.hpp b/src/Game.hpp index b7c294f..b28dfea 100644 --- a/src/Game.hpp +++ b/src/Game.hpp @@ -58,7 +58,7 @@ private: Image fuelMeterImage; Texture* fuelBarTexture; - static const int FUELBAR_Y; + static const int FUELBAR_Y, FUELBAR_OFFSET; int fuel, maxfuel; TextureQuad border; @@ -95,7 +95,10 @@ private: static const float TURN_ANGLE, DEATH_SPIN_RATE; static const int FUEL_BASE, FUEL_PER_LEVEL; static const int SCORE_PAD_SIZE, SCORE_LEVEL, SCORE_FUEL_DIV; - static const int SCORE_Y, DEATH_TIMEOUT; + static const int SCORE_Y, DEATH_TIMEOUT, LEVEL_TEXT_TIMEOUT; + static const int MAX_SURFACE_HEIGHT, MAX_PAD_SIZE, FUEL_OFFSET; + static const float SHIP_SPEED, GRAVITY, GAME_FADE_IN_SPEED, + GAME_FADE_OUT_SPEED, LIFE_ALPHA_BASE; void MakeLandingPads(); void MakeKeys(); -- 2.39.2