diff --git a/game/game.jai b/game/game.jai index e081df9..77f171a 100644 --- a/game/game.jai +++ b/game/game.jai @@ -1,33 +1,16 @@ #scope_file -#load "./roule/roule.jai"; - -bg_tex : Ui_Texture; - +cam : Camera = .{ + far = 1000.0 +}; #scope_export game_init :: () { - print("Game init...\n"); - print("Loading bg...\n"); - img := create_texture_from_pack("./game/resources/bg.png"); - bg_tex.tex = img; - table_init(); } game_tick :: () { - if input_button_states[#char "W"] & .START { - table_roll(); - } } - game_draw :: () { - w,h := get_window_size(); - - - set_shader_for_images(*bg_tex); - immediate_rect(0,0,xx w,xx h); - immediate_flush(); - - draw_table(); + draw_sky(*cam); } diff --git a/game/resources/bg.png b/game/resources/bg.png deleted file mode 100644 index 9806269..0000000 Binary files a/game/resources/bg.png and /dev/null differ diff --git a/game/resources/roule-ball.png b/game/resources/roule-ball.png deleted file mode 100644 index ad46009..0000000 Binary files a/game/resources/roule-ball.png and /dev/null differ diff --git a/game/resources/roule-spin.png b/game/resources/roule-spin.png deleted file mode 100644 index 4104b20..0000000 Binary files a/game/resources/roule-spin.png and /dev/null differ diff --git a/game/resources/roule.aseprite b/game/resources/roule.aseprite deleted file mode 100644 index d868a26..0000000 Binary files a/game/resources/roule.aseprite and /dev/null differ diff --git a/game/resources/roule.png b/game/resources/roule.png deleted file mode 100644 index 340cab8..0000000 Binary files a/game/resources/roule.png and /dev/null differ diff --git a/game/roule/roule.jai b/game/roule/roule.jai deleted file mode 100644 index eeeee8d..0000000 --- a/game/roule/roule.jai +++ /dev/null @@ -1,125 +0,0 @@ -// #scope_file - -random :: #import "Random"; - -Color :: enum { - RED; - BLACK; - GREEN; -}; - -RouleMode :: enum { - WAITING; - ANIMATING; - DONE; -}; - -Slot :: struct { - color : Color; - number : int; -}; - -RouleTable :: struct { - animStart : float = -1; - angle : float = 0; - slot : Slot = .{}; - mode : RouleMode = .WAITING; -}; - -tableState : RouleTable; - - - -rouleSlots : []Slot = .[ - .{.GREEN, 0}, - .{.RED, 32}, - .{.BLACK, 15}, - .{.RED, 19}, - .{.BLACK, 4}, - .{.RED, 21}, - .{.BLACK, 2}, - .{.RED, 25}, - .{.BLACK, 17}, - .{.RED, 34}, - .{.BLACK, 6}, - .{.RED, 27}, - .{.BLACK, 13}, - .{.RED, 36}, - .{.BLACK, 11}, - .{.RED, 30}, - .{.BLACK, 8}, - .{.RED, 23}, - .{.BLACK, 10}, - .{.RED, 5}, - .{.BLACK, 24}, - .{.RED, 16}, - .{.BLACK, 33}, - .{.RED, 1}, - .{.BLACK, 20}, - .{.RED, 14}, - .{.BLACK, 31}, - .{.RED, 9}, - .{.BLACK, 22}, - .{.RED, 18}, - .{.BLACK, 29}, - .{.RED, 7}, - .{.BLACK, 28}, - .{.RED, 12}, - .{.BLACK, 35}, - .{.RED, 3}, - .{.BLACK, 26}, -]; - -get_roll_result :: () -> (Slot, float) { - slot := random.random_get() % rouleSlots.count.(u64); - return rouleSlots[xx slot], slot.(float) / rouleSlots.count.(float); -} - -wheel_tex : Ui_Texture; -base_tex : Ui_Texture; -ball_tex : Ui_Texture; - -WHEEL_SIZE :: 3.5; - -get_ball :: () -> (ball_size: float, ball_speed: float) { - if tableState.mode == .WAITING { - return 4.7, -20; - } else if tableState.mode == .ANIMATING { - return lerp(4.7, 3, min(1.0, get_time().(float) - tableState.animStart.(float))), -20; - } -} - -#scope_export - -table_roll :: () { - tableState.animStart = get_time().(float); - tableState.slot, tableState.angle = get_roll_result(); - tableState.mode = .ANIMATING; -} - -table_init :: () { - img := create_texture_from_pack("./game/resources/roule-spin.png"); - wheel_tex.tex = img; - img = create_texture_from_pack("./game/resources/roule.png"); - base_tex.tex = img; - img = create_texture_from_pack("./game/resources/roule-ball.png"); - ball_tex.tex = img; -} - -draw_table :: () { - w,h := get_window_size(); - uw := ui_w(10,0); - - ball_size, ball_speed := get_ball(); - - diff := ball_size * uw - WHEEL_SIZE * uw; - set_shader_for_images(*base_tex); - immediate_rect((5-(WHEEL_SIZE/2)) * uw, 50,WHEEL_SIZE*uw,WHEEL_SIZE*uw); - immediate_flush(); - set_shader_for_images(*wheel_tex); - immediate_rect((5-(WHEEL_SIZE/2)) * uw, 50,WHEEL_SIZE*uw,WHEEL_SIZE*uw, cast(float) get_time()); - immediate_flush(); - set_shader_for_images(*ball_tex); - immediate_rect((5-(ball_size/2)) * uw, 50 - diff/2 ,ball_size*uw,ball_size*uw, cast(float) (ball_size * -1 * get_time())); - immediate_flush(); -} diff --git a/src/arbtri.jai b/src/arbtri.jai index ac4486e..0f19b6b 100644 --- a/src/arbtri.jai +++ b/src/arbtri.jai @@ -13,6 +13,8 @@ Arb_Draw_Command_Type :: enum { FONT_BOUNDARY; QUAD_OCCLUDER; REMOVE_TEXTURE; + SET_SCISSOR; + REMOVE_SCISSOR; } Arb_Draw_Command :: struct { @@ -26,6 +28,8 @@ Arb_Draw_Command :: struct { // for text layer: s32 = 0; + scissor: Ui_Rect; + } Arb_Tri_State :: struct { @@ -100,7 +104,7 @@ arb_tri_flush :: () { flush_arb_commands(); } -debug_arb_flush : bool : false; +debug_arb_flush : bool : true; layer : s32 = 0; @@ -122,6 +126,15 @@ flush_arb_commands :: () { sg_apply_bindings(*gPipelines.arbtri.bind); sg_draw(xx (it.tri_offset * 3), xx (it.tri_count * 3), 1); case .PREPARE_TEXT; + case .SET_SCISSOR; + s := it.scissor; + w,h := get_window_size(); + sgl_viewport(0,0,w,h,true); + sg_apply_scissor_rect(s.x, s.y, s.w, s.h, true); + case .REMOVE_SCISSOR; + print("REMOVING scissor!\n"); + w,h := get_window_size(); + sg_apply_scissor_rect(0, 0, w, w, true); case .DRAW_TEXT; sgl_draw_layer(it.layer); } diff --git a/src/ui/ui.jai b/src/ui/ui.jai index 281cc99..381b7a8 100644 --- a/src/ui/ui.jai +++ b/src/ui/ui.jai @@ -122,12 +122,10 @@ get_render_size :: () -> (s32, s32) { } set_scissor :: (x0: s32, y0: s32, x1: s32, y1: s32) { - w,h := get_render_size(); - gScissor = .{x0, y0, x1 - x0, y1 - y0}; - gScissorActive = true; + arb_tri_command_add(.{ type = .SET_SCISSOR, scissor = .{x0, y0, x1 - x0, y1 - y0}}); } clear_scissor :: () { - gScissorActive = false; + arb_tri_command_add(.{type = .REMOVE_SCISSOR}); } gCurrentTexture : *Ui_Texture = null;