added logo to main screen and set up the game to start from the logo screen

This commit is contained in:
Stefan Stefanov 2024-02-10 16:09:04 +02:00
parent 31de4ca06c
commit 78af71a33a
5 changed files with 66 additions and 54 deletions

View file

@ -28,6 +28,7 @@ Alien :: struct {
death_animation_index: int,
position: glm.vec2,
id: AlienKind,
last_time_fired: f64,
}
Bullet :: struct {
@ -102,12 +103,7 @@ update_game :: proc(state: ^GameState) {
// Press space to change to fire
if (rl.IsKeyPressed(rl.KeyboardKey.SPACE)) {
bullet := &bullets[bullet_index];bullet_index = (bullet_index + 1) % MAX_BULLETS
bullet.alive = true
bullet.player_bullet = true
bullet.position = player_pos
bullet.position.y = bullet.position.y - ((PLAYER_RECT.y / 2) + BULLET_RECT.y / 2.0)
log.info("Fired bullet: ", bullet)
fire_bullet(state, shot_from_player = true)
}
if (rl.IsKeyDown(rl.KeyboardKey.RIGHT)) {
@ -149,6 +145,10 @@ update_game :: proc(state: ^GameState) {
}
}
// for alien_idx in 0..< ALIENS_PER_ROW {
//
// }
// Update bullets & aliens
{
for &bullet, bi in bullets {
@ -204,6 +204,17 @@ update_game :: proc(state: ^GameState) {
}
}
fire_bullet :: proc(state: ^GameState, shot_from_player := true) {
using state
bullet := &bullets[bullet_index];bullet_index = (bullet_index + 1) % MAX_BULLETS
bullet.alive = true
bullet.player_bullet = true
bullet.position = player_pos
bullet.position.y = bullet.position.y - ((PLAYER_RECT.y / 2) + BULLET_RECT.y / 2.0)
log.info("Fired bullet: ", bullet)
}
// Since I'm using a #soa array I can't directly modify the alien & bullet entities...
damage_alien :: proc(
state: ^GameState,