diff --git a/assets/map b/assets/map deleted file mode 100644 index 1ece295..0000000 --- a/assets/map +++ /dev/null @@ -1,20 +0,0 @@ -######### ######### -# # -# # -# # -# P # -# # -# # -# # - - -# # -# # -# # -# # -# # -# # -# # -# # -# # -######### ######### diff --git a/assets/sprites/pacman.png b/assets/sprites/pacman.png index 25dfc88..63e7438 100644 Binary files a/assets/sprites/pacman.png and b/assets/sprites/pacman.png differ diff --git a/assets/sprites/wall.png b/assets/sprites/wall.png deleted file mode 100644 index b984984..0000000 Binary files a/assets/sprites/wall.png and /dev/null differ diff --git a/compiler_flags.txt b/compiler_flags.txt index c518829..63dd840 100644 --- a/compiler_flags.txt +++ b/compiler_flags.txt @@ -2,3 +2,4 @@ -lraylib -lstdc++ -lm +-v diff --git a/makefile b/makefile index cffd6c4..5a71e4e 100644 --- a/makefile +++ b/makefile @@ -1,10 +1,9 @@ -CP=clang -CFLAGS=$(shell cat compiler_flags.txt | tr '\n' ' ') +CFLAGS=$(shell cat compiler_flags.txt) FILES=$(wildcard src/*.cpp) build/raylib-test-linux.x86_64 : $(FILES) mkdir -p build - $(CP) $(FILES) $(CFLAGS) -o build/raylib-test-linux.x86_64 + clang $(FILES) $(CFLAGS) -o build/raylib-test-linux.x86_64 clean : diff --git a/src/components.cpp b/src/components.cpp index c9d40d7..b3e44e7 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -5,9 +5,9 @@ // Pacman definitions -Rectangle Pacman::getTextureRect() const{ +Rectangle Pacman::getTextureRect(){ Rectangle result; - result.x = 16*frame; + result.x = 0; result.y = facing*16; result.height = 16; result.width = 16; @@ -17,7 +17,6 @@ Pacman::Pacman() { this->texture = LoadTexture("assets/sprites/pacman.png"); this->facing = 0; this->position = {0.,0.}; - this->frame = 0; } Pacman::Pacman(Vector2 position) { this->texture = LoadTexture("assets/sprites/pacman.png"); @@ -54,19 +53,7 @@ void Pacman::tick() { } } -void Pacman::process() { - this->time += GetFrameTime(); - if (this->time >= 1.0/this->fps){ - this->time = 0.; - this->animation_tick(); - } -} - -void Pacman::animation_tick() { - this->frame = (this->frame+1)%frame_count; -} - -void Pacman::draw() const { +void Pacman::draw() { // Drawing DrawTextureRec(this->texture, this->getTextureRect(), this->position, WHITE); } @@ -85,7 +72,7 @@ void Wall::ready() { // Set neigbors depending on state } -void Wall::draw() const { +void Wall::draw() { // Draw based on neighbors } diff --git a/src/components.h b/src/components.h index 2db18e3..b1f4dfe 100644 --- a/src/components.h +++ b/src/components.h @@ -8,34 +8,27 @@ class Entity{ public: virtual ~Entity(){} - Vector2 position; - virtual void ready() {} virtual void process() {} - virtual void draw() const {} + virtual void draw() {} virtual void tick() {} }; class Pacman : public Entity{ const int speed = 16; - const int frame_count = 7; - const int fps = 24; private: Texture2D texture; + Vector2 position; int facing; - Rectangle getTextureRect() const; - public: - unsigned char frame; - float time; + Rectangle getTextureRect(); + public: Pacman(); Pacman(Vector2 position); ~Pacman(); void tick() override; - void process() override; - void animation_tick(); - void draw() const override; + void draw() override; }; class Wall : public Entity { @@ -45,7 +38,7 @@ class Wall : public Entity { Wall(); ~Wall(); void ready() override; - void draw() const override; + void draw() override; }; #endif diff --git a/src/main.cpp b/src/main.cpp index ba4d5b1..9616590 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,7 +12,7 @@ int main() { SetTargetFPS(60); - world = create_world_with(1./10.); + world = create_world_with(.25); world.entities.push_back(new Pacman({SCREEN_WIDTH/2,SCREEN_HEIGHT/2})); @@ -35,7 +35,3 @@ int main() { return 0; } - -void load_map(const char * path){ - -} diff --git a/src/maploader.cpp b/src/maploader.cpp deleted file mode 100644 index a646687..0000000 --- a/src/maploader.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "maploader.h" -#include -#include "world.h" - -void loadmap() { - -} - diff --git a/src/maploader.h b/src/maploader.h deleted file mode 100644 index f27ac8b..0000000 --- a/src/maploader.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MAPLOADER_H -#define MAPLOADER_H - -void loadmap(); - -#endif diff --git a/src/world.cpp b/src/world.cpp index 73fc1a9..641330d 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -21,8 +21,6 @@ void World::setup(){ void World::process(){ this->clock += GetFrameTime(); - this->update_grid(); - for(int i = 0; i < this->entities.size(); i++) { this->entities[i]->process(); if (this->clock>=this->seconds_per_tick) { @@ -35,31 +33,12 @@ void World::process(){ } } -void World::draw() const { +void World::draw() { for(int i = 0; i < this->entities.size(); i++) { this->entities[i]->draw(); } } -int indexify_position(Vector2 vector){ - return (int)(vector.x / 16.0) + GRID_COLUMNS * (int)(vector.y / 16.0); -} - -void World::update_grid() { - for(int i = 0; i < GRID_CAPACITY; i++) - this->grid[i] = nullptr; - - for(int i = 0; i < this->entities.size(); i++) - { - int indexified_position = indexify_position(this->entities[i]->position); - if (indexified_position < 0 || indexified_position >= GRID_CAPACITY) - continue; - grid[indexified_position] = this->entities[i]; - } -} - - - World create_world_with(float seconds_per_tick){ World result = World(); diff --git a/src/world.h b/src/world.h index 1a7ed51..5c2fbe9 100644 --- a/src/world.h +++ b/src/world.h @@ -4,10 +4,6 @@ #include "components.h" #include -const int GRID_ROWS = 20; -const int GRID_COLUMNS = 20; -const int GRID_CAPACITY = GRID_COLUMNS*GRID_ROWS; - /// Class that holds information about game world class World { public: @@ -15,8 +11,7 @@ class World { ~World(); std::vector entities; /// Main subjects of game world. - Entity* grid[GRID_CAPACITY]; /// Grid representation - float seconds_per_tick; /// Internal clock speed + float seconds_per_tick; /// Internal clock speed void setup(); /// Sets up game world. /// Should be called once when entites are set. @@ -24,16 +19,14 @@ class World { void process(); /// Should be called every frame. Calls /// process() on every entity - void draw() const; /// Should be called at the end of frame. + void draw(); /// Should be called at the end of frame. /// Calls draw() on every entity private: float clock; - void update_grid(); }; static World world; /// World singleton World create_world_with(float seconds_per_tick); -int indexify_position(Vector2 vector); #endif