diff --git a/libsuicmez/libsuicmez.c b/libsuicmez/libsuicmez.c index a9f1f9b..4f8d5fb 100644 --- a/libsuicmez/libsuicmez.c +++ b/libsuicmez/libsuicmez.c @@ -148,31 +148,6 @@ void suic_draw_cube_wires(float x, float y, float z, float width, float height, DrawCubeWires((Vector3){x, y, z}, width, height, length, (Color){r, g, b, a}); } -// 2D Drawing (UI Framework Utils) -void suic_draw_text(const char *text, int x, int y, int font_size, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - DrawText(text, x, y, font_size, (Color){r, g, b, a}); -} - -void suic_draw_rectangle(int x, int y, int width, int height, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - DrawRectangle(x, y, width, height, (Color){r, g, b, a}); -} - -void suic_draw_rectangle_lines(int x, int y, int width, int height, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - DrawRectangleLines(x, y, width, height, (Color){r, g, b, a}); -} - -int suic_measure_text(const char *text, int font_size) { - return MeasureText(text, font_size); -} - -void suic_draw_circle(int center_x, int center_y, float radius, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - DrawCircle(center_x, center_y, radius, (Color){r, g, b, a}); -} - -void suic_draw_line(int start_x, int start_y, int end_x, int end_y, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - DrawLine(start_x, start_y, end_x, end_y, (Color){r, g, b, a}); -} - // Input - Keyboard bool suic_is_key_down(int key) { return IsKeyDown(key); } diff --git a/libsuicmez/libsuicmez.h b/libsuicmez/libsuicmez.h index 07d6ef9..94da220 100644 --- a/libsuicmez/libsuicmez.h +++ b/libsuicmez/libsuicmez.h @@ -128,14 +128,6 @@ void suic_end_mode3d(void); void suic_draw_cube(float x, float y, float z, float width, float height, float length, unsigned char r, unsigned char g, unsigned char b, unsigned char a); void suic_draw_cube_wires(float x, float y, float z, float width, float height, float length, unsigned char r, unsigned char g, unsigned char b, unsigned char a); -// 2D Drawing (UI Framework Utils) -void suic_draw_text(const char *text, int x, int y, int font_size, unsigned char r, unsigned char g, unsigned char b, unsigned char a); -void suic_draw_rectangle(int x, int y, int width, int height, unsigned char r, unsigned char g, unsigned char b, unsigned char a); -void suic_draw_rectangle_lines(int x, int y, int width, int height, unsigned char r, unsigned char g, unsigned char b, unsigned char a); -int suic_measure_text(const char *text, int font_size); -void suic_draw_circle(int center_x, int center_y, float radius, unsigned char r, unsigned char g, unsigned char b, unsigned char a); -void suic_draw_line(int start_x, int start_y, int end_x, int end_y, unsigned char r, unsigned char g, unsigned char b, unsigned char a); - // Input - Keyboard bool suic_is_key_down(int key); bool suic_is_key_pressed(int key); diff --git a/soup/main.c b/soup/main.c index fdd6c5c..0b35402 100644 --- a/soup/main.c +++ b/soup/main.c @@ -76,8 +76,6 @@ 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; @@ -170,15 +168,6 @@ 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); @@ -205,29 +194,6 @@ 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); diff --git a/soup/main.o b/soup/main.o index 0511bc5..1a3592b 100755 Binary files a/soup/main.o and b/soup/main.o differ diff --git a/soup/main.sui b/soup/main.sui index 8868611..a9a3672 100644 --- a/soup/main.sui +++ b/soup/main.sui @@ -100,10 +100,6 @@ 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 @@ -239,17 +235,6 @@ 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) @@ -295,51 +280,7 @@ 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 diff --git a/src/codegen/transpiler.rs b/src/codegen/transpiler.rs index eed43eb..8522c6b 100644 --- a/src/codegen/transpiler.rs +++ b/src/codegen/transpiler.rs @@ -637,13 +637,6 @@ impl Transpiler { "rl_pop_matrix" => "suic_rl_pop_matrix", "rl_translate_f" => "suic_rl_translate_f", "rl_rotate_f" => "suic_rl_rotate_f", - // UI Framework Utils - "draw_text" => "suic_draw_text", - "draw_rectangle" => "suic_draw_rectangle", - "draw_rectangle_lines" => "suic_draw_rectangle_lines", - "measure_text" => "suic_measure_text", - "draw_circle" => "suic_draw_circle", - "draw_line" => "suic_draw_line", // Player controller functions "player_controller_create" => "suic_player_controller_create", "player_controller_destroy" => "suic_player_controller_destroy", @@ -659,8 +652,6 @@ impl Transpiler { "cos" => "cos", "floor" => "floor", // Perlin noise functions - "pnoise1d" => "pnoise1d", - "pnoise2d" => "pnoise2d", "pnoise3d" => "pnoise3d", // File I/O API "file_open" => "suic_file_open", @@ -786,25 +777,13 @@ impl Transpiler { .iter() .map(|expr| self.generate_expr(expr)) .collect(); - - // Check if this is a string array (all elements are string allocations) - let is_string_array = vec.iter().all(|elem| elem.starts_with("suic_alloc_array(NULL, sizeof(char), ")); - - if is_string_array { - // String array: use char* elements - format!( - "suic_alloc_array(NULL, sizeof(char*), {}, (char*[]){{{}}})", - vec.len(), - vec.join(", ") - ) - } else { - // Regular primitive array - format!( - "suic_alloc_array(NULL, sizeof(int), {}, (int[]){{{}}})", - vec.len(), - vec.join(", ") - ) - } + // Generate heap-allocated array using helper function + // Use NULL for TypeInfo since arrays of primitives don't contain pointers + format!( + "suic_alloc_array(NULL, sizeof(int), {}, (int[]){{{}}})", + vec.len(), + vec.join(", ") + ) } } CExpr::Assign(lhs, rhs) => { diff --git a/src/typechecker.rs b/src/typechecker.rs index 2e4b122..db49f36 100644 --- a/src/typechecker.rs +++ b/src/typechecker.rs @@ -743,7 +743,6 @@ impl TypeChecker { "KEY_A", "KEY_S", "KEY_D", - "KEY_I", "KEY_SPACE", "KEY_LEFT_SHIFT", "KEY_EQUAL", @@ -998,33 +997,6 @@ impl TypeChecker { ); // Perlin noise functions - self.env.functions.insert( - "pnoise1d".to_string(), - FunctionType { - type_params: vec![], - params: vec![ - Type::Float, - Type::Float, - Type::Int, - Type::Int, - ], // x, persistence, octaves, seed - return_type: Type::Float, - }, - ); - self.env.functions.insert( - "pnoise2d".to_string(), - FunctionType { - type_params: vec![], - params: vec![ - Type::Float, - Type::Float, - Type::Float, - Type::Int, - Type::Int, - ], // x, y, persistence, octaves, seed - return_type: Type::Float, - }, - ); self.env.functions.insert( "pnoise3d".to_string(), FunctionType { @@ -1211,56 +1183,6 @@ impl TypeChecker { }, ); - // ===== UI FRAMEWORK UTILS ===== - self.env.functions.insert( - "draw_text".to_string(), - FunctionType { - type_params: vec![], - params: vec![Type::String, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int], // text, x, y, font_size, r, g, b, a - return_type: Type::Unit, - }, - ); - self.env.functions.insert( - "draw_rectangle".to_string(), - FunctionType { - type_params: vec![], - params: vec![Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int], // x, y, width, height, r, g, b, a - return_type: Type::Unit, - }, - ); - self.env.functions.insert( - "draw_rectangle_lines".to_string(), - FunctionType { - type_params: vec![], - params: vec![Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int], // x, y, width, height, r, g, b, a - return_type: Type::Unit, - }, - ); - self.env.functions.insert( - "measure_text".to_string(), - FunctionType { - type_params: vec![], - params: vec![Type::String, Type::Int], // text, font_size - return_type: Type::Int, - }, - ); - self.env.functions.insert( - "draw_circle".to_string(), - FunctionType { - type_params: vec![], - params: vec![Type::Int, Type::Int, Type::Float, Type::Int, Type::Int, Type::Int, Type::Int], // center_x, center_y, radius, r, g, b, a - return_type: Type::Unit, - }, - ); - self.env.functions.insert( - "draw_line".to_string(), - FunctionType { - type_params: vec![], - params: vec![Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int, Type::Int], // start_x, start_y, end_x, end_y, r, g, b, a - return_type: Type::Unit, - }, - ); - // ===== UUID GENERATION API ===== self.env.functions.insert( "uuid_generate_v4".to_string(), diff --git a/tests/fps_game.o b/tests/fps_game.o deleted file mode 100755 index 2b4cb75..0000000 Binary files a/tests/fps_game.o and /dev/null differ