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
55 lines (50 loc) · 1.15 KB
/
Game.h
File metadata and controls
55 lines (50 loc) · 1.15 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
// ----------------------------------------------------------------
// 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"
// Vector2 struct just stores x/y coordinates
// (for now)
struct Vector2
{
float x;
float y;
};
// Game class
class Game
{
public:
Game();
// Initialize the game
bool Initialize();
// Runs the game loop until the game is over
void RunLoop();
// Shutdown the game
void Shutdown();
private:
// Helper functions for the game loop
void ProcessInput();
void UpdateGame();
void GenerateOutput();
// Window created by SDL
SDL_Window* mWindow;
// Renderer for 2D drawing
SDL_Renderer* mRenderer;
// Number of ticks since start of game
Uint32 mTicksCount;
// Game should continue to run
bool mIsRunning;
// Pong specific
// Direction of paddle
int mPaddleDir;
// Position of paddle
Vector2 mPaddlePos;
// Position of ball
Vector2 mBallPos;
// Velocity of ball
Vector2 mBallVel;
};