mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 03:08:36 -07:00
fbt format
This commit is contained in:
@@ -48,7 +48,10 @@ void nfc_scene_passport_auth_on_enter(void* context) {
|
|||||||
|
|
||||||
const size_t temp_str_size = 15;
|
const size_t temp_str_size = 15;
|
||||||
char temp_str[temp_str_size];
|
char temp_str[temp_str_size];
|
||||||
snprintf(temp_str, temp_str_size, "%02u%02u%02u",
|
snprintf(
|
||||||
|
temp_str,
|
||||||
|
temp_str_size,
|
||||||
|
"%02u%02u%02u",
|
||||||
mrtd_data->auth.birth_date.year,
|
mrtd_data->auth.birth_date.year,
|
||||||
mrtd_data->auth.birth_date.month,
|
mrtd_data->auth.birth_date.month,
|
||||||
mrtd_data->auth.birth_date.day);
|
mrtd_data->auth.birth_date.day);
|
||||||
@@ -56,7 +59,10 @@ void nfc_scene_passport_auth_on_enter(void* context) {
|
|||||||
item = variable_item_list_add(variable_item_list, "Birth Date", 1, NULL, NULL);
|
item = variable_item_list_add(variable_item_list, "Birth Date", 1, NULL, NULL);
|
||||||
variable_item_set_current_value_text(item, temp_str);
|
variable_item_set_current_value_text(item, temp_str);
|
||||||
|
|
||||||
snprintf(temp_str, temp_str_size, "%02u%02u%02u",
|
snprintf(
|
||||||
|
temp_str,
|
||||||
|
temp_str_size,
|
||||||
|
"%02u%02u%02u",
|
||||||
mrtd_data->auth.expiry_date.year,
|
mrtd_data->auth.expiry_date.year,
|
||||||
mrtd_data->auth.expiry_date.month,
|
mrtd_data->auth.expiry_date.month,
|
||||||
mrtd_data->auth.expiry_date.day);
|
mrtd_data->auth.expiry_date.day);
|
||||||
@@ -74,9 +80,7 @@ void nfc_scene_passport_auth_on_enter(void* context) {
|
|||||||
temp_str[10] = '.';
|
temp_str[10] = '.';
|
||||||
temp_str[11] = '\x00';
|
temp_str[11] = '\x00';
|
||||||
}
|
}
|
||||||
variable_item_set_current_value_text(
|
variable_item_set_current_value_text(item, temp_str);
|
||||||
item,
|
|
||||||
temp_str);
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
variable_item_list,
|
variable_item_list,
|
||||||
|
|||||||
@@ -44,13 +44,7 @@ void nfc_scene_passport_date_on_enter(void* context) {
|
|||||||
date_empty = true;
|
date_empty = true;
|
||||||
} else {
|
} else {
|
||||||
char temp_str[10];
|
char temp_str[10];
|
||||||
snprintf(
|
snprintf(temp_str, 10, "%02u%02u%02u", date_value.year, date_value.month, date_value.day);
|
||||||
temp_str,
|
|
||||||
10,
|
|
||||||
"%02u%02u%02u",
|
|
||||||
date_value.year,
|
|
||||||
date_value.month,
|
|
||||||
date_value.day);
|
|
||||||
|
|
||||||
memcpy(nfc->text_store, temp_str, DATE_LENGTH);
|
memcpy(nfc->text_store, temp_str, DATE_LENGTH);
|
||||||
nfc->text_store[DATE_LENGTH] = '\x00';
|
nfc->text_store[DATE_LENGTH] = '\x00';
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ const char months[13][4] = {
|
|||||||
"DEC",
|
"DEC",
|
||||||
};
|
};
|
||||||
|
|
||||||
void nfc_scene_passport_read_auth_widget_callback(GuiButtonType result, InputType type, void* context) {
|
void nfc_scene_passport_read_auth_widget_callback(
|
||||||
|
GuiButtonType result,
|
||||||
|
InputType type,
|
||||||
|
void* context) {
|
||||||
Nfc* nfc = context;
|
Nfc* nfc = context;
|
||||||
if(type == InputTypeShort) {
|
if(type == InputTypeShort) {
|
||||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
|
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
|
||||||
@@ -38,13 +41,18 @@ void nfc_scene_passport_read_auth_on_enter(void* context) {
|
|||||||
// TODO: indicate BAC / PACE used
|
// TODO: indicate BAC / PACE used
|
||||||
|
|
||||||
uint16_t lds_version = mrtd_data->files.EF_COM.lds_version;
|
uint16_t lds_version = mrtd_data->files.EF_COM.lds_version;
|
||||||
furi_string_cat_printf(temp_str, "LDS version: %d.%d\n", lds_version/100, lds_version%100);
|
furi_string_cat_printf(temp_str, "LDS version: %d.%d\n", lds_version / 100, lds_version % 100);
|
||||||
|
|
||||||
uint32_t unicode_version = mrtd_data->files.EF_COM.unicode_version;
|
uint32_t unicode_version = mrtd_data->files.EF_COM.unicode_version;
|
||||||
furi_string_cat_printf(temp_str, "Unicode version: %d.%d.%d\n", (uint8_t)(unicode_version/10000), (uint8_t)(unicode_version/100%100), (uint8_t)(unicode_version%100));
|
furi_string_cat_printf(
|
||||||
|
temp_str,
|
||||||
|
"Unicode version: %d.%d.%d\n",
|
||||||
|
(uint8_t)(unicode_version / 10000),
|
||||||
|
(uint8_t)(unicode_version / 100 % 100),
|
||||||
|
(uint8_t)(unicode_version % 100));
|
||||||
|
|
||||||
furi_string_cat_printf(temp_str, "Avail.files: ");
|
furi_string_cat_printf(temp_str, "Avail.files: ");
|
||||||
for(size_t i=0; i<MAX_EFCOM_TAGS; ++i) {
|
for(size_t i = 0; i < MAX_EFCOM_TAGS; ++i) {
|
||||||
uint8_t tag = mrtd_data->files.EF_COM.tag_list[i];
|
uint8_t tag = mrtd_data->files.EF_COM.tag_list[i];
|
||||||
const EFFile* file = mrtd_tag_to_file(tag);
|
const EFFile* file = mrtd_tag_to_file(tag);
|
||||||
if(file->tag) {
|
if(file->tag) {
|
||||||
@@ -57,8 +65,8 @@ void nfc_scene_passport_read_auth_on_enter(void* context) {
|
|||||||
EF_DIR_contents* EF_DIR = &mrtd_data->files.EF_DIR;
|
EF_DIR_contents* EF_DIR = &mrtd_data->files.EF_DIR;
|
||||||
if(EF_DIR->applications_count > 0) {
|
if(EF_DIR->applications_count > 0) {
|
||||||
furi_string_cat_printf(temp_str, "Apps:\n");
|
furi_string_cat_printf(temp_str, "Apps:\n");
|
||||||
for(uint8_t i=0; i<EF_DIR->applications_count; ++i) {
|
for(uint8_t i = 0; i < EF_DIR->applications_count; ++i) {
|
||||||
for(uint8_t n=0; n<sizeof(AIDValue); ++n) {
|
for(uint8_t n = 0; n < sizeof(AIDValue); ++n) {
|
||||||
furi_string_cat_printf(temp_str, "%02X ", EF_DIR->applications[i][n]);
|
furi_string_cat_printf(temp_str, "%02X ", EF_DIR->applications[i][n]);
|
||||||
}
|
}
|
||||||
furi_string_cat_printf(temp_str, "\n");
|
furi_string_cat_printf(temp_str, "\n");
|
||||||
@@ -72,9 +80,19 @@ void nfc_scene_passport_read_auth_on_enter(void* context) {
|
|||||||
furi_string_cat_printf(temp_str, "Name: %s\n", DG1->name);
|
furi_string_cat_printf(temp_str, "Name: %s\n", DG1->name);
|
||||||
furi_string_cat_printf(temp_str, "DocNr: %s\n", DG1->docnr);
|
furi_string_cat_printf(temp_str, "DocNr: %s\n", DG1->docnr);
|
||||||
furi_string_cat_printf(temp_str, "Nationality: %s\n", DG1->nationality);
|
furi_string_cat_printf(temp_str, "Nationality: %s\n", DG1->nationality);
|
||||||
furi_string_cat_printf(temp_str, "Birth Date: %02d %s %02d\n", DG1->birth_date.day, months[DG1->birth_date.month], DG1->birth_date.year);
|
furi_string_cat_printf(
|
||||||
|
temp_str,
|
||||||
|
"Birth Date: %02d %s %02d\n",
|
||||||
|
DG1->birth_date.day,
|
||||||
|
months[DG1->birth_date.month],
|
||||||
|
DG1->birth_date.year);
|
||||||
furi_string_cat_printf(temp_str, "Sex: %s\n", DG1->sex);
|
furi_string_cat_printf(temp_str, "Sex: %s\n", DG1->sex);
|
||||||
furi_string_cat_printf(temp_str, "Expiry Date: %02d %s %02d\n", DG1->expiry_date.day, months[DG1->expiry_date.month], DG1->expiry_date.year);
|
furi_string_cat_printf(
|
||||||
|
temp_str,
|
||||||
|
"Expiry Date: %02d %s %02d\n",
|
||||||
|
DG1->expiry_date.day,
|
||||||
|
months[DG1->expiry_date.month],
|
||||||
|
DG1->expiry_date.year);
|
||||||
|
|
||||||
widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||||
furi_string_free(temp_str);
|
furi_string_free(temp_str);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ bool nfc_scene_read_on_event(void* context, SceneManagerEvent event) {
|
|||||||
notification_message(nfc->notifications, &sequence_success);
|
notification_message(nfc->notifications, &sequence_success);
|
||||||
if(nfc->dev->dev_data.mrtd_data.auth_success) {
|
if(nfc->dev->dev_data.mrtd_data.auth_success) {
|
||||||
scene_manager_next_scene(nfc->scene_manager, NfcScenePassportReadAuthSuccess);
|
scene_manager_next_scene(nfc->scene_manager, NfcScenePassportReadAuthSuccess);
|
||||||
//TODO: } else if(nfc->dev->dev_data.mrtd_data.auth.method != MrtdAuthMethodNone) {
|
//TODO: } else if(nfc->dev->dev_data.mrtd_data.auth.method != MrtdAuthMethodNone) {
|
||||||
//scene_manager_next_scene(nfc->scene_manager, NfcScenePassportReadAuthFailed);
|
//scene_manager_next_scene(nfc->scene_manager, NfcScenePassportReadAuthFailed);
|
||||||
} else {
|
} else {
|
||||||
scene_manager_next_scene(nfc->scene_manager, NfcScenePassportReadSuccess);
|
scene_manager_next_scene(nfc->scene_manager, NfcScenePassportReadSuccess);
|
||||||
|
|||||||
@@ -216,63 +216,25 @@ const NotificationMessage message_blue_127 = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const NotificationSequence sequence_rainbow = {
|
const NotificationSequence sequence_rainbow = {
|
||||||
&message_red_255,
|
&message_red_255, &message_green_0, &message_blue_0,
|
||||||
&message_green_0,
|
&message_delay_250, &message_red_255, &message_green_127,
|
||||||
&message_blue_0,
|
&message_blue_0, &message_delay_250, &message_red_255,
|
||||||
&message_delay_250,
|
&message_green_255, &message_blue_0, &message_delay_250,
|
||||||
&message_red_255,
|
&message_red_127, &message_green_255, &message_blue_0,
|
||||||
&message_green_127,
|
&message_delay_250, &message_red_0, &message_green_255,
|
||||||
&message_blue_0,
|
&message_blue_0, &message_delay_250, &message_red_0,
|
||||||
&message_delay_250,
|
&message_green_255, &message_blue_127, &message_delay_250,
|
||||||
&message_red_255,
|
&message_red_0, &message_green_255, &message_blue_255,
|
||||||
&message_green_255,
|
&message_delay_250, &message_red_0, &message_green_127,
|
||||||
&message_blue_0,
|
&message_blue_255, &message_delay_250, &message_red_0,
|
||||||
&message_delay_250,
|
&message_green_0, &message_blue_255, &message_delay_250,
|
||||||
&message_red_127,
|
&message_red_127, &message_green_0, &message_blue_255,
|
||||||
&message_green_255,
|
&message_delay_250, &message_red_255, &message_green_0,
|
||||||
&message_blue_0,
|
&message_blue_255, &message_delay_250, &message_red_255,
|
||||||
&message_delay_250,
|
&message_green_0, &message_blue_127, &message_delay_250,
|
||||||
&message_red_0,
|
&message_red_127, &message_green_127, &message_blue_127,
|
||||||
&message_green_255,
|
&message_delay_250, &message_red_255, &message_green_255,
|
||||||
&message_blue_0,
|
&message_blue_255, &message_delay_250, NULL,
|
||||||
&message_delay_250,
|
|
||||||
&message_red_0,
|
|
||||||
&message_green_255,
|
|
||||||
&message_blue_127,
|
|
||||||
&message_delay_250,
|
|
||||||
&message_red_0,
|
|
||||||
&message_green_255,
|
|
||||||
&message_blue_255,
|
|
||||||
&message_delay_250,
|
|
||||||
&message_red_0,
|
|
||||||
&message_green_127,
|
|
||||||
&message_blue_255,
|
|
||||||
&message_delay_250,
|
|
||||||
&message_red_0,
|
|
||||||
&message_green_0,
|
|
||||||
&message_blue_255,
|
|
||||||
&message_delay_250,
|
|
||||||
&message_red_127,
|
|
||||||
&message_green_0,
|
|
||||||
&message_blue_255,
|
|
||||||
&message_delay_250,
|
|
||||||
&message_red_255,
|
|
||||||
&message_green_0,
|
|
||||||
&message_blue_255,
|
|
||||||
&message_delay_250,
|
|
||||||
&message_red_255,
|
|
||||||
&message_green_0,
|
|
||||||
&message_blue_127,
|
|
||||||
&message_delay_250,
|
|
||||||
&message_red_127,
|
|
||||||
&message_green_127,
|
|
||||||
&message_blue_127,
|
|
||||||
&message_delay_250,
|
|
||||||
&message_red_255,
|
|
||||||
&message_green_255,
|
|
||||||
&message_blue_255,
|
|
||||||
&message_delay_250,
|
|
||||||
NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void desktop_view_main_dumbmode_changed(DesktopSettings* settings) {
|
static void desktop_view_main_dumbmode_changed(DesktopSettings* settings) {
|
||||||
@@ -369,7 +331,8 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) {
|
|||||||
elements_button_right(canvas, "S:ByMin");
|
elements_button_right(canvas, "S:ByMin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(state->w_test && state->desktop_settings->is_dumbmode) canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8);
|
if(state->w_test && state->desktop_settings->is_dumbmode)
|
||||||
|
canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clock_state_init(ClockState* const state) {
|
static void clock_state_init(ClockState* const state) {
|
||||||
|
|||||||
@@ -4,8 +4,25 @@
|
|||||||
#include "hede_assets.h"
|
#include "hede_assets.h"
|
||||||
#include <gui/icon_i.h>
|
#include <gui/icon_i.h>
|
||||||
|
|
||||||
const uint8_t _A_HD_BoxDestroyed_10x10_0[] = {0x01,0x00,0x10,0x00,0x00,0x1d,0xa2,0x01,0xc8,0x80,0x6d,0x20,0x15,0x08,0x06,0x72,0x01,0x48,0x07,0xa0,};
|
const uint8_t _A_HD_BoxDestroyed_10x10_0[] = {
|
||||||
const uint8_t _A_HD_BoxDestroyed_10x10_1[] = {0x00,0x00,0x00,0x28,0x01,0x4A,0x00,0xA8,0x01,0x84,0x00,0x22,0x00,0x88,0x00,0x58,0x01,0x22,0x00,0x00,0x00,};
|
0x01, 0x00, 0x10, 0x00, 0x00, 0x1d, 0xa2, 0x01, 0xc8, 0x80,
|
||||||
const uint8_t _A_HD_BoxDestroyed_10x10_2[] = {0x00,0x00,0x00,0x08,0x01,0x42,0x00,0x09,0x01,0x00,0x02,0x02,0x00,0x01,0x02,0x00,0x01,0x21,0x00,0x42,0x02,};
|
0x6d, 0x20, 0x15, 0x08, 0x06, 0x72, 0x01, 0x48, 0x07, 0xa0,
|
||||||
const uint8_t *_A_HD_BoxDestroyed_10x10[] = {_A_HD_BoxDestroyed_10x10_0,_A_HD_BoxDestroyed_10x10_1,_A_HD_BoxDestroyed_10x10_2};
|
};
|
||||||
const Icon A_HD_BoxDestroyed_10x10 = {.width=10,.height=10,.frame_count=3,.frame_rate=4,.frames=_A_HD_BoxDestroyed_10x10};
|
const uint8_t _A_HD_BoxDestroyed_10x10_1[] = {
|
||||||
|
0x00, 0x00, 0x00, 0x28, 0x01, 0x4A, 0x00, 0xA8, 0x01, 0x84, 0x00,
|
||||||
|
0x22, 0x00, 0x88, 0x00, 0x58, 0x01, 0x22, 0x00, 0x00, 0x00,
|
||||||
|
};
|
||||||
|
const uint8_t _A_HD_BoxDestroyed_10x10_2[] = {
|
||||||
|
0x00, 0x00, 0x00, 0x08, 0x01, 0x42, 0x00, 0x09, 0x01, 0x00, 0x02,
|
||||||
|
0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x21, 0x00, 0x42, 0x02,
|
||||||
|
};
|
||||||
|
const uint8_t* _A_HD_BoxDestroyed_10x10[] = {
|
||||||
|
_A_HD_BoxDestroyed_10x10_0,
|
||||||
|
_A_HD_BoxDestroyed_10x10_1,
|
||||||
|
_A_HD_BoxDestroyed_10x10_2};
|
||||||
|
const Icon A_HD_BoxDestroyed_10x10 = {
|
||||||
|
.width = 10,
|
||||||
|
.height = 10,
|
||||||
|
.frame_count = 3,
|
||||||
|
.frame_rate = 4,
|
||||||
|
.frames = _A_HD_BoxDestroyed_10x10};
|
||||||
@@ -7,7 +7,8 @@ extern "C" int32_t sam_app(void* p) {
|
|||||||
UNUSED(p);
|
UNUSED(p);
|
||||||
|
|
||||||
voice.begin();
|
voice.begin();
|
||||||
voice.say("All your base are belong to us. You have no chance to survive make your time. ha. ha. ha. GOOD BYE. ");
|
voice.say(
|
||||||
|
"All your base are belong to us. You have no chance to survive make your time. ha. ha. ha. GOOD BYE. ");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
// That's a filthy workaround but sin(player.aimAngle) breaks it all... If you're able to fix it, please do create a PR!
|
// That's a filthy workaround but sin(player.aimAngle) breaks it all... If you're able to fix it, please do create a PR!
|
||||||
double scorched_tanks_sin[91] = {
|
double scorched_tanks_sin[91] = {
|
||||||
0.000, -0.017, -0.035, -0.052, -0.070, -0.087, -0.105, -0.122, -0.139, -0.156, -0.174, -0.191,
|
0.000, -0.017, -0.035, -0.052, -0.070, -0.087, -0.105, -0.122, -0.139, -0.156, -0.174, -0.191,
|
||||||
-0.208, -0.225, -0.242, -0.259, -0.276, -0.292, -0.309, -0.326, -0.342, -0.358, -0.375, -0.391,
|
-0.208, -0.225, -0.242, -0.259, -0.276, -0.292, -0.309, -0.326, -0.342, -0.358, -0.375, -0.391,
|
||||||
-0.407, -0.423, -0.438, -0.454, -0.469, -0.485, -0.500, -0.515, -0.530, -0.545, -0.559, -0.574,
|
-0.407, -0.423, -0.438, -0.454, -0.469, -0.485, -0.500, -0.515, -0.530, -0.545, -0.559, -0.574,
|
||||||
-0.588, -0.602, -0.616, -0.629, -0.643, -0.656, -0.669, -0.682, -0.695, -0.707, -0.719, -0.731,
|
-0.588, -0.602, -0.616, -0.629, -0.643, -0.656, -0.669, -0.682, -0.695, -0.707, -0.719, -0.731,
|
||||||
@@ -42,19 +42,24 @@ double scorched_tanks_cos[91] = {
|
|||||||
0.423, 0.407, 0.391, 0.375, 0.358, 0.342, 0.326, 0.309, 0.292, 0.276, 0.259, 0.242, 0.225,
|
0.423, 0.407, 0.391, 0.375, 0.358, 0.342, 0.326, 0.309, 0.292, 0.276, 0.259, 0.242, 0.225,
|
||||||
0.208, 0.191, 0.174, 0.156, 0.139, 0.122, 0.105, 0.087, 0.070, 0.052, 0.035, 0.017, 0.000};
|
0.208, 0.191, 0.174, 0.156, 0.139, 0.122, 0.105, 0.087, 0.070, 0.052, 0.035, 0.017, 0.000};
|
||||||
double scorched_tanks_tan[91] = {
|
double scorched_tanks_tan[91] = {
|
||||||
0.000, -0.017, -0.035, -0.052, -0.070, -0.087, -0.105, -0.123, -0.141, -0.158, -0.176,
|
0.000, -0.017, -0.035, -0.052, -0.070, -0.087, -0.105, -0.123, -0.141, -0.158, -0.176,
|
||||||
-0.194, -0.213, -0.231, -0.249, -0.268, -0.287, -0.306, -0.325, -0.344, -0.364, -0.384,
|
-0.194, -0.213, -0.231, -0.249, -0.268, -0.287, -0.306, -0.325, -0.344, -0.364, -0.384,
|
||||||
-0.404, -0.424, -0.445, -0.466, -0.488, -0.510, -0.532, -0.554, -0.577, -0.601, -0.625,
|
-0.404, -0.424, -0.445, -0.466, -0.488, -0.510, -0.532, -0.554, -0.577, -0.601, -0.625,
|
||||||
-0.649, -0.674, -0.700, -0.727, -0.754, -0.781, -0.810, -0.839, -0.869, -0.900, -0.932,
|
-0.649, -0.674, -0.700, -0.727, -0.754, -0.781, -0.810, -0.839, -0.869, -0.900, -0.932,
|
||||||
-0.966, -1.000, -1.036, -1.072, -1.111, -1.150, -1.192, -1.235, -1.280, -1.327, -1.376,
|
-0.966, -1.000, -1.036, -1.072, -1.111, -1.150, -1.192, -1.235, -1.280, -1.327, -1.376,
|
||||||
-1.428, -1.483, -1.540, -1.600, -1.664, -1.732, -1.804, -1.881, -1.963, -2.050, -2.144,
|
-1.428, -1.483, -1.540, -1.600, -1.664, -1.732, -1.804, -1.881, -1.963, -2.050, -2.144,
|
||||||
-2.246, -2.356, -2.475, -2.605, -2.747, -2.904, -3.078, -3.271, -3.487, -3.732, -4.011,
|
-2.246, -2.356, -2.475, -2.605, -2.747, -2.904, -3.078, -3.271, -3.487, -3.732, -4.011,
|
||||||
-4.331, -4.704, -5.144, -5.671, -6.313, -7.115, -8.144, -9.513, -11.429, -14.298, -19.077,
|
-4.331, -4.704, -5.144, -5.671, -6.313, -7.115, -8.144, -9.513, -11.429, -14.298, -19.077,
|
||||||
-28.627, -57.254, -90747.269};
|
-28.627, -57.254, -90747.269};
|
||||||
unsigned char scorched_tanks_ground_modifiers[SCREEN_WIDTH] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
unsigned char scorched_tanks_ground_modifiers[SCREEN_WIDTH] = {
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 28, 26, 24, 22, 20,
|
||||||
|
18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
// +-----x
|
// +-----x
|
||||||
// |
|
// |
|
||||||
// |
|
// |
|
||||||
@@ -63,8 +68,7 @@ typedef struct
|
|||||||
uint8_t y;
|
uint8_t y;
|
||||||
} Point;
|
} Point;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
// +-----x
|
// +-----x
|
||||||
// |
|
// |
|
||||||
// |
|
// |
|
||||||
@@ -73,16 +77,14 @@ typedef struct
|
|||||||
double y;
|
double y;
|
||||||
} PointDetailed;
|
} PointDetailed;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
unsigned char locationX;
|
unsigned char locationX;
|
||||||
unsigned char hp;
|
unsigned char hp;
|
||||||
int aimAngle;
|
int aimAngle;
|
||||||
unsigned char firePower;
|
unsigned char firePower;
|
||||||
} Tank;
|
} Tank;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
Point ground[SCREEN_WIDTH];
|
Point ground[SCREEN_WIDTH];
|
||||||
Tank player;
|
Tank player;
|
||||||
Tank enemy;
|
Tank enemy;
|
||||||
@@ -95,41 +97,33 @@ typedef struct
|
|||||||
PointDetailed bulletVector;
|
PointDetailed bulletVector;
|
||||||
} Game;
|
} Game;
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
EventTypeTick,
|
EventTypeTick,
|
||||||
EventTypeKey,
|
EventTypeKey,
|
||||||
} EventType;
|
} EventType;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
EventType type;
|
EventType type;
|
||||||
InputEvent input;
|
InputEvent input;
|
||||||
} ScorchedTanksEvent;
|
} ScorchedTanksEvent;
|
||||||
|
|
||||||
int scorched_tanks_random(int min, int max)
|
int scorched_tanks_random(int min, int max) {
|
||||||
{
|
|
||||||
return min + rand() % ((max + 1) - min);
|
return min + rand() % ((max + 1) - min);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scorched_tanks_generate_ground(Game *game_state)
|
void scorched_tanks_generate_ground(Game* game_state) {
|
||||||
{
|
|
||||||
int lastHeight = 45;
|
int lastHeight = 45;
|
||||||
|
|
||||||
for (unsigned char a = 0; a < SCREEN_WIDTH; a++)
|
for(unsigned char a = 0; a < SCREEN_WIDTH; a++) {
|
||||||
{
|
|
||||||
int diffHeight = scorched_tanks_random(-2, 3);
|
int diffHeight = scorched_tanks_random(-2, 3);
|
||||||
int changeLength = scorched_tanks_random(1, 6);
|
int changeLength = scorched_tanks_random(1, 6);
|
||||||
|
|
||||||
if (diffHeight == 0)
|
if(diffHeight == 0) {
|
||||||
{
|
|
||||||
changeLength = 1;
|
changeLength = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int b = 0; b < changeLength; b++)
|
for(int b = 0; b < changeLength; b++) {
|
||||||
{
|
if(a + b < SCREEN_WIDTH) {
|
||||||
if (a + b < SCREEN_WIDTH)
|
|
||||||
{
|
|
||||||
int index = a + b;
|
int index = a + b;
|
||||||
int newPoint = lastHeight + diffHeight;
|
int newPoint = lastHeight + diffHeight;
|
||||||
newPoint = newPoint < MIN_GROUND_HEIGHT ? MIN_GROUND_HEIGHT : newPoint;
|
newPoint = newPoint < MIN_GROUND_HEIGHT ? MIN_GROUND_HEIGHT : newPoint;
|
||||||
@@ -137,9 +131,7 @@ void scorched_tanks_generate_ground(Game *game_state)
|
|||||||
game_state->ground[index].x = index;
|
game_state->ground[index].x = index;
|
||||||
game_state->ground[index].y = newPoint - scorched_tanks_ground_modifiers[a];
|
game_state->ground[index].y = newPoint - scorched_tanks_ground_modifiers[a];
|
||||||
lastHeight = newPoint;
|
lastHeight = newPoint;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
a += b;
|
a += b;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -149,20 +141,21 @@ void scorched_tanks_generate_ground(Game *game_state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scorched_tanks_init_game(Game *game_state)
|
void scorched_tanks_init_game(Game* game_state) {
|
||||||
{
|
game_state->player.locationX = PLAYER_INIT_LOCATION_X +
|
||||||
game_state->player.locationX = PLAYER_INIT_LOCATION_X + scorched_tanks_random(0, MAX_PLAYER_DIFF_X) - MAX_PLAYER_DIFF_X / 2;
|
scorched_tanks_random(0, MAX_PLAYER_DIFF_X) -
|
||||||
|
MAX_PLAYER_DIFF_X / 2;
|
||||||
game_state->player.aimAngle = PLAYER_INIT_AIM;
|
game_state->player.aimAngle = PLAYER_INIT_AIM;
|
||||||
game_state->player.firePower = PLAYER_INIT_POWER;
|
game_state->player.firePower = PLAYER_INIT_POWER;
|
||||||
game_state->enemy.aimAngle = PLAYER_INIT_AIM;
|
game_state->enemy.aimAngle = PLAYER_INIT_AIM;
|
||||||
game_state->enemy.firePower = PLAYER_INIT_POWER;
|
game_state->enemy.firePower = PLAYER_INIT_POWER;
|
||||||
game_state->enemy.locationX = ENEMY_INIT_LOCATION_X + scorched_tanks_random(0, MAX_ENEMY_DIFF_X) - MAX_ENEMY_DIFF_X / 2;
|
game_state->enemy.locationX =
|
||||||
|
ENEMY_INIT_LOCATION_X + scorched_tanks_random(0, MAX_ENEMY_DIFF_X) - MAX_ENEMY_DIFF_X / 2;
|
||||||
game_state->isPlayerTurn = true;
|
game_state->isPlayerTurn = true;
|
||||||
|
|
||||||
game_state->windSpeed = scorched_tanks_random(0, MAX_WIND);
|
game_state->windSpeed = scorched_tanks_random(0, MAX_WIND);
|
||||||
|
|
||||||
for (int x = 0; x < SCREEN_WIDTH; x++)
|
for(int x = 0; x < SCREEN_WIDTH; x++) {
|
||||||
{
|
|
||||||
game_state->trajectory[x].x = 0;
|
game_state->trajectory[x].x = 0;
|
||||||
game_state->trajectory[x].y = 0;
|
game_state->trajectory[x].y = 0;
|
||||||
}
|
}
|
||||||
@@ -170,10 +163,8 @@ void scorched_tanks_init_game(Game *game_state)
|
|||||||
scorched_tanks_generate_ground(game_state);
|
scorched_tanks_generate_ground(game_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scorched_tanks_calculate_trajectory(Game *game_state)
|
void scorched_tanks_calculate_trajectory(Game* game_state) {
|
||||||
{
|
if(game_state->isShooting) {
|
||||||
if (game_state->isShooting)
|
|
||||||
{
|
|
||||||
game_state->bulletVector.x += ((double)game_state->windSpeed - MAX_WIND / 2) / 40;
|
game_state->bulletVector.x += ((double)game_state->windSpeed - MAX_WIND / 2) / 40;
|
||||||
game_state->bulletVector.y += GRAVITY_FORCE;
|
game_state->bulletVector.y += GRAVITY_FORCE;
|
||||||
|
|
||||||
@@ -182,30 +173,30 @@ void scorched_tanks_calculate_trajectory(Game *game_state)
|
|||||||
|
|
||||||
int totalDistanceToEnemy = 100;
|
int totalDistanceToEnemy = 100;
|
||||||
|
|
||||||
if (game_state->isPlayerTurn)
|
if(game_state->isPlayerTurn) {
|
||||||
{
|
|
||||||
double distanceToEnemyX = game_state->enemy.locationX - game_state->bulletPosition.x;
|
double distanceToEnemyX = game_state->enemy.locationX - game_state->bulletPosition.x;
|
||||||
double distanceToEnemyY = game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE - game_state->bulletPosition.y;
|
double distanceToEnemyY = game_state->ground[game_state->enemy.locationX].y -
|
||||||
totalDistanceToEnemy = sqrt(distanceToEnemyX * distanceToEnemyX + distanceToEnemyY * distanceToEnemyY);
|
TANK_COLLIDER_SIZE - game_state->bulletPosition.y;
|
||||||
}
|
totalDistanceToEnemy =
|
||||||
else
|
sqrt(distanceToEnemyX * distanceToEnemyX + distanceToEnemyY * distanceToEnemyY);
|
||||||
{
|
} else {
|
||||||
double distanceToEnemyX = game_state->player.locationX - game_state->bulletPosition.x;
|
double distanceToEnemyX = game_state->player.locationX - game_state->bulletPosition.x;
|
||||||
double distanceToEnemyY = game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE - game_state->bulletPosition.y;
|
double distanceToEnemyY = game_state->ground[game_state->player.locationX].y -
|
||||||
totalDistanceToEnemy = sqrt(distanceToEnemyX * distanceToEnemyX + distanceToEnemyY * distanceToEnemyY);
|
TANK_COLLIDER_SIZE - game_state->bulletPosition.y;
|
||||||
|
totalDistanceToEnemy =
|
||||||
|
sqrt(distanceToEnemyX * distanceToEnemyX + distanceToEnemyY * distanceToEnemyY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalDistanceToEnemy <= TANK_COLLIDER_SIZE)
|
if(totalDistanceToEnemy <= TANK_COLLIDER_SIZE) {
|
||||||
{
|
|
||||||
game_state->isShooting = false;
|
game_state->isShooting = false;
|
||||||
scorched_tanks_init_game(game_state);
|
scorched_tanks_init_game(game_state);
|
||||||
game_state->isPlayerTurn = !game_state->isPlayerTurn;
|
game_state->isPlayerTurn = !game_state->isPlayerTurn;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game_state->bulletPosition.x > SCREEN_WIDTH ||
|
if(game_state->bulletPosition.x > SCREEN_WIDTH ||
|
||||||
game_state->bulletPosition.y > game_state->ground[(int)round(game_state->bulletPosition.x)].y)
|
game_state->bulletPosition.y >
|
||||||
{
|
game_state->ground[(int)round(game_state->bulletPosition.x)].y) {
|
||||||
game_state->isShooting = false;
|
game_state->isShooting = false;
|
||||||
game_state->bulletPosition.x = 0;
|
game_state->bulletPosition.x = 0;
|
||||||
game_state->bulletPosition.y = 0;
|
game_state->bulletPosition.y = 0;
|
||||||
@@ -214,21 +205,24 @@ void scorched_tanks_calculate_trajectory(Game *game_state)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game_state->bulletPosition.y > 0)
|
if(game_state->bulletPosition.y > 0) {
|
||||||
{
|
game_state->trajectory[game_state->trajectoryAnimationStep].x =
|
||||||
game_state->trajectory[game_state->trajectoryAnimationStep].x = round(game_state->bulletPosition.x);
|
round(game_state->bulletPosition.x);
|
||||||
game_state->trajectory[game_state->trajectoryAnimationStep].y = round(game_state->bulletPosition.y);
|
game_state->trajectory[game_state->trajectoryAnimationStep].y =
|
||||||
|
round(game_state->bulletPosition.y);
|
||||||
game_state->trajectoryAnimationStep++;
|
game_state->trajectoryAnimationStep++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scorched_tanks_draw_tank(Canvas *const canvas, unsigned char x, unsigned char y, bool isPlayer)
|
static void scorched_tanks_draw_tank(
|
||||||
{
|
Canvas* const canvas,
|
||||||
|
unsigned char x,
|
||||||
|
unsigned char y,
|
||||||
|
bool isPlayer) {
|
||||||
unsigned char lineIndex = 0;
|
unsigned char lineIndex = 0;
|
||||||
|
|
||||||
if (isPlayer)
|
if(isPlayer) {
|
||||||
{
|
|
||||||
// Draw tank base
|
// Draw tank base
|
||||||
canvas_draw_line(canvas, x - 3, y - lineIndex, x + 3, y - lineIndex++);
|
canvas_draw_line(canvas, x - 3, y - lineIndex, x + 3, y - lineIndex++);
|
||||||
canvas_draw_line(canvas, x - 4, y - lineIndex, x + 4, y - lineIndex++);
|
canvas_draw_line(canvas, x - 4, y - lineIndex, x + 4, y - lineIndex++);
|
||||||
@@ -237,9 +231,7 @@ static void scorched_tanks_draw_tank(Canvas *const canvas, unsigned char x, unsi
|
|||||||
// draw turret
|
// draw turret
|
||||||
canvas_draw_line(canvas, x - 2, y - lineIndex, x + 1, y - lineIndex++);
|
canvas_draw_line(canvas, x - 2, y - lineIndex, x + 1, y - lineIndex++);
|
||||||
canvas_draw_line(canvas, x - 2, y - lineIndex, x, y - lineIndex++);
|
canvas_draw_line(canvas, x - 2, y - lineIndex, x, y - lineIndex++);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Draw tank base
|
// Draw tank base
|
||||||
canvas_draw_line(canvas, x - 3, y - lineIndex, x + 3, y - lineIndex++);
|
canvas_draw_line(canvas, x - 3, y - lineIndex, x + 3, y - lineIndex++);
|
||||||
canvas_draw_line(canvas, x - 4, y - lineIndex, x + 4, y - lineIndex++);
|
canvas_draw_line(canvas, x - 4, y - lineIndex, x + 4, y - lineIndex++);
|
||||||
@@ -251,12 +243,10 @@ static void scorched_tanks_draw_tank(Canvas *const canvas, unsigned char x, unsi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx)
|
static void scorched_tanks_render_callback(Canvas* const canvas, void* ctx) {
|
||||||
{
|
const Game* game_state = acquire_mutex((ValueMutex*)ctx, 25);
|
||||||
const Game *game_state = acquire_mutex((ValueMutex *)ctx, 25);
|
|
||||||
|
|
||||||
if (game_state == NULL)
|
if(game_state == NULL) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,13 +254,11 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx)
|
|||||||
|
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
if (game_state->isShooting)
|
if(game_state->isShooting) {
|
||||||
{
|
|
||||||
canvas_draw_dot(canvas, game_state->bulletPosition.x, game_state->bulletPosition.y);
|
canvas_draw_dot(canvas, game_state->bulletPosition.x, game_state->bulletPosition.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a = 1; a < SCREEN_WIDTH; a++)
|
for(int a = 1; a < SCREEN_WIDTH; a++) {
|
||||||
{
|
|
||||||
canvas_draw_line(
|
canvas_draw_line(
|
||||||
canvas,
|
canvas,
|
||||||
game_state->ground[a - 1].x,
|
game_state->ground[a - 1].x,
|
||||||
@@ -278,23 +266,29 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx)
|
|||||||
game_state->ground[a].x,
|
game_state->ground[a].x,
|
||||||
game_state->ground[a].y);
|
game_state->ground[a].y);
|
||||||
|
|
||||||
if (game_state->trajectory[a].y != 0)
|
if(game_state->trajectory[a].y != 0) {
|
||||||
{
|
|
||||||
canvas_draw_dot(canvas, game_state->trajectory[a].x, game_state->trajectory[a].y);
|
canvas_draw_dot(canvas, game_state->trajectory[a].x, game_state->trajectory[a].y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scorched_tanks_draw_tank(canvas, game_state->enemy.locationX, game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE, true);
|
scorched_tanks_draw_tank(
|
||||||
|
canvas,
|
||||||
|
game_state->enemy.locationX,
|
||||||
|
game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE,
|
||||||
|
true);
|
||||||
|
|
||||||
scorched_tanks_draw_tank(canvas, game_state->player.locationX, game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE, false);
|
scorched_tanks_draw_tank(
|
||||||
|
canvas,
|
||||||
|
game_state->player.locationX,
|
||||||
|
game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE,
|
||||||
|
false);
|
||||||
|
|
||||||
int aimX1 = 0;
|
int aimX1 = 0;
|
||||||
int aimY1 = 0;
|
int aimY1 = 0;
|
||||||
int aimX2 = 0;
|
int aimX2 = 0;
|
||||||
int aimY2 = 0;
|
int aimY2 = 0;
|
||||||
|
|
||||||
if (game_state->isPlayerTurn)
|
if(game_state->isPlayerTurn) {
|
||||||
{
|
|
||||||
aimX1 = game_state->player.locationX;
|
aimX1 = game_state->player.locationX;
|
||||||
aimY1 = game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE;
|
aimY1 = game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE;
|
||||||
|
|
||||||
@@ -305,9 +299,7 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx)
|
|||||||
|
|
||||||
aimX1 += 1;
|
aimX1 += 1;
|
||||||
aimX2 += 1;
|
aimX2 += 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
aimX1 = game_state->enemy.locationX;
|
aimX1 = game_state->enemy.locationX;
|
||||||
aimY1 = game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE;
|
aimY1 = game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE;
|
||||||
|
|
||||||
@@ -330,8 +322,7 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx)
|
|||||||
snprintf(buffer2, sizeof(buffer2), "wind: %i", game_state->windSpeed - MAX_WIND / 2);
|
snprintf(buffer2, sizeof(buffer2), "wind: %i", game_state->windSpeed - MAX_WIND / 2);
|
||||||
canvas_draw_str(canvas, 55, 10, buffer2);
|
canvas_draw_str(canvas, 55, 10, buffer2);
|
||||||
|
|
||||||
if (game_state->isPlayerTurn)
|
if(game_state->isPlayerTurn) {
|
||||||
{
|
|
||||||
canvas_draw_str(canvas, 93, 10, "player1");
|
canvas_draw_str(canvas, 93, 10, "player1");
|
||||||
|
|
||||||
char buffer[12];
|
char buffer[12];
|
||||||
@@ -340,9 +331,7 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx)
|
|||||||
|
|
||||||
snprintf(buffer, sizeof(buffer), "p: %u", game_state->player.firePower);
|
snprintf(buffer, sizeof(buffer), "p: %u", game_state->player.firePower);
|
||||||
canvas_draw_str(canvas, 27, 10, buffer);
|
canvas_draw_str(canvas, 27, 10, buffer);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
canvas_draw_str(canvas, 93, 10, "player2");
|
canvas_draw_str(canvas, 93, 10, "player2");
|
||||||
|
|
||||||
char buffer[12];
|
char buffer[12];
|
||||||
@@ -353,83 +342,64 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx)
|
|||||||
canvas_draw_str(canvas, 27, 10, buffer);
|
canvas_draw_str(canvas, 27, 10, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
release_mutex((ValueMutex *)ctx, game_state);
|
release_mutex((ValueMutex*)ctx, game_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scorched_tanks_input_callback(InputEvent *input_event, FuriMessageQueue *event_queue)
|
static void scorched_tanks_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
|
||||||
{
|
|
||||||
furi_assert(event_queue);
|
furi_assert(event_queue);
|
||||||
|
|
||||||
ScorchedTanksEvent event = {.type = EventTypeKey, .input = *input_event};
|
ScorchedTanksEvent event = {.type = EventTypeKey, .input = *input_event};
|
||||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scorched_tanks_update_timer_callback(FuriMessageQueue *event_queue)
|
static void scorched_tanks_update_timer_callback(FuriMessageQueue* event_queue) {
|
||||||
{
|
|
||||||
furi_assert(event_queue);
|
furi_assert(event_queue);
|
||||||
|
|
||||||
ScorchedTanksEvent event = {.type = EventTypeTick};
|
ScorchedTanksEvent event = {.type = EventTypeTick};
|
||||||
furi_message_queue_put(event_queue, &event, 0);
|
furi_message_queue_put(event_queue, &event, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scorched_tanks_increase_power(Game *game_state)
|
static void scorched_tanks_increase_power(Game* game_state) {
|
||||||
{
|
if(game_state->player.firePower < MAX_FIRE_POWER && !game_state->isShooting) {
|
||||||
if (game_state->player.firePower < MAX_FIRE_POWER && !game_state->isShooting)
|
if(game_state->isPlayerTurn && game_state->player.firePower < MAX_FIRE_POWER) {
|
||||||
{
|
|
||||||
if (game_state->isPlayerTurn && game_state->player.firePower < MAX_FIRE_POWER)
|
|
||||||
{
|
|
||||||
game_state->player.firePower++;
|
game_state->player.firePower++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!game_state->isPlayerTurn && game_state->enemy.firePower < MAX_FIRE_POWER)
|
if(!game_state->isPlayerTurn && game_state->enemy.firePower < MAX_FIRE_POWER) {
|
||||||
{
|
|
||||||
game_state->enemy.firePower++;
|
game_state->enemy.firePower++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scorched_tanks_decrease_power(Game *game_state)
|
static void scorched_tanks_decrease_power(Game* game_state) {
|
||||||
{
|
if(game_state->player.firePower > MIN_FIRE_POWER && !game_state->isShooting) {
|
||||||
if (game_state->player.firePower > MIN_FIRE_POWER && !game_state->isShooting)
|
if(game_state->isPlayerTurn && game_state->player.firePower > MIN_FIRE_POWER) {
|
||||||
{
|
|
||||||
if (game_state->isPlayerTurn && game_state->player.firePower > MIN_FIRE_POWER)
|
|
||||||
{
|
|
||||||
game_state->player.firePower--;
|
game_state->player.firePower--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!game_state->isPlayerTurn && game_state->enemy.firePower > MIN_FIRE_POWER)
|
if(!game_state->isPlayerTurn && game_state->enemy.firePower > MIN_FIRE_POWER) {
|
||||||
{
|
|
||||||
game_state->enemy.firePower--;
|
game_state->enemy.firePower--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scorched_tanks_aim_up(Game *game_state)
|
static void scorched_tanks_aim_up(Game* game_state) {
|
||||||
{
|
if(!game_state->isShooting) {
|
||||||
if (!game_state->isShooting)
|
if(game_state->isPlayerTurn && game_state->player.aimAngle < 90) {
|
||||||
{
|
|
||||||
if (game_state->isPlayerTurn && game_state->player.aimAngle < 90)
|
|
||||||
{
|
|
||||||
game_state->player.aimAngle++;
|
game_state->player.aimAngle++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!game_state->isPlayerTurn && game_state->enemy.aimAngle < 90)
|
if(!game_state->isPlayerTurn && game_state->enemy.aimAngle < 90) {
|
||||||
{
|
|
||||||
game_state->enemy.aimAngle++;
|
game_state->enemy.aimAngle++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scorched_tanks_aim_down(Game *game_state)
|
static void scorched_tanks_aim_down(Game* game_state) {
|
||||||
{
|
if(game_state->player.aimAngle > 0 && !game_state->isShooting) {
|
||||||
if (game_state->player.aimAngle > 0 && !game_state->isShooting)
|
if(game_state->isPlayerTurn) {
|
||||||
{
|
|
||||||
if (game_state->isPlayerTurn)
|
|
||||||
{
|
|
||||||
game_state->player.aimAngle--;
|
game_state->player.aimAngle--;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
game_state->enemy.aimAngle--;
|
game_state->enemy.aimAngle--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -442,97 +412,91 @@ const NotificationSequence sequence_long_vibro = {
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void scorched_tanks_fire(Game *game_state)
|
static void scorched_tanks_fire(Game* game_state) {
|
||||||
{
|
if(!game_state->isShooting) {
|
||||||
if (!game_state->isShooting)
|
if(game_state->isPlayerTurn) {
|
||||||
{
|
|
||||||
if (game_state->isPlayerTurn)
|
|
||||||
{
|
|
||||||
double sinFromAngle = scorched_tanks_sin[game_state->player.aimAngle];
|
double sinFromAngle = scorched_tanks_sin[game_state->player.aimAngle];
|
||||||
double cosFromAngle = scorched_tanks_cos[game_state->player.aimAngle];
|
double cosFromAngle = scorched_tanks_cos[game_state->player.aimAngle];
|
||||||
unsigned char aimX1 = game_state->player.locationX;
|
unsigned char aimX1 = game_state->player.locationX;
|
||||||
unsigned char aimY1 = game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE;
|
unsigned char aimY1 =
|
||||||
|
game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE;
|
||||||
int aimX2 = aimX1 + TANK_BARREL_LENGTH * cosFromAngle;
|
int aimX2 = aimX1 + TANK_BARREL_LENGTH * cosFromAngle;
|
||||||
int aimY2 = aimY1 + TANK_BARREL_LENGTH * sinFromAngle;
|
int aimY2 = aimY1 + TANK_BARREL_LENGTH * sinFromAngle;
|
||||||
game_state->bulletPosition.x = aimX2;
|
game_state->bulletPosition.x = aimX2;
|
||||||
game_state->bulletPosition.y = aimY2;
|
game_state->bulletPosition.y = aimY2;
|
||||||
game_state->bulletVector.x = scorched_tanks_cos[game_state->player.aimAngle] * ((double)game_state->player.firePower / 10);
|
game_state->bulletVector.x = scorched_tanks_cos[game_state->player.aimAngle] *
|
||||||
game_state->bulletVector.y = scorched_tanks_sin[game_state->player.aimAngle] * ((double)game_state->player.firePower / 10);
|
((double)game_state->player.firePower / 10);
|
||||||
}
|
game_state->bulletVector.y = scorched_tanks_sin[game_state->player.aimAngle] *
|
||||||
else
|
((double)game_state->player.firePower / 10);
|
||||||
{
|
} else {
|
||||||
double sinFromAngle = scorched_tanks_sin[game_state->enemy.aimAngle];
|
double sinFromAngle = scorched_tanks_sin[game_state->enemy.aimAngle];
|
||||||
double cosFromAngle = scorched_tanks_cos[game_state->enemy.aimAngle];
|
double cosFromAngle = scorched_tanks_cos[game_state->enemy.aimAngle];
|
||||||
unsigned char aimX1 = game_state->enemy.locationX;
|
unsigned char aimX1 = game_state->enemy.locationX;
|
||||||
unsigned char aimY1 = game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE;
|
unsigned char aimY1 =
|
||||||
|
game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE;
|
||||||
int aimX2 = aimX1 + TANK_BARREL_LENGTH * cosFromAngle;
|
int aimX2 = aimX1 + TANK_BARREL_LENGTH * cosFromAngle;
|
||||||
int aimY2 = aimY1 + TANK_BARREL_LENGTH * sinFromAngle;
|
int aimY2 = aimY1 + TANK_BARREL_LENGTH * sinFromAngle;
|
||||||
aimX2 = aimX1 - (aimX2 - aimX1);
|
aimX2 = aimX1 - (aimX2 - aimX1);
|
||||||
|
|
||||||
game_state->bulletPosition.x = aimX2;
|
game_state->bulletPosition.x = aimX2;
|
||||||
game_state->bulletPosition.y = aimY2;
|
game_state->bulletPosition.y = aimY2;
|
||||||
game_state->bulletVector.x = -scorched_tanks_cos[game_state->enemy.aimAngle] * ((double)game_state->enemy.firePower / 10);
|
game_state->bulletVector.x = -scorched_tanks_cos[game_state->enemy.aimAngle] *
|
||||||
game_state->bulletVector.y = scorched_tanks_sin[game_state->enemy.aimAngle] * ((double)game_state->enemy.firePower / 10);
|
((double)game_state->enemy.firePower / 10);
|
||||||
|
game_state->bulletVector.y = scorched_tanks_sin[game_state->enemy.aimAngle] *
|
||||||
|
((double)game_state->enemy.firePower / 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
game_state->trajectoryAnimationStep = 0;
|
game_state->trajectoryAnimationStep = 0;
|
||||||
|
|
||||||
for (int x = 0; x < SCREEN_WIDTH; x++)
|
for(int x = 0; x < SCREEN_WIDTH; x++) {
|
||||||
{
|
|
||||||
game_state->trajectory[x].x = 0;
|
game_state->trajectory[x].x = 0;
|
||||||
game_state->trajectory[x].y = 0;
|
game_state->trajectory[x].y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
game_state->isShooting = true;
|
game_state->isShooting = true;
|
||||||
|
|
||||||
NotificationApp *notification = furi_record_open("notification");
|
NotificationApp* notification = furi_record_open("notification");
|
||||||
notification_message(notification, &sequence_long_vibro);
|
notification_message(notification, &sequence_long_vibro);
|
||||||
notification_message(notification, &sequence_blink_white_100);
|
notification_message(notification, &sequence_blink_white_100);
|
||||||
furi_record_close("notification");
|
furi_record_close("notification");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t scorched_tanks_game_app(void *p)
|
int32_t scorched_tanks_game_app(void* p) {
|
||||||
{
|
|
||||||
UNUSED(p);
|
UNUSED(p);
|
||||||
srand(DWT->CYCCNT);
|
srand(DWT->CYCCNT);
|
||||||
|
|
||||||
FuriMessageQueue *event_queue = furi_message_queue_alloc(8, sizeof(ScorchedTanksEvent));
|
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(ScorchedTanksEvent));
|
||||||
|
|
||||||
Game *game_state = malloc(sizeof(Game));
|
Game* game_state = malloc(sizeof(Game));
|
||||||
scorched_tanks_init_game(game_state);
|
scorched_tanks_init_game(game_state);
|
||||||
|
|
||||||
ValueMutex state_mutex;
|
ValueMutex state_mutex;
|
||||||
if (!init_mutex(&state_mutex, game_state, sizeof(ScorchedTanksEvent)))
|
if(!init_mutex(&state_mutex, game_state, sizeof(ScorchedTanksEvent))) {
|
||||||
{
|
|
||||||
FURI_LOG_E("ScorchedTanks", "cannot create mutex\r\n");
|
FURI_LOG_E("ScorchedTanks", "cannot create mutex\r\n");
|
||||||
free(game_state);
|
free(game_state);
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewPort *view_port = view_port_alloc();
|
ViewPort* view_port = view_port_alloc();
|
||||||
view_port_draw_callback_set(view_port, scorched_tanks_render_callback, &state_mutex);
|
view_port_draw_callback_set(view_port, scorched_tanks_render_callback, &state_mutex);
|
||||||
view_port_input_callback_set(view_port, scorched_tanks_input_callback, event_queue);
|
view_port_input_callback_set(view_port, scorched_tanks_input_callback, event_queue);
|
||||||
|
|
||||||
FuriTimer *timer =
|
FuriTimer* timer =
|
||||||
furi_timer_alloc(scorched_tanks_update_timer_callback, FuriTimerTypePeriodic, event_queue);
|
furi_timer_alloc(scorched_tanks_update_timer_callback, FuriTimerTypePeriodic, event_queue);
|
||||||
furi_timer_start(timer, 2000);
|
furi_timer_start(timer, 2000);
|
||||||
|
|
||||||
// Open GUI and register view_port
|
// Open GUI and register view_port
|
||||||
Gui *gui = furi_record_open(RECORD_GUI);
|
Gui* gui = furi_record_open(RECORD_GUI);
|
||||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||||
|
|
||||||
ScorchedTanksEvent event;
|
ScorchedTanksEvent event;
|
||||||
for (bool processing = true; processing;)
|
for(bool processing = true; processing;) {
|
||||||
{
|
|
||||||
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 50);
|
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 50);
|
||||||
|
|
||||||
if (event.type == EventTypeKey)
|
if(event.type == EventTypeKey) { // && game->isPlayerTurn
|
||||||
{ // && game->isPlayerTurn
|
if(event.input.type == InputTypeRepeat || event.input.type == InputTypeShort) {
|
||||||
if (event.input.type == InputTypeRepeat || event.input.type == InputTypeShort)
|
switch(event.input.key) {
|
||||||
{
|
|
||||||
switch (event.input.key)
|
|
||||||
{
|
|
||||||
case InputKeyUp:
|
case InputKeyUp:
|
||||||
scorched_tanks_aim_up(game_state);
|
scorched_tanks_aim_up(game_state);
|
||||||
break;
|
break;
|
||||||
@@ -553,9 +517,7 @@ int32_t scorched_tanks_game_app(void *p)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if(event.type == EventTypeTick) {
|
||||||
else if (event.type == EventTypeTick)
|
|
||||||
{
|
|
||||||
scorched_tanks_calculate_trajectory(game_state);
|
scorched_tanks_calculate_trajectory(game_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ bool subbrute_worker_start(SubBruteWorker* instance) {
|
|||||||
void subbrute_worker_stop(SubBruteWorker* instance) {
|
void subbrute_worker_stop(SubBruteWorker* instance) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
if (!instance->worker_running) {
|
if(!instance->worker_running) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,9 +47,14 @@ bool subbrute_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
|||||||
if(strcmp(instance->text_store, "")) {
|
if(strcmp(instance->text_store, "")) {
|
||||||
furi_string_reset(instance->file_path);
|
furi_string_reset(instance->file_path);
|
||||||
furi_string_cat_printf(
|
furi_string_cat_printf(
|
||||||
instance->file_path, "%s/%s%s", SUBBRUTE_PATH, instance->text_store, SUBBRUTE_FILE_EXT);
|
instance->file_path,
|
||||||
|
"%s/%s%s",
|
||||||
|
SUBBRUTE_PATH,
|
||||||
|
instance->text_store,
|
||||||
|
SUBBRUTE_FILE_EXT);
|
||||||
|
|
||||||
if(subbrute_device_save_file(instance->device, furi_string_get_cstr(instance->file_path))) {
|
if(subbrute_device_save_file(
|
||||||
|
instance->device, furi_string_get_cstr(instance->file_path))) {
|
||||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSaveSuccess);
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSaveSuccess);
|
||||||
success = true;
|
success = true;
|
||||||
consumed = true;
|
consumed = true;
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ bool desktop_main_input_callback(InputEvent* event, void* context) {
|
|||||||
} else if(event->key == InputKeyDown) {
|
} else if(event->key == InputKeyDown) {
|
||||||
main_view->callback(DesktopMainEventOpenFavoriteSecondary, main_view->context);
|
main_view->callback(DesktopMainEventOpenFavoriteSecondary, main_view->context);
|
||||||
} else if(event->key == InputKeyLeft) {
|
} else if(event->key == InputKeyLeft) {
|
||||||
main_view->callback(DesktopMainEventOpenSubRemote, main_view->context); // OPENS SUBGHZ REMOTE
|
main_view->callback(
|
||||||
|
DesktopMainEventOpenSubRemote, main_view->context); // OPENS SUBGHZ REMOTE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(main_view->is_gamemode == true) {
|
} else if(main_view->is_gamemode == true) {
|
||||||
@@ -105,9 +106,11 @@ bool desktop_main_input_callback(InputEvent* event, void* context) {
|
|||||||
} else if(event->key == InputKeyUp) {
|
} else if(event->key == InputKeyUp) {
|
||||||
main_view->callback(DesktopMainEventOpenDOOM, main_view->context); // OPENS DOOM
|
main_view->callback(DesktopMainEventOpenDOOM, main_view->context); // OPENS DOOM
|
||||||
} else if(event->key == InputKeyDown) {
|
} else if(event->key == InputKeyDown) {
|
||||||
main_view->callback(DesktopMainEventOpenZombiez, main_view->context); // OPENS Zombiez
|
main_view->callback(
|
||||||
|
DesktopMainEventOpenZombiez, main_view->context); // OPENS Zombiez
|
||||||
} else if(event->key == InputKeyLeft) {
|
} else if(event->key == InputKeyLeft) {
|
||||||
main_view->callback(DesktopMainEventOpenTetris, main_view->context); // OPENS TETRIS
|
main_view->callback(
|
||||||
|
DesktopMainEventOpenTetris, main_view->context); // OPENS TETRIS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -127,9 +130,11 @@ bool desktop_main_input_callback(InputEvent* event, void* context) {
|
|||||||
} else if(event->key == InputKeyUp) {
|
} else if(event->key == InputKeyUp) {
|
||||||
main_view->callback(DesktopMainEventOpenSnake, main_view->context); // OPENS SNAKE
|
main_view->callback(DesktopMainEventOpenSnake, main_view->context); // OPENS SNAKE
|
||||||
} else if(event->key == InputKeyDown) {
|
} else if(event->key == InputKeyDown) {
|
||||||
main_view->callback(DesktopMainEventOpenZombiez, main_view->context); // OPENS Zombiez
|
main_view->callback(
|
||||||
|
DesktopMainEventOpenZombiez, main_view->context); // OPENS Zombiez
|
||||||
} else if(event->key == InputKeyLeft) {
|
} else if(event->key == InputKeyLeft) {
|
||||||
main_view->callback(DesktopMainEventOpenTetris, main_view->context); // OPENS TETRIS
|
main_view->callback(
|
||||||
|
DesktopMainEventOpenTetris, main_view->context); // OPENS TETRIS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
|||||||
2,
|
2,
|
||||||
canvas_width(gui->canvas) - 1,
|
canvas_width(gui->canvas) - 1,
|
||||||
canvas_height(gui->canvas) - 4);
|
canvas_height(gui->canvas) - 4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Left side
|
// Left side
|
||||||
@@ -128,7 +127,7 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
|||||||
canvas_frame_set(
|
canvas_frame_set(
|
||||||
gui->canvas,
|
gui->canvas,
|
||||||
x - 1,
|
x - 1,
|
||||||
// SASQUACH SAYS : This is the white box behind the left bar, move it 64 to hide it
|
// SASQUACH SAYS : This is the white box behind the left bar, move it 64 to hide it
|
||||||
GUI_STATUS_BAR_Y + 64,
|
GUI_STATUS_BAR_Y + 64,
|
||||||
width + 2,
|
width + 2,
|
||||||
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
||||||
@@ -138,8 +137,12 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
|||||||
canvas_set_color(gui->canvas, ColorBlack);
|
canvas_set_color(gui->canvas, ColorBlack);
|
||||||
// ViewPort draw
|
// ViewPort draw
|
||||||
canvas_frame_set(
|
canvas_frame_set(
|
||||||
// SASQUACH SAYS : This is where you move the Icons for the left bar, 64 to hide it
|
// SASQUACH SAYS : This is where you move the Icons for the left bar, 64 to hide it
|
||||||
gui->canvas, x, GUI_STATUS_BAR_Y + 64, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
gui->canvas,
|
||||||
|
x,
|
||||||
|
GUI_STATUS_BAR_Y + 64,
|
||||||
|
width,
|
||||||
|
GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
||||||
view_port_draw(view_port, gui->canvas);
|
view_port_draw(view_port, gui->canvas);
|
||||||
// Recalculate next position
|
// Recalculate next position
|
||||||
left_used += (width + 2);
|
left_used += (width + 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user