Skip to content

Commit

Permalink
Merge pull request #10 from jblanked/dev_0.2
Browse files Browse the repository at this point in the history
FlipWorld - v0.2
  • Loading branch information
jblanked authored Jan 2, 2025
2 parents f9b6fa9 + 392f3f0 commit 597a892
Show file tree
Hide file tree
Showing 73 changed files with 3,770 additions and 1,869 deletions.
63 changes: 56 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,87 @@
The first open-world multiplayer game for the Flipper Zero, best played with the VGM.

## Requirements
- WiFi Developer Board, Raspberry Pi, or ESP32 device with the FlipperHTTP flash: https://github.com/jblanked/FlipperHTTP

- WiFi Developer Board, Raspberry Pi, or ESP32 device with the FlipperHTTP flash: [FlipperHTTP GitHub](https://github.com/jblanked/FlipperHTTP)
- 2.4 GHz WiFi access point

## How It Works
FlipWorld and FlipSocial are connected. Your login information is the same in both apps; if you register an account in either app, you can log in to both using that information. This also means that your friends, messages, and achievements are synced between apps. You only need a username and password to start, which is set in the User Settings. Keep in mind your username will be displayed to others, so choose wisely.

We've simplified the settings for easy use of the app. In the Game Settings, you can adjust the FPS (30, 60, 120, or 240), download World Packs, and select whether you want the screen backlight to always be on.
FlipWorld and FlipSocial are connected. Your login information is the same in both apps; if you register an account in either app, you can log in to both using that information. This also means that your friends, messages, and achievements are synced between apps. You only need a username and password to start, which are set in the User Settings. Keep in mind your username will be displayed to others, so choose wisely.

**Settings**

- **WiFi**: Enter your SSID and password to connect to your 2.4 GHz network.
- **User**: Add or update your username and password (this is the same login information as your FlipSocial account).
- **Game**: Install the Official World Pack, set your FPS (30, 60, 120, or 240), and select whether you want the screen backlight to always be on, the sound to be on, and the vibration to be on.

**Controls**

- **Press/Hold LEFT**: Turn left if not already facing left, then walk left if the button is still pressed.
- **Press/Hold RIGHT**: Turn right if not already facing right, then walk right if the button is still pressed.
- **Press/Hold UP**: Walk up.
- **Press/Hold DOWN**: Walk down.
- **Press/Hold UP**: Attack/Teleport (set to attack until all enemies are defeated).

**Player Attributes**

- **Health**: The amount of life points the player has.
- **XP**: The amount of experience points the player has.
- **Level**: The rank/level of the player.
- **Strength**: The attack power of the player's attacks.
- **Health Regeneration**: The amount of health a player gains per second.
- **Attack Timer**: The duration the player must wait between attacks.

As a new player, you have 100 health, 0 XP, 10 strength, 1 health regeneration, an attack timer of 1, and are level 1. Each level, the player gains an extra 1 strength and 10 health. Additionally, the amount of XP needed to level up increases exponentially by 1.5. For example, to reach level 2, you need 100 XP; for level 3, 150 XP; for level 4, 225 XP; and so on.

**Enemies**

Enemies have similar attributes to players but do not have XP or health regeneration. For example, level 1 enemies have 100 health and 10 strength, just like a level 1 player.

**Attacks**

If an enemy attacks you, your health decreases by the enemy's strength (attack power). Additionally, if an enemy defeats you, your XP decreases by the amount of the enemy's strength. Conversely, when you successfully attack an enemy, you gain 10% of the enemy's strength as health and increase your XP by the enemy's full strength.

## Short Tutorial

The controls in the game are straightforward. Press and hold left to go left, press and hold right to go right, etc. If you press the OK button, it will teleport you to the next available world. **Do NOT spam the OK button** as it could freeze your Flipper Zero. Press it once and wait for it to load.
1. Ensure your WiFi Developer Board and Video Game Module are flashed with FlipperHTTP.
2. Install the app.
3. Restart your Flipper Zero, then open FlipWorld.
4. Click `Settings -> WiFi`, then input your WiFi SSID and password.
5. Hit the `BACK` button, click `User`. If your username is not present, click `Username` and add one. Do the same for the password field.
6. Go back to the main menu and hit `Play`. It will register an account if necessary and fetch data from our API that's used to render our graphics.

## Roadmap

**v0.2**
- Stability patch

- Game Mechanics
- Video Game Module support

**v0.3**
- ???

- Stability patch

**v0.4**

- ???

**v0.5**

- ???

**v0.6**

- ???

**v0.7**

- ???

**v0.8**

- Multiplayer support

**v1.0**
- Official release

- Official release
4 changes: 3 additions & 1 deletion alloc/alloc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <alloc/alloc.h>
#include <callback/callback.h>

/**
* @brief Navigation callback for exiting the application
Expand Down Expand Up @@ -90,5 +91,6 @@ void flip_world_app_free(FlipWorldApp *app)
furi_record_close(RECORD_GUI);

// free the app
free(app);
if (app)
free(app);
}
5 changes: 2 additions & 3 deletions alloc/alloc.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once
#include <flip_world.h>
#include <callback/callback.h>

extern FlipWorldApp *flip_world_app_alloc();
extern void flip_world_app_free(FlipWorldApp *app);
FlipWorldApp *flip_world_app_alloc();
void flip_world_app_free(FlipWorldApp *app);
159 changes: 142 additions & 17 deletions app.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <alloc/alloc.h>
#include <flip_storage/storage.h>

// Entry point for the FlipWorld application
int32_t flip_world_main(void *p)
Expand All @@ -14,34 +15,158 @@ int32_t flip_world_main(void *p)
return -1;
}

// initialize the VGM
furi_hal_gpio_init_simple(&gpio_ext_pc1, GpioModeOutputPushPull);
furi_hal_gpio_write(&gpio_ext_pc1, false); // pull pin 15 low

// check if board is connected (Derek Jamison)
// initialize the http
if (flipper_http_init(flipper_http_rx_callback, app))
FlipperHTTP *fhttp = flipper_http_alloc();
if (!fhttp)
{
if (!flipper_http_ping())
{
FURI_LOG_E(TAG, "Failed to ping the device");
return -1;
}
easy_flipper_dialog("FlipperHTTP Error", "The UART is likely busy.\nEnsure you have the correct\nflash for your board then\nrestart your Flipper Zero.");
return -1;
}

if (!flipper_http_ping(fhttp))
{
FURI_LOG_E(TAG, "Failed to ping the device");
flipper_http_free(fhttp);
return -1;
}

// Try to wait for pong response.
uint8_t counter = 10;
while (fhttp.state == INACTIVE && --counter > 0)
// Try to wait for pong response.
uint32_t counter = 10;
while (fhttp->state == INACTIVE && --counter > 0)
{
FURI_LOG_D(TAG, "Waiting for PONG");
furi_delay_ms(100); // this causes a BusFault
}

flipper_http_free(fhttp);
if (counter == 0)
{
easy_flipper_dialog("FlipperHTTP Error", "Ensure your WiFi Developer\nBoard or Pico W is connected\nand the latest FlipperHTTP\nfirmware is installed.");
}

// this will be removed in version 0.3. we'll keep all our data in the data folder from now on
// load app version
char saved_app_version[16];
if (load_char("app_version", saved_app_version, sizeof(saved_app_version)))
{
float saved_version = strtod(saved_app_version, NULL);
if (saved_version == 0.1)
{
FURI_LOG_D(TAG, "Waiting for PONG");
furi_delay_ms(100);
}
// transfer files over into the data folder (to bs used to load the player context)
char directory_path[256];
snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_world/data");

// Create the directory
Storage *storage = furi_record_open(RECORD_STORAGE);
storage_common_mkdir(storage, directory_path);

if (counter == 0)
easy_flipper_dialog("FlipperHTTP Error", "Ensure your WiFi Developer\nBoard or Pico W is connected\nand the latest FlipperHTTP\nfirmware is installed.");
// copy the whole folder
char source_path[128];
snprintf(source_path, sizeof(source_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_world");

flipper_http_deinit();
if (storage_common_migrate(storage, source_path, directory_path) != FSE_OK)
{
FURI_LOG_E(TAG, "Failed to migrate files");
}
else
{

void clean_up(char *file_path)
{
char updated_file_path[128];
snprintf(updated_file_path, sizeof(updated_file_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_world/%s", file_path);

// check if the file exists
if (storage_file_exists(storage, updated_file_path) &&
storage_common_remove(storage, updated_file_path) != FSE_OK)
{
FURI_LOG_E(TAG, "Failed to delete %s", updated_file_path);
}

// check if the directory exists
if (storage_dir_exists(storage, updated_file_path) &&
storage_common_remove(storage, updated_file_path) != FSE_OK)
{
FURI_LOG_E(TAG, "Failed to delete %s", updated_file_path);
}
}

// clean up
clean_up("WiFi-SSID.txt");
clean_up("WiFi-Password.txt");
clean_up("Flip-Social-Username.txt");
clean_up("Flip-Social-Password.txt");
clean_up("Game-FPS.txt");
clean_up("Game-Screen-Always-On.txt");
clean_up("is_logged_in.txt");
clean_up("data/worlds");
clean_up("data/settings.bin");
}
}
}
else
{
easy_flipper_dialog("FlipperHTTP Error", "The UART is likely busy.\nEnsure you have the correct\nflash for your board then\nrestart your Flipper Zero.");
// transfer files over into the data folder (to bs used to load the player context)
char directory_path[128];
snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_world/data");

// Create the directory
Storage *storage = furi_record_open(RECORD_STORAGE);
storage_common_mkdir(storage, directory_path);

// copy the whole folder
char source_path[128];
snprintf(source_path, sizeof(source_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_world");

if (storage_common_migrate(storage, source_path, directory_path) != FSE_OK)
{
FURI_LOG_E(TAG, "Failed to migrate files");
}
else
{

void clean_up(char *file_path)
{
char updated_file_path[128];
snprintf(updated_file_path, sizeof(updated_file_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_world/%s", file_path);

// check if the file exists
if (storage_file_exists(storage, updated_file_path) &&
storage_common_remove(storage, updated_file_path) != FSE_OK)
{
FURI_LOG_E(TAG, "Failed to delete %s", updated_file_path);
}

// check if the directory exists
if (storage_dir_exists(storage, updated_file_path) &&
storage_common_remove(storage, updated_file_path) != FSE_OK)
{
FURI_LOG_E(TAG, "Failed to delete %s", updated_file_path);
}
}

// clean up
clean_up("WiFi-SSID.txt");
clean_up("WiFi-Password.txt");
clean_up("Flip-Social-Username.txt");
clean_up("Flip-Social-Password.txt");
clean_up("Game-FPS.txt");
clean_up("Game-Screen-Always-On.txt");
clean_up("is_logged_in.txt");
clean_up("data/worlds");
clean_up("data/settings.bin");
}
}

// svae app version
char app_version[16];
snprintf(app_version, sizeof(app_version), "%f", (double)VERSION);
save_char("app_version", app_version);

// Run the view dispatcher
view_dispatcher_run(app->view_dispatcher);

Expand Down
7 changes: 5 additions & 2 deletions application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ App(
fap_category="GPIO",
fap_description="The first open-world multiplayer game, best played with the VGM.",
fap_icon_assets="assets",
fap_file_assets="assets",
fap_file_assets="file_assets",
fap_extbuild=(
ExtFile(
path="${FAP_SRC_DIR}/assets",
path="${FAP_SRC_DIR}/file_assets",
command="${PYTHON3} ${FAP_SRC_DIR}/engine/scripts/sprite_builder.py ${FAP_SRC_DIR.abspath}/sprites ${TARGET.abspath}/sprites",
),
),
fap_author="JBlanked",
fap_weburl="https://github.com/jblanked/FlipWorld",
fap_version="0.2",
)
Binary file modified assets/01-home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 18 additions & 2 deletions assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
## 0.1
- Initial Release
## 0.2 (2025-01-02)
Added
- **Video Game Module Support:** Added support for the Video Game Module (requires FlipperHTTP flash).
- **Enemies:** Introduced various enemy types to enhance gameplay.
- **Player Attributes:** Added player health, XP, level, health regeneration, attack, and strength.
- **Notifications:** Implemented vibration, sound, and LED notifications when a player is attacking or being attacked.
- **User Interface Enhancements:**: Displayed the player's username above their character and showed the player's health, XP, and level in the bottom left corner of the screen, visible at all times.

Changed
- **Icons:** Updated all game icons for better visual appeal.
- **Library Update:** Upgraded to the latest version of the FlipperHTTP library.
- **Game Settings:** Revised toggles in the Game Settings to ensure they work as intended.
- **Collisions:** Improved collision mechanics for more accurate interactions.
- **Default Character Icon:** Updated the default icon representing the player's character.

## 0.1 (2024-12-21)
Added
- **Initial Release:** Launched the first version of the game with basic features.
Loading

0 comments on commit 597a892

Please sign in to comment.