interpreting monopoly as multi scree game

This commit is contained in:
Adolfo Reyna
2026-01-31 19:05:58 -05:00
parent 2165186b6b
commit 561f7c5951
7 changed files with 138 additions and 221 deletions

View File

@@ -0,0 +1,47 @@
// PropertyModalGame.h
#pragma once
#include "../../lib/game.h"
#include "../../display/low_level_render.h"
#include "../../display/low_level_gui.h"
#include "input_manager.h"
#include "monopoly_board.h"
class PropertyModalGame : public Game {
const BoardTile* property;
bool dismissed;
public:
PropertyModalGame(uint16_t width, uint16_t height, LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager, const BoardTile* prop)
: Game(width, height, renderer, gui, input_manager), property(prop), dismissed(false) {}
void init() override { dismissed = false; }
bool update(const InputEvent& event) override {
if (event.type == INPUT_BUTTON_0 || event.type == INPUT_BUTTON_1) {
dismissed = true;
return true;
}
return false;
}
void draw() override {
int win_w = 320, win_h = 180;
int win_x = (width - win_w) / 2, win_y = (height - win_h) / 2;
char buf[128];
snprintf(buf, sizeof(buf), "Property: %s", property->name);
gui->draw_new_window(win_x, win_y, win_w, win_h, buf);
int py = win_y + 30;
char pbuf[128];
if (property->type == TILE_PROPERTY) {
snprintf(pbuf, sizeof(pbuf), "Cost: $%d", property->cost);
renderer->draw_string_scaled(win_x + 20, py, pbuf, 2);
py += 25;
snprintf(pbuf, sizeof(pbuf), "Rent: $%d", property->rent[0]);
renderer->draw_string_scaled(win_x + 20, py, pbuf, 2);
py += 25;
snprintf(pbuf, sizeof(pbuf), "House Cost: $%d", property->house_cost);
renderer->draw_string_scaled(win_x + 20, py, pbuf, 2);
} else if (property->type == TILE_RAILROAD || property->type == TILE_UTILITY) {
snprintf(pbuf, sizeof(pbuf), "Cost: $%d", property->cost);
renderer->draw_string_scaled(win_x + 20, py, pbuf, 2);
}
renderer->draw_string_scaled(10, height - 20, "Press any button...", 2);
}
bool is_dismissed() const { return dismissed; }
};