Skip to content

Commit

Permalink
add desktop icon
Browse files Browse the repository at this point in the history
  • Loading branch information
julesgrc0 committed Mar 2, 2024
1 parent 30c54df commit ae1ac1a
Show file tree
Hide file tree
Showing 34 changed files with 96 additions and 92 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# 🎮 Wispy

<img src="./logo/logo.png" width="100" height="100" alt="Wispy Logo" style="border-radius: 10px;"/>

![C](https://img.shields.io/github/languages/top/julesgrc0/wispy?label=C%20🔥) ![Platform](https://img.shields.io/badge/Platform%20🌍-Windows%20|%20Linux%20|%20Android-purple) ![Game](https://img.shields.io/badge/Game%20🎮-Wispy-green) ![Version](https://shields.io/github/v/release/julesgrc0/wispy?label=Version%20🧮&color=lightblue) [![Downloads](https://img.shields.io/github/downloads/julesgrc0/wispy/total.svg?label=Downloads%20📊)](https://github.com/julesgrc0/wispy/releases/latest)
[![Release Build](https://github.com/julesgrc0/wispy/actions/workflows/windows.yml/badge.svg)](https://github.com/julesgrc0/wispy/actions/workflows/windows.yml) [![Release Build](https://github.com/julesgrc0/wispy/actions/workflows/linux.yml/badge.svg)](https://github.com/julesgrc0/wispy/actions/workflows/linux.yml) [![Release Build](https://github.com/julesgrc0/wispy/actions/workflows/android.yml/badge.svg)](https://github.com/julesgrc0/wispy/actions/workflows/android.yml)


**Concept**: Wipsy is a kind of 2D Minecraft.

![Wispy Icon](./android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp)

> Preview 🎥
| ![video 0](./preview/game0.gif) | ![video 1](./preview/game1.gif) |
| ![video 0](./.github/preview/game0.gif) | ![video 1](./.github/preview/game1.gif) |
| ------------------------------- | ------------------------------- |
| ![video 2](./preview/game2.gif) | ![video 3](./preview/game3.gif) |
| ![video 2](./.github/preview/game2.gif) | ![video 3](./.github/preview/game3.gif) |

## 🚀 Project Insight

Expand Down Expand Up @@ -77,11 +79,6 @@ cmake --build out --config <debug|release>

**📱 Building for Android**


> 🚧 Experimental 🚧
The android version is still in development and may not work as expected. For the moment, the camera is laggy and the game is not very optimized for mobile devices.

> Build with Android Studio
Open the project folder with Android Studio and select the build configuration.
Expand All @@ -92,7 +89,9 @@ See the workflow file [android.yml](.github/workflows/android.yml) for more deta

## 🤝 Get Involved

Wellcome to the community ! We are happy to see you here. If you want to [contribute](CONTRIBUTING.md) to the project, you can start by forking the repository and then submit a pull request 🔥 .
Wellcome to the community ! We are happy to see you here. If you want to [contribute](CONTRIBUTING.md) to the project, you can start by forking the repository and then submit a pull request 🔥.

[![](https://dcbadge.vercel.app/api/server/5KjGkDGpUp)](https://discord.gg/5KjGkDGpUp)

## 📃 License

Expand Down
File renamed without changes
File renamed without changes
Binary file added logo/logo.ico
Binary file not shown.
File renamed without changes
6 changes: 5 additions & 1 deletion src/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ w_config *load_config() {
cfg->fullscreen = 1;
cfg->msaa4x = 1;

#if defined(_DEBUG) && !defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
cfg->vsync = 1;
#endif

#if defined(_DEBUG) && !defined(WISPY_ANDROID)
cfg->width = RENDER_W;
cfg->height = RENDER_H;
cfg->fullscreen = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/core/controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void destroy_controls(w_controls *kb) {
}

void update_controls(w_controls *kb) {
#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
kb->jump = kb->is_jumping;
if (!kb->is_breaking) {
kb->left = kb->joystick.x < -0.5;
Expand All @@ -32,7 +32,7 @@ void update_controls(w_controls *kb) {
}

void clear_controls(w_controls *kb) {
#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
kb->is_jumping = false;
kb->is_breaking = false;
kb->joystick = VEC_ZERO;
Expand All @@ -41,7 +41,7 @@ void clear_controls(w_controls *kb) {
kb->key = 0;
}

#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
bool check_collision_touch(Vector2 position, float size) {
return !Vector2Equals(get_collision_touch(position, size), VEC_ZERO);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef struct w_controls {
uint8_t key;
};

#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
Vector2 joystick;
bool is_jumping;
bool is_breaking;
Expand All @@ -31,7 +31,7 @@ void destroy_controls(w_controls *kb);
void update_controls(w_controls *kb);
void clear_controls(w_controls *kb);

#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
bool check_collision_touch(Vector2 position, float size);
Vector2 get_nearest_touch(Vector2 position);
Vector2 get_collision_touch(Vector2 position, float size);
Expand Down
2 changes: 1 addition & 1 deletion src/core/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ typedef struct w_state {

w_config *config;

#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
HINSTANCE hInstance;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/gui/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ w_guiaction *create_action(w_guicontext *ctx, Vector2 position, float size,
}

bool update_action(w_guiaction *act) {
#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
bool clicked = check_collision_touch(act->position, act->size);
#else
bool clicked =
Expand Down
4 changes: 2 additions & 2 deletions src/gui/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void move_button(w_guibutton *button, Vector2 position) {
}

bool update_button(w_guibutton *button) {
#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
bool is_hover = has_touch() && check_collision_touch_rect(button->rect);
#else
bool is_hover = CheckCollisionRecs(
Expand All @@ -46,7 +46,7 @@ bool update_button(w_guibutton *button) {
DrawText(button->text, (int)button->position.x, (int)button->position.y,
(int)button->ctx->font_size, color);

#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
return is_hover;
#else
return IsMouseButtonDown(MOUSE_LEFT_BUTTON) && is_hover;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Vector2 update_joystick(w_guijoystick *js) {
DrawCircleV(js->position, js->size, Fade(WHITE, 0.3f));
DrawCircleV(js->position, js->size * 0.9f, Fade(WHITE, 0.3f));

#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
if (has_touch()) {
Vector2 mouse =
get_nearest_touch(Vector2SubtractValue(js->position, js->size / 2.f));
Expand All @@ -32,7 +32,7 @@ Vector2 update_joystick(w_guijoystick *js) {
else if(js->touch_count != GetTouchPointCount())
{
js->cursor = js->position;
#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
js->touch_count = 0;
#endif
}else
Expand Down Expand Up @@ -61,7 +61,7 @@ Vector2 update_joystick(w_guijoystick *js) {
}
} else {
js->cursor = js->position;
#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
js->touch_count = 0;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ typedef struct w_guijoystick {
Vector2 cursor;
w_guicontext *ctx;

#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
int touch_count;
#endif
} w_guijoystick;
Expand Down
8 changes: 4 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "core/mainframe.h"
#include "stdafx.h"

#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
_In_ char *pCmdLine, _In_ int nCmdShow)
#else
int main(int argc, const char **argv)
#endif
{
#if defined(_DEBUG) && defined(PLATFORM_WINDOWS)
#if defined(_DEBUG) && defined(WISPY_WINDOWS)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);

Expand All @@ -27,7 +27,7 @@ int main(int argc, const char **argv)
#endif

w_state *state = init_mainframe();
#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
state->hInstance = hInstance;
#endif

Expand All @@ -37,7 +37,7 @@ int main(int argc, const char **argv)
loop_mainframe(state);
destroy_mainframe(state);

#if defined(_DEBUG) && defined(PLATFORM_WINDOWS)
#if defined(_DEBUG) && defined(WISPY_WINDOWS)
FreeConsole();
_CrtDumpMemoryLeaks();
#endif
Expand Down
1 change: 1 addition & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#define IDR_ASSETS_PACK1 101
#define IDI_WISPY_ICON1 102

#if defined(APSTUDIO_INVOKED)
#ifndef APSTUDIO_READONLY_SYMBOLS
Expand Down
Binary file modified src/resource.rc
Binary file not shown.
18 changes: 9 additions & 9 deletions src/screens/game/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ w_bridge *create_bridge() {
}

td->is_active = true;
#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_LINUX)
#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS) || defined(WISPY_LINUX)
#if defined(WISPY_WINDOWS)
QueryPerformanceFrequency(&td->time_frequency);
QueryPerformanceCounter(&td->time_start);

Expand All @@ -69,11 +69,11 @@ void destroy_bridge(w_bridge *td) {
LOG("destroying bridge thread");

td->is_active = false;
#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
if (td->handle != INVALID_HANDLE_VALUE && td->handle != NULL) {
WaitForSingleObject(td->handle, INFINITE);
}
#elif defined(PLATFORM_LINUX)
#elif defined(WISPY_LINUX)
if (td->handle != 0) {
pthread_join(td->handle, NULL);
}
Expand Down Expand Up @@ -123,13 +123,13 @@ void update_bridge(w_bridge *td) {
td->force_update = false;
}

#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
QueryPerformanceCounter(&td->time_end);
if (td->time_end.QuadPart - td->time_start.QuadPart >=
td->time_frequency.QuadPart * PHYSICS_TICK)
{
QueryPerformanceCounter(&td->time_start);
#elif defined(PLATFORM_LINUX)
#elif defined(WISPY_LINUX)
clock_gettime(CLOCK_MONOTONIC, &td->time_end);
if ((td->time_end.tv_sec - td->time_start.tv_sec) +
(td->time_end.tv_nsec - td->time_start.tv_nsec) / 1000000000.0 >=
Expand All @@ -143,15 +143,15 @@ void update_bridge(w_bridge *td) {
}
}

#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
int WINAPI thread_bridge(PVOID arg)
#else
void *thread_bridge(void *arg)
#endif
{
LOG("starting bridge thread");
if (!arg) {
#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
return EXIT_FAILURE;
#else
return NULL;
Expand All @@ -164,7 +164,7 @@ void *thread_bridge(void *arg)
} while (td->is_active);

LOG("exiting bridge thread");
#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
return EXIT_SUCCESS;
#else
return NULL;
Expand Down
8 changes: 4 additions & 4 deletions src/screens/game/bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ typedef struct w_bridge {
w_player *player;
w_camera *camera;

#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
HANDLE handle;
LARGE_INTEGER time_start, time_end, time_frequency;
#elif defined(PLATFORM_LINUX)
#elif defined(WISPY_LINUX)
struct timespec time_start, time_end;
pthread_t handle;
#endif
Expand All @@ -38,8 +38,8 @@ void destroy_bridge(w_bridge *td);
void physics_update_bridge(w_bridge *td);
void update_bridge(w_bridge *td);

#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
int WINAPI thread_bridge(PVOID arg);
#elif defined(PLATFORM_LINUX)
#elif defined(WISPY_LINUX)
void *thread_bridge(void *arg);
#endif
20 changes: 10 additions & 10 deletions src/screens/game/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void game_screen(w_state *state) {
return;
}

#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
w_guicontext *ctx = create_gui();
if (ctx == NULL) {
destroy_bridge(td);
Expand Down Expand Up @@ -72,7 +72,7 @@ void game_screen(w_state *state) {

w_breakstate bstate = BS_NONE;
while (!WindowShouldClose() && td->is_active) {
#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
update_controls(td->ctrl);
set_camera_vec(td->camera, VEC(roundf(td->camera->target_position.x),
roundf(td->camera->target_position.y)));
Expand All @@ -87,9 +87,9 @@ void game_screen(w_state *state) {
Vector2Distance(td->player->position, player_position) * speed);
#endif

#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
if (TryEnterCriticalSection(&td->chunk_view->csec))
#elif defined(PLATFORM_LINUX)
#elif defined(WISPY_LINUX)
if (pthread_mutex_trylock(&td->chunk_view->mutex) == 0)
#endif
{
Expand All @@ -108,7 +108,7 @@ void game_screen(w_state *state) {
td->chunk_view->blocks[i].light);
}

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_LINUX)
#if defined(WISPY_WINDOWS) || defined(WISPY_LINUX)
bstate = update_blockbreaker(bb, td->ctrl, td->player, GetFrameTime());
#endif
if (bstate == BS_BREAKING) {
Expand All @@ -117,7 +117,7 @@ void game_screen(w_state *state) {
td->force_update = true;
}

#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_LINUX)
#if defined(WISPY_WINDOWS) || defined(WISPY_LINUX)
DrawTexturePro(player_textures[td->player->state], td->player->src,
RECT(player_position.x, player_position.y,
td->player->dst.width, td->player->dst.height),
Expand All @@ -126,7 +126,7 @@ void game_screen(w_state *state) {

end_camera();

#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
DrawTexturePro(player_textures[td->player->state], td->player->src,
RECT((RENDER_W - td->player->dst.width) / 2,
(RENDER_H - td->player->dst.height) / 2,
Expand All @@ -141,9 +141,9 @@ void game_screen(w_state *state) {
DrawText(TextFormat("FPS: %i", GetFPS()), 50, 50, 30, WHITE);
EndTextureMode();

#if defined(PLATFORM_WINDOWS)
#if defined(WISPY_WINDOWS)
LeaveCriticalSection(&td->chunk_view->csec);
#elif defined(PLATFORM_LINUX)
#elif defined(WISPY_LINUX)
pthread_mutex_unlock(&td->chunk_view->mutex);
#endif
}
Expand All @@ -154,7 +154,7 @@ void game_screen(w_state *state) {
EndDrawing();
}

#if defined(PLATFORM_ANDROID)
#if defined(WISPY_ANDROID)
destroy_joystick(js);
destroy_action(break_button);
destroy_action(jump_button);
Expand Down
Loading

0 comments on commit ae1ac1a

Please sign in to comment.