added logo to main screen and set up the game to start from the logo screen
This commit is contained in:
parent
31de4ca06c
commit
78af71a33a
5 changed files with 66 additions and 54 deletions
23
game.odin
23
game.odin
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue