From 01f749b81f89c702891231dc1e4e7ecda1caa8a0 Mon Sep 17 00:00:00 2001 From: Rendo Date: Sat, 14 Mar 2026 15:25:25 +0500 Subject: [PATCH] Initialization to prevent unforseen consequences --- src/atlas.h | 8 ++++---- src/components.h | 8 ++++---- src/world.h | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/atlas.h b/src/atlas.h index 1d2cee4..76a0e04 100644 --- a/src/atlas.h +++ b/src/atlas.h @@ -11,10 +11,10 @@ class TextureAtlas { Rectangle full_view() const; const Texture2D get_texture() const; private: - int offset_x; - int offset_y; - int width; - int height; + int offset_x = 0; + int offset_y = 0; + int width = 0; + int height = 0; Texture2D* texture; }; diff --git a/src/components.h b/src/components.h index 89cd62b..d7a6e32 100644 --- a/src/components.h +++ b/src/components.h @@ -19,7 +19,7 @@ class Entity{ void queue_free(); bool get_free_flag(); private: - bool free_queued; + bool free_queued = false; }; @@ -29,11 +29,11 @@ class Pacman : public Entity{ const int fps = 24; private: TextureAtlas texture; - int facing; + int facing = 0; Rectangle getTextureRect() const; public: - unsigned char frame; - float time; + unsigned char frame = 0.; + float time = 0.; Pacman(); Pacman(Vector2 position); diff --git a/src/world.h b/src/world.h index 6422667..ea94aca 100644 --- a/src/world.h +++ b/src/world.h @@ -19,13 +19,13 @@ class World { public: World(); ~World(); - bool debug; + bool debug = false; std::vector entities; /// Main subjects of game world. Entity** grid; /// Grid representation - float seconds_per_tick; /// Internal clock speed - int width; - int height; - int bound_offset; + float seconds_per_tick = 0.; /// Internal clock speed + int width = 0; + int height = 0; + int bound_offset = 1; void setup(); /// Sets up game world. /// Should be called once when entites are set. @@ -42,9 +42,9 @@ class World { void load_atlas(); Texture2D* get_atlas(); int indexify_position(Vector2 vector); - int points; + int points = 0; private: - float clock; + float clock = 0.; void update_grid(); Texture2D texture_atlas; };