package main import rl "vendor:raylib" import "core:fmt" Pad :: struct { position: Vec2, size: Vec2, } Ball :: struct { position: Vec2, velocity: Vec2, radius: f32, } Brick :: struct { position: Vec2, size: Vec2, color: rl.Color, hits: u8, } Game :: struct { using state: GameState, lives: u8, pad: Pad, balls: [dynamic]Ball, bricks: [dynamic]Brick, } game_init :: proc() -> ^GameState { state := new(Game) state.variant = state state.draw = game_draw state.update = game_update state.lives = 3 state.pad = Pad{ position = {f32(WINDOW_WIDTH / 2), f32(WINDOW_HEIGHT - 40)}, size = {80, 10}, } return state } game_update :: proc(state: ^GameState, delta: f32) { game := transmute(^Game)state using game if rl.IsKeyDown(rl.KeyboardKey.LEFT) { pad.position.x -= 100 * delta fmt.println(pad.position) } if rl.IsKeyDown(rl.KeyboardKey.RIGHT) { pad.position.x += 100 * delta } } game_draw :: proc(state: ^GameState) { game := transmute(^Game)state using game rl.ClearBackground(rl.RAYWHITE) rl.DrawRectangleV(pad.position, pad.size, rl.GREEN) }