This commit is contained in:
Masashi 2025-12-17 20:07:00 +05:30
commit 91b851acd6
8 changed files with 204 additions and 8 deletions

View file

@ -76,6 +76,8 @@ int suic_main(void) {
float pitch = 0.000000;
float mouse_sensitivity = 0.003000;
int fps_meter_visible = 1;
char** inventory = suic_alloc_array(NULL, sizeof(char*), 3, (char*[]){suic_alloc_array(NULL, sizeof(char), 6, "Sword"), suic_alloc_array(NULL, sizeof(char), 7, "Shield"), suic_alloc_array(NULL, sizeof(char), 7, "Potion")});
bool inventory_open = false;
float cube1_x = 0.000000;
float cube1_y = 0.000000;
float cube1_z = 0.000000;
@ -168,6 +170,15 @@ int suic_main(void) {
if ((suic_is_key_pressed(KEY_F3) != 0)) {
suic_show_fps_meter((suic_vec2){ .x = 10.000000, .y = 10.000000 });
fps_meter_visible = 1;
}
if ((suic_is_key_pressed(KEY_I) != 0)) {
if (inventory_open) {
inventory_open = false;
suic_disable_cursor();
} else {
inventory_open = true;
suic_enable_cursor();
}
}
camera_x = (player_x + (forward_x * 0.500000));
camera_y = (player_y + 0.900000);
@ -194,6 +205,29 @@ int suic_main(void) {
suic_draw_cube_wires(0.000000, 0.000000, 0.000000, 0.800000, 1.600000, 0.800000, 0, 0, 0, 255);
suic_rl_pop_matrix();
suic_end_mode3d();
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 2, "N"), 1260, 20, 20, 255, 255, 255, 255);
suic_draw_line(1270, 40, 1270, 60, 255, 255, 255, 255);
suic_draw_rectangle(1100, 20, 150, 150, 0, 0, 0, 128);
suic_draw_rectangle_lines(1100, 20, 150, 150, 255, 255, 255, 128);
int minimap_center_x = 1175;
int minimap_center_y = 95;
suic_draw_circle(minimap_center_x, minimap_center_y, 3.000000, 255, 255, 0, 128);
if (inventory_open) {
suic_draw_rectangle(200, 100, 400, 300, 0, 0, 0, 200);
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 10, "Inventory"), 220, 120, 24, 255, 255, 255, 255);
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 6, "Sword"), 220, 160, 18, 200, 200, 200, 255);
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 7, "Shield"), 220, 190, 18, 200, 200, 200, 255);
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 7, "Potion"), 220, 220, 18, 200, 200, 200, 255);
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 17, "Press I to close"), 220, 350, 16, 150, 150, 150, 255);
}
suic_draw_rectangle(20, 680, 200, 20, 255, 0, 0, 128);
suic_draw_rectangle(20, 680, 150, 20, 0, 255, 0, 128);
int screen_width = 1280;
int screen_height = 720;
int crosshair_x = (screen_width / 2);
int crosshair_y = (screen_height / 2);
suic_draw_line((crosshair_x - 10), crosshair_y, (crosshair_x + 10), crosshair_y, 255, 255, 255, 255);
suic_draw_line(crosshair_x, (crosshair_y - 10), crosshair_x, (crosshair_y + 10), 255, 255, 255, 255);
suic_end_drawing();
}
suic_ode_geom_destroy(cube3_geom);

Binary file not shown.

View file

@ -100,6 +100,10 @@ fn main() -> int do
# FPS meter toggle
let mut fps_meter_visible = 1
# Inventory system
let mut inventory = ["Sword", "Shield", "Potion"] # Array of item names
let mut inventory_open = false # Whether inventory UI is open
# Cube position variables
let mut cube1_x = 0.0
@ -235,6 +239,17 @@ fn main() -> int do
fps_meter_visible = 1
end
# Toggle inventory with I key
if is_key_pressed(KEY_I) != 0 do
if inventory_open do
inventory_open = false
disable_cursor() # Hide cursor when inventory is closed
end else do
inventory_open = true
enable_cursor() # Show cursor when inventory is open
end
end
# Direction vectors are updated above
# Camera follows player (at eye position, slightly in front)
@ -280,7 +295,51 @@ fn main() -> int do
rl_pop_matrix()
end_mode3d()
# 2D UI Rendering
# Direction indicator (compass)
draw_text("N", 1260, 20, 20, 255, 255, 255, 255)
draw_line(1270, 40, 1270, 60, 255, 255, 255, 255) # North indicator line
# Simple minimap (top-right corner)
draw_rectangle(1100, 20, 150, 150, 0, 0, 0, 128) # Semi-transparent background
draw_rectangle_lines(1100, 20, 150, 150, 255, 255, 255, 128) # Border
# Player position on minimap (center)
let minimap_center_x = 1175
let minimap_center_y = 95
draw_circle(minimap_center_x, minimap_center_y, 3.0, 255, 255, 0, 128) # Yellow dot for player
# Inventory UI (when open)
if inventory_open do
# Semi-transparent background
draw_rectangle(200, 100, 400, 300, 0, 0, 0, 200)
# Title
draw_text("Inventory", 220, 120, 24, 255, 255, 255, 255)
# Inventory items (hardcoded for now)
draw_text("Sword", 220, 160, 18, 200, 200, 200, 255)
draw_text("Shield", 220, 190, 18, 200, 200, 200, 255)
draw_text("Potion", 220, 220, 18, 200, 200, 200, 255)
# Instructions
draw_text("Press I to close", 220, 350, 16, 150, 150, 150, 255)
end
# HUD elements (always visible)
# Health bar
draw_rectangle(20, 680, 200, 20, 255, 0, 0, 128) # Red background
draw_rectangle(20, 680, 150, 20, 0, 255, 0, 128) # Green fill (75% health)
# Crosshair
let screen_width = 1280
let screen_height = 720
let crosshair_x = screen_width / 2
let crosshair_y = screen_height / 2
draw_line(crosshair_x - 10, crosshair_y, crosshair_x + 10, crosshair_y, 255, 255, 255, 255)
draw_line(crosshair_x, crosshair_y - 10, crosshair_x, crosshair_y + 10, 255, 255, 255, 255)
end_drawing()
end