diff --git a/semestralka1/src/assets/character_crawl_frames.h b/semestralka1/src/assets/character_crawl_frames.h index c2c71a6..8c30fe4 100644 --- a/semestralka1/src/assets/character_crawl_frames.h +++ b/semestralka1/src/assets/character_crawl_frames.h @@ -49,7 +49,7 @@ static const int CHARACTER_CRAWL1_COLLISION_RIGHT_OFFSET = 1; static const int CHARACTER_CRAWL1_COLLISION_WIDTH = CHARACTER_CRAWL1_FRAME_WIDTH - (CHARACTER_CRAWL1_COLLISION_LEFT_OFFSET + CHARACTER_CRAWL1_COLLISION_RIGHT_OFFSET); static const int CHARACTER_CRAWL1_COLLISION_HEIGHT = CHARACTER_CRAWL1_FRAME_HEIGHT - 2; -// Crawl2 collision box (lower posture → smaller collision height) +// Crawl2 collision box (lower posture - smaller collision height) static const int CHARACTER_CRAWL2_FRAME_WIDTH = 8; static const int CHARACTER_CRAWL2_COLLISION_LEFT_OFFSET = 1; static const int CHARACTER_CRAWL2_COLLISION_RIGHT_OFFSET = 0; diff --git a/semestralka1/src/game/collision.h b/semestralka1/src/game/collision.h index 2163bbf..1ea0ba4 100644 --- a/semestralka1/src/game/collision.h +++ b/semestralka1/src/game/collision.h @@ -5,7 +5,7 @@ #include "../assets/character_run_frames.h" #include "../assets/character_crawl_frames.h" -// Simple obstacle representation +// Obstacle representation struct Obstacle { int x; int y; @@ -48,7 +48,7 @@ inline bool check_collision(const CharacterPosition& player, break; } - // Player's bounding box + // Player bounding box const int player_left = box_x; const int player_right = player_left + box_w; const int player_top = player_bottom + box_h; @@ -59,7 +59,7 @@ inline bool check_collision(const CharacterPosition& player, const int obs_bottom = obs.y; const int obs_top = obs_bottom + obs.height; - // Simple overlap check + // Overlap check bool horizontal = player_left < obs_right && player_right > obs_left; bool vertical = player_bottom < obs_top && player_top > obs_bottom; return horizontal && vertical; diff --git a/semestralka1/src/game/obstacle_manager.h b/semestralka1/src/game/obstacle_manager.h index 2a7722c..0e6eee7 100644 --- a/semestralka1/src/game/obstacle_manager.h +++ b/semestralka1/src/game/obstacle_manager.h @@ -4,7 +4,7 @@ #include "../assets/obstacle_crawl_frames.h" #include "../assets/background_frame.h" -// One movable obstacle +// Movable obstacle struct MovingObstacle { Obstacle data; CrawlObstacleType type; @@ -26,7 +26,7 @@ inline int spawn_obstacle(CrawlObstacleType type, int x_start) { obstacle_pool[i].data.width = (type == CrawlObstacleType::Crawl1) ? OBSTACLE_CRAWL1_COLLISION_WIDTH : OBSTACLE_CRAWL2_COLLISION_WIDTH; obstacle_pool[i].data.height = (type == CrawlObstacleType::Crawl1) ? OBSTACLE_CRAWL1_COLLISION_HEIGHT : OBSTACLE_CRAWL2_COLLISION_HEIGHT; - // Default Y so that the SPRITE touches the top of the screen. + // Default Y so that the character touches the top of the screen. // We store Y as the bottom of the COLLISION BOX in bottom-based world coords. int top_offset = 0; if (type == CrawlObstacleType::Crawl1) { diff --git a/semestralka1/src/game/obstacle_system.h b/semestralka1/src/game/obstacle_system.h index 636fc8f..cfaa321 100644 --- a/semestralka1/src/game/obstacle_system.h +++ b/semestralka1/src/game/obstacle_system.h @@ -6,7 +6,6 @@ #include "collision.h" #include "mbed.h" -// Small helper for minimal mbed-safe clamp inline int clamp_min(int a, int b) { return (a > b) ? a : b; } inline int clamp_max(int a, int b) { return (a < b) ? a : b; } @@ -26,12 +25,8 @@ public: // Periodically spawn new obstacle if (tick_counter_ % SPAWN_EVERY_TICKS == 0) { - auto type = (spawn_index_++ % 2 == 0) - ? CrawlObstacleType::Crawl1 - : CrawlObstacleType::Crawl2; - const int w = (type == CrawlObstacleType::Crawl1) - ? OBSTACLE_CRAWL1_FRAME_WIDTH - : OBSTACLE_CRAWL2_FRAME_WIDTH; + auto type = (spawn_index_++ % 2 == 0) ? CrawlObstacleType::Crawl1 : CrawlObstacleType::Crawl2; + const int w = (type == CrawlObstacleType::Crawl1) ? OBSTACLE_CRAWL1_FRAME_WIDTH : OBSTACLE_CRAWL2_FRAME_WIDTH; spawn_obstacle(type, VIEW_WIDTH - w - 1); } diff --git a/semestralka1/src/main.cpp b/semestralka1/src/main.cpp index eab7434..01ab922 100644 --- a/semestralka1/src/main.cpp +++ b/semestralka1/src/main.cpp @@ -21,6 +21,5 @@ int main(void) { serial_port.set_format(8, BufferedSerial::None, 1); printf("Baud: %d, Format: 8-N-1\r\n", BAUD_RATE); - // Just call into render feature render_loop(6); } diff --git a/semestralka1/src/timing/speed_controller.h b/semestralka1/src/timing/speed_controller.h index 00eb74b..b19000d 100644 --- a/semestralka1/src/timing/speed_controller.h +++ b/semestralka1/src/timing/speed_controller.h @@ -13,7 +13,5 @@ public: int get_ground_speed() const { return ground_speed; } // Calculates how many frames to advance for current tick. - // Takes object’s current speed and a global tick counter - // to automatically handle slower "wait" behavior. int frame_advance_for(int object_speed, int tick_counter) const; };