diff options
author | BoredGuy <osome3717@gmail.com> | 2025-01-03 11:38:13 +0300 |
---|---|---|
committer | BoredGuy <osome3717@gmail.com> | 2025-01-03 11:38:13 +0300 |
commit | 5f7e0d8cf88d0adb9739e2cc7e26ba26243975f8 (patch) | |
tree | 099937e59239471f0f611602b5b7788dfde91814 /Week1-Pacman/src/main.c | |
parent | 1d1554652888fa4f0cd12a51fda8d9bd54dbcee6 (diff) |
Minor optimization
Animations can now share a single texture
Diffstat (limited to 'Week1-Pacman/src/main.c')
-rw-r--r-- | Week1-Pacman/src/main.c | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/Week1-Pacman/src/main.c b/Week1-Pacman/src/main.c index 66e1278..6ae2fde 100644 --- a/Week1-Pacman/src/main.c +++ b/Week1-Pacman/src/main.c @@ -40,38 +40,12 @@ int main(int argc, char** argv) { keyboard = SDL_GetKeyboardState(NULL); - for(int i = 0; i < 4; i++) - init_animation(&pacman.animations[i], &(struct animation_init){ - .ren = demo.ren, - .spritesheet = "assets/Sprites/sprites.png", - - .initial_angle = 90.0 * i, - .initial_frame_count = 3, - .initial_frame_times = (float[]){0.05, 0.05, 0.05}, - .initial_frames = (SDL_Rect[]) { - { - .x = 0, - .y = 285, - .w = 180, - .h = 195 - }, - { - .x = 240, - .y = 285, - .w = 180, - .h = 195 - }, - { - .x = 465, - .y = 285, - .w = 195, - .h = 195 - } - } - }); - pacman.facing = FACING_DOWN; - pacman.xpos = 100; - pacman.ypos = 200; + load_pacman_spritesheet(&demo); + init_pacman(&pacman, &(struct pacman_init) { + .initial_xpos = 100, + .initial_ypos = 200, + .initial_facing = FACING_DOWN + }); int then = SDL_GetTicks(); |