diff --git a/README.md b/README.md deleted file mode 100644 index c048214..0000000 --- a/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Space Invaders - -## About -This is a simple clone I wrote in a weekend using `odin-lang` and the available `raylib` bindings. - -# Software used -* `Aseprite` for pixel art -* `neovim` and the `ols` LSP -* `make` - -# Building & running -This should be buildable through the makefile on any platform (Windows, OSX & Linux) as long as you have the Odin compiler on hand. -If the makefile is causing you trouble the project can be directly ran with (which creates a binary file as well): - -```bash -odin run . -``` -or compiled to a binary with a custom output directory & speed optimizations (although they are not needed at all): -```bash -odin build . -out:space_invaders.exe -o:speed -``` - -# Gallery -![Space Invaders Start Game Screen](https://git.stefanstefanov.eu/bersk/odin-space-invaders/raw/commit/fd0cb31206a526aefe8be0cbf391e7f446c86afe/repo/start_game_screenshot.png) - -![In Game Screen](https://git.stefanstefanov.eu/bersk/odin-space-invaders/raw/commit/fd0cb31206a526aefe8be0cbf391e7f446c86afe/repo/in_game_screenshot.png) \ No newline at end of file diff --git a/main.odin b/main.odin index 291bab2..85a7d5a 100644 --- a/main.odin +++ b/main.odin @@ -17,22 +17,24 @@ GameEndType :: enum { } state: GameState -ratio: f32 +ratio: i32 texture_atlas_image: rl.Image texture_atlas: rl.Texture2D -window_width: i32 -window_height: i32 +camera := rl.Camera2D { + zoom = GLOBAL_SPRITE_SCALE, +} +window_width : i32; window_height: i32 // orignal resolution of space invaders: 256 x 224 px setup :: proc(state: ^GameState) { using state target_fps = 60 - // monitor := rl.GetCurrentMonitor() - window_width = rl.GetScreenWidth() - window_height = rl.GetScreenHeight() + monitor := rl.GetCurrentMonitor() + window_width = rl.GetMonitorWidth(monitor) + window_height = rl.GetMonitorHeight(monitor) current_frame_time = rl.GetTime() previous_screen = .TITLE @@ -58,7 +60,6 @@ update :: proc(state: ^GameState) { update_screen(state) } - target: rl.RenderTexture2D draw :: proc(state: ^GameState) { rl.BeginTextureMode(target) @@ -74,10 +75,10 @@ draw :: proc(state: ^GameState) { target.texture, {0, 0, f32(target.texture.width), f32(-target.texture.height)}, { - (f32(window_width) - (f32(target.texture.width) * ratio)) / 2, + f32((window_width - (target.texture.width * ratio)) / 2), 0, - f32(target.texture.width) * ratio, - f32(target.texture.height) * ratio, + f32(target.texture.width * ratio), + f32(target.texture.height * ratio), }, {0, 0}, 0, @@ -102,11 +103,9 @@ main :: proc() { state.screen_width = 720 state.screen_height = 520 - rl.SetWindowMinSize(state.screen_width, state.screen_height) - target = rl.LoadRenderTexture(state.screen_width, state.screen_height) defer rl.UnloadRenderTexture(target) - ratio = f32(window_height) / f32(target.texture.height) + ratio = i32(window_height / target.texture.height) texture_atlas_image = rl.LoadImage(TEXTURE_ATLAS_PATH) texture_atlas = rl.LoadTextureFromImage(texture_atlas_image) @@ -114,11 +113,6 @@ main :: proc() { log.info("Loaded images") for !rl.WindowShouldClose() { - if rl.IsWindowResized() { - window_width = rl.GetScreenWidth() - window_height = rl.GetScreenHeight() - ratio = f32(window_height) / f32(target.texture.height) - } update(&state) draw(&state) } diff --git a/repo/in_game_screenshot.png b/repo/in_game_screenshot.png deleted file mode 100644 index 5444f6d..0000000 Binary files a/repo/in_game_screenshot.png and /dev/null differ diff --git a/repo/start_game_screenshot.png b/repo/start_game_screenshot.png deleted file mode 100644 index 9cfa28a..0000000 Binary files a/repo/start_game_screenshot.png and /dev/null differ