forked from gameprogcpp/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.h
More file actions
57 lines (47 loc) · 1.35 KB
/
Game.h
File metadata and controls
57 lines (47 loc) · 1.35 KB
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
// ----------------------------------------------------------------
// From Game Programming in C++ by Sanjay Madhav
// Copyright (C) 2017 Sanjay Madhav. All rights reserved.
//
// Released under the BSD License
// See LICENSE in root directory for full details.
// ----------------------------------------------------------------
#pragma once
#include "SDL/SDL.h"
#include <unordered_map>
#include <string>
#include <vector>
class Game
{
public:
Game();
bool Initialize();
void RunLoop();
void Shutdown();
void AddActor(class Actor* actor);
void RemoveActor(class Actor* actor);
void AddSprite(class SpriteComponent* sprite);
void RemoveSprite(class SpriteComponent* sprite);
SDL_Texture* GetTexture(const std::string& fileName);
private:
void ProcessInput();
void UpdateGame();
void GenerateOutput();
void LoadData();
void UnloadData();
// Map of textures loaded
std::unordered_map<std::string, SDL_Texture*> mTextures;
// All the actors in the game
std::vector<class Actor*> mActors;
// Any pending actors
std::vector<class Actor*> mPendingActors;
// All the sprite components drawn
std::vector<class SpriteComponent*> mSprites;
SDL_Window* mWindow;
SDL_Renderer* mRenderer;
Uint32 mTicksCount;
bool mIsRunning;
// Track if we're updating actors right now
bool mUpdatingActors;
// Game-specific
class Ship* mShip; // Player's ship
};