diff --git a/Makefile b/Makefile index a6fc16dcb..865becb3b 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ CC = gcc -TARGET = main -SRC = main.c +TARGET = build/main +SRC = src/main.c +INBE_DIR = libinbe +INBE_A = $(INBE_DIR)/libinbe.a RAYLIB_DIR = ../vendor/raylib/src RAYLIB_BUILD_DIR = ../vendor/raylib/build/sdl RAYLIB_A = $(RAYLIB_BUILD_DIR)/libraylib.a -ANDROID_DIR = android -GRADLEW = ../droid/gradlew +ANDROID_DIR = droid +GRADLEW = ./droid/gradlew ANDROID_APP_ID = xyz.waozi.inbe ANDROID_ACTIVITY = android.app.NativeActivity @@ -32,21 +34,28 @@ endif all: $(TARGET) -$(RAYLIB_BUILD_DIR): +build: + mkdir -p $@ + +$(RAYLIB_BUILD_DIR): build mkdir -p $@ $(RAYLIB_A): FORCE | $(RAYLIB_BUILD_DIR) $(MAKE) -C $(RAYLIB_DIR) clean $(MAKE) -j1 -C $(RAYLIB_DIR) PLATFORM=PLATFORM_DESKTOP_SDL GRAPHICS=GRAPHICS_API_OPENGL_ES2 RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH=../build/sdl RAYLIB_MODULE_AUDIO=FALSE RAYLIB_MODULE_MODELS=FALSE SDL_INCLUDE_PATH="$(RAY_SDL_INCLUDE_DIR)" SDL_LIBRARIES="$(RAY_SDL_LDLIBS)" CUSTOM_CFLAGS="-DUSING_SDL2_PROJECT $(RAY_CFLAGS) $(RAY_RAYLIB_CONFIG) -Os -ffunction-sections -fdata-sections" -$(TARGET): $(SRC) $(RAYLIB_A) - $(CC) $(CFLAGS) -I$(RAYLIB_DIR) $(RAY_CFLAGS) -o $@ $(SRC) $(RAYLIB_A) $(RAY_LDLIBS) -lm -lpthread -ldl -lrt $(LDFLAGS) +$(INBE_A): + $(MAKE) -C $(INBE_DIR) + +$(TARGET): $(SRC) $(RAYLIB_A) $(INBE_A) | build + $(CC) $(CFLAGS) -I$(RAYLIB_DIR) -I$(INBE_DIR) $(RAY_CFLAGS) -o $@ $(SRC) $(INBE_A) $(RAYLIB_A) $(RAY_LDLIBS) -lm -lpthread -ldl -lrt $(LDFLAGS) run: $(TARGET) ./$(TARGET) clean: - rm -f $(TARGET) + rm -rf build + $(MAKE) -C $(INBE_DIR) clean clean-raylib: $(MAKE) -C $(RAYLIB_DIR) clean @@ -107,4 +116,4 @@ android-clean: FORCE: -.PHONY: all run clean clean-raylib android-init-signing android-debug android-release android-install android-install-release android-clean FORCE +.PHONY: all run clean clean-raylib android-init-signing android-debug android-release android-install android-install-release android-clean FORCE $(INBE_A) diff --git a/android/app/build.gradle b/droid/app/build.gradle similarity index 91% rename from android/app/build.gradle rename to droid/app/build.gradle index c0120f93c..12a662060 100644 --- a/android/app/build.gradle +++ b/droid/app/build.gradle @@ -27,16 +27,10 @@ android { defaultConfig { applicationId 'xyz.waozi.inbe' - minSdk 23 + minSdk 19 targetSdk 34 versionCode 1 versionName '1.0' - - externalNativeBuild { - cmake { - arguments '-DANDROID_STL=c++_static' - } - } } buildTypes { diff --git a/android/build.gradle b/droid/build.gradle similarity index 100% rename from android/build.gradle rename to droid/build.gradle diff --git a/droid/gradle/wrapper/gradle-wrapper.jar b/droid/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..1b33c55ba Binary files /dev/null and b/droid/gradle/wrapper/gradle-wrapper.jar differ diff --git a/droid/gradle/wrapper/gradle-wrapper.properties b/droid/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..e650f0277 --- /dev/null +++ b/droid/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/droid/gradlew b/droid/gradlew new file mode 100755 index 000000000..23d15a936 --- /dev/null +++ b/droid/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/droid/gradlew.bat b/droid/gradlew.bat new file mode 100644 index 000000000..5eed7ee84 --- /dev/null +++ b/droid/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/settings.gradle b/droid/settings.gradle similarity index 89% rename from android/settings.gradle rename to droid/settings.gradle index 802779504..885b3d0b1 100644 --- a/android/settings.gradle +++ b/droid/settings.gradle @@ -13,5 +13,5 @@ dependencyResolutionManagement { } } -rootProject.name = "RayInbe" +rootProject.name = "InnerBreeze" include ':app' diff --git a/flake.nix b/flake.nix index d951c3376..94920650c 100644 --- a/flake.nix +++ b/flake.nix @@ -76,8 +76,10 @@ export RAY_RAYLIB_CONFIG="-DSUPPORT_SCREEN_CAPTURE=0 -DSUPPORT_COMPRESSION_API=0 -DSUPPORT_AUTOMATION_EVENTS=0 -DSUPPORT_CLIPBOARD_IMAGE=0 -DSUPPORT_FILEFORMAT_PNG=0 -DSUPPORT_FILEFORMAT_BMP=0 -DSUPPORT_FILEFORMAT_GIF=0 -DSUPPORT_FILEFORMAT_QOI=0 -DSUPPORT_FILEFORMAT_DDS=0 -DSUPPORT_FILEFORMAT_TTF=0" export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH" - if [ ! -f android/local.properties ]; then - cat > android/local.properties < local.properties <screen = LotusScreenStart; - l->phase = LotusPhaseBreathe; + l->screen = InbeScreenStart; + l->phase = InbePhaseBreathe; l->round = 0; l->r = 25; @@ -80,7 +80,7 @@ lotusinit(Lotus *l) static void -breathe(Lotus *l) +breathe(Inbe *l) { l->breathtick++; if(l->breathtick < l->breathtickmax) @@ -103,12 +103,12 @@ breathe(Lotus *l) if(eqcount(l->count, l->maxbreaths)){ cpcount(l->count, "000"); - l->phase = LotusPhaseHold; + l->phase = InbePhaseHold; } } static void -next(Lotus *l) +next(Inbe *l) { l->sectick++; if(l->sectick < 60) @@ -118,24 +118,24 @@ next(Lotus *l) if(l->round < MaxRounds - 1){ cpcount(l->count, "000"); l->round++; - l->phase = LotusPhaseBreathe; + l->phase = InbePhaseBreathe; }else{ - l->screen = LotusScreenResults; + l->screen = InbeScreenResults; } } static void -recover(Lotus *l) +recover(Inbe *l) { if(l->r < l->rmax && strcmp(l->count, "000") == 0) { - + l->breathtick++; if(l->breathtick < l->breathtickmax) return; l->breathtick = 0; l->r += l->speed; - + } else { if(strcmp(l->count, "015") == 0 && l->r > l->rmin) { @@ -148,21 +148,21 @@ recover(Lotus *l) l->r -= l->speed; if(l->r == l->rmin) - l->phase = LotusPhaseNext; + l->phase = InbePhaseNext; } else { l->sectick++; if(l->sectick < 60) return; l->sectick = 0; - + inccount(l->count); } } } static void -hold(Lotus *l) +hold(Inbe *l) { l->sectick++; if(l->sectick < 60) @@ -173,22 +173,22 @@ hold(Lotus *l) } void -lotusstep(Lotus *l) +inbestep(Inbe *l) { if(l == 0) return; switch(l->phase){ - case LotusPhaseBreathe: + case InbePhaseBreathe: breathe(l); break; - case LotusPhaseHold: + case InbePhaseHold: hold(l); break; - case LotusPhaseRecover: + case InbePhaseRecover: recover(l); break; - case LotusPhaseNext: + case InbePhaseNext: next(l); break; } diff --git a/liblotus/lotus.h b/libinbe/inbe.h similarity index 78% rename from liblotus/lotus.h rename to libinbe/inbe.h index f3380935e..c2d327bb7 100644 --- a/liblotus/lotus.h +++ b/libinbe/inbe.h @@ -1,5 +1,5 @@ -#ifndef LOTUS_H -#define LOTUS_H +#ifndef INBE_H +#define INBE_H #if defined(__PLAN9__) || (!defined(__STDC__) && (defined(__i386__) || defined(__amd64__) || defined(__arm__))) typedef unsigned char uint8_t; @@ -25,21 +25,21 @@ enum { }; enum { - LotusScreenStart = 0, - LotusScreenSession, - LotusScreenResults + InbeScreenStart = 0, + InbeScreenSession, + InbeScreenResults }; enum { - LotusPhaseBreathe = 0, - LotusPhaseHold, - LotusPhaseRecover, - LotusPhaseNext + InbePhaseBreathe = 0, + InbePhaseHold, + InbePhaseRecover, + InbePhaseNext }; -typedef struct Lotus Lotus; +typedef struct Inbe Inbe; -struct Lotus { +struct Inbe { int screen; int phase; int round; @@ -62,9 +62,9 @@ struct Lotus { char results[MaxRounds][CountSize]; }; -void lotusinit(Lotus *l); -void lotusstep(Lotus *l); +void inbeinit(Inbe *l); +void inbestep(Inbe *l); void inccount(char v[CountSize]); void cpcount(char dst[CountSize], const char src[CountSize]); -#endif \ No newline at end of file +#endif diff --git a/love2d/inbe.html b/love2d/inbe.html index 8cd19de83..435acfb69 100644 --- a/love2d/inbe.html +++ b/love2d/inbe.html @@ -3,10 +3,10 @@ - + - + Inner Breeze - Guided Breathing @@ -31,7 +31,7 @@ - back to lotus + back home diff --git a/main.c b/main.c deleted file mode 100644 index 6d1e636c2..000000000 --- a/main.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "raylib.h" - -#if defined(PLATFORM_ANDROID) -#include - -void android_main(struct android_app *app) { - (void)app; - - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib - basic window"); - - SetTargetFPS(60); - - while (!WindowShouldClose()) { - BeginDrawing(); - ClearBackground(RAYWHITE); - DrawText("Hello, raylib!", 190, 200, 20, LIGHTGRAY); - EndDrawing(); - } - - CloseWindow(); -} - -#else - -int main(int argc, char **argv) { - (void)argc; - (void)argv; - - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib - basic window"); - - SetTargetFPS(60); - - while (!WindowShouldClose()) { - BeginDrawing(); - ClearBackground(RAYWHITE); - DrawText("Hello, raylib!", 190, 200, 20, LIGHTGRAY); - EndDrawing(); - } - - CloseWindow(); - - return 0; -} - -#endif diff --git a/src/main.c b/src/main.c new file mode 100644 index 000000000..b75114b6c --- /dev/null +++ b/src/main.c @@ -0,0 +1,145 @@ +#include "raylib.h" +#include "../libinbe/inbe.h" + +#if defined(PLATFORM_ANDROID) +#include +#else +#include +#endif + +#define WINDOW_WIDTH 800 +#define WINDOW_HEIGHT 450 +#define SCALE 3 + +Inbe inbe; + +static int +drawbtn(int x, int y, const char *label, int *hover) +{ + int mx = GetMouseX(); + int my = GetMouseY(); + int mb = IsMouseButtonDown(MOUSE_BUTTON_LEFT); + int w = (int)MeasureText(label, 20) + 20; + int h = 30; + + x = x - w / 2; + + if(mx > x && mx < x + w && my > y && my < y + h){ + DrawRectangle(x, y, w, h, (Color){235, 107, 111, 255}); + *hover = 1; + if(mb) + return 1; + }else{ + DrawRectangle(x, y, w, h, (Color){249, 168, 117, 255}); + *hover = 0; + } + + DrawText(label, x + 10, y + 5, 20, (Color){124, 63, 88, 255}); + + return 0; +} + +static void +drawinbe(int center_x, int center_y) +{ + DrawCircle(center_x, center_y, inbe.r * SCALE, (Color){249, 168, 117, 255}); + int text_w = MeasureText(inbe.count, 20); + DrawText(inbe.count, center_x - text_w / 2, center_y - 10, 20, (Color){124, 63, 88, 255}); +} + +static void +initapp(void) +{ + inbeinit(&inbe); +} + +static int +updateapp(void) +{ + int center_x = WINDOW_WIDTH / 2; + int center_y = WINDOW_HEIGHT / 2; + int hover = 0; + + if(inbe.screen == InbeScreenStart){ + int title_w = MeasureText("INNER BREEZE", 30); + DrawText("INNER BREEZE", center_x - title_w / 2, 100, 30, (Color){124, 63, 88, 255}); + drawinbe(center_x, center_y); + if(drawbtn(center_x, center_y + 100, "PLAY", &hover)) + inbe.screen = InbeScreenSession; + }else if(inbe.screen == InbeScreenSession){ + inbestep(&inbe); + + if(inbe.phase == InbePhaseHold){ + if(drawbtn(center_x, center_y + 120, "BREATH", &hover)){ + cpcount(inbe.results[inbe.round], inbe.count); + cpcount(inbe.count, "000"); + inbe.phase = InbePhaseRecover; + } + } + + drawinbe(center_x, center_y - 20); + }else if(inbe.screen == InbeScreenResults){ + int title_w = MeasureText("RESULTS", 30); + DrawText("RESULTS", center_x - title_w / 2, 50, 30, (Color){124, 63, 88, 255}); + + for(int i = 0; i < MaxRounds; i++){ + char txt[16]; + txt[0] = 'R'; + txt[1] = (char)('1' + i); + txt[2] = ':'; + txt[3] = ' '; + txt[4] = inbe.results[i][0]; + txt[5] = inbe.results[i][1]; + txt[6] = inbe.results[i][2]; + txt[7] = 0; + + DrawText(txt, center_x - 40, 100 + i * 40, 24, (Color){124, 63, 88, 255}); + } + + if(drawbtn(center_x, WINDOW_HEIGHT - 80, "RESTART", &hover)) + initapp(); + } + + inbe.frame++; + + return 0; +} + +#if defined(PLATFORM_ANDROID) +void android_main(struct android_app *app) { + (void)app; + + InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "inbe - inbe"); + initapp(); + SetTargetFPS(60); + + while (!WindowShouldClose()) { + BeginDrawing(); + ClearBackground((Color){255, 246, 211, 255}); + updateapp(); + EndDrawing(); + } + + CloseWindow(); +} +#else +int main(int argc, char **argv) { + (void)argc; + (void)argv; + + InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "inbe - inbe"); + initapp(); + SetTargetFPS(60); + + while (!WindowShouldClose()) { + BeginDrawing(); + ClearBackground((Color){255, 246, 211, 255}); + updateapp(); + EndDrawing(); + } + + CloseWindow(); + + return 0; +} +#endif diff --git a/uxn/inbe.tal b/uxn/inbe.tal index 80c0fc5aa..f07b9212d 100644 --- a/uxn/inbe.tal +++ b/uxn/inbe.tal @@ -695,8 +695,6 @@ JMP2r @txt-out "OUT $1 @txt-it "IT $1 @txt-hold "HOLD $1 -( Tab names ) -@tab-back "LOTUS $1 @potato-rom-path "bin/potato.rom $1 @inbe-rom-path "bin/inbe.rom $1 diff --git a/uxn/index.html b/uxn/index.html index 75e3992e2..84d45cdc6 100644 --- a/uxn/index.html +++ b/uxn/index.html @@ -3,7 +3,7 @@ - + diff --git a/vendor/raylib b/vendor/raylib deleted file mode 160000 index 0d78f1016..000000000 --- a/vendor/raylib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0d78f10161f9d3df38b10bd33444451b7ee11eda diff --git a/wasm4/Makefile b/wasm4/Makefile index 7a55161a2..e5dcea2e9 100644 --- a/wasm4/Makefile +++ b/wasm4/Makefile @@ -31,14 +31,14 @@ else LDFLAGS += -Wl,--strip-all,--gc-sections,--lto-O3 endif -LOTUS_DIR = ../liblotus -LOTUS_SRC = $(LOTUS_DIR)/lotus.c -LOTUS_OBJ = build/lotus.o +INBE_DIR = ../libinbe +INBE_SRC = $(INBE_DIR)/inbe.c +INBE_OBJ = build/inbe.o -CFLAGS += -I$(LOTUS_DIR) +CFLAGS += -I$(INBE_DIR) SOURCES = $(wildcard src/*.c) $(wildcard src/*.cpp) -OBJECTS = $(patsubst src/%.c, build/%.o, $(patsubst src/%.cpp, build/%.o, $(SOURCES))) $(LOTUS_OBJ) +OBJECTS = $(patsubst src/%.c, build/%.o, $(patsubst src/%.cpp, build/%.o, $(SOURCES))) $(INBE_OBJ) DEPS = $(OBJECTS:.o=.d) all: build/cart.wasm bundle dist package @@ -55,9 +55,9 @@ ifneq ($(DEBUG), 1) fi endif -$(LOTUS_OBJ): $(LOTUS_SRC) $(LOTUS_DIR)/lotus.h +$(INBE_OBJ): $(INBE_SRC) $(INBE_DIR)/inbe.h @mkdir -p build - $(CC) -c $(LOTUS_SRC) -o $(LOTUS_OBJ) $(CFLAGS) + $(CC) -c $(INBE_SRC) -o $(INBE_OBJ) $(CFLAGS) build/%.o: src/%.c @mkdir -p build diff --git a/wasm4/src/main.c b/wasm4/src/main.c index bac6390af..e093d033e 100644 --- a/wasm4/src/main.c +++ b/wasm4/src/main.c @@ -1,5 +1,5 @@ #include "wasm4.h" -#include "lotus.h" +#include "../../libinbe/inbe.h" void* memset(void *dest, int byte, unsigned long n) @@ -16,7 +16,7 @@ memset(void *dest, int byte, unsigned long n) #define WINDOW_WIDTH 160 #define WINDOW_HEIGHT 160 -Lotus lotus; +Inbe inbe; int strlen(const char *s1) @@ -64,7 +64,7 @@ start(void) PALETTE[2] = 0xeb6b6f; PALETTE[3] = 0x7c3f58; - lotusinit(&lotus); + inbeinit(&inbe); } void @@ -90,35 +90,23 @@ update(void) center_y = (int32_t)(WINDOW_HEIGHT * 0.5); - if(lotus.screen == LotusScreenStart){ + if(inbe.screen == InbeScreenStart){ if(drawbtn(mx, my, mb, center_x, center_y + 40, "PLAY") == 1) - lotus.screen = LotusScreenSession; - }else if(lotus.screen == LotusScreenSession){ - lotusstep(&lotus); + inbe.screen = InbeScreenSession; + }else if(inbe.screen == InbeScreenSession){ + inbestep(&inbe); - switch(lotus.phase){ - case LotusPhaseHold: + switch(inbe.phase){ + case InbePhaseHold: if(drawbtn(mx, my, mb, center_x, center_y + 40, "BREATH") == 1){ - cpcount(lotus.results[lotus.round], lotus.count); - cpcount(lotus.count, "000"); - lotus.phase = LotusPhaseRecover; + cpcount(inbe.results[inbe.round], inbe.count); + cpcount(inbe.count, "000"); + inbe.phase = InbePhaseRecover; } break; } - } - - if(lotus.screen < LotusScreenResults){ - *DRAW_COLORS = 3; - - current_x = center_x - (int32_t)lotus.r; - current_y = center_y - (int32_t)lotus.r; - - oval(current_x, current_y, (uint32_t)lotus.r * 2, (uint32_t)lotus.r * 2); - - *DRAW_COLORS = 2; - text(lotus.count, center_x - (3 * 4), center_y - 4); - }else{ + }else if(inbe.screen == InbeScreenResults){ text("RESULTS", center_x - 4 * 7, 10); for(i = 0; i < MaxRounds; i++){ @@ -128,12 +116,24 @@ update(void) txt_r[3] = 0; text(txt_r, center_x - 30, 40 + i * 20); - text(lotus.results[i], center_x - 4 * 3 + 20, 40 + i * 20); + text(inbe.results[i], center_x - 4 * 3 + 20, 40 + i * 20); } if(drawbtn(mx, my, mb, center_x, WINDOW_HEIGHT - 40, "RESTART") == 1) - lotusinit(&lotus); + inbeinit(&inbe); } - lotus.frame++; + if(inbe.screen < InbeScreenResults){ + *DRAW_COLORS = 3; + + current_x = center_x - (int32_t)inbe.r; + current_y = center_y - (int32_t)inbe.r; + + oval(current_x, current_y, (uint32_t)inbe.r * 2, (uint32_t)inbe.r * 2); + + *DRAW_COLORS = 2; + text(inbe.count, center_x - 3, center_y - 4); + } + + inbe.frame++; }