diff --git a/assets/ball.png b/assets/ball.png new file mode 100644 index 0000000..3a25831 Binary files /dev/null and b/assets/ball.png differ diff --git a/assets/jet.png b/assets/jet.png new file mode 100644 index 0000000..3b2ffff Binary files /dev/null and b/assets/jet.png differ diff --git a/assets/pad.png b/assets/pad.png new file mode 100644 index 0000000..969dd21 Binary files /dev/null and b/assets/pad.png differ diff --git a/assets_src/ball.aseprite b/assets_src/ball.aseprite new file mode 100644 index 0000000..e0af645 Binary files /dev/null and b/assets_src/ball.aseprite differ diff --git a/assets_src/jet.aseprite b/assets_src/jet.aseprite new file mode 100644 index 0000000..a560120 Binary files /dev/null and b/assets_src/jet.aseprite differ diff --git a/assets_src/pad.aseprite b/assets_src/pad.aseprite new file mode 100644 index 0000000..3ca981f Binary files /dev/null and b/assets_src/pad.aseprite differ diff --git a/game.odin b/game.odin index 3633c43..fe21263 100644 --- a/game.odin +++ b/game.odin @@ -1,8 +1,12 @@ package main import rl "vendor:raylib" +import "vendor:raylib/rlgl" import "core:fmt" +// Virtual game field dimensions +GameField := Vec2{800, 600} + Pad :: struct { position: Vec2, @@ -29,6 +33,7 @@ Game :: struct { pad: Pad, balls: [dynamic]Ball, bricks: [dynamic]Brick, + camera: rl.Camera2D } @@ -38,8 +43,12 @@ game_init :: proc() -> ^GameState { state.draw = game_draw state.update = game_update state.lives = 3 + state.camera = rl.Camera2D{ + zoom = 1, + target = GameField / 2, + } state.pad = Pad{ - position = {f32(WINDOW_WIDTH / 2), f32(WINDOW_HEIGHT - 40)}, + position = Vec2{GameField.x / 2, GameField.y - 40}, size = {80, 10}, } return state @@ -58,6 +67,8 @@ game_update :: proc(state: ^GameState, delta: f32) { pad.position.x += 100 * delta } + game.camera.offset = WINDOWF / 2 + } game_draw :: proc(state: ^GameState) { @@ -65,7 +76,12 @@ game_draw :: proc(state: ^GameState) { using game + rl.BeginMode2D(camera) + rl.ClearBackground(rl.RAYWHITE) + + rl.DrawRectangleV({0, 0}, GameField, rl.RED) rl.DrawRectangleV(pad.position, pad.size, rl.GREEN) + rl.EndMode2D() } diff --git a/main.odin b/main.odin index 0051dbf..ca801d7 100644 --- a/main.odin +++ b/main.odin @@ -2,22 +2,25 @@ package main import rl "vendor:raylib" import "core:slice" +import "core:fmt" Vec2 :: [2]f32 Vec2i :: [2]i32 -WINDOW_WIDTH : i32 = 800 -WINDOW_HEIGHT : i32 = 480 +WINDOW : Vec2i +WINDOWF : Vec2 main :: proc() { - rl.SetConfigFlags(rl.ConfigFlags{.BORDERLESS_WINDOWED_MODE, .VSYNC_HINT, .WINDOW_RESIZABLE}) + rl.SetConfigFlags(rl.ConfigFlags{.FULLSCREEN_MODE, .VSYNC_HINT, .WINDOW_MAXIMIZED, .WINDOW_UNDECORATED}) monitor := rl.GetCurrentMonitor() - WINDOW_WIDTH = rl.GetMonitorWidth(monitor) - WINDOW_HEIGHT = rl.GetMonitorHeight(monitor) - rl.InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "SinePong") + rl.InitWindow(0, 0, "SinePong") rl.SetTargetFPS(9999) + WINDOW.x = rl.GetScreenWidth() + WINDOW.y = rl.GetScreenHeight() + WINDOWF = Vec2{f32(WINDOW.x), f32(WINDOW.y)} + stack_init() defer { @@ -31,8 +34,9 @@ main :: proc() { for (!rl.WindowShouldClose()) { if rl.IsWindowResized() { - WINDOW_WIDTH = rl.GetScreenWidth() - WINDOW_HEIGHT = rl.GetScreenHeight() + WINDOW.x = rl.GetScreenWidth() + WINDOW.y = rl.GetScreenHeight() + WINDOWF = Vec2{f32(WINDOW.x), f32(WINDOW.y)} } current_state := state_stack[len(state_stack)-1] diff --git a/sineys-arkanoid b/sineys-arkanoid new file mode 100755 index 0000000..fbc54fe Binary files /dev/null and b/sineys-arkanoid differ diff --git a/state.odin b/state.odin index 58b9279..7036481 100644 --- a/state.odin +++ b/state.odin @@ -23,6 +23,7 @@ STACK_SIZE :: 16 state_buf : [STACK_SIZE]^GameState state_stack : [dynamic]^GameState + stack_init :: proc() { state_stack = slice.into_dynamic(state_buf[:]) }