forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
85 changed files
with
6,887 additions
and
1 deletion.
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
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,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 not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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,13 @@ | ||
# Flipper Zero Game Engine | ||
|
||
Welcome to the Flipper Zero game engine! This engine is designed to help you create games for the Flipper Zero device. | ||
|
||
## Example App | ||
|
||
To see the game engine in action, check out our [example app](https://github.com/flipperdevices/flipperzero-game-engine-example). This app demonstrates how to use the game engine to create a simple game. | ||
|
||
## Contributing | ||
|
||
We welcome contributions to the Flipper Zero game engine! If you have any bug reports, feature requests, or pull requests, please submit them to the [official repository](https://github.com/flipperdevices/flipperzero-game-engine). | ||
|
||
Happy game development with Flipper Zero! |
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,28 @@ | ||
#include <furi.h> | ||
#include "canvas.h" | ||
|
||
void canvas_printf(Canvas* canvas, uint8_t x, uint8_t y, const char* format, ...) { | ||
FuriString* string = furi_string_alloc(); | ||
va_list args; | ||
va_start(args, format); | ||
furi_string_vprintf(string, format, args); | ||
va_end(args); | ||
|
||
canvas_draw_str(canvas, x, y, furi_string_get_cstr(string)); | ||
|
||
furi_string_free(string); | ||
} | ||
|
||
size_t canvas_printf_width(Canvas* canvas, const char* format, ...) { | ||
FuriString* string = furi_string_alloc(); | ||
va_list args; | ||
va_start(args, format); | ||
furi_string_vprintf(string, format, args); | ||
va_end(args); | ||
|
||
size_t size = canvas_string_width(canvas, furi_string_get_cstr(string)); | ||
|
||
furi_string_free(string); | ||
|
||
return size; | ||
} |
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,32 @@ | ||
#pragma once | ||
#include <stddef.h> | ||
#include <gui/canvas.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Print formatted string to canvas | ||
* | ||
* @param canvas canvas instance | ||
* @param x x position | ||
* @param y y position | ||
* @param format format string | ||
* @param ... arguments | ||
*/ | ||
void canvas_printf(Canvas* canvas, uint8_t x, uint8_t y, const char* format, ...); | ||
|
||
/** | ||
* @brief Get width of formatted string | ||
* | ||
* @param canvas canvas instance | ||
* @param format format string | ||
* @param ... arguments | ||
* @return size_t width of formatted string | ||
*/ | ||
size_t canvas_printf_width(Canvas* canvas, const char* format, ...); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
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,53 @@ | ||
#include "clock_timer.h" | ||
#include <stdlib.h> | ||
|
||
#include <furi_hal_interrupt.h> | ||
#include <furi_hal_bus.h> | ||
#include <stm32wbxx_ll_tim.h> | ||
|
||
#define FURI_HAL_CLOCK_TIMER TIM2 | ||
#define FURI_HAL_CLOCK_TIMER_BUS FuriHalBusTIM2 | ||
#define FURI_HAL_CLOCK_TIMER_IRQ FuriHalInterruptIdTIM2 | ||
|
||
typedef struct { | ||
ClockTimerCallback callback; | ||
void* context; | ||
} ClockTimer; | ||
|
||
static ClockTimer clock_timer = { | ||
.callback = NULL, | ||
.context = NULL, | ||
}; | ||
|
||
static void clock_timer_isr(void* context) { | ||
if(clock_timer.callback) { | ||
clock_timer.callback(context); | ||
} | ||
|
||
LL_TIM_ClearFlag_UPDATE(FURI_HAL_CLOCK_TIMER); | ||
} | ||
|
||
void clock_timer_start(ClockTimerCallback callback, void* context, float period) { | ||
clock_timer.callback = callback; | ||
clock_timer.context = context; | ||
|
||
furi_hal_bus_enable(FURI_HAL_CLOCK_TIMER_BUS); | ||
|
||
// init timer to produce interrupts | ||
LL_TIM_InitTypeDef TIM_InitStruct = {0}; | ||
TIM_InitStruct.Autoreload = (SystemCoreClock / period) - 1; | ||
LL_TIM_Init(FURI_HAL_CLOCK_TIMER, &TIM_InitStruct); | ||
|
||
furi_hal_interrupt_set_isr(FURI_HAL_CLOCK_TIMER_IRQ, clock_timer_isr, clock_timer.context); | ||
|
||
LL_TIM_EnableIT_UPDATE(FURI_HAL_CLOCK_TIMER); | ||
LL_TIM_EnableCounter(FURI_HAL_CLOCK_TIMER); | ||
} | ||
|
||
void clock_timer_stop(void) { | ||
LL_TIM_DisableIT_UPDATE(FURI_HAL_CLOCK_TIMER); | ||
LL_TIM_DisableCounter(FURI_HAL_CLOCK_TIMER); | ||
|
||
furi_hal_bus_disable(FURI_HAL_CLOCK_TIMER_BUS); | ||
furi_hal_interrupt_set_isr(FURI_HAL_CLOCK_TIMER_IRQ, NULL, NULL); | ||
} |
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 @@ | ||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef void (*ClockTimerCallback)(void* context); | ||
|
||
void clock_timer_start(ClockTimerCallback callback, void* context, float period); | ||
|
||
void clock_timer_stop(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
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,25 @@ | ||
#pragma once | ||
#include <furi.h> | ||
#include "game_engine.h" | ||
#include "level.h" | ||
#include "entity.h" | ||
#include "game_manager.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct { | ||
float target_fps; | ||
bool show_fps; | ||
bool always_backlight; | ||
void (*start)(GameManager* game_manager, void* context); | ||
void (*stop)(void* context); | ||
size_t context_size; | ||
} Game; | ||
|
||
extern const Game game; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
Oops, something went wrong.