World definitions
This commit is contained in:
parent
9b1acbbe28
commit
3701c4555d
2 changed files with 34 additions and 2 deletions
|
|
@ -4,6 +4,8 @@
|
|||
#include <raylib.h>
|
||||
#include <raymath.h>
|
||||
|
||||
class Entity{};
|
||||
|
||||
class IProcessable {
|
||||
public:
|
||||
virtual ~IProcessable() {}
|
||||
|
|
@ -23,7 +25,7 @@ class IDrawable {
|
|||
virtual void draw() = 0;
|
||||
};
|
||||
|
||||
class Pacman : public IProcessable, public IDrawable {
|
||||
class Pacman : public Entity, public IProcessable, public IDrawable {
|
||||
const int speed = 64;
|
||||
private:
|
||||
Texture2D texture;
|
||||
|
|
@ -39,7 +41,7 @@ class Pacman : public IProcessable, public IDrawable {
|
|||
virtual void draw();
|
||||
};
|
||||
|
||||
class Wall : public IReadible, public IDrawable {
|
||||
class Wall :public Entity,public IReadible, public IDrawable {
|
||||
private:
|
||||
Texture2D texture;
|
||||
public:
|
||||
|
|
|
|||
30
src/world.h
Normal file
30
src/world.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef WORLD_H
|
||||
#define WORLD_H
|
||||
|
||||
#include "components.h"
|
||||
|
||||
/// Class that holds information about game world
|
||||
class World {
|
||||
public:
|
||||
const int GRID_SIZE = 20*20;
|
||||
World();
|
||||
~World();
|
||||
Entity* entities; /// Main subjects of game world.
|
||||
|
||||
void setup(); /// Sets up game world.
|
||||
/// Should be called once when entites are set.
|
||||
|
||||
void process(); /// Should be called every frame. Calls
|
||||
/// process() on every processable
|
||||
|
||||
void draw(); /// Should be called at the end of frame.
|
||||
/// Calls draw() on every drawable
|
||||
|
||||
private:
|
||||
IProcessable* processables;
|
||||
IDrawable* drawables;
|
||||
};
|
||||
|
||||
static World world; /// World singleton
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue