mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-11 02:53:23 +08:00
Add full source code of the finished (and revised code) Breakout example. Not set up for cross-platform compilation as it has irrKlang and FreeType dependency, but at least source code is available online (and can be referenced from Breakout chapters).
This commit is contained in:
40
src/7.in_practice/3.2d_game/0.full_source/game_object.h
Normal file
40
src/7.in_practice/3.2d_game/0.full_source/game_object.h
Normal 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.
|
||||
******************************************************************/
|
||||
#ifndef GAMEOBJECT_H
|
||||
#define GAMEOBJECT_H
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "texture.h"
|
||||
#include "sprite_renderer.h"
|
||||
|
||||
|
||||
// Container object for holding all state relevant for a single
|
||||
// game object entity. Each object in the game likely needs the
|
||||
// minimal of state as described within GameObject.
|
||||
class GameObject
|
||||
{
|
||||
public:
|
||||
// object state
|
||||
glm::vec2 Position, Size, Velocity;
|
||||
glm::vec3 Color;
|
||||
float Rotation;
|
||||
bool IsSolid;
|
||||
bool Destroyed;
|
||||
// render state
|
||||
Texture2D Sprite;
|
||||
// constructor(s)
|
||||
GameObject();
|
||||
GameObject(glm::vec2 pos, glm::vec2 size, Texture2D sprite, glm::vec3 color = glm::vec3(1.0f), glm::vec2 velocity = glm::vec2(0.0f, 0.0f));
|
||||
// draw sprite
|
||||
virtual void Draw(SpriteRenderer &renderer);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user