diff --git a/src/game.odin b/src/game.odin index 84469c8..ee562d8 100644 --- a/src/game.odin +++ b/src/game.odin @@ -1,39 +1,46 @@ package game - -import rl "vendor:raylib" import "core:strings" +import rl "vendor:raylib" Game :: struct { - assets: Asset_Manager, - camera: rl.Camera2D, + // debug info + debug: Debug, + + // Game info world: rl.RenderTexture2D, + camera: rl.Camera2D, + assets: Asset_Manager, current_map: Game_Map, player: Player, enemies: [MAX_ENEMIES]Enemy, - enemy_cnt: int, - debug: Debug + enemy_count: int, + + // Timers + enenmy_spawn_timer: Timer } -// @TODO: load the full txt file on game start -GAMEPAD_MAPPINGS :: `03000000c82d00000a31000014010000,8BitDo Ultimate 2C,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, -03000000c82d00001d30000011010000,8BitDo Ultimate 2C,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,paddle1:b5,paddle2:b2,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, -05000000c82d00001b30000001000000,8BitDo Ultimate 2C,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,paddle1:b5,paddle2:b2,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,` - +// awesome odin lets me load this at compile time! +gamepad_compat := #load("../gamecontrollerdb.txt", string) game_init :: proc() -> Game { game := Game{} - rl.InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE) - rl.SetGamepadMappings(GAMEPAD_MAPPINGS) rl.SetTargetFPS(60) + gamepad_cstr := strings.clone_to_cstring(gamepad_compat) + defer delete(gamepad_cstr) + rl.SetGamepadMappings(gamepad_cstr) + game.assets = asset_manager_init() game.player = player_init(&game.assets.player) game.camera = camera_init(&game.player, 1) game.world = rl.LoadRenderTexture(GAME_WIDTH, GAME_HEIGHT) game.current_map = map_init() + // ! init timers + game.enenmy_spawn_timer = init_timer(1, true) + // @ DEBUG debug_init(&game)