basic sprites working

This commit is contained in:
Stefan Stefanov 2024-02-09 22:06:25 +02:00
parent 178cf92f44
commit 348b4fd181
6 changed files with 216 additions and 63 deletions

View file

@ -9,6 +9,11 @@ import rl "vendor:raylib"
// orignal resolution of space invaders
// 256 x 224 px
TEXTURE_ATLAS_PATH :: "./assets/texture_atlas.png"
DEBUG_MODE :: true
GameState :: struct {
// window
target_fps: c.int,
@ -24,15 +29,20 @@ GameState :: struct {
screen: GameScreen,
previous_screen: GameScreen,
last_frame_screen: GameScreen,
reset_game: bool,
aliens: #soa[ALIENS]Alien,
bullets: #soa[MAX_BULLETS]Bullet,
bullet_index: int,
player_pos: glm.vec2,
player_health: c.int,
player_score: c.int,
player_high_score: c.int,
}
state: GameState
texture_atlas_image : rl.Image
texture_atlas : rl.Texture2D
setup :: proc(state: ^GameState) {
using state
target_fps = 60
@ -76,6 +86,12 @@ main :: proc() {
rl.InitWindow(state.screen_width, state.screen_height, state.title)
defer rl.CloseWindow()
texture_atlas_image = rl.LoadImage(TEXTURE_ATLAS_PATH)
texture_atlas = rl.LoadTextureFromImage(texture_atlas_image)
rl.UnloadImage(texture_atlas_image)
log.info("Loaded images")
for !rl.WindowShouldClose() {
update(&state)
draw(&state)