|
@@ -12,6 +12,7 @@
|
|
|
#include "includes/particle.h"
|
|
#include "includes/particle.h"
|
|
|
#include "includes/coin.h"
|
|
#include "includes/coin.h"
|
|
|
#include "includes/missile.h"
|
|
#include "includes/missile.h"
|
|
|
|
|
+#include "includes/background_assets.h"
|
|
|
|
|
|
|
|
#include "includes/game_state.h"
|
|
#include "includes/game_state.h"
|
|
|
|
|
|
|
@@ -47,14 +48,14 @@ static void jetpack_game_state_init(GameState* const game_state) {
|
|
|
sprites.missile = icon_animation_alloc(&A_missile);
|
|
sprites.missile = icon_animation_alloc(&A_missile);
|
|
|
sprites.missile_infill = &I_missile_infill;
|
|
sprites.missile_infill = &I_missile_infill;
|
|
|
|
|
|
|
|
- sprites.bg[0] = &I_bg1;
|
|
|
|
|
- sprites.bg[1] = &I_bg2;
|
|
|
|
|
- sprites.bg[2] = &I_bg3;
|
|
|
|
|
|
|
+ // sprites.bg[0] = &I_bg1;
|
|
|
|
|
+ // sprites.bg[1] = &I_bg2;
|
|
|
|
|
+ // sprites.bg[2] = &I_bg3;
|
|
|
|
|
|
|
|
- for(int i = 0; i < 3; ++i) {
|
|
|
|
|
- sprites.bg_pos[i].x = i * 128;
|
|
|
|
|
- sprites.bg_pos[i].y = 0;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // for(int i = 0; i < 3; ++i) {
|
|
|
|
|
+ // sprites.bg_pos[i].x = i * 128;
|
|
|
|
|
+ // sprites.bg_pos[i].y = 0;
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
icon_animation_start(sprites.barry);
|
|
icon_animation_start(sprites.barry);
|
|
|
icon_animation_start(sprites.missile);
|
|
icon_animation_start(sprites.missile);
|
|
@@ -86,13 +87,19 @@ static void jetpack_game_tick(GameState* const game_state) {
|
|
|
scientist_tick(game_state->scientists);
|
|
scientist_tick(game_state->scientists);
|
|
|
missile_tick(game_state->missiles, &game_state->barry, &game_state->state);
|
|
missile_tick(game_state->missiles, &game_state->barry, &game_state->state);
|
|
|
|
|
|
|
|
- for(int i = 0; i < 3; ++i) {
|
|
|
|
|
- game_state->sprites.bg_pos[i].x -= 1;
|
|
|
|
|
- if(game_state->sprites.bg_pos[i].x <= -128) {
|
|
|
|
|
- game_state->sprites.bg_pos[i].x = 128 * 2; // 2 other images are 128 px each
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ background_assets_tick(game_state->bg_assets);
|
|
|
|
|
+
|
|
|
|
|
+ if(game_state->distance % 64 == 0) {
|
|
|
|
|
+ spawn_random_background_asset(game_state->bg_assets);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // for(int i = 0; i < 3; ++i) {
|
|
|
|
|
+ // game_state->sprites.bg_pos[i].x -= 1;
|
|
|
|
|
+ // if(game_state->sprites.bg_pos[i].x <= -128) {
|
|
|
|
|
+ // game_state->sprites.bg_pos[i].x = 128 * 2; // 2 other images are 128 px each
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
if((rand() % 100) < 1) {
|
|
if((rand() % 100) < 1) {
|
|
|
spawn_random_coin(game_state->coins);
|
|
spawn_random_coin(game_state->coins);
|
|
|
}
|
|
}
|
|
@@ -116,13 +123,17 @@ static void jetpack_game_render_callback(Canvas* const canvas, void* ctx) {
|
|
|
if(game_state->state == GameStateLife) {
|
|
if(game_state->state == GameStateLife) {
|
|
|
// canvas_draw_box(canvas, 0, 0, 128, 32);
|
|
// canvas_draw_box(canvas, 0, 0, 128, 32);
|
|
|
|
|
|
|
|
- for(int i = 0; i < 3; ++i) {
|
|
|
|
|
- // Check if the image is within the screen's boundaries
|
|
|
|
|
- if(game_state->sprites.bg_pos[i].x >= -127 && game_state->sprites.bg_pos[i].x < 128) {
|
|
|
|
|
- // canvas_draw_icon(
|
|
|
|
|
- // canvas, game_state->sprites.bg_pos[i].x, 0, game_state->sprites.bg[i]);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // for(int i = 0; i < 3; ++i) {
|
|
|
|
|
+ // // Check if the image is within the screen's boundaries
|
|
|
|
|
+ // if(game_state->sprites.bg_pos[i].x >= -127 && game_state->sprites.bg_pos[i].x < 128) {
|
|
|
|
|
+ // canvas_draw_icon(
|
|
|
|
|
+ // canvas, game_state->sprites.bg_pos[i].x, 0, game_state->sprites.bg[i]);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ canvas_set_bitmap_mode(canvas, false);
|
|
|
|
|
+
|
|
|
|
|
+ draw_background_assets(game_state->bg_assets, canvas, game_state->distance);
|
|
|
|
|
|
|
|
canvas_set_bitmap_mode(canvas, true);
|
|
canvas_set_bitmap_mode(canvas, true);
|
|
|
|
|
|