end of scaling issues (tm)

This commit is contained in:
Stefan Stefanov 2024-02-10 23:31:03 +02:00
parent 799e5ad9eb
commit 7eaa303d6f
4 changed files with 22 additions and 34 deletions

View file

@ -54,8 +54,8 @@ setup_game :: proc(state: ^GameState) {
using state
player_pos = glm.vec2 {
f32(screen_width) / (2 * camera.zoom),
f32(screen_height) / camera.zoom - PLAYER_RECT.x,
f32(screen_width) / 2,
f32(screen_height) - PLAYER_RECT.x,
}
player_score = 0
player_health = 3
@ -101,14 +101,8 @@ update_game :: proc(state: ^GameState) {
// update bullet frame idx
if frame_counter % 10 == 0 {BULLET_FRAME_ANIM = (BULLET_FRAME_ANIM + 1) % len(BULLET_TO)}
// Press enter to change to ENDING screen
if (rl.IsKeyPressed(rl.KeyboardKey.ENTER)) {
state.screen = .ENDING
log.info("Updated screen enum", state.screen)
}
// Press space to change to fire
if (rl.IsKeyPressed(rl.KeyboardKey.SPACE)) {
if (rl.IsKeyPressed(rl.KeyboardKey.SPACE) || rl.IsKeyPressed(rl.KeyboardKey.ENTER)) {
fire_bullet(&bullets, &bullet_index)
}
@ -147,6 +141,7 @@ update_game :: proc(state: ^GameState) {
if game_over {
screen = .ENDING
log.info("Game over!", game_end)
return
}
}
@ -177,7 +172,7 @@ update_game :: proc(state: ^GameState) {
corner_alien_pos :=
shuffle_dir == .RIGHT ? aliens[ALIENS_PER_ROW - 1].position : aliens[0].position
if corner_alien_pos.x <= SPRITE_CELL ||
corner_alien_pos.x >= f32(screen_width / GLOBAL_SPRITE_SCALE) - SPRITE_CELL ||
corner_alien_pos.x >= f32(screen_width) - SPRITE_CELL ||
shuffle_dir == .DOWN {
switch shuffle_dir {
case .RIGHT:
@ -373,7 +368,7 @@ draw_game :: proc(state: ^GameState) {
texture_atlas,
{HEART_TO.x, HEART_TO.y, SPRITE_CELL, SPRITE_CELL},
{
f32(screen_width / GLOBAL_SPRITE_SCALE) - f32(hi * SPRITE_CELL * GLOBAL_SPRITE_SCALE),
f32(screen_width) - f32(hi * SPRITE),
0,
f32(PLAYER_RECT.x),
f32(PLAYER_RECT.y),