Skip to content

Commit b6a6f83

Browse files
authored
Add Air Arkanoid (#141)
1 parent de2ee6a commit b6a6f83

23 files changed

+1044
-0
lines changed

.github/workflows/build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
uses: actions/checkout@v3
2525
with:
2626
fetch-depth: 2
27+
submodules: recursive
28+
2729

2830
- name: Set up ufbt
2931
uses: flipperdevices/[email protected]

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "air_arkanoid/engine"]
2+
path = air_arkanoid/engine
3+
url = https://github.com/flipperdevices/flipperzero-game-engine.git

air_arkanoid/application.fam

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
App(
2+
appid="air_arkanoid",
3+
name="Air Arkanoid",
4+
apptype=FlipperAppType.EXTERNAL,
5+
entry_point="game_app",
6+
stack_size=4 * 1024,
7+
fap_icon="icon.png",
8+
fap_category="Games",
9+
fap_file_assets="assets",
10+
fap_extbuild=(
11+
ExtFile(
12+
path="${FAP_SRC_DIR}/assets",
13+
command="python3 ${FAP_SRC_DIR}/engine/scripts/sprite_builder.py ${FAP_SRC_DIR.abspath}/sprites ${TARGET.abspath}/sprites",
14+
),
15+
),
16+
)
102 Bytes
Binary file not shown.
327 Bytes
Binary file not shown.

air_arkanoid/engine

Submodule engine added at e9ae35c

air_arkanoid/fonts/fonts.c

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

air_arkanoid/fonts/fonts.h

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#pragma once
2+
#include <stdint.h>
3+
4+
extern const uint8_t u8g2_font_u8glib_4_tr[];

air_arkanoid/game.c

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#include "game.h"
2+
#include "game_settings.h"
3+
#include "levels/level_menu.h"
4+
#include "levels/level_game.h"
5+
#include "levels/level_settings.h"
6+
#include "levels/level_message.h"
7+
8+
const NotificationSequence sequence_sound_blip = {
9+
&message_note_c7,
10+
&message_delay_50,
11+
&message_sound_off,
12+
NULL,
13+
};
14+
15+
const NotificationSequence sequence_sound_menu = {
16+
&message_note_c6,
17+
&message_delay_10,
18+
&message_sound_off,
19+
NULL,
20+
};
21+
22+
void game_start(GameManager* game_manager, void* ctx) {
23+
GameContext* context = ctx;
24+
context->imu = imu_alloc();
25+
context->imu_present = imu_present(context->imu);
26+
context->levels.menu = game_manager_add_level(game_manager, &level_menu);
27+
context->levels.settings = game_manager_add_level(game_manager, &level_settings);
28+
context->levels.game = game_manager_add_level(game_manager, &level_game);
29+
context->levels.message = game_manager_add_level(game_manager, &level_message);
30+
31+
if(!game_settings_load(&context->settings)) {
32+
context->settings.sound = true;
33+
context->settings.show_fps = false;
34+
}
35+
36+
context->app = furi_record_open(RECORD_NOTIFICATION);
37+
context->game_manager = game_manager;
38+
39+
game_manager_show_fps_set(context->game_manager, context->settings.show_fps);
40+
}
41+
42+
void game_stop(void* ctx) {
43+
GameContext* context = ctx;
44+
imu_free(context->imu);
45+
46+
furi_record_close(RECORD_NOTIFICATION);
47+
}
48+
49+
const Game game = {
50+
.target_fps = 30,
51+
.show_fps = false,
52+
.always_backlight = true,
53+
.start = game_start,
54+
.stop = game_stop,
55+
.context_size = sizeof(GameContext),
56+
};
57+
58+
void game_switch_sound(GameContext* context) {
59+
context->settings.sound = !context->settings.sound;
60+
game_settings_save(&context->settings);
61+
}
62+
63+
void game_switch_show_fps(GameContext* context) {
64+
context->settings.show_fps = !context->settings.show_fps;
65+
game_manager_show_fps_set(context->game_manager, context->settings.show_fps);
66+
game_settings_save(&context->settings);
67+
}
68+
69+
void game_sound_play(GameContext* context, const NotificationSequence* sequence) {
70+
if(context->settings.sound) {
71+
notification_message(context->app, sequence);
72+
}
73+
}

air_arkanoid/game.h

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#pragma once
2+
#include "engine/engine.h"
3+
#include "engine/sensors/imu.h"
4+
#include <notification/notification_messages.h>
5+
6+
typedef struct {
7+
Level* menu;
8+
Level* settings;
9+
Level* game;
10+
Level* message;
11+
} Levels;
12+
13+
typedef struct {
14+
bool sound;
15+
bool show_fps;
16+
} Settings;
17+
18+
typedef struct {
19+
Imu* imu;
20+
bool imu_present;
21+
22+
Levels levels;
23+
Settings settings;
24+
25+
NotificationApp* app;
26+
GameManager* game_manager;
27+
} GameContext;
28+
29+
void game_switch_sound(GameContext* context);
30+
31+
void game_switch_show_fps(GameContext* context);
32+
33+
void game_sound_play(GameContext* context, const NotificationSequence* sequence);
34+
35+
extern const NotificationSequence sequence_sound_menu;

air_arkanoid/game_settings.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <storage/storage.h>
2+
#include "game_settings.h"
3+
#include <lib/toolbox/saved_struct.h>
4+
5+
#define SETTINGS_PATH APP_DATA_PATH("settings.bin")
6+
#define SETTINGS_VERSION (0)
7+
#define SETTINGS_MAGIC (0x69)
8+
9+
bool game_settings_load(Settings* settings) {
10+
furi_assert(settings);
11+
12+
return saved_struct_load(
13+
SETTINGS_PATH, settings, sizeof(Settings), SETTINGS_MAGIC, SETTINGS_VERSION);
14+
}
15+
16+
bool game_settings_save(Settings* settings) {
17+
furi_assert(settings);
18+
19+
return saved_struct_save(
20+
SETTINGS_PATH, settings, sizeof(Settings), SETTINGS_MAGIC, SETTINGS_VERSION);
21+
}

air_arkanoid/game_settings.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
#include "game.h"
3+
4+
bool game_settings_save(Settings* settings);
5+
6+
bool game_settings_load(Settings* settings);

air_arkanoid/icon.png

7.7 KB
Loading

0 commit comments

Comments
 (0)