First chapter-specific progress breakout code; test to see if I can link these directly from article.

This commit is contained in:
Joey de Vries
2020-04-22 16:05:11 +02:00
parent d756ed80fa
commit 599355fba8
2 changed files with 83 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
/*******************************************************************
** This code is part of Breakout.
**
** Breakout is free software: you can redistribute it and/or modify
** it under the terms of the CC BY 4.0 license as published by
** Creative Commons, either version 4 of the License, or (at your
** option) any later version.
******************************************************************/
#include "game.h"
Game::Game(unsigned int width, unsigned int height)
: State(GAME_MENU), Keys(), Width(width), Height(height)
{
}
Game::~Game()
{
}
void Game::Init()
{
}
void Game::Update(float dt)
{
}
void Game::ProcessInput(float dt)
{
}
void Game::Render()
{
}

View File

@@ -0,0 +1,43 @@
/*******************************************************************
** This code is part of Breakout.
**
** Breakout is free software: you can redistribute it and/or modify
** it under the terms of the CC BY 4.0 license as published by
** Creative Commons, either version 4 of the License, or (at your
** option) any later version.
******************************************************************/
#ifndef GAME_H
#define GAME_H
#include <glad/glad.h>
#include <GLFW/glfw3.h>
// Represents the current state of the game
enum GameState {
GAME_ACTIVE,
GAME_MENU,
GAME_WIN
};
// Game holds all game-related state and functionality.
// Combines all game-related data into a single class for
// easy access to each of the components and manageability.
class Game
{
public:
// game state
GameState State;
bool Keys[1024];
unsigned int Width, Height;
// constructor/destructor
Game(unsigned int width, unsigned int height);
~Game();
// initialize game state (load all shaders/textures/levels)
void Init();
// game loop
void ProcessInput(float dt);
void Update(float dt);
void Render();
};
#endif