-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspacewar.h
136 lines (111 loc) · 3.34 KB
/
spacewar.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Module: Gameplay Programming
// Assignment 1: Pixl
// Programming 2D Games
// Copyright (c) 2011 by:
// Charles Kelly
// Chapter 6 spacewar.h v1.0
#ifndef _SPACEWAR_H
#define _SPACEWAR_H
#define WIN32_LEAN_AND_MEAN
#include <algorithm>
#include <functional>
#include "game.h"
#include "textureManager.h"
#include "image.h"
#include "ship.h"
#include "Font.h"
#include "Triangle.h"
#include "Circle.h"
#include "Blackhole.h"
#include "Missile.h"
#include "Pickup.h"
#include "Explosion.h"
#include "Freeze.h"
#include "audio.h"
enum GameState {
GAME_STATE_MENU,
GAME_STATE_GAME,
GAME_STATE_SETTING,
GAME_STATE_GAMEOVER,
GAME_STATE_INSTRUCTIONS,
GAME_STATE_CREDITS,
GAME_STATE_HIGHSCORE,
GAME_STATE_NEW_HIGHSCORE
};
class Spacewar : public Game {
private:
// game items
// Player
TextureManager shipTextures;
// Enemy
TextureManager triangleTextures;
TextureManager circleTextures;
// Pickups
TextureManager destructorObstructorTexture;
TextureManager missileTexture;
TextureManager explosionTexture;
TextureManager blackHoleTexture;
TextureManager freezeTexture;
// GUI
TextureManager fontTexture;
TextureManager heartTexture;
std::vector<Entity*> hearts;
TextureManager instructionsTexture;
// vectors to store the entities
// entities includes most thing in the game, such as dynamically
// generated enemies that does not deserve a member variable in
// this class
std::vector<Entity*> entities;
// missiles is purely to store the missiles. It is seperated from
// entities to lessen the amount of things to be iterated through.
std::vector<Missile*> missiles;
// Fonts
Font* timeFont;
Font* comboFont;
Font* scoreFont;
Font* menuFont;
Font* effectFont;
// since we know that there will be one pickup dedicated to health,
// it will be easier to store the pointer here for easy referencing
// the same applies for player
Pickup* healthPickup;
Ship* player;
Entity* instructions;
Entity* selectBox;
// state of the game
GameState gameState;
// controls the game state
bool isRunning;
std::map<int, std::string> highscores;
std::vector<int> scoreVect;
std::vector<Entity*> kbdSprite;
std::vector<int> alphaVect;
std::map<UCHAR, bool> inputMap;
std::vector<int> textVect;
Audio* audio;
public:
// Constructor
Spacewar();
// Destructor
virtual ~Spacewar();
void initialize(HWND hwnd);
void update();
void ai();
void collisions();
void collisions(Entity* entity);
void render();
void releaseAll();
void resetAll();
void addEntity(Entity* entity); // add entities to the entities vector
void UpdateEntities();
void DrawEntities();
int genScore(int combo); // return Score based on combo
double calculateF(Entity* entity, Entity* entity2); // return Force based 2 entities
GameState getGameState() { return this->gameState; }
void setGameState(GameState gameState) { this->gameState = gameState; }
// remove entites from the entities vector to prevent unncessary overhead of iterating dead stuff
void KillEntities();
void ParseScore(std::string fileName);
int minMaxRand(int min, int max) { return rand() % (max - min + 1) + min;}
};
#endif