This repository has been archived by the owner on Jul 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NFC Maker and Jetpack Joyride apps
- Loading branch information
Showing
65 changed files
with
2,347 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# For details & more options, see documentation/AppManifests.md in firmware repo | ||
|
||
App( | ||
appid="jetpack_joyride", | ||
name="Jetpack Joyride", | ||
apptype=FlipperAppType.EXTERNAL, | ||
entry_point="jetpack_game_app", | ||
cdefines=["APP_JETPACK_GAME"], | ||
requires=["gui"], | ||
stack_size=4 * 1024, | ||
order=100, | ||
fap_icon="icon.png", | ||
fap_category="Games", | ||
fap_icon_assets="assets", | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.86 KB
applications/external/jetpack_joyride/assets/dead_scientist_infill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
applications/external/jetpack_joyride/assets/missile/frame_rate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.16 KB
applications/external/jetpack_joyride/assets/scientist_left_infill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.16 KB
applications/external/jetpack_joyride/assets/scientist_right_infill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions
81
applications/external/jetpack_joyride/includes/background_asset.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include <jetpack_joyride_icons.h> | ||
|
||
#include "background_assets.h" | ||
|
||
static AssetProperties assetProperties[BG_ASSETS_MAX] = { | ||
{.width = 27, .spawn_chance = 1, .x_offset = 24, .y_offset = 36, .sprite = &I_door}, | ||
{.width = 12, .spawn_chance = 6, .x_offset = 33, .y_offset = 14, .sprite = &I_air_vent}}; | ||
|
||
void background_assets_tick(BackgroundAsset* const assets) { | ||
// Move assets towards the player | ||
for(int i = 0; i < BG_ASSETS_MAX; i++) { | ||
if(assets[i].visible) { | ||
assets[i].point.x -= 1; // move left by 2 units | ||
if(assets[i].point.x <= | ||
-assets[i].properties->width) { // if the asset is out of screen | ||
assets[i].visible = false; // set asset x coordinate to 0 to mark it as "inactive" | ||
} | ||
} | ||
} | ||
} | ||
|
||
void spawn_random_background_asset(BackgroundAsset* const assets) { | ||
// Calculate the total spawn chances for all assets | ||
int total_spawn_chance = 0; | ||
for(int i = 0; i < BG_ASSETS_MAX; ++i) { | ||
total_spawn_chance += assetProperties[i].spawn_chance; | ||
} | ||
|
||
// Generate a random number between 0 and total_spawn_chance | ||
int random_number = rand() % total_spawn_chance; | ||
|
||
// Select the asset based on the random number | ||
int chosen_asset = -1; | ||
int accumulated_chance = 0; | ||
for(int i = 0; i < BG_ASSETS_MAX; ++i) { | ||
accumulated_chance += assetProperties[i].spawn_chance; | ||
if(random_number < accumulated_chance) { | ||
chosen_asset = i; | ||
break; | ||
} | ||
} | ||
|
||
// If no asset is chosen, return | ||
if(chosen_asset == -1) { | ||
return; | ||
} | ||
|
||
// Look for an available slot for the chosen asset | ||
for(int i = 0; i < BG_ASSETS_MAX; ++i) { | ||
if(assets[i].visible == false) { | ||
// Spawn the asset | ||
assets[i].point.x = 127 + assetProperties[chosen_asset].x_offset; | ||
assets[i].point.y = assetProperties[chosen_asset].y_offset; | ||
assets[i].properties = &assetProperties[chosen_asset]; | ||
assets[i].visible = true; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
void draw_background_assets(const BackgroundAsset* assets, Canvas* const canvas, int distance) { | ||
canvas_draw_box(canvas, 0, 6, 128, 1); | ||
canvas_draw_box(canvas, 0, 56, 128, 2); | ||
|
||
// Calculate the pillar offset based on the traveled distance | ||
int pillar_offset = distance % 64; | ||
|
||
// Draw pillars | ||
for(int x = -pillar_offset; x < 128; x += 64) { | ||
canvas_draw_icon(canvas, x, 6, &I_pillar); | ||
} | ||
|
||
// Draw assets | ||
for(int i = 0; i < BG_ASSETS_MAX; ++i) { | ||
if(assets[i].visible) { | ||
canvas_set_color(canvas, ColorBlack); | ||
canvas_draw_icon( | ||
canvas, assets[i].point.x, assets[i].point.y, assets[i].properties->sprite); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
applications/external/jetpack_joyride/includes/background_assets.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef BACKGROUND_ASSETS_H | ||
#define BACKGROUND_ASSETS_H | ||
|
||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
#include <gui/gui.h> | ||
|
||
#include "point.h" | ||
#include "states.h" | ||
#include "game_sprites.h" | ||
#include <jetpack_joyride_icons.h> | ||
|
||
#define BG_ASSETS_MAX 3 | ||
|
||
typedef struct { | ||
int width; | ||
int spawn_chance; | ||
int x_offset; | ||
int y_offset; | ||
const Icon* sprite; | ||
} AssetProperties; | ||
|
||
typedef struct { | ||
POINT point; | ||
AssetProperties* properties; | ||
bool visible; | ||
} BackgroundAsset; | ||
|
||
void background_assets_tick(BackgroundAsset* const assets); | ||
void spawn_random_background_asset(BackgroundAsset* const assets); | ||
void draw_background_assets(const BackgroundAsset* assets, Canvas* const canvas, int distance); | ||
|
||
#endif // BACKGROUND_ASSETS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "barry.h" | ||
#include "game_sprites.h" | ||
|
||
#include <gui/gui.h> | ||
#include <furi.h> | ||
|
||
void barry_tick(BARRY* const barry) { | ||
// Do jetpack things | ||
if(barry->isBoosting) { | ||
barry->gravity += GRAVITY_BOOST; // Increase upward momentum | ||
} else { | ||
barry->gravity += GRAVITY_FALL; // Increase downward momentum faster | ||
} | ||
|
||
barry->point.y += barry->gravity; | ||
|
||
// Constrain barry's height within sprite_height and 64 - sprite_height | ||
if(barry->point.y > (64 - BARRY_HEIGHT)) { | ||
barry->point.y = 64 - BARRY_HEIGHT; | ||
barry->gravity = 0; // stop upward momentum | ||
} else if(barry->point.y < 0) { | ||
barry->point.y = 0; | ||
barry->gravity = 0; // stop downward momentum | ||
} | ||
} | ||
|
||
void draw_barry(const BARRY* barry, Canvas* const canvas, const GameSprites* sprites) { | ||
canvas_set_color(canvas, ColorBlack); | ||
canvas_draw_icon_animation(canvas, barry->point.x, barry->point.y, sprites->barry); | ||
|
||
canvas_set_color(canvas, ColorWhite); | ||
canvas_draw_icon(canvas, barry->point.x, barry->point.y, sprites->barry_infill); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef BARRY_H | ||
#define BARRY_H | ||
|
||
#include <stdbool.h> | ||
|
||
#include <gui/gui.h> | ||
#include "point.h" | ||
#include "game_sprites.h" | ||
|
||
#define GRAVITY_TICK 0.2 | ||
#define GRAVITY_BOOST -0.4 | ||
#define GRAVITY_FALL 0.3 | ||
|
||
typedef struct { | ||
float gravity; | ||
POINT point; | ||
bool isBoosting; | ||
} BARRY; | ||
|
||
void barry_tick(BARRY* const barry); | ||
void draw_barry(const BARRY* barry, Canvas* const canvas, const GameSprites* sprites); | ||
|
||
#endif // BARRY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
#include <jetpack_joyride_icons.h> | ||
#include <gui/gui.h> | ||
|
||
#include "coin.h" | ||
#include "barry.h" | ||
|
||
#define PATTERN_MAX_HEIGHT 40 | ||
|
||
// Patterns | ||
const COIN_PATTERN coin_patterns[] = { | ||
{// Square pattern | ||
.count = 9, | ||
.coins = {{0, 0}, {8, 0}, {16, 0}, {0, 8}, {8, 8}, {16, 8}, {0, 16}, {8, 16}, {16, 16}}}, | ||
{// Wavy pattern (approximate sine wave) | ||
.count = 8, | ||
.coins = {{0, 8}, {8, 16}, {16, 24}, {24, 16}, {32, 8}, {40, 0}, {48, 8}, {56, 16}}}, | ||
{// Diagonal pattern | ||
.count = 5, | ||
.coins = {{0, 0}, {8, 8}, {16, 16}, {24, 24}, {32, 32}}}, | ||
// Add more patterns here | ||
}; | ||
|
||
void coin_tick(COIN* const coins, BARRY* const barry, int* const total_coins) { | ||
// Move coins towards the player | ||
for(int i = 0; i < COINS_MAX; i++) { | ||
if(coin_colides(&coins[i], barry)) { | ||
coins[i].point.x = 0; // Remove the coin | ||
(*total_coins)++; | ||
} | ||
if(coins[i].point.x > 0) { | ||
coins[i].point.x -= 1; // move left by 1 unit | ||
if(coins[i].point.x < -COIN_WIDTH) { // if the coin is out of screen | ||
coins[i].point.x = 0; // set coin x coordinate to 0 to mark it as "inactive" | ||
} | ||
} | ||
} | ||
} | ||
|
||
bool coin_colides(COIN* const coin, BARRY* const barry) { | ||
return !( | ||
barry->point.x > coin->point.x + COIN_WIDTH || // Barry is to the right of the coin | ||
barry->point.x + BARRY_WIDTH < coin->point.x || // Barry is to the left of the coin | ||
barry->point.y > coin->point.y + COIN_WIDTH || // Barry is below the coin | ||
barry->point.y + BARRY_HEIGHT < coin->point.y); // Barry is above the coin | ||
} | ||
|
||
void spawn_random_coin(COIN* const coins) { | ||
// Select a random pattern | ||
int pattern_index = rand() % (sizeof(coin_patterns) / sizeof(coin_patterns[0])); | ||
const COIN_PATTERN* pattern = &coin_patterns[pattern_index]; | ||
|
||
// Count available slots for new coins | ||
int available_slots = 0; | ||
for(int i = 0; i < COINS_MAX; ++i) { | ||
if(coins[i].point.x <= 0) { | ||
++available_slots; | ||
} | ||
} | ||
|
||
// If there aren't enough slots, return without spawning coins | ||
if(available_slots < pattern->count) return; | ||
|
||
// Spawn coins according to the selected pattern | ||
int coin_index = 0; | ||
int random_offset = rand() % (SCREEN_HEIGHT - PATTERN_MAX_HEIGHT); | ||
int random_offset_x = rand() % 16; | ||
for(int i = 0; i < pattern->count; ++i) { | ||
// Find an available slot for a new coin | ||
while(coins[coin_index].point.x > 0 && coin_index < COINS_MAX) { | ||
++coin_index; | ||
} | ||
// If no slot is available, stop spawning coins | ||
if(coin_index == COINS_MAX) break; | ||
|
||
// Spawn the coin | ||
coins[coin_index].point.x = SCREEN_WIDTH - 1 + pattern->coins[i].x + random_offset_x; | ||
coins[coin_index].point.y = | ||
random_offset + | ||
pattern->coins[i] | ||
.y; // The pattern is spawned at a random y position, but not too close to the screen edge | ||
} | ||
} | ||
|
||
void draw_coins(const COIN* coins, Canvas* const canvas, const GameSprites* sprites) { | ||
canvas_set_color(canvas, ColorBlack); | ||
for(int i = 0; i < COINS_MAX; ++i) { | ||
if(coins[i].point.x > 0) { | ||
canvas_set_color(canvas, ColorBlack); | ||
canvas_draw_icon(canvas, coins[i].point.x, coins[i].point.y, sprites->coin); | ||
|
||
canvas_set_color(canvas, ColorWhite); | ||
canvas_draw_icon(canvas, coins[i].point.x, coins[i].point.y, sprites->coin_infill); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef COIN_H | ||
#define COIN_H | ||
|
||
#include <gui/gui.h> | ||
|
||
#include "point.h" | ||
#include "barry.h" | ||
|
||
#define COINS_MAX 15 | ||
|
||
typedef struct { | ||
float gravity; | ||
POINT point; | ||
} COIN; | ||
|
||
typedef struct { | ||
int count; | ||
POINT coins[COINS_MAX]; | ||
} COIN_PATTERN; | ||
|
||
void coin_tick(COIN* const coins, BARRY* const barry, int* const poins); | ||
void spawn_random_coin(COIN* const coins); | ||
bool coin_colides(COIN* const coin, BARRY* const barry); | ||
void draw_coins(const COIN* coins, Canvas* const canvas, const GameSprites* sprites); | ||
|
||
#endif // COIN_H |
35 changes: 35 additions & 0 deletions
35
applications/external/jetpack_joyride/includes/game_sprites.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef GAME_SPRITES_H | ||
#define GAME_SPRITES_H | ||
|
||
#include "point.h" | ||
#include <gui/icon_animation.h> | ||
|
||
#define SCREEN_WIDTH 128 | ||
#define SCREEN_HEIGHT 64 | ||
|
||
#define BARRY_WIDTH 11 | ||
#define BARRY_HEIGHT 15 | ||
|
||
#define MISSILE_WIDTH 26 | ||
#define MISSILE_HEIGHT 12 | ||
|
||
#define SCIENTIST_WIDTH 9 | ||
#define SCIENTIST_HEIGHT 14 | ||
|
||
#define COIN_WIDTH 7 | ||
|
||
typedef struct { | ||
IconAnimation* barry; | ||
const Icon* barry_infill; | ||
const Icon* scientist_left; | ||
const Icon* scientist_left_infill; | ||
const Icon* scientist_right; | ||
const Icon* scientist_right_infill; | ||
const Icon* coin; | ||
const Icon* coin_infill; | ||
IconAnimation* missile; | ||
IconAnimation* alert; | ||
const Icon* missile_infill; | ||
} GameSprites; | ||
|
||
#endif // GAME_SPRITES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "game_state.h" | ||
|
||
void game_state_tick(GameState* const game_state) { | ||
game_state->distance++; | ||
} |
Oops, something went wrong.