Compare commits

..

No commits in common. "a5882211a9bd86d686e252bd9a3ee326a45cf482" and "c67ddcc6d220c1dd5e62261b9ee405a40a12118c" have entirely different histories.

8 changed files with 32 additions and 45 deletions

View file

@ -1,22 +1,22 @@
############################
# ## #
# #### ##### ## ##### #### #
#C#__# #___# ## #___# #__#C#
#C#### ##### ## ##### ####C#
# #### ##### ## ##### #### #
# #
# #### ## ######## ## #### #
# #### ## ######## ## #### #
# ## ## ## #
###### ##### ## ##### ######
_____# ##### ## ##### #_____
_____# ## ## #_____
_____# ## #++# ## #_____
###### ##### ## ##### ######
###### ## ## ######
###### ## #++# ## ######
###### ## #__# ## ######
- #GG# -
###### ## #GG# ## ######
_____# ## #### ## #_____
_____# ## ## #_____
_____# ## ######## ## #_____
###### ## #### ## ######
###### ## ## ######
###### ## ######## ## ######
###### ## ######## ## ######
# ## #
# #### ##### ## ##### #### #

View file

@ -66,7 +66,6 @@ class Scorepoint : public Entity {
public:
Scorepoint();
void draw() const override;
void ready() override;
};
class Ghost : public Entity {
@ -79,7 +78,7 @@ class Ghost : public Entity {
Vector2 start_position;
int respawn_timer = 0;
void recalculate_direction();
void try_switch_direction();
void try_to_chase();
public:
Ghost();
void ready() override;
@ -94,7 +93,6 @@ class Cherry : public Entity {
public:
Cherry();
void draw() const override;
void ready() override;
};
#endif

View file

@ -30,6 +30,7 @@ void Ghost::ready() {
}
void Ghost::tick() {
try_to_chase();
Vector2 check_position = project_position(direction, 1);
World& world = get_world();
@ -45,21 +46,10 @@ void Ghost::tick() {
}
position = check_position;
try_switch_direction();
}
void Ghost::try_switch_direction(){
/*if(rand()%10!=0)
return;
World world = get_world();
if(dynamic_cast<GhostWall*>(world.grid[world.indexify_position(project_position((direction+1)%4, 1))]) == nullptr){
direction = (direction+1)%4;
}
else if(dynamic_cast<GhostWall*>(world.grid[world.indexify_position(project_position((direction-1)%4,1))]) == nullptr){
direction = (direction-1)%4;
}*/
void Ghost::try_to_chase(){
// Todo
}
void Ghost::recalculate_direction(){

View file

@ -21,15 +21,15 @@ int main() {
while (WindowShouldClose() == false) {
if(IsKeyPressed(KEY_F1))
get_world().debug = !get_world().debug;
world.debug = !world.debug;
get_world().process();
world.process();
BeginDrawing();
ClearBackground(BLACK);
get_world().draw();
world.draw();
EndDrawing();
}

View file

@ -93,18 +93,12 @@ void Pacman::collision(Entity* with){
if (score != nullptr) {
score->queue_free();
get_world().points+=10;
get_world().total_scorepoints--;
if(get_world().total_scorepoints == 0)
get_world().win();
}
Cherry* cherry = dynamic_cast<Cherry*>(with);
if (cherry != nullptr) {
cherry->queue_free();
get_world().points+=30;
get_world().start_killmode();
get_world().total_scorepoints--;
if(get_world().total_scorepoints == 0)
get_world().win();
}
}

View file

@ -10,10 +10,6 @@ void Scorepoint::draw() const {
DrawTextureRec(this->texture.get_texture(), this->texture.full_view(), this->position, WHITE);
}
void Scorepoint::ready() {
get_world().total_scorepoints++;
}
Cherry::Cherry(){
texture = {get_world().get_atlas(),112,16,16,16};
}
@ -21,7 +17,3 @@ Cherry::Cherry(){
void Cherry::draw() const {
DrawTextureRec(texture.get_texture(),texture.full_view(),position,WHITE);
}
void Cherry::ready() {
get_world().total_scorepoints++;
}

View file

@ -4,6 +4,18 @@
#include <raylib.h>
#include <string>
void init_world() {
create_world_with(1./5.);
World& world = get_world();
Vector2i window_size = get_map_size("assets/map");
world.set_size(window_size);
load_world(world,"assets/map");
world.setup();
}
World::World(){
this->entities = {};
this->grid = new Entity*[get_capacity()];
@ -45,10 +57,12 @@ void World::process(){
this->seconds_per_tick-=0.025;
if(IsKeyPressed(KEY_F3))
this->seconds_per_tick+=0.025;
if(IsKeyPressed(KEY_Q))
CloseWindow();
if(state != LevelState::NotFinished){
if(IsKeyPressed(KEY_Q))
CloseWindow();
if(IsKeyPressed(KEY_R))
init_world();
return;
}
@ -101,7 +115,7 @@ void World::draw() const {
else {
DrawText("You lost!",16,16,24,WHITE);
}
DrawText("q to quit",0,40,16,WHITE);
DrawText("q to quit, r to restart",0,40,16,WHITE);
DrawText(TextFormat("Score: %i",this->points),16,56,16,WHITE);
}

View file

@ -33,7 +33,6 @@ class World {
int width = 0;
int height = 0;
int bound_offset = 1;
int total_scorepoints = 0;
void setup(); /// Sets up game world.
/// Should be called once when entites are set.