Skip to content

Commit

Permalink
Add Air Arkanoid (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrZlo13 authored Feb 12, 2024
1 parent de2ee6a commit b6a6f83
Show file tree
Hide file tree
Showing 23 changed files with 1,044 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: recursive


- name: Set up ufbt
uses: flipperdevices/flipperzero-ufbt-action@v0.1.2
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "air_arkanoid/engine"]
path = air_arkanoid/engine
url = https://github.com/flipperdevices/flipperzero-game-engine.git
16 changes: 16 additions & 0 deletions air_arkanoid/application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
App(
appid="air_arkanoid",
name="Air Arkanoid",
apptype=FlipperAppType.EXTERNAL,
entry_point="game_app",
stack_size=4 * 1024,
fap_icon="icon.png",
fap_category="Games",
fap_file_assets="assets",
fap_extbuild=(
ExtFile(
path="${FAP_SRC_DIR}/assets",
command="python3 ${FAP_SRC_DIR}/engine/scripts/sprite_builder.py ${FAP_SRC_DIR.abspath}/sprites ${TARGET.abspath}/sprites",
),
),
)
Binary file added air_arkanoid/assets/sprites/logo_air.fxbm
Binary file not shown.
Binary file added air_arkanoid/assets/sprites/logo_arkanoid.fxbm
Binary file not shown.
1 change: 1 addition & 0 deletions air_arkanoid/engine
Submodule engine added at e9ae35
25 changes: 25 additions & 0 deletions air_arkanoid/fonts/fonts.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "fonts.h"

const uint8_t u8g2_font_u8glib_4_tr[681] =
"`\0\2\2\3\3\1\3\4\5\6\0\377\4\377\5\377\0\325\1\272\2\214 \4@*!\5a**"
"\42\6\323\63I\5#\12\355y\325P\325P\25\0$\13\365\271\31\34\31\215\221A\4%\6d\66\261"
"\7&\11lv\61\305*\215\0'\5\321+\2(\6\362m\252\31)\7\362-\61U\12*\5\322."
"#+\7[ri%\0,\5\321)\2-\5\313\62\3.\5I*\1/\7d\366 \266\1\60\7"
"c\62#\251\21\61\6bn\253\0\62\7c\62\63\245\1\63\7c\62+\203\21\64\7c\62\61\215\30"
"\65\7c\62C\203\21\66\7c\62#\216\1\67\7c\62\63\225\0\70\7c\62G\32\1\71\6c\62"
"\347\10:\5Y*);\5\341)I<\5Zn\62=\6[\62\33\14>\6Z.Q\1\77\7b"
".*\203\0@\10d\66Cm\60\2A\7dv*\216\31B\7d\66k\310!C\7cr\63\3"
"\1D\10d\66+\312\221\0E\10d\66G\312`\4F\10d\66C\203\225\1G\10d\66C\203\64"
"\6H\7d\66qL\31I\5a*#J\7c\62\63.\0K\10d\66q\244(\3L\6c\62"
"\261\34M\11e:\31\254\225\64\10N\7d\66q\251\31O\10dv*\312\244\0P\10d\66+\216"
"\224\1Q\11e:#\305\24\323\12R\6d\66\257\62S\10dvC\243\241\0T\7c\62+V\0"
"U\7d\66\321\34\2V\7d\66\321L\12W\11e:\31\250\244\272\0X\7c\62\251L\5Y\10"
"d\66qh\60\4Z\7d\66#\226#[\6\362-\253%\134\11d\66\31e\224Q\0]\6\362-"
"\252\65^\5\323s\15_\5\314\65#`\5\322/\61a\6[rG\0b\7c\62Q\245\5c\5"
"Z.Kd\7c\262i%\1e\7[\62#-\0f\7c\262)\255\4g\6\343\61g\22h\7"
"c\62Q%\25i\5a*Ij\7\352m\31$\5k\7c\62\61\255\2l\5a*#m\7]"
":\252\245\12n\7[\62*\251\0o\7[\62#\215\0p\7\343\61*\255\10q\7\343q+\311\0"
"r\6Z.+\1s\7[r*)\0t\7criE\1u\7[\62I\215\0v\7[\62I"
"U\0w\10]:\31\250.\0x\6[\62\251\3y\7\343\61i\304\21z\6[\62\62\12{\10\363"
"q\252\314 \12|\5\361)\7}\11\363\61\62\203\230\222\2~\7\324wI%\0\177\7l\66C\232"
"C\0\0\0\4\377\377\0";
4 changes: 4 additions & 0 deletions air_arkanoid/fonts/fonts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once
#include <stdint.h>

extern const uint8_t u8g2_font_u8glib_4_tr[];
73 changes: 73 additions & 0 deletions air_arkanoid/game.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "game.h"
#include "game_settings.h"
#include "levels/level_menu.h"
#include "levels/level_game.h"
#include "levels/level_settings.h"
#include "levels/level_message.h"

const NotificationSequence sequence_sound_blip = {
&message_note_c7,
&message_delay_50,
&message_sound_off,
NULL,
};

const NotificationSequence sequence_sound_menu = {
&message_note_c6,
&message_delay_10,
&message_sound_off,
NULL,
};

void game_start(GameManager* game_manager, void* ctx) {
GameContext* context = ctx;
context->imu = imu_alloc();
context->imu_present = imu_present(context->imu);
context->levels.menu = game_manager_add_level(game_manager, &level_menu);
context->levels.settings = game_manager_add_level(game_manager, &level_settings);
context->levels.game = game_manager_add_level(game_manager, &level_game);
context->levels.message = game_manager_add_level(game_manager, &level_message);

if(!game_settings_load(&context->settings)) {
context->settings.sound = true;
context->settings.show_fps = false;
}

context->app = furi_record_open(RECORD_NOTIFICATION);
context->game_manager = game_manager;

game_manager_show_fps_set(context->game_manager, context->settings.show_fps);
}

void game_stop(void* ctx) {
GameContext* context = ctx;
imu_free(context->imu);

furi_record_close(RECORD_NOTIFICATION);
}

const Game game = {
.target_fps = 30,
.show_fps = false,
.always_backlight = true,
.start = game_start,
.stop = game_stop,
.context_size = sizeof(GameContext),
};

void game_switch_sound(GameContext* context) {
context->settings.sound = !context->settings.sound;
game_settings_save(&context->settings);
}

void game_switch_show_fps(GameContext* context) {
context->settings.show_fps = !context->settings.show_fps;
game_manager_show_fps_set(context->game_manager, context->settings.show_fps);
game_settings_save(&context->settings);
}

void game_sound_play(GameContext* context, const NotificationSequence* sequence) {
if(context->settings.sound) {
notification_message(context->app, sequence);
}
}
35 changes: 35 additions & 0 deletions air_arkanoid/game.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once
#include "engine/engine.h"
#include "engine/sensors/imu.h"
#include <notification/notification_messages.h>

typedef struct {
Level* menu;
Level* settings;
Level* game;
Level* message;
} Levels;

typedef struct {
bool sound;
bool show_fps;
} Settings;

typedef struct {
Imu* imu;
bool imu_present;

Levels levels;
Settings settings;

NotificationApp* app;
GameManager* game_manager;
} GameContext;

void game_switch_sound(GameContext* context);

void game_switch_show_fps(GameContext* context);

void game_sound_play(GameContext* context, const NotificationSequence* sequence);

extern const NotificationSequence sequence_sound_menu;
21 changes: 21 additions & 0 deletions air_arkanoid/game_settings.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <storage/storage.h>
#include "game_settings.h"
#include <lib/toolbox/saved_struct.h>

#define SETTINGS_PATH APP_DATA_PATH("settings.bin")
#define SETTINGS_VERSION (0)
#define SETTINGS_MAGIC (0x69)

bool game_settings_load(Settings* settings) {
furi_assert(settings);

return saved_struct_load(
SETTINGS_PATH, settings, sizeof(Settings), SETTINGS_MAGIC, SETTINGS_VERSION);
}

bool game_settings_save(Settings* settings) {
furi_assert(settings);

return saved_struct_save(
SETTINGS_PATH, settings, sizeof(Settings), SETTINGS_MAGIC, SETTINGS_VERSION);
}
6 changes: 6 additions & 0 deletions air_arkanoid/game_settings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#include "game.h"

bool game_settings_save(Settings* settings);

bool game_settings_load(Settings* settings);
Binary file added air_arkanoid/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b6a6f83

Please sign in to comment.