diff --git a/games/CMakeLists.txt b/games/CMakeLists.txt deleted file mode 100644 index 90a5ed08b..000000000 --- a/games/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Setup the project and settings -project(games) - -# Get the source toegher -file(GLOB sources *.c) - -set(OUTPUT_EXT) - -if(${PLATFORM} MATCHES "Web") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html") - set(OUTPUT_EXT ".html") - - # Remove the -rdynamic flag because otherwise emscripten - # does not generate HTML+JS+WASM files, only a non-working - # and fat HTML - string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}) -endif() - -if (NOT TARGET raylib) - find_package(raylib 2.0 REQUIRED) -endif() - -# Do each game -foreach(game_source ${sources}) - # Create the basename for the game - get_filename_component(game_name ${game_source} NAME) - string(REPLACE ".c" "${OUTPUT_EXT}" game_name ${game_name}) - - # Setup the game - add_executable(${game_name} ${game_source}) - - # Link the libraries - target_link_libraries(${game_name} raylib) -endforeach() - -# Do the games with subdirectories -add_subdirectory(drturtle) -add_subdirectory(just_do) -add_subdirectory(koala_seasons) -add_subdirectory(light_my_ritual) -add_subdirectory(skully_escape) -add_subdirectory(wave_collector) diff --git a/games/Makefile b/games/Makefile deleted file mode 100644 index 0d44b2dcd..000000000 --- a/games/Makefile +++ /dev/null @@ -1,398 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= raylib_examples -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= .. - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - # -Wl,--subsystem,windows hides the console window - CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - ifeq ($(BUILD_MODE), RELEASE) - CFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -SAMPLES = \ - arkanoid \ - asteroids \ - asteroids_survival \ - floppy \ - gold_fever \ - gorilas \ - missile_commander \ - pang \ - snake \ - space_invaders \ - tetris \ - -# typing 'make' will invoke the default target entry -all: $(SAMPLES) - -# Generic compilation pattern -# NOTE: Examples must be ready for Android compilation! -%: %.c -ifeq ($(PLATFORM),PLATFORM_ANDROID) - $(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$< -else - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -endif - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/Makefile.Android b/games/Makefile.Android deleted file mode 100644 index 29d437b1b..000000000 --- a/games/Makefile.Android +++ /dev/null @@ -1,300 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Android project (APK building) -# -# Copyright (c) 2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -# Define required raylib variables -PLATFORM ?= PLATFORM_ANDROID -RAYLIB_PATH ?= ..\.. - -# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version -ANDROID_ARCH ?= ARM -ANDROID_API_VERSION = 21 -ifeq ($(ANDROID_ARCH),ARM) - ANDROID_ARCH_NAME = armeabi-v7a -endif -ifeq ($(ANDROID_ARCH),ARM64) - ANDROID_ARCH_NAME = arm64-v8a -endif - -# Required path variables -# NOTE: JAVA_HOME must be set to JDK -JAVA_HOME ?= C:/JavaJDK -ANDROID_HOME = C:/android-sdk -ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION) -ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1 -ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools - -# Android project configuration variables -PROJECT_NAME ?= raylib_game -PROJECT_LIBRARY_NAME ?= main -PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME) -PROJECT_RESOURCES_PATH ?= resources -PROJECT_SOURCE_FILES ?= raylib_game.c - -# Some source files are placed in directories, when compiling to some -# output directory other than source, that directory must pre-exist. -# Here we get a list of required folders that need to be created on -# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors. -PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES))) - -# Android app configuration variables -APP_LABEL_NAME ?= rGame -APP_COMPANY_NAME ?= raylib -APP_PRODUCT_NAME ?= rgame -APP_VERSION_CODE ?= 1 -APP_VERSION_NAME ?= 1.0 -APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png -APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png -APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png -APP_SCREEN_ORIENTATION ?= landscape -APP_KEYSTORE_PASS ?= raylib - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Library path for libraylib.a/libraylib.so -RAYLIB_LIB_PATH = $(RAYLIB_PATH)\src - -# Shared libs must be added to APK if required -# NOTE: Generated NativeLoader.java automatically load those libraries -ifeq ($(RAYLIB_LIBTYPE),SHARED) - PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so -endif - -# Compiler and archiver -# NOTE: GCC is being deprecated in Android NDK r16 -ifeq ($(ANDROID_ARCH),ARM) - CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang - AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar -endif -ifeq ($(ANDROID_ARCH),ARM64) - CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang - AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar -endif - -# Compiler flags for arquitecture -ifeq ($(ANDROID_ARCH),ARM) - CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -endif -ifeq ($(ANDROID_ARCH),ARM64) - CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769 -endif -# Compilation functions attributes options -CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC -# Compiler options for the linker -CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes -# Preprocessor macro definitions -CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) - -# Paths containing required header files -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue - -# Linker options -LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a -LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -# Force linking of library module to define symbol -LDFLAGS += -u ANativeActivity_onCreate -# Library paths containing required libs -LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME) -L$(ANDROID_TOOLCHAIN)\sysroot\usr\lib - -# Define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl - -# Generate target objects list from PROJECT_SOURCE_FILES -OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES)) - -# Android APK building process... some steps required... -# NOTE: typing 'make' will invoke the default target entry called 'all', -all: create_temp_project_dirs \ - copy_project_required_libs \ - copy_project_resources \ - generate_loader_script \ - generate_android_manifest \ - generate_apk_keystore \ - config_project_package \ - compile_project_code \ - compile_project_class \ - compile_project_class_dex \ - create_project_apk_package \ - sign_project_apk_package \ - zipalign_project_apk_package - -# Create required temp directories for APK building -create_temp_project_dirs: - if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj - if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src - if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) - if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib - if not exist $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) mkdir $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) - if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin - if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res - if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi - if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values - if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets - if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens - $(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir))) - -define create_dir - if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1) -endef - -# Copy required shared libs for integration into APK -# NOTE: If using shared libs they are loaded by generated NativeLoader.java -copy_project_required_libs: -ifeq ($(RAYLIB_LIBTYPE),SHARED) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so -endif -ifeq ($(RAYLIB_LIBTYPE),STATIC) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a -endif - -# Copy project required resources: strings.xml, icon.png, assets -# NOTE: Required strings.xml is generated and game resources are copied to assets folder -# TODO: Review xcopy usage, it can not be found in some systems! -copy_project_resources: - copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y - copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y - copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y - @echo ^ > $(PROJECT_BUILD_PATH)/res/values/strings.xml - @echo ^^$(APP_LABEL_NAME)^^ >> $(PROJECT_BUILD_PATH)/res/values/strings.xml - if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F - -# Generate NativeLoader.java to load required shared libraries -# NOTE: Probably not the bet way to generate this file... but it works. -generate_loader_script: - @echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -ifeq ($(RAYLIB_LIBTYPE),SHARED) - @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -endif - @echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Generate AndroidManifest.xml with all the required options -# NOTE: Probably not the bet way to generate this file... but it works. -generate_android_manifest: - @echo ^ > $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - -# Generate storekey for APK signing: $(PROJECT_NAME).keystore -# NOTE: Configure here your Distinguished Names (-dname) if required! -generate_apk_keystore: - if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA - -# Config project package and resource using AndroidManifest.xml and res/values/strings.xml -# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java -config_project_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar - -# Compile native_app_glue code as static library: obj/libnative_app_glue.a -compile_native_app_glue: - $(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS) - $(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o - -# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so -compile_project_code: $(OBJS) - $(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) - -# Compile all .c files required into object (.o) files -# NOTE: Those files will be linked into a shared library -$(PROJECT_BUILD_PATH)/obj/%.o:%.c - $(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot - -# Compile project .java code into .class (Java bytecode) -compile_project_class: - $(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Compile .class files into Dalvik executable bytecode (.dex) -# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT) -compile_project_class_dex: - $(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj - -# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk -# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so -# NOTE: Use -A resources to define additional directory in which to find raw asset files -create_project_apk_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin - cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS) - -# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk -sign_project_apk_package: - $(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key - -# Create zip-aligned APK package: $(PROJECT_NAME).apk -zipalign_project_apk_package: - $(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk - -# Install $(PROJECT_NAME).apk to default emulator/device -# NOTE: Use -e (emulator) or -d (device) parameters if required -install: - $(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk - -# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64) -check_device_abi: - $(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi - -# Monitorize output log coming from device, only raylib tag -logcat: - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -# Install and monitorize $(PROJECT_NAME).apk to default emulator/device -deploy: - $(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W - -# Clean everything -clean: - del $(PROJECT_BUILD_PATH)\* /f /s /q - rmdir $(PROJECT_BUILD_PATH) /s /q - @echo Cleaning done diff --git a/games/arkanoid.c b/games/arkanoid.c deleted file mode 100644 index f72d85b31..000000000 --- a/games/arkanoid.c +++ /dev/null @@ -1,323 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: arkanoid -* -* Sample game Marc Palau and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include -#include -#include -#include - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Some Defines -//---------------------------------------------------------------------------------- -#define PLAYER_MAX_LIFE 5 -#define LINES_OF_BRICKS 5 -#define BRICKS_PER_LINE 20 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum GameScreen { LOGO, TITLE, GAMEPLAY, ENDING } GameScreen; - -typedef struct Player { - Vector2 position; - Vector2 size; - int life; -} Player; - -typedef struct Ball { - Vector2 position; - Vector2 speed; - int radius; - bool active; -} Ball; - -typedef struct Brick { - Vector2 position; - bool active; -} Brick; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static const int screenWidth = 800; -static const int screenHeight = 450; - -static bool gameOver = false; -static bool pause = false; - -static Player player = { 0 }; -static Ball ball = { 0 }; -static Brick brick[LINES_OF_BRICKS][BRICKS_PER_LINE] = { 0 }; -static Vector2 brickSize = { 0 }; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: arkanoid"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Initialize game variables -void InitGame(void) -{ - brickSize = (Vector2){ GetScreenWidth()/BRICKS_PER_LINE, 40 }; - - // Initialize player - player.position = (Vector2){ screenWidth/2, screenHeight*7/8 }; - player.size = (Vector2){ screenWidth/10, 20 }; - player.life = PLAYER_MAX_LIFE; - - // Initialize ball - ball.position = (Vector2){ screenWidth/2, screenHeight*7/8 - 30 }; - ball.speed = (Vector2){ 0, 0 }; - ball.radius = 7; - ball.active = false; - - // Initialize bricks - int initialDownPosition = 50; - - for (int i = 0; i < LINES_OF_BRICKS; i++) - { - for (int j = 0; j < BRICKS_PER_LINE; j++) - { - brick[i][j].position = (Vector2){ j*brickSize.x + brickSize.x/2, i*brickSize.y + initialDownPosition }; - brick[i][j].active = true; - } - } -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - // Player movement logic - if (IsKeyDown(KEY_LEFT)) player.position.x -= 5; - if ((player.position.x - player.size.x/2) <= 0) player.position.x = player.size.x/2; - if (IsKeyDown(KEY_RIGHT)) player.position.x += 5; - if ((player.position.x + player.size.x/2) >= screenWidth) player.position.x = screenWidth - player.size.x/2; - - // Ball launching logic - if (!ball.active) - { - if (IsKeyPressed(KEY_SPACE)) - { - ball.active = true; - ball.speed = (Vector2){ 0, -5 }; - } - } - - // Ball movement logic - if (ball.active) - { - ball.position.x += ball.speed.x; - ball.position.y += ball.speed.y; - } - else - { - ball.position = (Vector2){ player.position.x, screenHeight*7/8 - 30 }; - } - - // Collision logic: ball vs walls - if (((ball.position.x + ball.radius) >= screenWidth) || ((ball.position.x - ball.radius) <= 0)) ball.speed.x *= -1; - if ((ball.position.y - ball.radius) <= 0) ball.speed.y *= -1; - if ((ball.position.y + ball.radius) >= screenHeight) - { - ball.speed = (Vector2){ 0, 0 }; - ball.active = false; - - player.life--; - } - - // Collision logic: ball vs player - if (CheckCollisionCircleRec(ball.position, ball.radius, - (Rectangle){ player.position.x - player.size.x/2, player.position.y - player.size.y/2, player.size.x, player.size.y})) - { - if (ball.speed.y > 0) - { - ball.speed.y *= -1; - ball.speed.x = (ball.position.x - player.position.x)/(player.size.x/2)*5; - } - } - - // Collision logic: ball vs bricks - for (int i = 0; i < LINES_OF_BRICKS; i++) - { - for (int j = 0; j < BRICKS_PER_LINE; j++) - { - if (brick[i][j].active) - { - // Hit below - if (((ball.position.y - ball.radius) <= (brick[i][j].position.y + brickSize.y/2)) && - ((ball.position.y - ball.radius) > (brick[i][j].position.y + brickSize.y/2 + ball.speed.y)) && - ((fabs(ball.position.x - brick[i][j].position.x)) < (brickSize.x/2 + ball.radius*2/3)) && (ball.speed.y < 0)) - { - brick[i][j].active = false; - ball.speed.y *= -1; - } - // Hit above - else if (((ball.position.y + ball.radius) >= (brick[i][j].position.y - brickSize.y/2)) && - ((ball.position.y + ball.radius) < (brick[i][j].position.y - brickSize.y/2 + ball.speed.y)) && - ((fabs(ball.position.x - brick[i][j].position.x)) < (brickSize.x/2 + ball.radius*2/3)) && (ball.speed.y > 0)) - { - brick[i][j].active = false; - ball.speed.y *= -1; - } - // Hit left - else if (((ball.position.x + ball.radius) >= (brick[i][j].position.x - brickSize.x/2)) && - ((ball.position.x + ball.radius) < (brick[i][j].position.x - brickSize.x/2 + ball.speed.x)) && - ((fabs(ball.position.y - brick[i][j].position.y)) < (brickSize.y/2 + ball.radius*2/3)) && (ball.speed.x > 0)) - { - brick[i][j].active = false; - ball.speed.x *= -1; - } - // Hit right - else if (((ball.position.x - ball.radius) <= (brick[i][j].position.x + brickSize.x/2)) && - ((ball.position.x - ball.radius) > (brick[i][j].position.x + brickSize.x/2 + ball.speed.x)) && - ((fabs(ball.position.y - brick[i][j].position.y)) < (brickSize.y/2 + ball.radius*2/3)) && (ball.speed.x < 0)) - { - brick[i][j].active = false; - ball.speed.x *= -1; - } - } - } - } - - // Game over logic - if (player.life <= 0) gameOver = true; - else - { - gameOver = true; - - for (int i = 0; i < LINES_OF_BRICKS; i++) - { - for (int j = 0; j < BRICKS_PER_LINE; j++) - { - if (brick[i][j].active) gameOver = false; - } - } - } - } - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - // Draw player bar - DrawRectangle(player.position.x - player.size.x/2, player.position.y - player.size.y/2, player.size.x, player.size.y, BLACK); - - // Draw player lives - for (int i = 0; i < player.life; i++) DrawRectangle(20 + 40*i, screenHeight - 30, 35, 10, LIGHTGRAY); - - // Draw ball - DrawCircleV(ball.position, ball.radius, MAROON); - - // Draw bricks - for (int i = 0; i < LINES_OF_BRICKS; i++) - { - for (int j = 0; j < BRICKS_PER_LINE; j++) - { - if (brick[i][j].active) - { - if ((i + j) % 2 == 0) DrawRectangle(brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, GRAY); - else DrawRectangle(brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, DARKGRAY); - } - } - } - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); - - EndDrawing(); -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} diff --git a/games/asteroids.c b/games/asteroids.c deleted file mode 100644 index 93d5065b4..000000000 --- a/games/asteroids.c +++ /dev/null @@ -1,565 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: asteroids -* -* Sample game developed by Ian Eito, Albert Martos and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Some Defines -//---------------------------------------------------------------------------------- -#define PLAYER_BASE_SIZE 20.0f -#define PLAYER_SPEED 6.0f -#define PLAYER_MAX_SHOOTS 10 - -#define METEORS_SPEED 2 -#define MAX_BIG_METEORS 4 -#define MAX_MEDIUM_METEORS 8 -#define MAX_SMALL_METEORS 16 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef struct Player { - Vector2 position; - Vector2 speed; - float acceleration; - float rotation; - Vector3 collider; - Color color; -} Player; - -typedef struct Shoot { - Vector2 position; - Vector2 speed; - float radius; - float rotation; - int lifeSpawn; - bool active; - Color color; -} Shoot; - -typedef struct Meteor { - Vector2 position; - Vector2 speed; - float radius; - bool active; - Color color; -} Meteor; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static const int screenWidth = 800; -static const int screenHeight = 450; - -static bool gameOver = false; -static bool pause = false; -static bool victory = false; - -// NOTE: Defined triangle is isosceles with common angles of 70 degrees. -static float shipHeight = 0.0f; - -static Player player = { 0 }; -static Shoot shoot[PLAYER_MAX_SHOOTS] = { 0 }; -static Meteor bigMeteor[MAX_BIG_METEORS] = { 0 }; -static Meteor mediumMeteor[MAX_MEDIUM_METEORS] = { 0 }; -static Meteor smallMeteor[MAX_SMALL_METEORS] = { 0 }; - -static int midMeteorsCount = 0; -static int smallMeteorsCount = 0; -static int destroyedMeteorsCount = 0; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: asteroids"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Initialize game variables -void InitGame(void) -{ - int posx, posy; - int velx, vely; - bool correctRange = false; - victory = false; - pause = false; - - shipHeight = (PLAYER_BASE_SIZE/2)/tanf(20*DEG2RAD); - - // Initialization player - player.position = (Vector2){screenWidth/2, screenHeight/2 - shipHeight/2}; - player.speed = (Vector2){0, 0}; - player.acceleration = 0; - player.rotation = 0; - player.collider = (Vector3){player.position.x + sin(player.rotation*DEG2RAD)*(shipHeight/2.5f), player.position.y - cos(player.rotation*DEG2RAD)*(shipHeight/2.5f), 12}; - player.color = LIGHTGRAY; - - destroyedMeteorsCount = 0; - - // Initialization shoot - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - shoot[i].position = (Vector2){0, 0}; - shoot[i].speed = (Vector2){0, 0}; - shoot[i].radius = 2; - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - shoot[i].color = WHITE; - } - - for (int i = 0; i < MAX_BIG_METEORS; i++) - { - posx = GetRandomValue(0, screenWidth); - - while(!correctRange) - { - if (posx > screenWidth/2 - 150 && posx < screenWidth/2 + 150) posx = GetRandomValue(0, screenWidth); - else correctRange = true; - } - - correctRange = false; - - posy = GetRandomValue(0, screenHeight); - - while(!correctRange) - { - if (posy > screenHeight/2 - 150 && posy < screenHeight/2 + 150) posy = GetRandomValue(0, screenHeight); - else correctRange = true; - } - - bigMeteor[i].position = (Vector2){posx, posy}; - - correctRange = false; - velx = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - vely = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - - while(!correctRange) - { - if (velx == 0 && vely == 0) - { - velx = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - vely = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - } - else correctRange = true; - } - - bigMeteor[i].speed = (Vector2){velx, vely}; - bigMeteor[i].radius = 40; - bigMeteor[i].active = true; - bigMeteor[i].color = BLUE; - } - - for (int i = 0; i < MAX_MEDIUM_METEORS; i++) - { - mediumMeteor[i].position = (Vector2){-100, -100}; - mediumMeteor[i].speed = (Vector2){0,0}; - mediumMeteor[i].radius = 20; - mediumMeteor[i].active = false; - mediumMeteor[i].color = BLUE; - } - - for (int i = 0; i < MAX_SMALL_METEORS; i++) - { - smallMeteor[i].position = (Vector2){-100, -100}; - smallMeteor[i].speed = (Vector2){0,0}; - smallMeteor[i].radius = 10; - smallMeteor[i].active = false; - smallMeteor[i].color = BLUE; - } - - midMeteorsCount = 0; - smallMeteorsCount = 0; -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - // Player logic: rotation - if (IsKeyDown(KEY_LEFT)) player.rotation -= 5; - if (IsKeyDown(KEY_RIGHT)) player.rotation += 5; - - // Player logic: speed - player.speed.x = sin(player.rotation*DEG2RAD)*PLAYER_SPEED; - player.speed.y = cos(player.rotation*DEG2RAD)*PLAYER_SPEED; - - // Player logic: acceleration - if (IsKeyDown(KEY_UP)) - { - if (player.acceleration < 1) player.acceleration += 0.04f; - } - else - { - if (player.acceleration > 0) player.acceleration -= 0.02f; - else if (player.acceleration < 0) player.acceleration = 0; - } - if (IsKeyDown(KEY_DOWN)) - { - if (player.acceleration > 0) player.acceleration -= 0.04f; - else if (player.acceleration < 0) player.acceleration = 0; - } - - // Player logic: movement - player.position.x += (player.speed.x*player.acceleration); - player.position.y -= (player.speed.y*player.acceleration); - - // Collision logic: player vs walls - if (player.position.x > screenWidth + shipHeight) player.position.x = -(shipHeight); - else if (player.position.x < -(shipHeight)) player.position.x = screenWidth + shipHeight; - if (player.position.y > (screenHeight + shipHeight)) player.position.y = -(shipHeight); - else if (player.position.y < -(shipHeight)) player.position.y = screenHeight + shipHeight; - - // Player shoot logic - if (IsKeyPressed(KEY_SPACE)) - { - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - if (!shoot[i].active) - { - shoot[i].position = (Vector2){ player.position.x + sin(player.rotation*DEG2RAD)*(shipHeight), player.position.y - cos(player.rotation*DEG2RAD)*(shipHeight) }; - shoot[i].active = true; - shoot[i].speed.x = 1.5*sin(player.rotation*DEG2RAD)*PLAYER_SPEED; - shoot[i].speed.y = 1.5*cos(player.rotation*DEG2RAD)*PLAYER_SPEED; - shoot[i].rotation = player.rotation; - break; - } - } - } - - // Shoot life timer - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - if (shoot[i].active) shoot[i].lifeSpawn++; - } - - // Shot logic - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - if (shoot[i].active) - { - // Movement - shoot[i].position.x += shoot[i].speed.x; - shoot[i].position.y -= shoot[i].speed.y; - - // Collision logic: shoot vs walls - if (shoot[i].position.x > screenWidth + shoot[i].radius) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - } - else if (shoot[i].position.x < 0 - shoot[i].radius) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - } - if (shoot[i].position.y > screenHeight + shoot[i].radius) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - } - else if (shoot[i].position.y < 0 - shoot[i].radius) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - } - - // Life of shoot - if (shoot[i].lifeSpawn >= 60) - { - shoot[i].position = (Vector2){0, 0}; - shoot[i].speed = (Vector2){0, 0}; - shoot[i].lifeSpawn = 0; - shoot[i].active = false; - } - } - } - - // Collision logic: player vs meteors - player.collider = (Vector3){player.position.x + sin(player.rotation*DEG2RAD)*(shipHeight/2.5f), player.position.y - cos(player.rotation*DEG2RAD)*(shipHeight/2.5f), 12}; - - for (int a = 0; a < MAX_BIG_METEORS; a++) - { - if (CheckCollisionCircles((Vector2){player.collider.x, player.collider.y}, player.collider.z, bigMeteor[a].position, bigMeteor[a].radius) && bigMeteor[a].active) gameOver = true; - } - - for (int a = 0; a < MAX_MEDIUM_METEORS; a++) - { - if (CheckCollisionCircles((Vector2){player.collider.x, player.collider.y}, player.collider.z, mediumMeteor[a].position, mediumMeteor[a].radius) && mediumMeteor[a].active) gameOver = true; - } - - for (int a = 0; a < MAX_SMALL_METEORS; a++) - { - if (CheckCollisionCircles((Vector2){player.collider.x, player.collider.y}, player.collider.z, smallMeteor[a].position, smallMeteor[a].radius) && smallMeteor[a].active) gameOver = true; - } - - // Meteors logic: big meteors - for (int i = 0; i < MAX_BIG_METEORS; i++) - { - if (bigMeteor[i].active) - { - // Movement - bigMeteor[i].position.x += bigMeteor[i].speed.x; - bigMeteor[i].position.y += bigMeteor[i].speed.y; - - // Collision logic: meteor vs wall - if (bigMeteor[i].position.x > screenWidth + bigMeteor[i].radius) bigMeteor[i].position.x = -(bigMeteor[i].radius); - else if (bigMeteor[i].position.x < 0 - bigMeteor[i].radius) bigMeteor[i].position.x = screenWidth + bigMeteor[i].radius; - if (bigMeteor[i].position.y > screenHeight + bigMeteor[i].radius) bigMeteor[i].position.y = -(bigMeteor[i].radius); - else if (bigMeteor[i].position.y < 0 - bigMeteor[i].radius) bigMeteor[i].position.y = screenHeight + bigMeteor[i].radius; - } - } - - // Meteors logic: medium meteors - for (int i = 0; i < MAX_MEDIUM_METEORS; i++) - { - if (mediumMeteor[i].active) - { - // Movement - mediumMeteor[i].position.x += mediumMeteor[i].speed.x; - mediumMeteor[i].position.y += mediumMeteor[i].speed.y; - - // Collision logic: meteor vs wall - if (mediumMeteor[i].position.x > screenWidth + mediumMeteor[i].radius) mediumMeteor[i].position.x = -(mediumMeteor[i].radius); - else if (mediumMeteor[i].position.x < 0 - mediumMeteor[i].radius) mediumMeteor[i].position.x = screenWidth + mediumMeteor[i].radius; - if (mediumMeteor[i].position.y > screenHeight + mediumMeteor[i].radius) mediumMeteor[i].position.y = -(mediumMeteor[i].radius); - else if (mediumMeteor[i].position.y < 0 - mediumMeteor[i].radius) mediumMeteor[i].position.y = screenHeight + mediumMeteor[i].radius; - } - } - - // Meteors logic: small meteors - for (int i = 0; i < MAX_SMALL_METEORS; i++) - { - if (smallMeteor[i].active) - { - // Movement - smallMeteor[i].position.x += smallMeteor[i].speed.x; - smallMeteor[i].position.y += smallMeteor[i].speed.y; - - // Collision logic: meteor vs wall - if (smallMeteor[i].position.x > screenWidth + smallMeteor[i].radius) smallMeteor[i].position.x = -(smallMeteor[i].radius); - else if (smallMeteor[i].position.x < 0 - smallMeteor[i].radius) smallMeteor[i].position.x = screenWidth + smallMeteor[i].radius; - if (smallMeteor[i].position.y > screenHeight + smallMeteor[i].radius) smallMeteor[i].position.y = -(smallMeteor[i].radius); - else if (smallMeteor[i].position.y < 0 - smallMeteor[i].radius) smallMeteor[i].position.y = screenHeight + smallMeteor[i].radius; - } - } - - // Collision logic: player-shoots vs meteors - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - if ((shoot[i].active)) - { - for (int a = 0; a < MAX_BIG_METEORS; a++) - { - if (bigMeteor[a].active && CheckCollisionCircles(shoot[i].position, shoot[i].radius, bigMeteor[a].position, bigMeteor[a].radius)) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - bigMeteor[a].active = false; - destroyedMeteorsCount++; - - for (int j = 0; j < 2; j ++) - { - if (midMeteorsCount%2 == 0) - { - mediumMeteor[midMeteorsCount].position = (Vector2){bigMeteor[a].position.x, bigMeteor[a].position.y}; - mediumMeteor[midMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1}; - } - else - { - mediumMeteor[midMeteorsCount].position = (Vector2){bigMeteor[a].position.x, bigMeteor[a].position.y}; - mediumMeteor[midMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED}; - } - - mediumMeteor[midMeteorsCount].active = true; - midMeteorsCount ++; - } - //bigMeteor[a].position = (Vector2){-100, -100}; - bigMeteor[a].color = RED; - a = MAX_BIG_METEORS; - } - } - - for (int b = 0; b < MAX_MEDIUM_METEORS; b++) - { - if (mediumMeteor[b].active && CheckCollisionCircles(shoot[i].position, shoot[i].radius, mediumMeteor[b].position, mediumMeteor[b].radius)) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - mediumMeteor[b].active = false; - destroyedMeteorsCount++; - - for (int j = 0; j < 2; j ++) - { - if (smallMeteorsCount%2 == 0) - { - smallMeteor[smallMeteorsCount].position = (Vector2){mediumMeteor[b].position.x, mediumMeteor[b].position.y}; - smallMeteor[smallMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1}; - } - else - { - smallMeteor[smallMeteorsCount].position = (Vector2){mediumMeteor[b].position.x, mediumMeteor[b].position.y}; - smallMeteor[smallMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED}; - } - - smallMeteor[smallMeteorsCount].active = true; - smallMeteorsCount ++; - } - //mediumMeteor[b].position = (Vector2){-100, -100}; - mediumMeteor[b].color = GREEN; - b = MAX_MEDIUM_METEORS; - } - } - - for (int c = 0; c < MAX_SMALL_METEORS; c++) - { - if (smallMeteor[c].active && CheckCollisionCircles(shoot[i].position, shoot[i].radius, smallMeteor[c].position, smallMeteor[c].radius)) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - smallMeteor[c].active = false; - destroyedMeteorsCount++; - smallMeteor[c].color = YELLOW; - // smallMeteor[c].position = (Vector2){-100, -100}; - c = MAX_SMALL_METEORS; - } - } - } - } - } - - if (destroyedMeteorsCount == MAX_BIG_METEORS + MAX_MEDIUM_METEORS + MAX_SMALL_METEORS) victory = true; - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - // Draw spaceship - Vector2 v1 = { player.position.x + sinf(player.rotation*DEG2RAD)*(shipHeight), player.position.y - cosf(player.rotation*DEG2RAD)*(shipHeight) }; - Vector2 v2 = { player.position.x - cosf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2), player.position.y - sinf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2) }; - Vector2 v3 = { player.position.x + cosf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2), player.position.y + sinf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2) }; - DrawTriangle(v1, v2, v3, MAROON); - - // Draw meteors - for (int i = 0; i < MAX_BIG_METEORS; i++) - { - if (bigMeteor[i].active) DrawCircleV(bigMeteor[i].position, bigMeteor[i].radius, DARKGRAY); - else DrawCircleV(bigMeteor[i].position, bigMeteor[i].radius, Fade(LIGHTGRAY, 0.3f)); - } - - for (int i = 0; i < MAX_MEDIUM_METEORS; i++) - { - if (mediumMeteor[i].active) DrawCircleV(mediumMeteor[i].position, mediumMeteor[i].radius, GRAY); - else DrawCircleV(mediumMeteor[i].position, mediumMeteor[i].radius, Fade(LIGHTGRAY, 0.3f)); - } - - for (int i = 0; i < MAX_SMALL_METEORS; i++) - { - if (smallMeteor[i].active) DrawCircleV(smallMeteor[i].position, smallMeteor[i].radius, GRAY); - else DrawCircleV(smallMeteor[i].position, smallMeteor[i].radius, Fade(LIGHTGRAY, 0.3f)); - } - - // Draw shoot - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - if (shoot[i].active) DrawCircleV(shoot[i].position, shoot[i].radius, BLACK); - } - - if (victory) DrawText("VICTORY", screenWidth/2 - MeasureText("VICTORY", 20)/2, screenHeight/2, 20, LIGHTGRAY); - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); - - EndDrawing(); -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} diff --git a/games/asteroids_survival.c b/games/asteroids_survival.c deleted file mode 100644 index def310d1b..000000000 --- a/games/asteroids_survival.c +++ /dev/null @@ -1,375 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: asteroids survival -* -* Sample game developed by Ian Eito, Albert Martos and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Some Defines -//---------------------------------------------------------------------------------- -#define PLAYER_BASE_SIZE 20.0f -#define PLAYER_SPEED 6.0f -#define PLAYER_MAX_SHOOTS 10 - -#define METEORS_SPEED 2 -#define MAX_MEDIUM_METEORS 8 -#define MAX_SMALL_METEORS 16 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef struct Player { - Vector2 position; - Vector2 speed; - float acceleration; - float rotation; - Vector3 collider; - Color color; -} Player; - -typedef struct Meteor { - Vector2 position; - Vector2 speed; - float radius; - bool active; - Color color; -} Meteor; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static const int screenWidth = 800; -static const int screenHeight = 450; - -static int framesCounter = 0; -static bool gameOver = false; -static bool pause = false; - -// NOTE: Defined triangle is isosceles with common angles of 70 degrees. -static float shipHeight = 0.0f; - -static Player player = { 0 }; -static Meteor mediumMeteor[MAX_MEDIUM_METEORS] = { 0 }; -static Meteor smallMeteor[MAX_SMALL_METEORS] = { 0 }; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: asteroids survival"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Initialize game variables -void InitGame(void) -{ - int posx, posy; - int velx, vely; - bool correctRange = false; - - pause = false; - - framesCounter = 0; - - shipHeight = (PLAYER_BASE_SIZE/2)/tanf(20*DEG2RAD); - - // Initialization player - player.position = (Vector2){screenWidth/2, screenHeight/2 - shipHeight/2}; - player.speed = (Vector2){0, 0}; - player.acceleration = 0; - player.rotation = 0; - player.collider = (Vector3){player.position.x + sin(player.rotation*DEG2RAD)*(shipHeight/2.5f), player.position.y - cos(player.rotation*DEG2RAD)*(shipHeight/2.5f), 12}; - player.color = LIGHTGRAY; - - for (int i = 0; i < MAX_MEDIUM_METEORS; i++) - { - posx = GetRandomValue(0, screenWidth); - - while(!correctRange) - { - if (posx > screenWidth/2 - 150 && posx < screenWidth/2 + 150) posx = GetRandomValue(0, screenWidth); - else correctRange = true; - } - - correctRange = false; - - posy = GetRandomValue(0, screenHeight); - - while(!correctRange) - { - if (posy > screenHeight/2 - 150 && posy < screenHeight/2 + 150) posy = GetRandomValue(0, screenHeight); - else correctRange = true; - } - - correctRange = false; - velx = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - vely = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - - while(!correctRange) - { - if (velx == 0 && vely == 0) - { - velx = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - vely = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - } - else correctRange = true; - } - mediumMeteor[i].position = (Vector2){posx, posy}; - mediumMeteor[i].speed = (Vector2){velx, vely}; - mediumMeteor[i].radius = 20; - mediumMeteor[i].active = true; - mediumMeteor[i].color = GREEN; - } - - for (int i = 0; i < MAX_SMALL_METEORS; i++) - { - posx = GetRandomValue(0, screenWidth); - - while(!correctRange) - { - if (posx > screenWidth/2 - 150 && posx < screenWidth/2 + 150) posx = GetRandomValue(0, screenWidth); - else correctRange = true; - } - - correctRange = false; - - posy = GetRandomValue(0, screenHeight); - - while(!correctRange) - { - if (posy > screenHeight/2 - 150 && posy < screenHeight/2 + 150) posy = GetRandomValue(0, screenHeight); - else correctRange = true; - } - - correctRange = false; - velx = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - vely = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - - while(!correctRange) - { - if (velx == 0 && vely == 0) - { - velx = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - vely = GetRandomValue(-METEORS_SPEED, METEORS_SPEED); - } - else correctRange = true; - } - smallMeteor[i].position = (Vector2){posx, posy}; - smallMeteor[i].speed = (Vector2){velx, vely}; - smallMeteor[i].radius = 10; - smallMeteor[i].active = true; - smallMeteor[i].color = YELLOW; - } -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - framesCounter++; - - // Player logic - - // Rotation - if (IsKeyDown(KEY_LEFT)) player.rotation -= 5; - if (IsKeyDown(KEY_RIGHT)) player.rotation += 5; - - // Speed - player.speed.x = sin(player.rotation*DEG2RAD)*PLAYER_SPEED; - player.speed.y = cos(player.rotation*DEG2RAD)*PLAYER_SPEED; - - // Controller - if (IsKeyDown(KEY_UP)) - { - if (player.acceleration < 1) player.acceleration += 0.04f; - } - else - { - if (player.acceleration > 0) player.acceleration -= 0.02f; - else if (player.acceleration < 0) player.acceleration = 0; - } - if (IsKeyDown(KEY_DOWN)) - { - if (player.acceleration > 0) player.acceleration -= 0.04f; - else if (player.acceleration < 0) player.acceleration = 0; - } - - // Movement - player.position.x += (player.speed.x*player.acceleration); - player.position.y -= (player.speed.y*player.acceleration); - - // Wall behaviour for player - if (player.position.x > screenWidth + shipHeight) player.position.x = -(shipHeight); - else if (player.position.x < -(shipHeight)) player.position.x = screenWidth + shipHeight; - if (player.position.y > (screenHeight + shipHeight)) player.position.y = -(shipHeight); - else if (player.position.y < -(shipHeight)) player.position.y = screenHeight + shipHeight; - - // Collision Player to meteors - player.collider = (Vector3){player.position.x + sin(player.rotation*DEG2RAD)*(shipHeight/2.5f), player.position.y - cos(player.rotation*DEG2RAD)*(shipHeight/2.5f), 12}; - - for (int a = 0; a < MAX_MEDIUM_METEORS; a++) - { - if (CheckCollisionCircles((Vector2){player.collider.x, player.collider.y}, player.collider.z, mediumMeteor[a].position, mediumMeteor[a].radius) && mediumMeteor[a].active) gameOver = true; - } - - for (int a = 0; a < MAX_SMALL_METEORS; a++) - { - if (CheckCollisionCircles((Vector2){player.collider.x, player.collider.y}, player.collider.z, smallMeteor[a].position, smallMeteor[a].radius) && smallMeteor[a].active) gameOver = true; - } - - // Meteor logic - - for (int i = 0; i < MAX_MEDIUM_METEORS; i++) - { - if (mediumMeteor[i].active) - { - // movement - mediumMeteor[i].position.x += mediumMeteor[i].speed.x; - mediumMeteor[i].position.y += mediumMeteor[i].speed.y; - - // wall behaviour - if (mediumMeteor[i].position.x > screenWidth + mediumMeteor[i].radius) mediumMeteor[i].position.x = -(mediumMeteor[i].radius); - else if (mediumMeteor[i].position.x < 0 - mediumMeteor[i].radius) mediumMeteor[i].position.x = screenWidth + mediumMeteor[i].radius; - if (mediumMeteor[i].position.y > screenHeight + mediumMeteor[i].radius) mediumMeteor[i].position.y = -(mediumMeteor[i].radius); - else if (mediumMeteor[i].position.y < 0 - mediumMeteor[i].radius) mediumMeteor[i].position.y = screenHeight + mediumMeteor[i].radius; - } - } - - for (int i = 0; i < MAX_SMALL_METEORS; i++) - { - if (smallMeteor[i].active) - { - // movement - smallMeteor[i].position.x += smallMeteor[i].speed.x; - smallMeteor[i].position.y += smallMeteor[i].speed.y; - - // wall behaviour - if (smallMeteor[i].position.x > screenWidth + smallMeteor[i].radius) smallMeteor[i].position.x = -(smallMeteor[i].radius); - else if (smallMeteor[i].position.x < 0 - smallMeteor[i].radius) smallMeteor[i].position.x = screenWidth + smallMeteor[i].radius; - if (smallMeteor[i].position.y > screenHeight + smallMeteor[i].radius) smallMeteor[i].position.y = -(smallMeteor[i].radius); - else if (smallMeteor[i].position.y < 0 - smallMeteor[i].radius) smallMeteor[i].position.y = screenHeight + smallMeteor[i].radius; - } - } - } - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - // Draw spaceship - Vector2 v1 = { player.position.x + sinf(player.rotation*DEG2RAD)*(shipHeight), player.position.y - cosf(player.rotation*DEG2RAD)*(shipHeight) }; - Vector2 v2 = { player.position.x - cosf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2), player.position.y - sinf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2) }; - Vector2 v3 = { player.position.x + cosf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2), player.position.y + sinf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2) }; - DrawTriangle(v1, v2, v3, MAROON); - - // Draw meteor - for (int i = 0;i < MAX_MEDIUM_METEORS; i++) - { - if (mediumMeteor[i].active) DrawCircleV(mediumMeteor[i].position, mediumMeteor[i].radius, GRAY); - else DrawCircleV(mediumMeteor[i].position, mediumMeteor[i].radius, Fade(LIGHTGRAY, 0.3f)); - } - - for (int i = 0;i < MAX_SMALL_METEORS; i++) - { - if (smallMeteor[i].active) DrawCircleV(smallMeteor[i].position, smallMeteor[i].radius, DARKGRAY); - else DrawCircleV(smallMeteor[i].position, smallMeteor[i].radius, Fade(LIGHTGRAY, 0.3f)); - } - - DrawText(TextFormat("TIME: %.02f", (float)framesCounter/60), 10, 10, 20, BLACK); - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} diff --git a/games/cat_vs_roomba/LICENSE.txt b/games/cat_vs_roomba/LICENSE.txt deleted file mode 100644 index bd3a20cef..000000000 --- a/games/cat_vs_roomba/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ - -This game sources are licensed under an unmodified zlib/libpng license, -which is an OSI-certified, BSD-like license: - -Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) - -This software is provided "as-is", without any express or implied warranty. In no event -will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial -applications, and to alter it and redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not claim that you - wrote the original software. If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be misrepresented - as being the original software. - - 3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/games/cat_vs_roomba/Makefile b/games/cat_vs_roomba/Makefile deleted file mode 100644 index 03cd56ff3..000000000 --- a/games/cat_vs_roomba/Makefile +++ /dev/null @@ -1,406 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= roomba -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= C:\GitHub\raylib - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 --preload-file resources - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - # -Wl,--subsystem,windows hides the console window - ifeq ($(BUILD_MODE), RELEASE) - LDFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -PROJECT_SOURCE_FILES ?= \ - roomba.c \ - screens/screen_logo.c \ - screens/screen_title.c \ - screens/screen_gameplay.c \ - screens/screen_ending.c - -# Define all object files from source files -OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) - -# For Android platform we call a custom Makefile.Android -ifeq ($(PLATFORM),PLATFORM_ANDROID) - MAKEFILE_PARAMS = -f Makefile.Android - export PROJECT_NAME - export PROJECT_SOURCE_FILES -else - MAKEFILE_PARAMS = $(PROJECT_NAME) -endif - -# Default target entry -# NOTE: We call this Makefile target or Makefile.Android target -all: - $(MAKE) $(MAKEFILE_PARAMS) - -# Project target defined by PROJECT_NAME -$(PROJECT_NAME): $(OBJS) - $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) - -# Compile source files -# NOTE: This pattern will compile every module defined on $(OBJS) -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/cat_vs_roomba/Makefile.Android b/games/cat_vs_roomba/Makefile.Android deleted file mode 100644 index 29d437b1b..000000000 --- a/games/cat_vs_roomba/Makefile.Android +++ /dev/null @@ -1,300 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Android project (APK building) -# -# Copyright (c) 2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -# Define required raylib variables -PLATFORM ?= PLATFORM_ANDROID -RAYLIB_PATH ?= ..\.. - -# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version -ANDROID_ARCH ?= ARM -ANDROID_API_VERSION = 21 -ifeq ($(ANDROID_ARCH),ARM) - ANDROID_ARCH_NAME = armeabi-v7a -endif -ifeq ($(ANDROID_ARCH),ARM64) - ANDROID_ARCH_NAME = arm64-v8a -endif - -# Required path variables -# NOTE: JAVA_HOME must be set to JDK -JAVA_HOME ?= C:/JavaJDK -ANDROID_HOME = C:/android-sdk -ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION) -ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1 -ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools - -# Android project configuration variables -PROJECT_NAME ?= raylib_game -PROJECT_LIBRARY_NAME ?= main -PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME) -PROJECT_RESOURCES_PATH ?= resources -PROJECT_SOURCE_FILES ?= raylib_game.c - -# Some source files are placed in directories, when compiling to some -# output directory other than source, that directory must pre-exist. -# Here we get a list of required folders that need to be created on -# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors. -PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES))) - -# Android app configuration variables -APP_LABEL_NAME ?= rGame -APP_COMPANY_NAME ?= raylib -APP_PRODUCT_NAME ?= rgame -APP_VERSION_CODE ?= 1 -APP_VERSION_NAME ?= 1.0 -APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png -APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png -APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png -APP_SCREEN_ORIENTATION ?= landscape -APP_KEYSTORE_PASS ?= raylib - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Library path for libraylib.a/libraylib.so -RAYLIB_LIB_PATH = $(RAYLIB_PATH)\src - -# Shared libs must be added to APK if required -# NOTE: Generated NativeLoader.java automatically load those libraries -ifeq ($(RAYLIB_LIBTYPE),SHARED) - PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so -endif - -# Compiler and archiver -# NOTE: GCC is being deprecated in Android NDK r16 -ifeq ($(ANDROID_ARCH),ARM) - CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang - AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar -endif -ifeq ($(ANDROID_ARCH),ARM64) - CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang - AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar -endif - -# Compiler flags for arquitecture -ifeq ($(ANDROID_ARCH),ARM) - CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -endif -ifeq ($(ANDROID_ARCH),ARM64) - CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769 -endif -# Compilation functions attributes options -CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC -# Compiler options for the linker -CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes -# Preprocessor macro definitions -CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) - -# Paths containing required header files -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue - -# Linker options -LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a -LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -# Force linking of library module to define symbol -LDFLAGS += -u ANativeActivity_onCreate -# Library paths containing required libs -LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME) -L$(ANDROID_TOOLCHAIN)\sysroot\usr\lib - -# Define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl - -# Generate target objects list from PROJECT_SOURCE_FILES -OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES)) - -# Android APK building process... some steps required... -# NOTE: typing 'make' will invoke the default target entry called 'all', -all: create_temp_project_dirs \ - copy_project_required_libs \ - copy_project_resources \ - generate_loader_script \ - generate_android_manifest \ - generate_apk_keystore \ - config_project_package \ - compile_project_code \ - compile_project_class \ - compile_project_class_dex \ - create_project_apk_package \ - sign_project_apk_package \ - zipalign_project_apk_package - -# Create required temp directories for APK building -create_temp_project_dirs: - if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj - if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src - if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) - if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib - if not exist $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) mkdir $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) - if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin - if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res - if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi - if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values - if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets - if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens - $(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir))) - -define create_dir - if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1) -endef - -# Copy required shared libs for integration into APK -# NOTE: If using shared libs they are loaded by generated NativeLoader.java -copy_project_required_libs: -ifeq ($(RAYLIB_LIBTYPE),SHARED) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so -endif -ifeq ($(RAYLIB_LIBTYPE),STATIC) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a -endif - -# Copy project required resources: strings.xml, icon.png, assets -# NOTE: Required strings.xml is generated and game resources are copied to assets folder -# TODO: Review xcopy usage, it can not be found in some systems! -copy_project_resources: - copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y - copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y - copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y - @echo ^ > $(PROJECT_BUILD_PATH)/res/values/strings.xml - @echo ^^$(APP_LABEL_NAME)^^ >> $(PROJECT_BUILD_PATH)/res/values/strings.xml - if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F - -# Generate NativeLoader.java to load required shared libraries -# NOTE: Probably not the bet way to generate this file... but it works. -generate_loader_script: - @echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -ifeq ($(RAYLIB_LIBTYPE),SHARED) - @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -endif - @echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Generate AndroidManifest.xml with all the required options -# NOTE: Probably not the bet way to generate this file... but it works. -generate_android_manifest: - @echo ^ > $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - -# Generate storekey for APK signing: $(PROJECT_NAME).keystore -# NOTE: Configure here your Distinguished Names (-dname) if required! -generate_apk_keystore: - if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA - -# Config project package and resource using AndroidManifest.xml and res/values/strings.xml -# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java -config_project_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar - -# Compile native_app_glue code as static library: obj/libnative_app_glue.a -compile_native_app_glue: - $(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS) - $(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o - -# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so -compile_project_code: $(OBJS) - $(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) - -# Compile all .c files required into object (.o) files -# NOTE: Those files will be linked into a shared library -$(PROJECT_BUILD_PATH)/obj/%.o:%.c - $(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot - -# Compile project .java code into .class (Java bytecode) -compile_project_class: - $(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Compile .class files into Dalvik executable bytecode (.dex) -# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT) -compile_project_class_dex: - $(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj - -# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk -# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so -# NOTE: Use -A resources to define additional directory in which to find raw asset files -create_project_apk_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin - cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS) - -# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk -sign_project_apk_package: - $(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key - -# Create zip-aligned APK package: $(PROJECT_NAME).apk -zipalign_project_apk_package: - $(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk - -# Install $(PROJECT_NAME).apk to default emulator/device -# NOTE: Use -e (emulator) or -d (device) parameters if required -install: - $(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk - -# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64) -check_device_abi: - $(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi - -# Monitorize output log coming from device, only raylib tag -logcat: - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -# Install and monitorize $(PROJECT_NAME).apk to default emulator/device -deploy: - $(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W - -# Clean everything -clean: - del $(PROJECT_BUILD_PATH)\* /f /s /q - rmdir $(PROJECT_BUILD_PATH) /s /q - @echo Cleaning done diff --git a/games/cat_vs_roomba/libraylib.bc b/games/cat_vs_roomba/libraylib.bc deleted file mode 100644 index 4febf88dd..000000000 Binary files a/games/cat_vs_roomba/libraylib.bc and /dev/null differ diff --git a/games/cat_vs_roomba/raymath.h b/games/cat_vs_roomba/raymath.h deleted file mode 100644 index 42a45ad6c..000000000 --- a/games/cat_vs_roomba/raymath.h +++ /dev/null @@ -1,1378 +0,0 @@ -/********************************************************************************************** -* -* raymath v1.2 - Math functions to work with Vector3, Matrix and Quaternions -* -* CONFIGURATION: -* -* #define RAYMATH_IMPLEMENTATION -* Generates the implementation of the library into the included file. -* If not defined, the library is in header only mode and can be included in other headers -* or source files without problems. But only ONE file should hold the implementation. -* -* #define RAYMATH_HEADER_ONLY -* Define static inline functions code, so #include header suffices for use. -* This may use up lots of memory. -* -* #define RAYMATH_STANDALONE -* Avoid raylib.h header inclusion in this file. -* Vector3 and Matrix data types are defined internally in raymath module. -* -* -* LICENSE: zlib/libpng -* -* Copyright (c) 2015-2017 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef RAYMATH_H -#define RAYMATH_H - -//#define RAYMATH_STANDALONE // NOTE: To use raymath as standalone lib, just uncomment this line -//#define RAYMATH_HEADER_ONLY // NOTE: To compile functions as static inline, uncomment this line - -#ifndef RAYMATH_STANDALONE - #include "raylib.h" // Required for structs: Vector3, Matrix -#endif - -#if defined(RAYMATH_IMPLEMENTATION) && defined(RAYMATH_HEADER_ONLY) - #error "Specifying both RAYMATH_IMPLEMENTATION and RAYMATH_HEADER_ONLY is contradictory" -#endif - -#if defined(RAYMATH_IMPLEMENTATION) - #if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED) - #define RMDEF __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll). - #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED) - #define RMDEF __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll) - #else - #define RMDEF extern inline // Provide external definition - #endif -#elif defined(RAYMATH_HEADER_ONLY) - #define RMDEF static inline // Functions may be inlined, no external out-of-line definition -#else - #if defined(__TINYC__) - #define RMDEF static inline // plain inline not supported by tinycc (See issue #435) - #else - #define RMDEF inline // Functions may be inlined or external definition used - #endif -#endif - -//---------------------------------------------------------------------------------- -// Defines and Macros -//---------------------------------------------------------------------------------- -#ifndef PI - #define PI 3.14159265358979323846 -#endif - -#ifndef DEG2RAD - #define DEG2RAD (PI/180.0f) -#endif - -#ifndef RAD2DEG - #define RAD2DEG (180.0f/PI) -#endif - -// Return float vector for Matrix -#ifndef MatrixToFloat - #define MatrixToFloat(mat) (MatrixToFloatV(mat).v) -#endif - -// Return float vector for Vector3 -#ifndef Vector3ToFloat - #define Vector3ToFloat(vec) (Vector3ToFloatV(vec).v) -#endif - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- - -#if defined(RAYMATH_STANDALONE) - // Vector2 type - typedef struct Vector2 { - float x; - float y; - } Vector2; - - // Vector3 type - typedef struct Vector3 { - float x; - float y; - float z; - } Vector3; - - // Quaternion type - typedef struct Quaternion { - float x; - float y; - float z; - float w; - } Quaternion; - - // Matrix type (OpenGL style 4x4 - right handed, column major) - typedef struct Matrix { - float m0, m4, m8, m12; - float m1, m5, m9, m13; - float m2, m6, m10, m14; - float m3, m7, m11, m15; - } Matrix; -#endif - -// NOTE: Helper types to be used instead of array return types for *ToFloat functions -typedef struct float3 { float v[3]; } float3; -typedef struct float16 { float v[16]; } float16; - -#include // Required for: sinf(), cosf(), tan(), fabs() - -//---------------------------------------------------------------------------------- -// Module Functions Definition - Utils math -//---------------------------------------------------------------------------------- - -// Clamp float value -RMDEF float Clamp(float value, float min, float max) -{ - const float res = value < min ? min : value; - return res > max ? max : res; -} - -// Calculate linear interpolation between two vectors -RMDEF float Lerp(float start, float end, float amount) -{ - return start + amount*(end - start); -} - -//---------------------------------------------------------------------------------- -// Module Functions Definition - Vector2 math -//---------------------------------------------------------------------------------- - -// Vector with components value 0.0f -RMDEF Vector2 Vector2Zero(void) -{ - Vector2 result = { 0.0f, 0.0f }; - return result; -} - -// Vector with components value 1.0f -RMDEF Vector2 Vector2One(void) -{ - Vector2 result = { 1.0f, 1.0f }; - return result; -} - -// Add two vectors (v1 + v2) -RMDEF Vector2 Vector2Add(Vector2 v1, Vector2 v2) -{ - Vector2 result = { v1.x + v2.x, v1.y + v2.y }; - return result; -} - -// Subtract two vectors (v1 - v2) -RMDEF Vector2 Vector2Subtract(Vector2 v1, Vector2 v2) -{ - Vector2 result = { v1.x - v2.x, v1.y - v2.y }; - return result; -} - -// Calculate vector length -RMDEF float Vector2Length(Vector2 v) -{ - float result = sqrtf((v.x*v.x) + (v.y*v.y)); - return result; -} - -// Calculate two vectors dot product -RMDEF float Vector2DotProduct(Vector2 v1, Vector2 v2) -{ - float result = (v1.x*v2.x + v1.y*v2.y); - return result; -} - -// Calculate distance between two vectors -RMDEF float Vector2Distance(Vector2 v1, Vector2 v2) -{ - float result = sqrtf((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y)); - return result; -} - -// Calculate angle from two vectors in X-axis -RMDEF float Vector2Angle(Vector2 v1, Vector2 v2) -{ - float result = atan2f(v2.y - v1.y, v2.x - v1.x)*(180.0f/PI); - if (result < 0) result += 360.0f; - return result; -} - -// Scale vector (multiply by value) -RMDEF Vector2 Vector2Scale(Vector2 v, float scale) -{ - Vector2 result = { v.x*scale, v.y*scale }; - return result; -} - -// Multiply vector by vector -RMDEF Vector2 Vector2MultiplyV(Vector2 v1, Vector2 v2) -{ - Vector2 result = { v1.x*v2.x, v1.y*v2.y }; - return result; -} - -// Negate vector -RMDEF Vector2 Vector2Negate(Vector2 v) -{ - Vector2 result = { -v.x, -v.y }; - return result; -} - -// Divide vector by a float value -RMDEF Vector2 Vector2Divide(Vector2 v, float div) -{ - Vector2 result = { v.x/div, v.y/div }; - return result; -} - -// Divide vector by vector -RMDEF Vector2 Vector2DivideV(Vector2 v1, Vector2 v2) -{ - Vector2 result = { v1.x/v2.x, v1.y/v2.y }; - return result; -} - -// Normalize provided vector -RMDEF Vector2 Vector2Normalize(Vector2 v) -{ - Vector2 result = Vector2Divide(v, Vector2Length(v)); - return result; -} - -// Calculate linear interpolation between two vectors -RMDEF Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount) -{ - Vector2 result = { 0 }; - - result.x = v1.x + amount*(v2.x - v1.x); - result.y = v1.y + amount*(v2.y - v1.y); - - return result; -} - -//---------------------------------------------------------------------------------- -// Module Functions Definition - Vector3 math -//---------------------------------------------------------------------------------- - -// Vector with components value 0.0f -RMDEF Vector3 Vector3Zero(void) -{ - Vector3 result = { 0.0f, 0.0f, 0.0f }; - return result; -} - -// Vector with components value 1.0f -RMDEF Vector3 Vector3One(void) -{ - Vector3 result = { 1.0f, 1.0f, 1.0f }; - return result; -} - -// Add two vectors -RMDEF Vector3 Vector3Add(Vector3 v1, Vector3 v2) -{ - Vector3 result = { v1.x + v2.x, v1.y + v2.y, v1.z + v2.z }; - return result; -} - -// Subtract two vectors -RMDEF Vector3 Vector3Subtract(Vector3 v1, Vector3 v2) -{ - Vector3 result = { v1.x - v2.x, v1.y - v2.y, v1.z - v2.z }; - return result; -} - -// Multiply vector by scalar -RMDEF Vector3 Vector3Multiply(Vector3 v, float scalar) -{ - Vector3 result = { v.x*scalar, v.y*scalar, v.z*scalar }; - return result; -} - -// Multiply vector by vector -RMDEF Vector3 Vector3MultiplyV(Vector3 v1, Vector3 v2) -{ - Vector3 result = { v1.x*v2.x, v1.y*v2.y, v1.z*v2.z }; - return result; -} - -// Calculate two vectors cross product -RMDEF Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2) -{ - Vector3 result = { v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x }; - return result; -} - -// Calculate one vector perpendicular vector -RMDEF Vector3 Vector3Perpendicular(Vector3 v) -{ - Vector3 result = { 0 }; - - float min = (float) fabs(v.x); - Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f}; - - if (fabs(v.y) < min) - { - min = (float) fabs(v.y); - Vector3 tmp = {0.0f, 1.0f, 0.0f}; - cardinalAxis = tmp; - } - - if (fabs(v.z) < min) - { - Vector3 tmp = {0.0f, 0.0f, 1.0f}; - cardinalAxis = tmp; - } - - result = Vector3CrossProduct(v, cardinalAxis); - - return result; -} - -// Calculate vector length -RMDEF float Vector3Length(const Vector3 v) -{ - float result = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); - return result; -} - -// Calculate two vectors dot product -RMDEF float Vector3DotProduct(Vector3 v1, Vector3 v2) -{ - float result = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z); - return result; -} - -// Calculate distance between two vectors -RMDEF float Vector3Distance(Vector3 v1, Vector3 v2) -{ - float dx = v2.x - v1.x; - float dy = v2.y - v1.y; - float dz = v2.z - v1.z; - float result = sqrtf(dx*dx + dy*dy + dz*dz); - return result; -} - -// Scale provided vector -RMDEF Vector3 Vector3Scale(Vector3 v, float scale) -{ - Vector3 result = { v.x*scale, v.y*scale, v.z*scale }; - return result; -} - -// Negate provided vector (invert direction) -RMDEF Vector3 Vector3Negate(Vector3 v) -{ - Vector3 result = { -v.x, -v.y, -v.z }; - return result; -} - -// Divide vector by a float value -RMDEF Vector3 Vector3Divide(Vector3 v, float div) -{ - Vector3 result = { v.x / div, v.y / div, v.z / div }; - return result; -} - -// Divide vector by vector -RMDEF Vector3 Vector3DivideV(Vector3 v1, Vector3 v2) -{ - Vector3 result = { v1.x/v2.x, v1.y/v2.y, v1.z/v2.z }; - return result; -} - -// Normalize provided vector -RMDEF Vector3 Vector3Normalize(Vector3 v) -{ - Vector3 result = v; - - float length, ilength; - length = Vector3Length(v); - if (length == 0.0f) length = 1.0f; - ilength = 1.0f/length; - - result.x *= ilength; - result.y *= ilength; - result.z *= ilength; - - return result; -} - -// Orthonormalize provided vectors -// Makes vectors normalized and orthogonal to each other -// Gram-Schmidt function implementation -RMDEF void Vector3OrthoNormalize(Vector3 *v1, Vector3 *v2) -{ - *v1 = Vector3Normalize(*v1); - Vector3 vn = Vector3CrossProduct(*v1, *v2); - vn = Vector3Normalize(vn); - *v2 = Vector3CrossProduct(vn, *v1); -} - -// Transforms a Vector3 by a given Matrix -RMDEF Vector3 Vector3Transform(Vector3 v, Matrix mat) -{ - Vector3 result = { 0 }; - float x = v.x; - float y = v.y; - float z = v.z; - - result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12; - result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13; - result.z = mat.m2*x + mat.m6*y + mat.m10*z + mat.m14; - - return result; -}; - -// Transform a vector by quaternion rotation -RMDEF Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q) -{ - Vector3 result = { 0 }; - - result.x = v.x*(q.x*q.x + q.w*q.w - q.y*q.y - q.z*q.z) + v.y*(2*q.x*q.y - 2*q.w*q.z) + v.z*(2*q.x*q.z + 2*q.w*q.y); - result.y = v.x*(2*q.w*q.z + 2*q.x*q.y) + v.y*(q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z) + v.z*(-2*q.w*q.x + 2*q.y*q.z); - result.z = v.x*(-2*q.w*q.y + 2*q.x*q.z) + v.y*(2*q.w*q.x + 2*q.y*q.z)+ v.z*(q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z); - - return result; -} - -// Calculate linear interpolation between two vectors -RMDEF Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount) -{ - Vector3 result = { 0 }; - - result.x = v1.x + amount*(v2.x - v1.x); - result.y = v1.y + amount*(v2.y - v1.y); - result.z = v1.z + amount*(v2.z - v1.z); - - return result; -} - -// Calculate reflected vector to normal -RMDEF Vector3 Vector3Reflect(Vector3 v, Vector3 normal) -{ - // I is the original vector - // N is the normal of the incident plane - // R = I - (2*N*( DotProduct[ I,N] )) - - Vector3 result = { 0 }; - - float dotProduct = Vector3DotProduct(v, normal); - - result.x = v.x - (2.0f*normal.x)*dotProduct; - result.y = v.y - (2.0f*normal.y)*dotProduct; - result.z = v.z - (2.0f*normal.z)*dotProduct; - - return result; -} - -// Return min value for each pair of components -RMDEF Vector3 Vector3Min(Vector3 v1, Vector3 v2) -{ - Vector3 result = { 0 }; - - result.x = fminf(v1.x, v2.x); - result.y = fminf(v1.y, v2.y); - result.z = fminf(v1.z, v2.z); - - return result; -} - -// Return max value for each pair of components -RMDEF Vector3 Vector3Max(Vector3 v1, Vector3 v2) -{ - Vector3 result = { 0 }; - - result.x = fmaxf(v1.x, v2.x); - result.y = fmaxf(v1.y, v2.y); - result.z = fmaxf(v1.z, v2.z); - - return result; -} - -// Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c) -// NOTE: Assumes P is on the plane of the triangle -RMDEF Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c) -{ - //Vector v0 = b - a, v1 = c - a, v2 = p - a; - - Vector3 v0 = Vector3Subtract(b, a); - Vector3 v1 = Vector3Subtract(c, a); - Vector3 v2 = Vector3Subtract(p, a); - float d00 = Vector3DotProduct(v0, v0); - float d01 = Vector3DotProduct(v0, v1); - float d11 = Vector3DotProduct(v1, v1); - float d20 = Vector3DotProduct(v2, v0); - float d21 = Vector3DotProduct(v2, v1); - - float denom = d00*d11 - d01*d01; - - Vector3 result = { 0 }; - - result.y = (d11*d20 - d01*d21)/denom; - result.z = (d00*d21 - d01*d20)/denom; - result.x = 1.0f - (result.z + result.y); - - return result; -} - -// Returns Vector3 as float array -RMDEF float3 Vector3ToFloatV(Vector3 v) -{ - float3 buffer = { 0 }; - - buffer.v[0] = v.x; - buffer.v[1] = v.y; - buffer.v[2] = v.z; - - return buffer; -} - -//---------------------------------------------------------------------------------- -// Module Functions Definition - Matrix math -//---------------------------------------------------------------------------------- - -// Compute matrix determinant -RMDEF float MatrixDeterminant(Matrix mat) -{ - float result = { 0 }; - - // Cache the matrix values (speed optimization) - float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3; - float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7; - float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11; - float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15; - - result = a30*a21*a12*a03 - a20*a31*a12*a03 - a30*a11*a22*a03 + a10*a31*a22*a03 + - a20*a11*a32*a03 - a10*a21*a32*a03 - a30*a21*a02*a13 + a20*a31*a02*a13 + - a30*a01*a22*a13 - a00*a31*a22*a13 - a20*a01*a32*a13 + a00*a21*a32*a13 + - a30*a11*a02*a23 - a10*a31*a02*a23 - a30*a01*a12*a23 + a00*a31*a12*a23 + - a10*a01*a32*a23 - a00*a11*a32*a23 - a20*a11*a02*a33 + a10*a21*a02*a33 + - a20*a01*a12*a33 - a00*a21*a12*a33 - a10*a01*a22*a33 + a00*a11*a22*a33; - - return result; -} - -// Returns the trace of the matrix (sum of the values along the diagonal) -RMDEF float MatrixTrace(Matrix mat) -{ - float result = (mat.m0 + mat.m5 + mat.m10 + mat.m15); - return result; -} - -// Transposes provided matrix -RMDEF Matrix MatrixTranspose(Matrix mat) -{ - Matrix result = { 0 }; - - result.m0 = mat.m0; - result.m1 = mat.m4; - result.m2 = mat.m8; - result.m3 = mat.m12; - result.m4 = mat.m1; - result.m5 = mat.m5; - result.m6 = mat.m9; - result.m7 = mat.m13; - result.m8 = mat.m2; - result.m9 = mat.m6; - result.m10 = mat.m10; - result.m11 = mat.m14; - result.m12 = mat.m3; - result.m13 = mat.m7; - result.m14 = mat.m11; - result.m15 = mat.m15; - - return result; -} - -// Invert provided matrix -RMDEF Matrix MatrixInvert(Matrix mat) -{ - Matrix result = { 0 }; - - // Cache the matrix values (speed optimization) - float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3; - float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7; - float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11; - float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15; - - float b00 = a00*a11 - a01*a10; - float b01 = a00*a12 - a02*a10; - float b02 = a00*a13 - a03*a10; - float b03 = a01*a12 - a02*a11; - float b04 = a01*a13 - a03*a11; - float b05 = a02*a13 - a03*a12; - float b06 = a20*a31 - a21*a30; - float b07 = a20*a32 - a22*a30; - float b08 = a20*a33 - a23*a30; - float b09 = a21*a32 - a22*a31; - float b10 = a21*a33 - a23*a31; - float b11 = a22*a33 - a23*a32; - - // Calculate the invert determinant (inlined to avoid double-caching) - float invDet = 1.0f/(b00*b11 - b01*b10 + b02*b09 + b03*b08 - b04*b07 + b05*b06); - - result.m0 = (a11*b11 - a12*b10 + a13*b09)*invDet; - result.m1 = (-a01*b11 + a02*b10 - a03*b09)*invDet; - result.m2 = (a31*b05 - a32*b04 + a33*b03)*invDet; - result.m3 = (-a21*b05 + a22*b04 - a23*b03)*invDet; - result.m4 = (-a10*b11 + a12*b08 - a13*b07)*invDet; - result.m5 = (a00*b11 - a02*b08 + a03*b07)*invDet; - result.m6 = (-a30*b05 + a32*b02 - a33*b01)*invDet; - result.m7 = (a20*b05 - a22*b02 + a23*b01)*invDet; - result.m8 = (a10*b10 - a11*b08 + a13*b06)*invDet; - result.m9 = (-a00*b10 + a01*b08 - a03*b06)*invDet; - result.m10 = (a30*b04 - a31*b02 + a33*b00)*invDet; - result.m11 = (-a20*b04 + a21*b02 - a23*b00)*invDet; - result.m12 = (-a10*b09 + a11*b07 - a12*b06)*invDet; - result.m13 = (a00*b09 - a01*b07 + a02*b06)*invDet; - result.m14 = (-a30*b03 + a31*b01 - a32*b00)*invDet; - result.m15 = (a20*b03 - a21*b01 + a22*b00)*invDet; - - return result; -} - -// Normalize provided matrix -RMDEF Matrix MatrixNormalize(Matrix mat) -{ - Matrix result = { 0 }; - - float det = MatrixDeterminant(mat); - - result.m0 = mat.m0/det; - result.m1 = mat.m1/det; - result.m2 = mat.m2/det; - result.m3 = mat.m3/det; - result.m4 = mat.m4/det; - result.m5 = mat.m5/det; - result.m6 = mat.m6/det; - result.m7 = mat.m7/det; - result.m8 = mat.m8/det; - result.m9 = mat.m9/det; - result.m10 = mat.m10/det; - result.m11 = mat.m11/det; - result.m12 = mat.m12/det; - result.m13 = mat.m13/det; - result.m14 = mat.m14/det; - result.m15 = mat.m15/det; - - return result; -} - -// Returns identity matrix -RMDEF Matrix MatrixIdentity(void) -{ - Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f }; - - return result; -} - -// Add two matrices -RMDEF Matrix MatrixAdd(Matrix left, Matrix right) -{ - Matrix result = MatrixIdentity(); - - result.m0 = left.m0 + right.m0; - result.m1 = left.m1 + right.m1; - result.m2 = left.m2 + right.m2; - result.m3 = left.m3 + right.m3; - result.m4 = left.m4 + right.m4; - result.m5 = left.m5 + right.m5; - result.m6 = left.m6 + right.m6; - result.m7 = left.m7 + right.m7; - result.m8 = left.m8 + right.m8; - result.m9 = left.m9 + right.m9; - result.m10 = left.m10 + right.m10; - result.m11 = left.m11 + right.m11; - result.m12 = left.m12 + right.m12; - result.m13 = left.m13 + right.m13; - result.m14 = left.m14 + right.m14; - result.m15 = left.m15 + right.m15; - - return result; -} - -// Subtract two matrices (left - right) -RMDEF Matrix MatrixSubtract(Matrix left, Matrix right) -{ - Matrix result = MatrixIdentity(); - - result.m0 = left.m0 - right.m0; - result.m1 = left.m1 - right.m1; - result.m2 = left.m2 - right.m2; - result.m3 = left.m3 - right.m3; - result.m4 = left.m4 - right.m4; - result.m5 = left.m5 - right.m5; - result.m6 = left.m6 - right.m6; - result.m7 = left.m7 - right.m7; - result.m8 = left.m8 - right.m8; - result.m9 = left.m9 - right.m9; - result.m10 = left.m10 - right.m10; - result.m11 = left.m11 - right.m11; - result.m12 = left.m12 - right.m12; - result.m13 = left.m13 - right.m13; - result.m14 = left.m14 - right.m14; - result.m15 = left.m15 - right.m15; - - return result; -} - -// Returns translation matrix -RMDEF Matrix MatrixTranslate(float x, float y, float z) -{ - Matrix result = { 1.0f, 0.0f, 0.0f, x, - 0.0f, 1.0f, 0.0f, y, - 0.0f, 0.0f, 1.0f, z, - 0.0f, 0.0f, 0.0f, 1.0f }; - - return result; -} - -// Create rotation matrix from axis and angle -// NOTE: Angle should be provided in radians -RMDEF Matrix MatrixRotate(Vector3 axis, float angle) -{ - Matrix result = { 0 }; - - float x = axis.x, y = axis.y, z = axis.z; - - float length = sqrtf(x*x + y*y + z*z); - - if ((length != 1.0f) && (length != 0.0f)) - { - length = 1.0f/length; - x *= length; - y *= length; - z *= length; - } - - float sinres = sinf(angle); - float cosres = cosf(angle); - float t = 1.0f - cosres; - - result.m0 = x*x*t + cosres; - result.m1 = y*x*t + z*sinres; - result.m2 = z*x*t - y*sinres; - result.m3 = 0.0f; - - result.m4 = x*y*t - z*sinres; - result.m5 = y*y*t + cosres; - result.m6 = z*y*t + x*sinres; - result.m7 = 0.0f; - - result.m8 = x*z*t + y*sinres; - result.m9 = y*z*t - x*sinres; - result.m10 = z*z*t + cosres; - result.m11 = 0.0f; - - result.m12 = 0.0f; - result.m13 = 0.0f; - result.m14 = 0.0f; - result.m15 = 1.0f; - - return result; -} - -// Returns x-rotation matrix (angle in radians) -RMDEF Matrix MatrixRotateX(float angle) -{ - Matrix result = MatrixIdentity(); - - float cosres = cosf(angle); - float sinres = sinf(angle); - - result.m5 = cosres; - result.m6 = -sinres; - result.m9 = sinres; - result.m10 = cosres; - - return result; -} - -// Returns y-rotation matrix (angle in radians) -RMDEF Matrix MatrixRotateY(float angle) -{ - Matrix result = MatrixIdentity(); - - float cosres = cosf(angle); - float sinres = sinf(angle); - - result.m0 = cosres; - result.m2 = sinres; - result.m8 = -sinres; - result.m10 = cosres; - - return result; -} - -// Returns z-rotation matrix (angle in radians) -RMDEF Matrix MatrixRotateZ(float angle) -{ - Matrix result = MatrixIdentity(); - - float cosres = cosf(angle); - float sinres = sinf(angle); - - result.m0 = cosres; - result.m1 = -sinres; - result.m4 = sinres; - result.m5 = cosres; - - return result; -} - -// Returns scaling matrix -RMDEF Matrix MatrixScale(float x, float y, float z) -{ - Matrix result = { x, 0.0f, 0.0f, 0.0f, - 0.0f, y, 0.0f, 0.0f, - 0.0f, 0.0f, z, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f }; - - return result; -} - -// Returns two matrix multiplication -// NOTE: When multiplying matrices... the order matters! -RMDEF Matrix MatrixMultiply(Matrix left, Matrix right) -{ - Matrix result = { 0 }; - - result.m0 = left.m0*right.m0 + left.m1*right.m4 + left.m2*right.m8 + left.m3*right.m12; - result.m1 = left.m0*right.m1 + left.m1*right.m5 + left.m2*right.m9 + left.m3*right.m13; - result.m2 = left.m0*right.m2 + left.m1*right.m6 + left.m2*right.m10 + left.m3*right.m14; - result.m3 = left.m0*right.m3 + left.m1*right.m7 + left.m2*right.m11 + left.m3*right.m15; - result.m4 = left.m4*right.m0 + left.m5*right.m4 + left.m6*right.m8 + left.m7*right.m12; - result.m5 = left.m4*right.m1 + left.m5*right.m5 + left.m6*right.m9 + left.m7*right.m13; - result.m6 = left.m4*right.m2 + left.m5*right.m6 + left.m6*right.m10 + left.m7*right.m14; - result.m7 = left.m4*right.m3 + left.m5*right.m7 + left.m6*right.m11 + left.m7*right.m15; - result.m8 = left.m8*right.m0 + left.m9*right.m4 + left.m10*right.m8 + left.m11*right.m12; - result.m9 = left.m8*right.m1 + left.m9*right.m5 + left.m10*right.m9 + left.m11*right.m13; - result.m10 = left.m8*right.m2 + left.m9*right.m6 + left.m10*right.m10 + left.m11*right.m14; - result.m11 = left.m8*right.m3 + left.m9*right.m7 + left.m10*right.m11 + left.m11*right.m15; - result.m12 = left.m12*right.m0 + left.m13*right.m4 + left.m14*right.m8 + left.m15*right.m12; - result.m13 = left.m12*right.m1 + left.m13*right.m5 + left.m14*right.m9 + left.m15*right.m13; - result.m14 = left.m12*right.m2 + left.m13*right.m6 + left.m14*right.m10 + left.m15*right.m14; - result.m15 = left.m12*right.m3 + left.m13*right.m7 + left.m14*right.m11 + left.m15*right.m15; - - return result; -} - -// Returns perspective projection matrix -RMDEF Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far) -{ - Matrix result = { 0 }; - - float rl = (float)(right - left); - float tb = (float)(top - bottom); - float fn = (float)(far - near); - - result.m0 = ((float) near*2.0f)/rl; - result.m1 = 0.0f; - result.m2 = 0.0f; - result.m3 = 0.0f; - - result.m4 = 0.0f; - result.m5 = ((float) near*2.0f)/tb; - result.m6 = 0.0f; - result.m7 = 0.0f; - - result.m8 = ((float)right + (float)left)/rl; - result.m9 = ((float)top + (float)bottom)/tb; - result.m10 = -((float)far + (float)near)/fn; - result.m11 = -1.0f; - - result.m12 = 0.0f; - result.m13 = 0.0f; - result.m14 = -((float)far*(float)near*2.0f)/fn; - result.m15 = 0.0f; - - return result; -} - -// Returns perspective projection matrix -// NOTE: Angle should be provided in radians -RMDEF Matrix MatrixPerspective(double fovy, double aspect, double near, double far) -{ - double top = near*tan(fovy*0.5); - double right = top*aspect; - Matrix result = MatrixFrustum(-right, right, -top, top, near, far); - - return result; -} - -// Returns orthographic projection matrix -RMDEF Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far) -{ - Matrix result = { 0 }; - - float rl = (float)(right - left); - float tb = (float)(top - bottom); - float fn = (float)(far - near); - - result.m0 = 2.0f/rl; - result.m1 = 0.0f; - result.m2 = 0.0f; - result.m3 = 0.0f; - result.m4 = 0.0f; - result.m5 = 2.0f/tb; - result.m6 = 0.0f; - result.m7 = 0.0f; - result.m8 = 0.0f; - result.m9 = 0.0f; - result.m10 = -2.0f/fn; - result.m11 = 0.0f; - result.m12 = -((float)left + (float)right)/rl; - result.m13 = -((float)top + (float)bottom)/tb; - result.m14 = -((float)far + (float)near)/fn; - result.m15 = 1.0f; - - return result; -} - -// Returns camera look-at matrix (view matrix) -RMDEF Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up) -{ - Matrix result = { 0 }; - - Vector3 z = Vector3Subtract(eye, target); - z = Vector3Normalize(z); - Vector3 x = Vector3CrossProduct(up, z); - x = Vector3Normalize(x); - Vector3 y = Vector3CrossProduct(z, x); - y = Vector3Normalize(y); - - result.m0 = x.x; - result.m1 = x.y; - result.m2 = x.z; - result.m3 = 0.0f; - result.m4 = y.x; - result.m5 = y.y; - result.m6 = y.z; - result.m7 = 0.0f; - result.m8 = z.x; - result.m9 = z.y; - result.m10 = z.z; - result.m11 = 0.0f; - result.m12 = eye.x; - result.m13 = eye.y; - result.m14 = eye.z; - result.m15 = 1.0f; - - result = MatrixInvert(result); - - return result; -} - -// Returns float array of matrix data -RMDEF float16 MatrixToFloatV(Matrix mat) -{ - float16 buffer = { 0 }; - - buffer.v[0] = mat.m0; - buffer.v[1] = mat.m1; - buffer.v[2] = mat.m2; - buffer.v[3] = mat.m3; - buffer.v[4] = mat.m4; - buffer.v[5] = mat.m5; - buffer.v[6] = mat.m6; - buffer.v[7] = mat.m7; - buffer.v[8] = mat.m8; - buffer.v[9] = mat.m9; - buffer.v[10] = mat.m10; - buffer.v[11] = mat.m11; - buffer.v[12] = mat.m12; - buffer.v[13] = mat.m13; - buffer.v[14] = mat.m14; - buffer.v[15] = mat.m15; - - return buffer; -} - -//---------------------------------------------------------------------------------- -// Module Functions Definition - Quaternion math -//---------------------------------------------------------------------------------- - -// Returns identity quaternion -RMDEF Quaternion QuaternionIdentity(void) -{ - Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f }; - return result; -} - -// Computes the length of a quaternion -RMDEF float QuaternionLength(Quaternion q) -{ - float result = (float)sqrt(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w); - return result; -} - -// Normalize provided quaternion -RMDEF Quaternion QuaternionNormalize(Quaternion q) -{ - Quaternion result = { 0 }; - - float length, ilength; - length = QuaternionLength(q); - if (length == 0.0f) length = 1.0f; - ilength = 1.0f/length; - - result.x = q.x*ilength; - result.y = q.y*ilength; - result.z = q.z*ilength; - result.w = q.w*ilength; - - return result; -} - -// Invert provided quaternion -RMDEF Quaternion QuaternionInvert(Quaternion q) -{ - Quaternion result = q; - float length = QuaternionLength(q); - float lengthSq = length*length; - - if (lengthSq != 0.0) - { - float i = 1.0f/lengthSq; - - result.x *= -i; - result.y *= -i; - result.z *= -i; - result.w *= i; - } - - return result; -} - -// Calculate two quaternion multiplication -RMDEF Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2) -{ - Quaternion result = { 0 }; - - float qax = q1.x, qay = q1.y, qaz = q1.z, qaw = q1.w; - float qbx = q2.x, qby = q2.y, qbz = q2.z, qbw = q2.w; - - result.x = qax*qbw + qaw*qbx + qay*qbz - qaz*qby; - result.y = qay*qbw + qaw*qby + qaz*qbx - qax*qbz; - result.z = qaz*qbw + qaw*qbz + qax*qby - qay*qbx; - result.w = qaw*qbw - qax*qbx - qay*qby - qaz*qbz; - - return result; -} - -// Calculate linear interpolation between two quaternions -RMDEF Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount) -{ - Quaternion result = { 0 }; - - result.x = q1.x + amount*(q2.x - q1.x); - result.y = q1.y + amount*(q2.y - q1.y); - result.z = q1.z + amount*(q2.z - q1.z); - result.w = q1.w + amount*(q2.w - q1.w); - - return result; -} - -// Calculate slerp-optimized interpolation between two quaternions -RMDEF Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount) -{ - Quaternion result = QuaternionLerp(q1, q2, amount); - result = QuaternionNormalize(result); - - return result; -} - -// Calculates spherical linear interpolation between two quaternions -RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount) -{ - Quaternion result = { 0 }; - - float cosHalfTheta = q1.x*q2.x + q1.y*q2.y + q1.z*q2.z + q1.w*q2.w; - - if (fabs(cosHalfTheta) >= 1.0f) result = q1; - else if (cosHalfTheta > 0.95f) result = QuaternionNlerp(q1, q2, amount); - else - { - float halfTheta = (float) acos(cosHalfTheta); - float sinHalfTheta = (float) sqrt(1.0f - cosHalfTheta*cosHalfTheta); - - if (fabs(sinHalfTheta) < 0.001f) - { - result.x = (q1.x*0.5f + q2.x*0.5f); - result.y = (q1.y*0.5f + q2.y*0.5f); - result.z = (q1.z*0.5f + q2.z*0.5f); - result.w = (q1.w*0.5f + q2.w*0.5f); - } - else - { - float ratioA = sinf((1 - amount)*halfTheta)/sinHalfTheta; - float ratioB = sinf(amount*halfTheta)/sinHalfTheta; - - result.x = (q1.x*ratioA + q2.x*ratioB); - result.y = (q1.y*ratioA + q2.y*ratioB); - result.z = (q1.z*ratioA + q2.z*ratioB); - result.w = (q1.w*ratioA + q2.w*ratioB); - } - } - - return result; -} - -// Calculate quaternion based on the rotation from one vector to another -RMDEF Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to) -{ - Quaternion result = { 0 }; - - float cos2Theta = Vector3DotProduct(from, to); - Vector3 cross = Vector3CrossProduct(from, to); - - result.x = cross.x; - result.y = cross.y; - result.z = cross.y; - result.w = 1.0f + cos2Theta; // NOTE: Added QuaternioIdentity() - - // Normalize to essentially nlerp the original and identity to 0.5 - result = QuaternionNormalize(result); - - // Above lines are equivalent to: - //Quaternion result = QuaternionNlerp(q, QuaternionIdentity(), 0.5f); - - return result; -} - -// Returns a quaternion for a given rotation matrix -RMDEF Quaternion QuaternionFromMatrix(Matrix mat) -{ - Quaternion result = { 0 }; - - float trace = MatrixTrace(mat); - - if (trace > 0.0f) - { - float s = (float)sqrt(trace + 1)*2.0f; - float invS = 1.0f/s; - - result.w = s*0.25f; - result.x = (mat.m6 - mat.m9)*invS; - result.y = (mat.m8 - mat.m2)*invS; - result.z = (mat.m1 - mat.m4)*invS; - } - else - { - float m00 = mat.m0, m11 = mat.m5, m22 = mat.m10; - - if (m00 > m11 && m00 > m22) - { - float s = (float)sqrt(1.0f + m00 - m11 - m22)*2.0f; - float invS = 1.0f/s; - - result.w = (mat.m6 - mat.m9)*invS; - result.x = s*0.25f; - result.y = (mat.m4 + mat.m1)*invS; - result.z = (mat.m8 + mat.m2)*invS; - } - else if (m11 > m22) - { - float s = (float)sqrt(1.0f + m11 - m00 - m22)*2.0f; - float invS = 1.0f/s; - - result.w = (mat.m8 - mat.m2)*invS; - result.x = (mat.m4 + mat.m1)*invS; - result.y = s*0.25f; - result.z = (mat.m9 + mat.m6)*invS; - } - else - { - float s = (float)sqrt(1.0f + m22 - m00 - m11)*2.0f; - float invS = 1.0f/s; - - result.w = (mat.m1 - mat.m4)*invS; - result.x = (mat.m8 + mat.m2)*invS; - result.y = (mat.m9 + mat.m6)*invS; - result.z = s*0.25f; - } - } - - return result; -} - -// Returns a matrix for a given quaternion -RMDEF Matrix QuaternionToMatrix(Quaternion q) -{ - Matrix result = { 0 }; - - float x = q.x, y = q.y, z = q.z, w = q.w; - - float x2 = x + x; - float y2 = y + y; - float z2 = z + z; - - float length = QuaternionLength(q); - float lengthSquared = length*length; - - float xx = x*x2/lengthSquared; - float xy = x*y2/lengthSquared; - float xz = x*z2/lengthSquared; - - float yy = y*y2/lengthSquared; - float yz = y*z2/lengthSquared; - float zz = z*z2/lengthSquared; - - float wx = w*x2/lengthSquared; - float wy = w*y2/lengthSquared; - float wz = w*z2/lengthSquared; - - result.m0 = 1.0f - (yy + zz); - result.m1 = xy - wz; - result.m2 = xz + wy; - result.m3 = 0.0f; - result.m4 = xy + wz; - result.m5 = 1.0f - (xx + zz); - result.m6 = yz - wx; - result.m7 = 0.0f; - result.m8 = xz - wy; - result.m9 = yz + wx; - result.m10 = 1.0f - (xx + yy); - result.m11 = 0.0f; - result.m12 = 0.0f; - result.m13 = 0.0f; - result.m14 = 0.0f; - result.m15 = 1.0f; - - return result; -} - -// Returns rotation quaternion for an angle and axis -// NOTE: angle must be provided in radians -RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle) -{ - Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f }; - - if (Vector3Length(axis) != 0.0f) - - angle *= 0.5f; - - axis = Vector3Normalize(axis); - - float sinres = sinf(angle); - float cosres = cosf(angle); - - result.x = axis.x*sinres; - result.y = axis.y*sinres; - result.z = axis.z*sinres; - result.w = cosres; - - result = QuaternionNormalize(result); - - return result; -} - -// Returns the rotation angle and axis for a given quaternion -RMDEF void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle) -{ - if (fabs(q.w) > 1.0f) q = QuaternionNormalize(q); - - Vector3 resAxis = { 0.0f, 0.0f, 0.0f }; - float resAngle = 0.0f; - - resAngle = 2.0f*(float)acos(q.w); - float den = (float)sqrt(1.0f - q.w*q.w); - - if (den > 0.0001f) - { - resAxis.x = q.x/den; - resAxis.y = q.y/den; - resAxis.z = q.z/den; - } - else - { - // This occurs when the angle is zero. - // Not a problem: just set an arbitrary normalized axis. - resAxis.x = 1.0f; - } - - *outAxis = resAxis; - *outAngle = resAngle; -} - -// Returns he quaternion equivalent to Euler angles -RMDEF Quaternion QuaternionFromEuler(float roll, float pitch, float yaw) -{ - Quaternion q = { 0 }; - - float x0 = cosf(roll*0.5f); - float x1 = sinf(roll*0.5f); - float y0 = cosf(pitch*0.5f); - float y1 = sinf(pitch*0.5f); - float z0 = cosf(yaw*0.5f); - float z1 = sinf(yaw*0.5f); - - q.x = x1*y0*z0 - x0*y1*z1; - q.y = x0*y1*z0 + x1*y0*z1; - q.z = x0*y0*z1 - x1*y1*z0; - q.w = x0*y0*z0 + x1*y1*z1; - - return q; -} - -// Return the Euler angles equivalent to quaternion (roll, pitch, yaw) -// NOTE: Angles are returned in a Vector3 struct in degrees -RMDEF Vector3 QuaternionToEuler(Quaternion q) -{ - Vector3 result = { 0 }; - - // roll (x-axis rotation) - float x0 = 2.0f*(q.w*q.x + q.y*q.z); - float x1 = 1.0f - 2.0f*(q.x*q.x + q.y*q.y); - result.x = atan2f(x0, x1)*RAD2DEG; - - // pitch (y-axis rotation) - float y0 = 2.0f*(q.w*q.y - q.z*q.x); - y0 = y0 > 1.0f ? 1.0f : y0; - y0 = y0 < -1.0f ? -1.0f : y0; - result.y = asinf(y0)*RAD2DEG; - - // yaw (z-axis rotation) - float z0 = 2.0f*(q.w*q.z + q.x*q.y); - float z1 = 1.0f - 2.0f*(q.y*q.y + q.z*q.z); - result.z = atan2f(z0, z1)*RAD2DEG; - - return result; -} - -// Transform a quaternion given a transformation matrix -RMDEF Quaternion QuaternionTransform(Quaternion q, Matrix mat) -{ - Quaternion result = { 0 }; - - result.x = mat.m0*q.x + mat.m4*q.y + mat.m8*q.z + mat.m12*q.w; - result.y = mat.m1*q.x + mat.m5*q.y + mat.m9*q.z + mat.m13*q.w; - result.z = mat.m2*q.x + mat.m6*q.y + mat.m10*q.z + mat.m14*q.w; - result.w = mat.m3*q.x + mat.m7*q.y + mat.m11*q.z + mat.m15*q.w; - - return result; -} - -#endif // RAYMATH_H diff --git a/games/cat_vs_roomba/resources/cat.png b/games/cat_vs_roomba/resources/cat.png deleted file mode 100644 index 872d029a2..000000000 Binary files a/games/cat_vs_roomba/resources/cat.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/cat_mouse.mod b/games/cat_vs_roomba/resources/cat_mouse.mod deleted file mode 100644 index ef7ce860f..000000000 Binary files a/games/cat_vs_roomba/resources/cat_mouse.mod and /dev/null differ diff --git a/games/cat_vs_roomba/resources/catch22.mod b/games/cat_vs_roomba/resources/catch22.mod deleted file mode 100644 index 1b793dc13..000000000 Binary files a/games/cat_vs_roomba/resources/catch22.mod and /dev/null differ diff --git a/games/cat_vs_roomba/resources/coin.wav b/games/cat_vs_roomba/resources/coin.wav deleted file mode 100644 index 6684ffc6a..000000000 Binary files a/games/cat_vs_roomba/resources/coin.wav and /dev/null differ diff --git a/games/cat_vs_roomba/resources/collisions.txt b/games/cat_vs_roomba/resources/collisions.txt deleted file mode 100644 index 839404cc2..000000000 --- a/games/cat_vs_roomba/resources/collisions.txt +++ /dev/null @@ -1,16 +0,0 @@ -1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,1,1,1,1,1,1,1,1, -1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,1,1,1,1,1,1,1,1, -1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, -1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, -0,0,1,1,1,1,2,2,2,1,1,1,0,0,1,1,1,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1, -0,0,1,1,1,1,2,2,2,1,1,1,0,0,1,1,1,2,2,2,1,1,1,1,0,0,1,1,1,1,0,0, -0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,0,0,1,1,1,1,0,0, -0,0,1,1,2,2,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,1,1,1,0,0,0,0,0,0,0,0, -1,1,1,1,2,2,2,2,2,2,2,2,0,0,1,1,1,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0, -1,1,1,1,2,2,2,2,2,2,2,2,0,0,1,1,1,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1, -1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, -1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,1,2,2,2,2,2,2,1,1, -0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,2,2,2,2,2,2,1,1, -0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,1,1, -0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,1,1, -0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,1,1,0,0,1,2,2,2,2,2,2,2,2,0,0 \ No newline at end of file diff --git a/games/cat_vs_roomba/resources/dirtiles.png b/games/cat_vs_roomba/resources/dirtiles.png deleted file mode 100644 index 9c4c46573..000000000 Binary files a/games/cat_vs_roomba/resources/dirtiles.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/dyson.png b/games/cat_vs_roomba/resources/dyson.png deleted file mode 100644 index 7b15c768b..000000000 Binary files a/games/cat_vs_roomba/resources/dyson.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/furmap.txt b/games/cat_vs_roomba/resources/furmap.txt deleted file mode 100644 index 0b9a2ee25..000000000 --- a/games/cat_vs_roomba/resources/furmap.txt +++ /dev/null @@ -1,34 +0,0 @@ -.furniture -.state: 0-Block, 1-Alpha, 2-Breakable -.f setId cellX cellY state counter -.puff and sits -f 3 0 4 0 0 -f 3 13 0 0 0 -f 3 22 0 0 0 -f 3 21 11 0 0 -f 2 19 15 0 0 -f 2 30 5 0 0 -f 4 12 4 0 0 -.wood pieces -f 26 3 0 0 0 -f 27 4 10 0 0 -f 27 24 7 0 0 -f 17 30 15 0 0 -.kitchen -f 11 0 15 0 0 -f 13 0 12 0 0 -.sofa and bed (alpha) -f 14 4 7 1 0 -f 10 24 11 1 0 -.glass and tables (alpha) -f 9 17 4 1 0 -f 16 6 4 1 0 -f 16 10 15 1 0 -f 15 22 15 1 0 -.plants (breakable) -f 6 0 6 2 1800 -f 6 12 10 2 1800 -f 7 17 0 2 1200 -f 7 15 15 2 1200 -f 8 13 15 2 2000 -f 8 24 5 2 2000 \ No newline at end of file diff --git a/games/cat_vs_roomba/resources/furniture.png b/games/cat_vs_roomba/resources/furniture.png deleted file mode 100644 index 7d040cfbb..000000000 Binary files a/games/cat_vs_roomba/resources/furniture.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/furset.txt b/games/cat_vs_roomba/resources/furset.txt deleted file mode 100644 index 306b24ca2..000000000 --- a/games/cat_vs_roomba/resources/furset.txt +++ /dev/null @@ -1,37 +0,0 @@ -.tileset -.first line -f 0 0 0 2 2 -f 1 2 0 2 2 -f 2 4 0 2 2 -f 3 6 0 2 2 -f 4 8 0 2 2 -f 5 10 0 2 2 -f 6 12 0 2 2 -f 7 14 0 2 2 -f 8 16 0 2 2 -f 9 18 0 5 6 -f 10 23 0 6 6 -.second line -f 11 0 2 10 2 -f 12 10 2 7 3 -.third line -f 13 0 4 2 3 -f 14 2 4 8 3 -f 15 10 5 2 2 -f 16 12 5 3 2 -f 17 15 5 2 2 -.cups -f 18 17 6 1 1 -f 19 18 6 1 1 -f 20 19 6 1 1 -f 21 20 6 1 1 -f 22 21 6 1 1 -f 23 22 6 1 1 -f 24 23 6 1 1 -f 25 24 6 1 1 -.four line -f 26 0 7 10 2 -f 27 10 7 8 2 -f 28 18 7 3 2 -f 29 21 7 3 2 -f 30 24 7 2 2 \ No newline at end of file diff --git a/games/cat_vs_roomba/resources/fursetid.png b/games/cat_vs_roomba/resources/fursetid.png deleted file mode 100644 index ccb31465f..000000000 Binary files a/games/cat_vs_roomba/resources/fursetid.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/fxcat01.wav b/games/cat_vs_roomba/resources/fxcat01.wav deleted file mode 100644 index 085903fb4..000000000 Binary files a/games/cat_vs_roomba/resources/fxcat01.wav and /dev/null differ diff --git a/games/cat_vs_roomba/resources/fxcat02.wav b/games/cat_vs_roomba/resources/fxcat02.wav deleted file mode 100644 index 41957a886..000000000 Binary files a/games/cat_vs_roomba/resources/fxcat02.wav and /dev/null differ diff --git a/games/cat_vs_roomba/resources/fxrobot01.wav b/games/cat_vs_roomba/resources/fxrobot01.wav deleted file mode 100644 index bd7c760fc..000000000 Binary files a/games/cat_vs_roomba/resources/fxrobot01.wav and /dev/null differ diff --git a/games/cat_vs_roomba/resources/fxrobot02.wav b/games/cat_vs_roomba/resources/fxrobot02.wav deleted file mode 100644 index 7aff7537f..000000000 Binary files a/games/cat_vs_roomba/resources/fxrobot02.wav and /dev/null differ diff --git a/games/cat_vs_roomba/resources/fxrobot03.wav b/games/cat_vs_roomba/resources/fxrobot03.wav deleted file mode 100644 index b97a57df7..000000000 Binary files a/games/cat_vs_roomba/resources/fxrobot03.wav and /dev/null differ diff --git a/games/cat_vs_roomba/resources/roomba.png b/games/cat_vs_roomba/resources/roomba.png deleted file mode 100644 index 899ecd5ea..000000000 Binary files a/games/cat_vs_roomba/resources/roomba.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/star.fnt b/games/cat_vs_roomba/resources/star.fnt deleted file mode 100644 index 48f4c37dd..000000000 --- a/games/cat_vs_roomba/resources/star.fnt +++ /dev/null @@ -1,139 +0,0 @@ -info face="Starcatcher" size=-64 bold=0 italic=0 charset="ANSI" unicode=0 stretchH=100 smooth=1 aa=1 padding=4,4,4,4 spacing=1,1 outline=0 -common lineHeight=63 base=50 scaleW=512 scaleH=512 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4 -page id=0 file="star.png" -chars count=135 -char id=32 x=416 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=33 x=347 y=360 width=17 height=71 xoffset=-4 yoffset=-4 xadvance=9 page=0 chnl=15 -char id=35 x=183 y=0 width=48 height=71 xoffset=-4 yoffset=-4 xadvance=40 page=0 chnl=15 -char id=36 x=328 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=37 x=67 y=0 width=62 height=71 xoffset=-4 yoffset=-4 xadvance=55 page=0 chnl=15 -char id=38 x=488 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=39 x=266 y=360 width=21 height=71 xoffset=-4 yoffset=-4 xadvance=13 page=0 chnl=15 -char id=40 x=471 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=41 x=387 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=42 x=415 y=0 width=42 height=71 xoffset=-4 yoffset=-4 xadvance=34 page=0 chnl=15 -char id=43 x=403 y=216 width=31 height=71 xoffset=-4 yoffset=-4 xadvance=23 page=0 chnl=15 -char id=44 x=309 y=360 width=18 height=71 xoffset=-4 yoffset=-4 xadvance=10 page=0 chnl=15 -char id=45 x=82 y=360 width=26 height=71 xoffset=-4 yoffset=-4 xadvance=18 page=0 chnl=15 -char id=46 x=365 y=360 width=16 height=71 xoffset=-4 yoffset=-4 xadvance=7 page=0 chnl=15 -char id=47 x=155 y=288 width=29 height=71 xoffset=-4 yoffset=-4 xadvance=21 page=0 chnl=15 -char id=48 x=38 y=144 width=36 height=71 xoffset=-4 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=49 x=188 y=360 width=25 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=50 x=339 y=216 width=31 height=71 xoffset=-4 yoffset=-4 xadvance=23 page=0 chnl=15 -char id=51 x=0 y=288 width=30 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=52 x=35 y=216 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=53 x=105 y=216 width=33 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=54 x=207 y=216 width=32 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=55 x=433 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=56 x=468 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=57 x=0 y=216 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=58 x=399 y=360 width=16 height=71 xoffset=-4 yoffset=-4 xadvance=7 page=0 chnl=15 -char id=59 x=328 y=360 width=18 height=71 xoffset=-4 yoffset=-4 xadvance=10 page=0 chnl=15 -char id=60 x=185 y=144 width=35 height=71 xoffset=-4 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=61 x=371 y=216 width=31 height=71 xoffset=-4 yoffset=-4 xadvance=23 page=0 chnl=15 -char id=62 x=221 y=144 width=35 height=71 xoffset=-4 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=63 x=398 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=25 page=0 chnl=15 -char id=64 x=130 y=0 width=52 height=71 xoffset=-4 yoffset=-4 xadvance=44 page=0 chnl=15 -char id=65 x=445 y=72 width=37 height=71 xoffset=-4 yoffset=-4 xadvance=29 page=0 chnl=15 -char id=66 x=209 y=72 width=40 height=71 xoffset=-4 yoffset=-4 xadvance=32 page=0 chnl=15 -char id=67 x=173 y=216 width=33 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=68 x=250 y=72 width=39 height=71 xoffset=-4 yoffset=-4 xadvance=31 page=0 chnl=15 -char id=69 x=306 y=216 width=32 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=70 x=149 y=144 width=35 height=71 xoffset=-4 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=71 x=112 y=144 width=36 height=71 xoffset=-4 yoffset=-4 xadvance=28 page=0 chnl=15 -char id=72 x=458 y=0 width=42 height=71 xoffset=-4 yoffset=-4 xadvance=34 page=0 chnl=15 -char id=73 x=288 y=360 width=20 height=71 xoffset=-4 yoffset=-4 xadvance=12 page=0 chnl=15 -char id=74 x=257 y=144 width=35 height=71 xoffset=-4 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=75 x=0 y=144 width=37 height=71 xoffset=-4 yoffset=-4 xadvance=29 page=0 chnl=15 -char id=76 x=139 y=216 width=33 height=71 xoffset=-4 yoffset=-4 xadvance=25 page=0 chnl=15 -char id=77 x=85 y=72 width=41 height=71 xoffset=-4 yoffset=-4 xadvance=33 page=0 chnl=15 -char id=78 x=371 y=0 width=43 height=71 xoffset=-4 yoffset=-4 xadvance=35 page=0 chnl=15 -char id=79 x=168 y=72 width=40 height=71 xoffset=-4 yoffset=-4 xadvance=31 page=0 chnl=15 -char id=80 x=75 y=144 width=36 height=71 xoffset=-4 yoffset=-4 xadvance=28 page=0 chnl=15 -char id=81 x=280 y=0 width=45 height=71 xoffset=-4 yoffset=-4 xadvance=37 page=0 chnl=15 -char id=82 x=369 y=72 width=37 height=71 xoffset=-4 yoffset=-4 xadvance=29 page=0 chnl=15 -char id=83 x=70 y=216 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=84 x=43 y=72 width=41 height=71 xoffset=-4 yoffset=-4 xadvance=33 page=0 chnl=15 -char id=85 x=0 y=72 width=42 height=71 xoffset=-4 yoffset=-4 xadvance=34 page=0 chnl=15 -char id=86 x=326 y=0 width=44 height=71 xoffset=-4 yoffset=-4 xadvance=36 page=0 chnl=15 -char id=87 x=232 y=0 width=47 height=71 xoffset=-4 yoffset=-4 xadvance=39 page=0 chnl=15 -char id=88 x=127 y=72 width=40 height=71 xoffset=-4 yoffset=-4 xadvance=33 page=0 chnl=15 -char id=89 x=290 y=72 width=39 height=71 xoffset=-4 yoffset=-4 xadvance=31 page=0 chnl=15 -char id=90 x=330 y=72 width=38 height=71 xoffset=-4 yoffset=-4 xadvance=30 page=0 chnl=15 -char id=91 x=499 y=288 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=92 x=109 y=360 width=26 height=71 xoffset=-4 yoffset=-4 xadvance=18 page=0 chnl=15 -char id=93 x=499 y=216 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=97 x=302 y=288 width=28 height=71 xoffset=-4 yoffset=-4 xadvance=20 page=0 chnl=15 -char id=98 x=415 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=99 x=136 y=360 width=25 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=100 x=124 y=288 width=30 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=101 x=162 y=360 width=25 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=102 x=443 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=103 x=0 y=360 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=104 x=240 y=216 width=32 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=105 x=382 y=360 width=16 height=71 xoffset=-4 yoffset=-4 xadvance=8 page=0 chnl=15 -char id=106 x=359 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=18 page=0 chnl=15 -char id=107 x=483 y=72 width=28 height=71 xoffset=-4 yoffset=-4 xadvance=20 page=0 chnl=15 -char id=108 x=55 y=360 width=26 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=109 x=435 y=216 width=31 height=71 xoffset=-4 yoffset=-4 xadvance=23 page=0 chnl=15 -char id=110 x=273 y=216 width=32 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=111 x=31 y=288 width=30 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=112 x=331 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=113 x=363 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=114 x=273 y=288 width=28 height=71 xoffset=-4 yoffset=-4 xadvance=20 page=0 chnl=15 -char id=115 x=28 y=360 width=26 height=71 xoffset=-4 yoffset=-4 xadvance=18 page=0 chnl=15 -char id=116 x=62 y=288 width=30 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=117 x=93 y=288 width=30 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=118 x=467 y=216 width=31 height=71 xoffset=-4 yoffset=-4 xadvance=23 page=0 chnl=15 -char id=119 x=293 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=120 x=185 y=288 width=29 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=121 x=215 y=288 width=28 height=71 xoffset=-4 yoffset=-4 xadvance=20 page=0 chnl=15 -char id=122 x=244 y=288 width=28 height=71 xoffset=-4 yoffset=-4 xadvance=20 page=0 chnl=15 -char id=123 x=428 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=124 x=440 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=125 x=452 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=126 x=0 y=0 width=66 height=71 xoffset=-4 yoffset=-4 xadvance=58 page=0 chnl=15 -char id=162 x=464 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=163 x=407 y=72 width=37 height=71 xoffset=-4 yoffset=-4 xadvance=29 page=0 chnl=15 -char id=167 x=476 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=171 x=214 y=360 width=25 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=187 x=240 y=360 width=25 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=191 x=500 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=192 x=0 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=193 x=12 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=194 x=24 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=196 x=36 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=199 x=48 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=200 x=60 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=201 x=72 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=202 x=84 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=203 x=96 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=206 x=108 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=207 x=120 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=209 x=132 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=211 x=144 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=212 x=156 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=214 x=168 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=217 x=180 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=218 x=192 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=219 x=204 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=220 x=216 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=223 x=228 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=224 x=240 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=225 x=252 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=226 x=264 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=228 x=276 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=231 x=288 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=232 x=300 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=233 x=312 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=234 x=324 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=235 x=336 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=238 x=348 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=239 x=360 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=243 x=372 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=244 x=384 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=246 x=396 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=249 x=408 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=250 x=420 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=251 x=432 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=252 x=444 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 diff --git a/games/cat_vs_roomba/resources/star.png b/games/cat_vs_roomba/resources/star.png deleted file mode 100644 index 682c5f0fd..000000000 Binary files a/games/cat_vs_roomba/resources/star.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/star2.fnt b/games/cat_vs_roomba/resources/star2.fnt deleted file mode 100644 index 3238321db..000000000 --- a/games/cat_vs_roomba/resources/star2.fnt +++ /dev/null @@ -1,139 +0,0 @@ -info face="Starcatcher" size=-64 bold=0 italic=0 charset="ANSI" unicode=0 stretchH=100 smooth=1 aa=1 padding=4,4,4,4 spacing=1,1 outline=0 -common lineHeight=63 base=50 scaleW=512 scaleH=512 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4 -page id=0 file="star2.png" -chars count=135 -char id=32 x=416 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=33 x=347 y=360 width=17 height=71 xoffset=-4 yoffset=-4 xadvance=9 page=0 chnl=15 -char id=35 x=183 y=0 width=48 height=71 xoffset=-4 yoffset=-4 xadvance=40 page=0 chnl=15 -char id=36 x=328 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=37 x=67 y=0 width=62 height=71 xoffset=-4 yoffset=-4 xadvance=55 page=0 chnl=15 -char id=38 x=488 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=39 x=266 y=360 width=21 height=71 xoffset=-4 yoffset=-4 xadvance=13 page=0 chnl=15 -char id=40 x=471 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=41 x=387 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=42 x=415 y=0 width=42 height=71 xoffset=-4 yoffset=-4 xadvance=34 page=0 chnl=15 -char id=43 x=403 y=216 width=31 height=71 xoffset=-4 yoffset=-4 xadvance=23 page=0 chnl=15 -char id=44 x=309 y=360 width=18 height=71 xoffset=-4 yoffset=-4 xadvance=10 page=0 chnl=15 -char id=45 x=82 y=360 width=26 height=71 xoffset=-4 yoffset=-4 xadvance=18 page=0 chnl=15 -char id=46 x=365 y=360 width=16 height=71 xoffset=-4 yoffset=-4 xadvance=7 page=0 chnl=15 -char id=47 x=155 y=288 width=29 height=71 xoffset=-4 yoffset=-4 xadvance=21 page=0 chnl=15 -char id=48 x=38 y=144 width=36 height=71 xoffset=-4 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=49 x=188 y=360 width=25 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=50 x=339 y=216 width=31 height=71 xoffset=-4 yoffset=-4 xadvance=23 page=0 chnl=15 -char id=51 x=0 y=288 width=30 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=52 x=35 y=216 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=53 x=105 y=216 width=33 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=54 x=207 y=216 width=32 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=55 x=433 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=56 x=468 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=57 x=0 y=216 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=58 x=399 y=360 width=16 height=71 xoffset=-4 yoffset=-4 xadvance=7 page=0 chnl=15 -char id=59 x=328 y=360 width=18 height=71 xoffset=-4 yoffset=-4 xadvance=10 page=0 chnl=15 -char id=60 x=185 y=144 width=35 height=71 xoffset=-4 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=61 x=371 y=216 width=31 height=71 xoffset=-4 yoffset=-4 xadvance=23 page=0 chnl=15 -char id=62 x=221 y=144 width=35 height=71 xoffset=-4 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=63 x=398 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=25 page=0 chnl=15 -char id=64 x=130 y=0 width=52 height=71 xoffset=-4 yoffset=-4 xadvance=44 page=0 chnl=15 -char id=65 x=445 y=72 width=37 height=71 xoffset=-4 yoffset=-4 xadvance=29 page=0 chnl=15 -char id=66 x=209 y=72 width=40 height=71 xoffset=-4 yoffset=-4 xadvance=32 page=0 chnl=15 -char id=67 x=173 y=216 width=33 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=68 x=250 y=72 width=39 height=71 xoffset=-4 yoffset=-4 xadvance=31 page=0 chnl=15 -char id=69 x=306 y=216 width=32 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=70 x=149 y=144 width=35 height=71 xoffset=-4 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=71 x=112 y=144 width=36 height=71 xoffset=-4 yoffset=-4 xadvance=28 page=0 chnl=15 -char id=72 x=458 y=0 width=42 height=71 xoffset=-4 yoffset=-4 xadvance=34 page=0 chnl=15 -char id=73 x=288 y=360 width=20 height=71 xoffset=-4 yoffset=-4 xadvance=12 page=0 chnl=15 -char id=74 x=257 y=144 width=35 height=71 xoffset=-4 yoffset=-4 xadvance=27 page=0 chnl=15 -char id=75 x=0 y=144 width=37 height=71 xoffset=-4 yoffset=-4 xadvance=29 page=0 chnl=15 -char id=76 x=139 y=216 width=33 height=71 xoffset=-4 yoffset=-4 xadvance=25 page=0 chnl=15 -char id=77 x=85 y=72 width=41 height=71 xoffset=-4 yoffset=-4 xadvance=33 page=0 chnl=15 -char id=78 x=371 y=0 width=43 height=71 xoffset=-4 yoffset=-4 xadvance=35 page=0 chnl=15 -char id=79 x=168 y=72 width=40 height=71 xoffset=-4 yoffset=-4 xadvance=31 page=0 chnl=15 -char id=80 x=75 y=144 width=36 height=71 xoffset=-4 yoffset=-4 xadvance=28 page=0 chnl=15 -char id=81 x=280 y=0 width=45 height=71 xoffset=-4 yoffset=-4 xadvance=37 page=0 chnl=15 -char id=82 x=369 y=72 width=37 height=71 xoffset=-4 yoffset=-4 xadvance=29 page=0 chnl=15 -char id=83 x=70 y=216 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=84 x=43 y=72 width=41 height=71 xoffset=-4 yoffset=-4 xadvance=33 page=0 chnl=15 -char id=85 x=0 y=72 width=42 height=71 xoffset=-4 yoffset=-4 xadvance=34 page=0 chnl=15 -char id=86 x=326 y=0 width=44 height=71 xoffset=-4 yoffset=-4 xadvance=36 page=0 chnl=15 -char id=87 x=232 y=0 width=47 height=71 xoffset=-4 yoffset=-4 xadvance=39 page=0 chnl=15 -char id=88 x=127 y=72 width=40 height=71 xoffset=-4 yoffset=-4 xadvance=33 page=0 chnl=15 -char id=89 x=290 y=72 width=39 height=71 xoffset=-4 yoffset=-4 xadvance=31 page=0 chnl=15 -char id=90 x=330 y=72 width=38 height=71 xoffset=-4 yoffset=-4 xadvance=30 page=0 chnl=15 -char id=91 x=499 y=288 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=92 x=109 y=360 width=26 height=71 xoffset=-4 yoffset=-4 xadvance=18 page=0 chnl=15 -char id=93 x=499 y=216 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=97 x=302 y=288 width=28 height=71 xoffset=-4 yoffset=-4 xadvance=20 page=0 chnl=15 -char id=98 x=415 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=99 x=136 y=360 width=25 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=100 x=124 y=288 width=30 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=101 x=162 y=360 width=25 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=102 x=443 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=103 x=0 y=360 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=104 x=240 y=216 width=32 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=105 x=382 y=360 width=16 height=71 xoffset=-4 yoffset=-4 xadvance=8 page=0 chnl=15 -char id=106 x=359 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=18 page=0 chnl=15 -char id=107 x=483 y=72 width=28 height=71 xoffset=-4 yoffset=-4 xadvance=20 page=0 chnl=15 -char id=108 x=55 y=360 width=26 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=109 x=435 y=216 width=31 height=71 xoffset=-4 yoffset=-4 xadvance=23 page=0 chnl=15 -char id=110 x=273 y=216 width=32 height=71 xoffset=-4 yoffset=-4 xadvance=24 page=0 chnl=15 -char id=111 x=31 y=288 width=30 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=112 x=331 y=288 width=27 height=71 xoffset=-4 yoffset=-4 xadvance=19 page=0 chnl=15 -char id=113 x=363 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=114 x=273 y=288 width=28 height=71 xoffset=-4 yoffset=-4 xadvance=20 page=0 chnl=15 -char id=115 x=28 y=360 width=26 height=71 xoffset=-4 yoffset=-4 xadvance=18 page=0 chnl=15 -char id=116 x=62 y=288 width=30 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=117 x=93 y=288 width=30 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=118 x=467 y=216 width=31 height=71 xoffset=-4 yoffset=-4 xadvance=23 page=0 chnl=15 -char id=119 x=293 y=144 width=34 height=71 xoffset=-4 yoffset=-4 xadvance=26 page=0 chnl=15 -char id=120 x=185 y=288 width=29 height=71 xoffset=-4 yoffset=-4 xadvance=22 page=0 chnl=15 -char id=121 x=215 y=288 width=28 height=71 xoffset=-4 yoffset=-4 xadvance=20 page=0 chnl=15 -char id=122 x=244 y=288 width=28 height=71 xoffset=-4 yoffset=-4 xadvance=20 page=0 chnl=15 -char id=123 x=428 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=124 x=440 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=125 x=452 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=126 x=0 y=0 width=66 height=71 xoffset=-4 yoffset=-4 xadvance=58 page=0 chnl=15 -char id=162 x=464 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=163 x=407 y=72 width=37 height=71 xoffset=-4 yoffset=-4 xadvance=29 page=0 chnl=15 -char id=167 x=476 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=171 x=214 y=360 width=25 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=187 x=240 y=360 width=25 height=71 xoffset=-4 yoffset=-4 xadvance=17 page=0 chnl=15 -char id=191 x=500 y=360 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=192 x=0 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=193 x=12 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=194 x=24 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=196 x=36 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=199 x=48 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=200 x=60 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=201 x=72 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=202 x=84 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=203 x=96 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=206 x=108 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=207 x=120 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=209 x=132 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=211 x=144 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=212 x=156 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=214 x=168 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=217 x=180 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=218 x=192 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=219 x=204 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=220 x=216 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=223 x=228 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=224 x=240 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=225 x=252 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=226 x=264 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=228 x=276 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=231 x=288 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=232 x=300 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=233 x=312 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=234 x=324 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=235 x=336 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=238 x=348 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=239 x=360 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=243 x=372 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=244 x=384 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=246 x=396 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=249 x=408 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=250 x=420 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=251 x=432 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 -char id=252 x=444 y=432 width=11 height=71 xoffset=-5 yoffset=-4 xadvance=1 page=0 chnl=15 diff --git a/games/cat_vs_roomba/resources/star2.png b/games/cat_vs_roomba/resources/star2.png deleted file mode 100644 index cd0074883..000000000 Binary files a/games/cat_vs_roomba/resources/star2.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/title_cat.png b/games/cat_vs_roomba/resources/title_cat.png deleted file mode 100644 index 01b88b0f8..000000000 Binary files a/games/cat_vs_roomba/resources/title_cat.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/title_roomba.png b/games/cat_vs_roomba/resources/title_roomba.png deleted file mode 100644 index dedf0fe34..000000000 Binary files a/games/cat_vs_roomba/resources/title_roomba.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/title_vs.png b/games/cat_vs_roomba/resources/title_vs.png deleted file mode 100644 index 742bf92c8..000000000 Binary files a/games/cat_vs_roomba/resources/title_vs.png and /dev/null differ diff --git a/games/cat_vs_roomba/resources/tracemap.png b/games/cat_vs_roomba/resources/tracemap.png deleted file mode 100644 index 228221c04..000000000 Binary files a/games/cat_vs_roomba/resources/tracemap.png and /dev/null differ diff --git a/games/cat_vs_roomba/roomba.c b/games/cat_vs_roomba/roomba.c deleted file mode 100644 index 303e7127a..000000000 --- a/games/cat_vs_roomba/roomba.c +++ /dev/null @@ -1,291 +0,0 @@ -/******************************************************************************************* -* -* CAT VS ROOMBA [GLOBAL GAME JAM 2019] -* -* Ah! Home, sweet home! Time for some automatic cleaning... -* if the worst enemy of Roomba allows it... be careful with Cat! -* -* This game has been created using raylib 2.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include "screens/screens.h" // NOTE: Defines global variable: currentScreen - -#if defined(PLATFORM_WEB) - #include -#endif - -GameScreen currentScreen = 0; -Font font = { 0 }; -Font font2 = { 0 }; -Music music = { 0 }; -Sound fxCoin = { 0 }; -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- -const int screenWidth = 1280; -#if defined(TILE_VIEWER_MODE) -const int screenHeight = 1080; -#else -const int screenHeight = 720; -#endif - -// Required variables to manage screen transitions (fade-in, fade-out) -static float transAlpha = 0.0f; -static bool onTransition = false; -static bool transFadeOut = false; -static int transFromScreen = -1; -static int transToScreen = -1; - -// NOTE: Some global variables that require to be visible for all screens, -// are defined in screens.h (i.e. currentScreen) - -//---------------------------------------------------------------------------------- -// Local Functions Declaration -//---------------------------------------------------------------------------------- -static void ChangeToScreen(int screen); // No transition effect - -static void TransitionToScreen(int screen); -static void UpdateTransition(void); -static void DrawTransition(void); - -static void UpdateDrawFrame(void); // Update and Draw one frame - -//---------------------------------------------------------------------------------- -// Main entry point -//---------------------------------------------------------------------------------- -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "CAT VS ROOMBA [GGJ19]"); - - // Global data loading (assets that must be available in all screens, i.e. fonts) - InitAudioDevice(); - - font = LoadFont("resources/star.fnt"); - font2 = LoadFont("resources/star2.fnt"); - music = LoadMusicStream("resources/cat_mouse.mod"); - fxCoin = LoadSound("resources/coin.wav"); - - SetMusicVolume(music, 1.0f); - PlayMusicStream(music); - - // Setup and Init first screen - currentScreen = LOGO; - InitLogoScreen(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - UpdateDrawFrame(); - } -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload current screen data before closing - switch (currentScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Unload all global loaded data (i.e. fonts) here! - UnloadFont(font); - UnloadFont(font2); - UnloadMusicStream(music); - UnloadSound(fxCoin); - - CloseAudioDevice(); // Close audio context - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//---------------------------------------------------------------------------------- -// Module specific Functions Definition -//---------------------------------------------------------------------------------- - -// Change to next screen, no transition -static void ChangeToScreen(int screen) -{ - // Unload current screen - switch (currentScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Init next screen - switch (screen) - { - case LOGO: InitLogoScreen(); break; - case TITLE: InitTitleScreen(); break; - case GAMEPLAY: InitGameplayScreen(); break; - case ENDING: InitEndingScreen(); break; - default: break; - } - - currentScreen = screen; -} - -// Define transition to next screen -static void TransitionToScreen(int screen) -{ - onTransition = true; - transFadeOut = false; - transFromScreen = currentScreen; - transToScreen = screen; - transAlpha = 0.0f; -} - -// Update transition effect -static void UpdateTransition(void) -{ - if (!transFadeOut) - { - transAlpha += 0.02f; - - // NOTE: Due to float internal representation, condition jumps on 1.0f instead of 1.05f - // For that reason we compare against 1.01f, to avoid last frame loading stop - if (transAlpha > 1.01f) - { - transAlpha = 1.0f; - - // Unload current screen - switch (transFromScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Load next screen - switch (transToScreen) - { - case LOGO: InitLogoScreen(); break; - case TITLE: InitTitleScreen(); break; - case GAMEPLAY: InitGameplayScreen(); break; - case ENDING: InitEndingScreen(); break; - default: break; - } - - currentScreen = transToScreen; - - // Activate fade out effect to next loaded screen - transFadeOut = true; - } - } - else // Transition fade out logic - { - transAlpha -= 0.02f; - - if (transAlpha < -0.01f) - { - transAlpha = 0.0f; - transFadeOut = false; - onTransition = false; - transFromScreen = -1; - transToScreen = -1; - } - } -} - -// Draw transition effect (full-screen rectangle) -static void DrawTransition(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha)); -} - -// Update and draw game frame -static void UpdateDrawFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - UpdateMusicStream(music); // NOTE: Music keeps playing between screens - - if (!onTransition) - { - switch(currentScreen) - { - case LOGO: - { - UpdateLogoScreen(); - - if (FinishLogoScreen()) TransitionToScreen(TITLE); - - } break; - case TITLE: - { - UpdateTitleScreen(); - - if (FinishTitleScreen() == 1) TransitionToScreen(OPTIONS); - else if (FinishTitleScreen() == 2) TransitionToScreen(GAMEPLAY); - - } break; - case GAMEPLAY: - { - UpdateGameplayScreen(); - - if (FinishGameplayScreen() == 1) TransitionToScreen(ENDING); - //else if (FinishGameplayScreen() == 2) TransitionToScreen(TITLE); - - } break; - case ENDING: - { - UpdateEndingScreen(); - - if (FinishEndingScreen() == 1) TransitionToScreen(TITLE); - - } break; - default: break; - } - } - else UpdateTransition(); // Update transition (fade-in, fade-out) - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch(currentScreen) - { - case LOGO: DrawLogoScreen(); break; - case TITLE: DrawTitleScreen(); break; - case GAMEPLAY: DrawGameplayScreen(); break; - case ENDING: DrawEndingScreen(); break; - default: break; - } - - // Draw full screen rectangle in front of everything - if (onTransition) DrawTransition(); - - //DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- -} diff --git a/games/cat_vs_roomba/screens/screen_ending.c b/games/cat_vs_roomba/screens/screen_ending.c deleted file mode 100644 index 466d9b916..000000000 --- a/games/cat_vs_roomba/screens/screen_ending.c +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Ending Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Ending screen global variables -static int framesCounter; -static int finishScreen; - -static int scrollPositionX; - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Ending Screen Initialization logic -void InitEndingScreen(void) -{ - // TODO: Initialize ENDING screen variables here! - framesCounter = 0; - finishScreen = 0; - - PlayMusicStream(music); -} - -// Ending Screen Update logic -void UpdateEndingScreen(void) -{ - framesCounter++; - - scrollPositionX -= 5; - if (scrollPositionX < -GetScreenWidth()) scrollPositionX = 0; - - // Press enter or tap to return to TITLE screen - if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) - { - finishScreen = 1; - PlaySound(fxCoin); - } -} - -// Ending Screen Draw logic -void DrawEndingScreen(void) -{ - for (int i = 0; i < 64*2*2; i++) - { - DrawRectangle(64*i + scrollPositionX, 0, 64, GetScreenHeight(), (i%2 == 0)? GetColor(0xf3726dff) : GetColor(0xffcf6bff)); - } - - if (result == 0) DrawTextEx(font2, "YOU LOOSE...", (Vector2){ 350, 200 }, font2.baseSize*2, 2, WHITE); - else if (result == 1) DrawTextEx(font, "YOU WIN!!!", (Vector2){ 380, 200 }, font.baseSize*2, 2, WHITE); - - // Draw score - DrawTextEx(font, FormatText("FINAL SCORE: %i", score), (Vector2){ 400, 360 }, font2.baseSize, 2, WHITE); - - if ((framesCounter/30)%2) DrawTextEx(font2, "PRESS ENTER to TITLE", (Vector2){ 340, 550 }, font2.baseSize, 2, WHITE); -} - -// Ending Screen Unload logic -void UnloadEndingScreen(void) -{ - // TODO: Unload ENDING screen variables here! -} - -// Ending Screen should finish? -int FinishEndingScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/cat_vs_roomba/screens/screen_gameplay.c b/games/cat_vs_roomba/screens/screen_gameplay.c deleted file mode 100644 index 4dd13856f..000000000 --- a/games/cat_vs_roomba/screens/screen_gameplay.c +++ /dev/null @@ -1,652 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include "raymath.h" - -#include - -#define TILE_REQUIRED_CLEAN_TIME 2 // Frames it takes to clean a dirt level -#define TILE_SCORE_BY_CLEANED_LEVEL 100 // Score by cleanied dirt level -#define TILE_REQUIRED_CLEAN_AREA 28*28 // Required are for actually cleaning tile - -#define TILE_SIZE 36 // Tile size, it should match texture -#define MAX_TILES_X 32 -#define MAX_TILES_Y 17 - -#define CAT_TARGET_RADIUS 3 // Target proximity radius -#define CAT_DIRT_CELL_RADIUS 2 // Cells around cat for dirt spreading - -#define TIME_LIMIT_SECONDS 180 // Time to complete the level in seconds - -#define MAX_SCORE_POPUPS 60 // Maximum simultaneous score pop-ups! - -//---------------------------------------------------------------------------------- -// Module types -//---------------------------------------------------------------------------------- -// One dirt tile type -typedef struct { - Vector2 position; // Relative to top-left corner - int level; // Dirtiness: 0-Clean, 1-2-3-Dirt levels - int state; // Current dirtiness state - int counter; // Frames counter for cleaning - //int time; // Time it takes to make it clean --> Depends on level - //int score; // It depends on the dirt level - bool cleaned; // If it was cleaned (not clean by default) -} Dirtile; - -// Score poping-up type -typedef struct { - Vector2 position; - int value; - float alpha; - bool enabled; -} ScorePopup; - -// Furniture tile set -typedef struct { - int id; // Furniture tile id - int posX; // Position X on tileset - int posY; // Position Y on tileset - int width; // Furniture piece width - int height; // Furniture piece height -} FurSet; - -// Furniture type -typedef struct { - int furId; // Tileset id - int cellX; // Cell position X - int cellY; // Cell position Y - int state; // 0-Block, 1-Alpha, 2-Breakable - int counter; // Counter in case of break -} Furniture; - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int timeLevelSeconds; -static bool levelFinished; -static int finishScreen; - -const Vector2 roomOffset = { 70, 70 }; - -static Texture2D roomba; -static Texture2D cat; -static Texture2D dirtiles; -static Texture2D furniture; - -#if defined(TILE_VIEWER_MODE) -static Texture2D tracemap; -static Texture2D fursetid; -#endif - -static Music catch; - -static Sound fxCat[2]; -static Sound fxRoomba[3]; - -static Vector2 roombaPosition = { 100, 100 }; -static Vector2 roombaSpeed = { 4, 4 }; -static int roombaTilePosX = 0, roombaTilePosY = 0; - -static Vector2 catPosition = { 0, 0 }; -static Vector2 catTargetPosition = { 0, 0 }; -static Vector2 catSpeed = { 3, 3 }; -static int catTilePosX = 0, catTilePosY = 0; -static bool catShouldMove = false; - -static Vector2 mousePosition = { 0, 0 }; -static int mouseTileX = -1, mouseTileY = -1; - -static Dirtile tiles[MAX_TILES_X*MAX_TILES_Y] = { 0 }; - -static ScorePopup popup[MAX_SCORE_POPUPS] = { 0 }; - -static FurSet furset[32] = { -1 }; -static Furniture furmap[40] = { -1 }; -static int furnitureCount = 0; - -// Furniture collisions map -// 0-block, 1-normal, 2-alpha, 3-breakable -static int furcolmap[MAX_TILES_X*MAX_TILES_Y] = { - 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,3,3,1,1,1,0,0,1,1,1,1,1,1,1,1, - 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,3,3,1,1,1,0,0,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 0,0,1,1,1,1,2,2,2,1,1,1,0,0,1,1,1,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1, - 0,0,1,1,1,1,2,2,2,1,1,1,0,0,1,1,1,2,2,2,1,1,1,1,3,3,1,1,1,1,0,0, - 3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,3,3,1,1,1,1,0,0, - 3,3,1,1,2,2,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,1,1,1,0,0,0,0,0,0,0,0, - 1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1,1,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0, - 1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1,1,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,0,0,0,0,0,0,0,0,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,0,0,0,0,0,0,0,0,3,3,1,1,1,1,1,1,1,0,0,1,2,2,2,2,2,2,1,1, - 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,2,2,2,2,2,2,1,1, - 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,1,1, - 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,1,1, - 0,0,0,0,0,0,0,0,0,0,2,2,2,3,3,3,3,1,1,0,0,1,2,2,2,2,2,2,2,2,0,0, - 0,0,0,0,0,0,0,0,0,0,2,2,2,3,3,3,3,1,1,0,0,1,2,2,2,2,2,2,2,2,0,0 }; - -static bool showObjective = false; - -//---------------------------------------------------------------------------------- -// Module Functions Definition -//---------------------------------------------------------------------------------- -static float GetTileCleanPercent(void); - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitGameplayScreen(void) -{ - // Initialize GAMEPLAY screen variables here! - framesCounter = 0; - finishScreen = 0; - timeLevelSeconds = TIME_LIMIT_SECONDS; - levelFinished = false; - - roomba = LoadTexture("resources/roomba.png"); - cat = LoadTexture("resources/cat.png"); - dirtiles = LoadTexture("resources/dirtiles.png"); - furniture = LoadTexture("resources/furniture.png"); - -#if defined(TILE_VIEWER_MODE) - tracemap = LoadTexture("resources/tracemap.png"); - fursetid = LoadTexture("resources/fursetid.png"); -#endif - - int furCount = 0; - FILE *fursetFile = fopen("resources/furset.txt", "rt"); - - if (fursetFile != NULL) - { - char buffer[512] = { 0 }; - - while (!feof(fursetFile)) - { - fgets(buffer, 512, fursetFile); - - switch (buffer[0]) - { - case 'f': - { - sscanf(buffer, "f %i %i %i %i %i", - &furset[furCount].id, - &furset[furCount].posX, - &furset[furCount].posY, - &furset[furCount].width, - &furset[furCount].height); - furCount++; - } break; - case '.': // This is a comment - default: break; - } - } - - fclose(fursetFile); - } - - // Position and size come in cell form, not pixels - for (int i = 0; i < furCount; i++) - { - furset[i].posX *= TILE_SIZE; - furset[i].posY *= TILE_SIZE; - furset[i].width *= TILE_SIZE; - furset[i].height *= TILE_SIZE; - } - - printf("Furniture SET elements read: %i\n", furCount); - - // Init furniture elements - FILE *furnitureFile = fopen("resources/furmap.txt", "rt"); - - if (furnitureFile != NULL) - { - char buffer[512] = { 0 }; - - while (!feof(furnitureFile)) - { - fgets(buffer, 512, furnitureFile); - - switch (buffer[0]) - { - case 'f': - { - sscanf(buffer, "f %i %i %i %i %i", - &furmap[furnitureCount].furId, - &furmap[furnitureCount].cellX, - &furmap[furnitureCount].cellY, - &furmap[furnitureCount].state, - &furmap[furnitureCount].counter); - furnitureCount++; - } break; - case '.': // This is a comment - default: break; - } - } - - fclose(furnitureFile); - } - - printf("Furniture MAP elements read: %i\n", furnitureCount); - - // Init dirt tiles - for (int y = 0; y < MAX_TILES_Y; y++) - { - for (int x = 0; x < MAX_TILES_X; x++) - { - tiles[y*MAX_TILES_X + x].position = (Vector2){ roomOffset.x + TILE_SIZE*x, roomOffset.y + TILE_SIZE*y }; - - if ((furcolmap[y*MAX_TILES_X + x] != 0) && - (furcolmap[y*MAX_TILES_X + x] != 3)) - { - // TODO: Level of dirtiness depends on difficulty level - // Adjust probability of every tile dirt level - int dirt = GetRandomValue(0, 100); - - if (dirt < 50) tiles[y*MAX_TILES_X + x].level = 0; // 50% probability - else if (dirt < 70) tiles[y*MAX_TILES_X + x].level = 1; // 20% probability - else if (dirt < 90) tiles[y*MAX_TILES_X + x].level = 2; // 10% probability - else if (dirt < 100) tiles[y*MAX_TILES_X + x].level = 3; // 10% probability - } - else tiles[y*MAX_TILES_X + x].level = 0; - - tiles[y*MAX_TILES_X + x].state = tiles[y*MAX_TILES_X + x].level; - tiles[y*MAX_TILES_X + x].counter = (tiles[y*MAX_TILES_X + x].level == 0)? 0 : TILE_REQUIRED_CLEAN_TIME; - tiles[y*MAX_TILES_X + x].cleaned = (tiles[y*MAX_TILES_X + x].level == 0)? true : false; - } - } - - // Init score popups - for (int i = 0; i < MAX_SCORE_POPUPS; i++) - { - popup[i].position = (Vector2){ 0, 0 }; - popup[i].value = TILE_SCORE_BY_CLEANED_LEVEL; - popup[i].enabled = false; - popup[i].alpha = 1.0f; - } - - // Init cat position - catPosition = (Vector2){ 30*TILE_SIZE + roomOffset.x, TILE_SIZE + roomOffset.y }; - catTargetPosition = catPosition; - - showObjective = true; - - // Load music and sounds - fxCat[0] = LoadSound("resources/fxcat01.wav"); - fxCat[1] = LoadSound("resources/fxcat02.wav"); - fxRoomba[0] = LoadSound("resources/fxrobot01.wav"); - fxRoomba[1] = LoadSound("resources/fxrobot02.wav"); - fxRoomba[2] = LoadSound("resources/fxrobot03.wav"); - - catch = LoadMusicStream("resources/catch22.mod"); - - StopMusicStream(music); - SetMusicVolume(catch, 0.6f); - PlayMusicStream(catch); - - result = 0; // Global variable: screens.h -} - -// Gameplay Screen Update logic -void UpdateGameplayScreen(void) -{ - UpdateMusicStream(catch); - - if (showObjective) - { - if (IsKeyPressed(KEY_ENTER)) - { - showObjective = false; - PlaySound(fxCoin); - } - - return; - } - - framesCounter++; - - if (framesCounter == 60) - { - timeLevelSeconds--; - - if (timeLevelSeconds == 0) - { - levelFinished = true; - finishScreen = 1; - PlaySound(fxCoin); - - if (GetTileCleanPercent() >= 80) result = 1; - } - - framesCounter = 0; - } - - mousePosition = GetMousePosition(); - mouseTileX = (int)floorf((mousePosition.x - roomOffset.x)/TILE_SIZE); - mouseTileY = (int)floorf((mousePosition.y - roomOffset.y)/TILE_SIZE); - - // Roomba movement logic - Vector2 prevPosition = roombaPosition; - - if (IsKeyDown(KEY_D)) roombaPosition.x += roombaSpeed.x; - else if (IsKeyDown(KEY_A)) roombaPosition.x -= roombaSpeed.x; - if (IsKeyDown(KEY_W)) roombaPosition.y -= roombaSpeed.y; - else if (IsKeyDown(KEY_S)) roombaPosition.y += roombaSpeed.y; - - // Verify current player position is valid or reset - roombaTilePosX = (int)(floorf(roombaPosition.x - roomOffset.x)/TILE_SIZE); - roombaTilePosY = (int)(floorf(roombaPosition.y - roomOffset.y)/TILE_SIZE); - if ((roombaPosition.x - roomba.width/2 < roomOffset.x) || - ((roombaPosition.x + roomba.width/2) >= (roomOffset.x + MAX_TILES_X*TILE_SIZE)) || - (roombaPosition.y - roomba.height/2 < roomOffset.y) || - ((roombaPosition.y + roomba.height/2) >= (roomOffset.y + MAX_TILES_Y*TILE_SIZE)) || - (furcolmap[roombaTilePosY*MAX_TILES_X + roombaTilePosX] == 0) || - (furcolmap[roombaTilePosY*MAX_TILES_X + roombaTilePosX] == 3)) roombaPosition = prevPosition; - - // Dyson movement logic - // if (IsKeyDown(KEY_RIGHT)) dysonPosition.x += dysonSpeed.x; - // else if (IsKeyDown(KEY_LEFT)) dysonPosition.x -= dysonSpeed.x; - // if (IsKeyDown(KEY_UP)) dysonPosition.y -= dysonSpeed.y; - // else if (IsKeyDown(KEY_DOWN)) dysonPosition.y += dysonSpeed.y; - - // Check collision area between Roomba and dirt tiles to verify it's beeing cleaned - // TODO: OPTIMIZATION: Check only Roomba surrounding tiles - for (int y = 0; y < MAX_TILES_Y; y++) - { - for (int x = 0; x < MAX_TILES_X; x++) - { - // Check if tile requires cleaning - if (tiles[y*MAX_TILES_X + x].state > 0) - { - // TODO: Get better collision area measure, considering round roomba - Rectangle cleanRec = GetCollisionRec((Rectangle){ tiles[y*MAX_TILES_X + x].position.x, tiles[y*MAX_TILES_X + x].position.y, 36, 36 }, - (Rectangle){ roombaPosition.x - roomba.width/2, roombaPosition.y - roomba.height/2, roomba.width, roomba.height }); - - // Check Roomba is covering at least half of the tile - if ((cleanRec.width*cleanRec.height) > TILE_REQUIRED_CLEAN_AREA) - { - // Start cleaning tile - tiles[y*MAX_TILES_X + x].counter--; - - if (tiles[y*MAX_TILES_X + x].counter < 0) - { - tiles[y*MAX_TILES_X + x].state--; - - if (tiles[y*MAX_TILES_X + x].state == 0) - { - tiles[y*MAX_TILES_X + x].counter = 0; - score += tiles[y*MAX_TILES_X + x].level*TILE_SCORE_BY_CLEANED_LEVEL; - - // Show scoring popup, enable first ready! - for (int i = 0; i < MAX_SCORE_POPUPS; i++) - { - if (!popup[i].enabled) - { - popup[i].position = tiles[y*MAX_TILES_X + x].position; - popup[i].value = TILE_SCORE_BY_CLEANED_LEVEL*tiles[y*MAX_TILES_X + x].level; - popup[i].enabled = true; - popup[i].alpha = 1.0f; - break; - } - } - } - else tiles[y*MAX_TILES_X + x].counter = TILE_REQUIRED_CLEAN_TIME; - } - } - } - } - } - - // Update enabled popups! - for (int i = 0; i < MAX_SCORE_POPUPS; i++) - { - if (popup[i].enabled) - { - popup[i].position.y -= 2; - popup[i].alpha -= 0.015f; - - if (popup[i].alpha < 0.0f) popup[i].enabled = false; - } - } - - // Cat movement logic - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - // Check for a valid cell to move on - if ((mousePosition.x > roomOffset.x) && (mousePosition.x < (roomOffset.x + MAX_TILES_X*TILE_SIZE)) && - (mousePosition.y > roomOffset.y) && (mousePosition.y < (roomOffset.y + MAX_TILES_Y*TILE_SIZE)) && - furcolmap[mouseTileY*MAX_TILES_X + mouseTileX] != 0) - { - catTargetPosition = GetMousePosition(); - catShouldMove = true; - } - } - - if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) PlaySound(fxCat[GetRandomValue(0,1)]); - if (IsKeyPressed(KEY_SPACE)) PlaySound(fxRoomba[GetRandomValue(0,2)]); - - // Check if cat should move - if (catShouldMove) - { - if (CheckCollisionPointCircle(catPosition, catTargetPosition, CAT_TARGET_RADIUS)) - { - catShouldMove = false; - - // Spread dirt all around selected cell! - // NOTE: We consider cat drawing offset - catTilePosX = (int)floorf((catPosition.x - cat.width/2 - roomOffset.x)/TILE_SIZE) + 1; - catTilePosY = (int)floorf((catPosition.y - cat.height/2 - 10 - roomOffset.y)/TILE_SIZE) + 1; - - // Check if tile includes a dirt element - if (furcolmap[mouseTileY*MAX_TILES_X + mouseTileX] == 3) - { - for (int y = (catTilePosY - CAT_DIRT_CELL_RADIUS); y < (catTilePosY + CAT_DIRT_CELL_RADIUS + 1); y++) - { - for (int x = (catTilePosX - CAT_DIRT_CELL_RADIUS); x < (catTilePosX + CAT_DIRT_CELL_RADIUS + 1); x++) - { - if (((y >= 0) && (y < MAX_TILES_Y) && (x >= 0) && (x < MAX_TILES_X)) && - (tiles[y*MAX_TILES_X + x].state == 0) && - (furcolmap[y*MAX_TILES_X + x] != 0) && - (furcolmap[y*MAX_TILES_X + x] != 3)) - { - int dirt = GetRandomValue(0, 100); - - if (dirt < 50) tiles[y*MAX_TILES_X + x].level = 0; // 50% probability - else if (dirt < 70) tiles[y*MAX_TILES_X + x].level = 1; // 20% probability - else if (dirt < 90) tiles[y*MAX_TILES_X + x].level = 2; // 10% probability - else if (dirt < 100) tiles[y*MAX_TILES_X + x].level = 3; // 10% probability - - tiles[y*MAX_TILES_X + x].state = tiles[y*MAX_TILES_X + x].level; - tiles[y*MAX_TILES_X + x].counter = (tiles[y*MAX_TILES_X + x].level == 0)? 0 : TILE_REQUIRED_CLEAN_TIME; - tiles[y*MAX_TILES_X + x].cleaned = (tiles[y*MAX_TILES_X + x].level == 0)? true : false; - } - } - } - } - } - else - { - Vector2 dir = Vector2Subtract(catTargetPosition, catPosition); - Vector2 dirnorm = Vector2Normalize(dir); - - catPosition.x += catSpeed.x*dirnorm.x; - catPosition.y += catSpeed.y*dirnorm.y; - } - } - - if (levelFinished) - { - // TODO: Check level finished - } -} - -// Gameplay Screen Draw logic -void DrawGameplayScreen(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GetColor(0x57374cff)); - - // Draw tiles - for (int y = 0; y < MAX_TILES_Y; y++) - { - for (int x = 0; x < MAX_TILES_X; x++) - { - // Draw dirty tiles - DrawTextureRec(dirtiles, (Rectangle){ tiles[y*MAX_TILES_X + x].state*TILE_SIZE, 0, TILE_SIZE, TILE_SIZE }, - (Vector2){ roomOffset.x + TILE_SIZE*x, roomOffset.y + TILE_SIZE*y }, WHITE); - - // TODO: Draw possible walls - } - } - - // Draw starting point for roomba and cat - DrawTextureRec(furniture, (Rectangle){ furset[30].posX, furset[30].posY, furset[30].width, furset[30].height }, roomOffset, WHITE); - DrawTextureRec(furniture, (Rectangle){ furset[29].posX, furset[29].posY, furset[29].width, furset[29].height }, (Vector2){ roomOffset.x + 29*36, roomOffset.y }, WHITE); - - DrawTexture(roomba, roombaPosition.x - roomba.width/2, roombaPosition.y - roomba.height/2, WHITE); - DrawTexture(cat, catPosition.x - cat.width/2, catPosition.y - cat.height/2 - 10, WHITE); - - float furAlpha = 1.0f; - - // Draw home objects - for (int i = 0; i < furnitureCount; i++) - { - if (CheckCollisionCircleRec((Vector2){ roombaPosition.x - roomba.width/2, roombaPosition.y - roomba.height/2 }, roomba.width, - (Rectangle){ roomOffset.x + furmap[i].cellX*TILE_SIZE, roomOffset.y + furmap[i].cellY*TILE_SIZE, - furset[furmap[i].furId].width, furset[furmap[i].furId].height}) && (furmap[i].state == 1)) - { - DrawTextureRec(furniture, (Rectangle){ furset[furmap[i].furId].posX, furset[furmap[i].furId].posY, furset[furmap[i].furId].width, furset[furmap[i].furId].height }, - (Vector2){ roomOffset.x + furmap[i].cellX*TILE_SIZE, roomOffset.y + furmap[i].cellY*TILE_SIZE }, Fade(WHITE, 0.5f)); - } - else - { - DrawTextureRec(furniture, (Rectangle){ furset[furmap[i].furId].posX, furset[furmap[i].furId].posY, furset[furmap[i].furId].width, furset[furmap[i].furId].height }, - (Vector2){ roomOffset.x + furmap[i].cellX*TILE_SIZE, roomOffset.y + furmap[i].cellY*TILE_SIZE }, Fade(WHITE, furAlpha)); - } - } - -#if defined(TILE_VIEWER_MODE) - DrawTexture(tracemap, roomOffset.x, roomOffset.y, Fade(WHITE, 0.5f)); - DrawTexture(fursetid, 0, 720, WHITE); -#endif - - // TODO: If an object has been used by cat, draw it in gray - // Maybe add a tempo bar for reusing? - - // Draw UI - DrawTextEx(font2, "SCORE:", (Vector2){ 80, 10 }, font2.baseSize, 2, WHITE); - DrawTextEx(font, FormatText("%i", score), (Vector2){ 260, 10 }, font.baseSize, 2, WHITE); - DrawTextEx(font2, "CLEAN:", (Vector2){ 500, 10 }, font2.baseSize, 2, WHITE); - DrawTextEx(font, FormatText("%.2f%%", GetTileCleanPercent()), (Vector2){ 690, 10 }, font.baseSize, 2, WHITE); - DrawTextEx(font2, "TIME:", (Vector2){ 950, 10 }, font2.baseSize, 2, WHITE); - DrawTextEx(font, FormatText("%i:%02is", timeLevelSeconds/60, timeLevelSeconds%60), (Vector2){ 1100, 10 }, font.baseSize, 2, WHITE); - - // Debug information - //DrawText(FormatText("CatTilePos: [ %i, %i ]", catTilePosX, catTilePosY), roomOffset.x, 690, 20, RAYWHITE); - //DrawText(FormatText("MousePos: [ %i, %i ]", mouseTileX, mouseTileY), 400, 690, 20, RED); - //DrawText(FormatText("RoombaPos: [ %i, %i ]", roombaTilePosX, roombaTilePosY), 600, 690, 20, GREEN); - - if ((mouseTileY >= 0) && (mouseTileY < MAX_TILES_Y) && (mouseTileX >= 0) && (mouseTileX < MAX_TILES_X)) - { - DrawRectangleLinesEx((Rectangle){ tiles[mouseTileY*MAX_TILES_X + mouseTileX].position.x, - tiles[mouseTileY*MAX_TILES_X + mouseTileX].position.y, TILE_SIZE, TILE_SIZE }, 2, RED); - } - - // Draw enabled popups! - for (int i = 0; i < MAX_SCORE_POPUPS; i++) - { - if (popup[i].enabled) DrawText(FormatText("+%i", popup[i].value), popup[i].position.x, popup[i].position.y, 20, Fade(RED, popup[i].alpha)); - } - - // Show objective - if (showObjective) - { - DrawRectangle(0, 150, GetScreenWidth(), GetScreenHeight() - 300, Fade(DARKGRAY, 0.7f)); - DrawTextEx(font2, "OBJECTIVE:", (Vector2){ 500, 240 }, font2.baseSize, 2, WHITE); - DrawTextEx(font, "CLEAN 80% OF THE ROOM", (Vector2){ 300, 320 }, font.baseSize, 2, WHITE); - } - -} - -// Gameplay Screen Unload logic -void UnloadGameplayScreen(void) -{ - // Unload GAMEPLAY screen variables here! - UnloadTexture(roomba); - UnloadTexture(cat); - UnloadTexture(dirtiles); - UnloadTexture(furniture); - - UnloadSound(fxCat[0]); - UnloadSound(fxCat[1]); - UnloadSound(fxRoomba[0]); - UnloadSound(fxRoomba[1]); - UnloadSound(fxRoomba[2]); - - StopMusicStream(catch); - UnloadMusicStream(catch); -} - -// Gameplay Screen should finish? -int FinishGameplayScreen(void) -{ - return finishScreen; -} - -//---------------------------------------------------------------------------------- -// Module Functions Declaration -//---------------------------------------------------------------------------------- - -// Check how much cleaning we have done -static float GetTileCleanPercent(void) -{ - float value = 0; - - int tileLevelsToClean = 0; - int tileLevelsCleaned = 0; - - for (int y = 0; y < MAX_TILES_Y; y++) - { - for (int x = 0; x < MAX_TILES_X; x++) - { - if (tiles[y*MAX_TILES_X + x].level > 0) - { - tileLevelsToClean += tiles[y*MAX_TILES_X + x].level; - tileLevelsCleaned += tiles[y*MAX_TILES_X + x].state; - } - } - } - - value = ((float)(tileLevelsToClean - tileLevelsCleaned)/tileLevelsToClean)*100.0f; - - return value; -} \ No newline at end of file diff --git a/games/cat_vs_roomba/screens/screen_logo.c b/games/cat_vs_roomba/screens/screen_logo.c deleted file mode 100644 index 1d8fa9783..000000000 --- a/games/cat_vs_roomba/screens/screen_logo.c +++ /dev/null @@ -1,211 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Logo Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#define LOGO_RECS_SIDE 16 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Logo screen global variables -static int framesCounter = 0; -static int finishScreen = 0; - -static int logoPositionX = 0; -static int logoPositionY = 0; - -static int lettersCount = 0; - -static int topSideRecWidth = 0; -static int leftSideRecHeight = 0; - -static int bottomSideRecWidth = 0; -static int rightSideRecHeight = 0; - -static char raylib[8] = { 0 }; // raylib text array, max 8 letters -static int state = 0; // Tracking animation states (State Machine) -static float alpha = 1.0f; // Useful for fading - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Logo Screen Initialization logic -void InitLogoScreen(void) -{ - // Initialize LOGO screen variables here! - finishScreen = 0; - framesCounter = 0; - lettersCount = 0; - - logoPositionX = GetScreenWidth()/2 - 128; - logoPositionY = GetScreenHeight()/2 - 128; - - topSideRecWidth = LOGO_RECS_SIDE; - leftSideRecHeight = LOGO_RECS_SIDE; - bottomSideRecWidth = LOGO_RECS_SIDE; - rightSideRecHeight = LOGO_RECS_SIDE; - - for (int i = 0; i < 8; i++) raylib[i] = '\0'; - - state = 0; - alpha = 1.0f; -} - -// Logo Screen Update logic -void UpdateLogoScreen(void) -{ - // Update LOGO screen variables here! - if (state == 0) // State 0: Small box blinking - { - framesCounter++; - - if (framesCounter == 80) - { - state = 1; - framesCounter = 0; // Reset counter... will be used later... - } - } - else if (state == 1) // State 1: Top and left bars growing - { - topSideRecWidth += 8; - leftSideRecHeight += 8; - - if (topSideRecWidth == 256) state = 2; - } - else if (state == 2) // State 2: Bottom and right bars growing - { - bottomSideRecWidth += 8; - rightSideRecHeight += 8; - - if (bottomSideRecWidth == 256) state = 3; - } - else if (state == 3) // State 3: Letters appearing (one by one) - { - framesCounter++; - - if (framesCounter/10) // Every 12 frames, one more letter! - { - lettersCount++; - framesCounter = 0; - } - - switch (lettersCount) - { - case 1: raylib[0] = 'r'; break; - case 2: raylib[1] = 'a'; break; - case 3: raylib[2] = 'y'; break; - case 4: raylib[3] = 'l'; break; - case 5: raylib[4] = 'i'; break; - case 6: raylib[5] = 'b'; break; - default: break; - } - - // When all letters have appeared... - if (lettersCount >= 10) - { - state = 4; - framesCounter = 0; - } - } - else if (state == 4) - { - framesCounter++; - - if (framesCounter > 100) - { - alpha -= 0.02f; - - if (alpha <= 0.0f) - { - alpha = 0.0f; - finishScreen = 1; - } - } - } -} - -// Logo Screen Draw logic -void DrawLogoScreen(void) -{ - if (state == 0) - { - if ((framesCounter/10)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK); - } - else if (state == 1) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - } - else if (state == 2) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK); - } - else if (state == 3) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - } - else if (state == 4) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - - if (framesCounter > 20) DrawText("powered by", logoPositionX, logoPositionY - 27, 20, Fade(DARKGRAY, alpha)); - } -} - -// Logo Screen Unload logic -void UnloadLogoScreen(void) -{ - // Unload LOGO screen variables here! -} - -// Logo Screen should finish? -int FinishLogoScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/cat_vs_roomba/screens/screen_title.c b/games/cat_vs_roomba/screens/screen_title.c deleted file mode 100644 index 6acadce5a..000000000 --- a/games/cat_vs_roomba/screens/screen_title.c +++ /dev/null @@ -1,154 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Title Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Title screen global variables -static int framesCounter; -static int finishScreen; -static int state; - -static int scrollPositionX; - -static int catPosX; -static int roombaPosX; - -static float vsAlpha; -static float vsScale; - -static Texture2D cat; -static Texture2D vs; -static Texture2D roomba; - -//---------------------------------------------------------------------------------- -// Title Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Title Screen Initialization logic -void InitTitleScreen(void) -{ - // TODO: Initialize TITLE screen variables here! - framesCounter = 0; - finishScreen = 0; - - cat = LoadTexture("resources/title_cat.png"); - vs = LoadTexture("resources/title_vs.png"); - roomba = LoadTexture("resources/title_roomba.png"); - - state = 0; - catPosX = 1760; - roombaPosX = -700; - scrollPositionX = 0; - - vsAlpha = 0.0f; - vsScale = 10.0f; - - PlayMusicStream(music); -} - -// Title Screen Update logic -void UpdateTitleScreen(void) -{ - scrollPositionX -= 5; - if (scrollPositionX < -GetScreenWidth()) scrollPositionX = 0; - - if (state == 0) - { - catPosX -= 4; - roombaPosX += 3; - - if (catPosX < (GetScreenWidth()/2 - cat.width/2)) catPosX = (GetScreenWidth()/2 - cat.width/2); - if (roombaPosX > (GetScreenWidth()/2 - roomba.width/2)) roombaPosX = (GetScreenWidth()/2 - roomba.width/2); - - if ((catPosX == (GetScreenWidth()/2 - cat.width/2)) && (roombaPosX == (GetScreenWidth()/2 - roomba.width/2))) - { - state = 1; - framesCounter = 0; - } - } - else if (state == 1) - { - framesCounter++; - - vsScale -= 0.1f; - vsAlpha += 0.01f; - - if (vsScale < 1.0f) vsScale = 1.0f; - if (vsAlpha > 1.0f) vsAlpha = 1.0f; - - if (framesCounter > 160) - { - state = 2; - framesCounter = 0; - } - } - else if (state == 2) framesCounter++; - - // Press enter or tap to change to GAMEPLAY screen - if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) - { - //finishScreen = 1; // OPTIONS - finishScreen = 2; // GAMEPLAY - PlaySound(fxCoin); - } -} - -// Title Screen Draw logic -void DrawTitleScreen(void) -{ - for (int i = 0; i < 64*2*2; i++) - { - DrawRectangle(64*i + scrollPositionX, 0, 64, GetScreenHeight(), (i%2 == 0)? GetColor(0xf3726dff) : GetColor(0xffcf6bff)); - } - - DrawTexture(cat, catPosX, 80, WHITE); - DrawTexture(roomba, roombaPosX, 320, WHITE); - - if (state > 0) - { - DrawTexturePro(vs, (Rectangle){ 0, 0, vs.width, vs.height }, (Rectangle){ GetScreenWidth()/2, 300, vs.width*vsScale, vs.height*vsScale }, (Vector2){ vs.width/2*vsScale, vs.height/2*vsScale }, 0.0f, Fade(WHITE, vsAlpha)); - } - - if ((state == 2) && ((framesCounter/30)%2)) DrawTextEx(font2, "PRESS ENTER to START", (Vector2){ 340, 550 }, font2.baseSize, 2, WHITE); -} - -// Title Screen Unload logic -void UnloadTitleScreen(void) -{ - UnloadTexture(cat); - UnloadTexture(vs); - UnloadTexture(roomba); -} - -// Title Screen should finish? -int FinishTitleScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/cat_vs_roomba/screens/screens.h b/games/cat_vs_roomba/screens/screens.h deleted file mode 100644 index b15c9b549..000000000 --- a/games/cat_vs_roomba/screens/screens.h +++ /dev/null @@ -1,92 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Screens Functions Declarations (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef SCREENS_H -#define SCREENS_H - -//#define TILE_VIEWER_MODE - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum GameScreen { LOGO = 0, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -extern GameScreen currentScreen; -extern Font font; -extern Font font2; -extern Music music; -extern Sound fxCoin; - -int score; -int result; // 0-Loose, 1-Win - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLogoScreen(void); -void UpdateLogoScreen(void); -void DrawLogoScreen(void); -void UnloadLogoScreen(void); -int FinishLogoScreen(void); - -//---------------------------------------------------------------------------------- -// Title Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitTitleScreen(void); -void UpdateTitleScreen(void); -void DrawTitleScreen(void); -void UnloadTitleScreen(void); -int FinishTitleScreen(void); - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitGameplayScreen(void); -void UpdateGameplayScreen(void); -void DrawGameplayScreen(void); -void UnloadGameplayScreen(void); -int FinishGameplayScreen(void); - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitEndingScreen(void); -void UpdateEndingScreen(void); -void DrawEndingScreen(void); -void UnloadEndingScreen(void); -int FinishEndingScreen(void); - -#ifdef __cplusplus -} -#endif - -#endif // SCREENS_H \ No newline at end of file diff --git a/games/drturtle/00_drturtle_screens.c b/games/drturtle/00_drturtle_screens.c deleted file mode 100644 index fd9b3dada..000000000 --- a/games/drturtle/00_drturtle_screens.c +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Define current screen - GameScreen currentScreen = TITLE; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - } - - } break; - case GAMEPLAY: - { - // Press enter to change to ending screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = ENDING; - } - - } break; - case ENDING: - { - // Press enter to change to title screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = TITLE; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch (currentScreen) - { - case TITLE: - { - // Draw title screen - DrawRectangle(0, 0, screenWidth, screenHeight, GREEN); - DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN); - - } break; - case GAMEPLAY: - { - // Draw gameplay screen - DrawRectangle(0, 0, screenWidth, screenHeight, RED); - DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); - - } break; - case ENDING: - { - // Draw ending screen - DrawRectangle(0, 0, screenWidth, screenHeight, BLUE); - DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file diff --git a/games/drturtle/01_drturtle_scrolling.c b/games/drturtle/01_drturtle_scrolling.c deleted file mode 100644 index b8a091de4..000000000 --- a/games/drturtle/01_drturtle_scrolling.c +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= 8; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to ending screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = ENDING; - } - - } break; - case ENDING: - { - // Press enter to change to title screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = TITLE; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - DrawTexture(sea, seaScrolling, 0, BLUE); - DrawTexture(sea, screenWidth + seaScrolling, 0, BLUE); - - switch (currentScreen) - { - case TITLE: - { - // Draw title screen - DrawText("PRESS ENTER", 450, 420, 40, BLACK); - - } break; - case GAMEPLAY: - { - // Draw gameplay screen - DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); - - } break; - case ENDING: - { - // Draw ending screen - - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file diff --git a/games/drturtle/02_drturtle_player.c b/games/drturtle/02_drturtle_player.c deleted file mode 100644 index bf49abe59..000000000 --- a/games/drturtle/02_drturtle_player.c +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - Texture2D title = LoadTexture("resources/title.png"); - Texture2D turtle = LoadTexture("resources/turtle.png"); - Texture2D gamera = LoadTexture("resources/gamera.png"); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - // Define player variables - int playerRail = 1; - Rectangle playerBounds = { 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - bool gameraMode = false; - - // Define additional game variables - int framesCounter = 0; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - framesCounter++; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= 8; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - if (IsKeyPressed(KEY_SPACE)) gameraMode = !gameraMode; - if (IsKeyPressed(KEY_ENTER)) currentScreen = ENDING; - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - gameraMode = false; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, BLUE); - DrawTexture(sea, screenWidth + seaScrolling, 0, BLUE); - } - else - { - DrawTexture(sea, seaScrolling, 0, RED); - DrawTexture(sea, screenWidth + seaScrolling, 0, RED); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - //DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - DrawRectangle(380, 140, 500, 300, GRAY); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawText("PRESS ENTER", 480, 480, 40, BLACK); - - } break; - case GAMEPLAY: - { - // Draw player - //if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - //else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - if (!gameraMode) DrawRectangleRec(playerBounds, GREEN); - else DrawRectangleRec(playerBounds, ORANGE); - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawText("GAME OVER", 300, 200, 100, MAROON); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawText("PRESS ENTER to REPLAY", 400, 420, 30, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(gamera); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file diff --git a/games/drturtle/03_drturtle_enemies.c b/games/drturtle/03_drturtle_enemies.c deleted file mode 100644 index f659a19a3..000000000 --- a/games/drturtle/03_drturtle_enemies.c +++ /dev/null @@ -1,393 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - Texture2D title = LoadTexture("resources/title.png"); - Texture2D turtle = LoadTexture("resources/turtle.png"); - Texture2D gamera = LoadTexture("resources/gamera.png"); - Texture2D shark = LoadTexture("resources/shark.png"); - Texture2D orca = LoadTexture("resources/orca.png"); - Texture2D swhale = LoadTexture("resources/swhale.png"); - Texture2D fish = LoadTexture("resources/fish.png"); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - // Define player variables - int playerRail = 1; - Rectangle playerBounds = { 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - bool gameraMode = false; - - // Define enemies variables - Rectangle enemyBounds[MAX_ENEMIES]; - int enemyRail[MAX_ENEMIES]; - int enemyType[MAX_ENEMIES]; - bool enemyActive[MAX_ENEMIES]; - float enemySpeed = 10; - - // Init enemies variables - for (int i = 0; i < MAX_ENEMIES; i++) - { - // Define enemy type (all same probability) - enemyType[i] = GetRandomValue(0, 3); - - // Define enemy rail - enemyRail[i] = GetRandomValue(0, 4); - - // Define enemy bounding box - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - // Define additional game variables - int foodBar = 0; - int framesCounter = 0; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - framesCounter++; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= (enemySpeed - 2); - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Enemies activation logic (every 40 frames) - if (framesCounter > 40) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i] == false) - { - enemyActive[i] = true; - i = MAX_ENEMIES; - } - } - - framesCounter = 0; - } - - // Enemies logic - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - enemyBounds[i].x -= enemySpeed; - } - - // Check enemies out of screen - if (enemyBounds[i].x <= 0 - 128) - { - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - } - - // Enemies speed increase every frame - if (!gameraMode) enemySpeed += 0.005; - - // Check collision player vs enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - if (CheckCollisionRecs(playerBounds, enemyBounds[i])) - { - if (enemyType[i] < 3) // Bad enemies - { - if (gameraMode) - { - foodBar += 15; - - // After enemy deactivation, reset enemy parameters to be reused - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - else - { - // Player die logic - currentScreen = ENDING; - framesCounter = 0; - } - } - else // Sweet fish - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - if (!gameraMode) foodBar += 80; - else foodBar += 25; - - if (foodBar == 400) - { - gameraMode = true; - } - } - } - } - } - - // Gamera mode logic - if (gameraMode) - { - foodBar--; - - if (foodBar <= 0) - { - gameraMode = false; - enemySpeed -= 2; - if (enemySpeed < 10) enemySpeed = 10; - } - } - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - gameraMode = false; - - // Reset enemies data - for (int i = 0; i < MAX_ENEMIES; i++) - { - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - enemySpeed = 10; - - // Reset game variables - foodBar = 0; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, BLUE); - DrawTexture(sea, screenWidth + seaScrolling, 0, BLUE); - } - else - { - DrawTexture(sea, seaScrolling, 0, RED); - DrawTexture(sea, screenWidth + seaScrolling, 0, RED); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawText("PRESS ENTER", 480, 480, 40, BLACK); - - } break; - case GAMEPLAY: - { - // Draw water lines - for (int i = 0; i < 5; i++) DrawRectangle(0, i*120 + 120, screenWidth, 110, Fade(SKYBLUE, 0.1f)); - - // Draw player - if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - //if (!gameraMode) DrawRectangleRec(playerBounds, Fade(GREEN, 0.4f)); - //else DrawRectangleRec(playerBounds, Fade(ORANGE, 0.4f)); - - // Draw enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - // Draw enemies - /* - switch(enemyType[i]) - { - case 0: DrawTexture(shark, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 1: DrawTexture(orca, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 2: DrawTexture(swhale, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 3: DrawTexture(fish, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - default: break; - } - */ - - // Draw enemies bounding boxes - switch(enemyType[i]) - { - case 0: DrawRectangleRec(enemyBounds[i], RED); break; - case 1: DrawRectangleRec(enemyBounds[i], RED); break; - case 2: DrawRectangleRec(enemyBounds[i], RED); break; - case 3: DrawRectangleRec(enemyBounds[i], GREEN); break; - default: break; - } - } - } - - // Draw gameplay interface - - // Draw food bar - DrawRectangle(20, 20, 400, 40, Fade(GRAY, 0.4f)); - DrawRectangle(20, 20, foodBar, 40, ORANGE); - DrawRectangleLines(20, 20, 400, 40, BLACK); - - if (gameraMode) - { - DrawText("GAMERA MODE", 60, 22, 40, GRAY); - } - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawText("GAME OVER", 300, 200, 100, MAROON); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawText("PRESS ENTER to REPLAY", 400, 420, 30, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(gamera); - UnloadTexture(shark); - UnloadTexture(orca); - UnloadTexture(swhale); - UnloadTexture(fish); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file diff --git a/games/drturtle/04_drturtle_gui.c b/games/drturtle/04_drturtle_gui.c deleted file mode 100644 index 0ec06fb68..000000000 --- a/games/drturtle/04_drturtle_gui.c +++ /dev/null @@ -1,447 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - Texture2D title = LoadTexture("resources/title.png"); - Texture2D turtle = LoadTexture("resources/turtle.png"); - Texture2D gamera = LoadTexture("resources/gamera.png"); - Texture2D shark = LoadTexture("resources/shark.png"); - Texture2D orca = LoadTexture("resources/orca.png"); - Texture2D swhale = LoadTexture("resources/swhale.png"); - Texture2D fish = LoadTexture("resources/fish.png"); - Texture2D gframe = LoadTexture("resources/gframe.png"); - - // Load game resources: fonts - Font font = LoadFont("resources/komika.png"); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - // Define player variables - int playerRail = 1; - Rectangle playerBounds = { 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - bool gameraMode = false; - - // Define enemies variables - Rectangle enemyBounds[MAX_ENEMIES]; - int enemyRail[MAX_ENEMIES]; - int enemyType[MAX_ENEMIES]; - bool enemyActive[MAX_ENEMIES]; - float enemySpeed = 10; - - // Init enemies variables - for (int i = 0; i < MAX_ENEMIES; i++) - { - // Define enemy type (all same probability) - //enemyType[i] = GetRandomValue(0, 3); - - // Probability system for enemies type - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - // Define enemy rail - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - // Define additional game variables - int score = 0; - float distance = 0.0f; - int hiscore = 0; - float hidistance = 0.0f; - int foodBar = 0; - int framesCounter = 0; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - framesCounter++; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= (enemySpeed - 2); - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Enemies activation logic (every 40 frames) - if (framesCounter > 40) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i] == false) - { - enemyActive[i] = true; - i = MAX_ENEMIES; - } - } - - framesCounter = 0; - } - - // Enemies logic - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - enemyBounds[i].x -= enemySpeed; - } - - // Check enemies out of screen - if (enemyBounds[i].x <= 0 - 128) - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - } - } - - if (!gameraMode) enemySpeed += 0.005; - - // Check collision player vs enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - if (CheckCollisionRecs(playerBounds, enemyBounds[i])) - { - if (enemyType[i] < 3) // Bad enemies - { - if (gameraMode) - { - if (enemyType[i] == 0) score += 50; - else if (enemyType[i] == 1) score += 150; - else if (enemyType[i] == 2) score += 300; - - foodBar += 15; - - enemyActive[i] = false; - - // After enemy deactivation, reset enemy parameters to be reused - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - } - else - { - // Player die logic - currentScreen = ENDING; - framesCounter = 0; - - // Save hiscore and hidistance for next game - if (score > hiscore) hiscore = score; - if (distance > hidistance) hidistance = distance; - } - } - else // Sweet fish - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - if (!gameraMode) foodBar += 80; - else foodBar += 25; - - score += 10; - - if (foodBar == 400) - { - gameraMode = true; - } - } - } - } - } - - // Gamera mode logic - if (gameraMode) - { - foodBar--; - - if (foodBar <= 0) - { - gameraMode = false; - enemySpeed -= 2; - if (enemySpeed < 10) enemySpeed = 10; - } - } - - // Update distance counter - distance += 0.5f; - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - gameraMode = false; - - // Reset enemies data - for (int i = 0; i < MAX_ENEMIES; i++) - { - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - //enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - enemySpeed = 10; - - // Reset game variables - score = 0; - distance = 0.0; - foodBar = 0; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, (Color){ 16, 189, 227, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 16, 189, 227, 255}); - } - else - { - DrawTexture(sea, seaScrolling, 0, (Color){ 255, 113, 66, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 255, 113, 66, 255}); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE); - - } break; - case GAMEPLAY: - { - // Draw water lines - for (int i = 0; i < 5; i++) DrawRectangle(0, i*120 + 120, screenWidth, 110, Fade(SKYBLUE, 0.1f)); - - // Draw player - if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - //if (!gameraMode) DrawRectangleRec(playerBounds, Fade(GREEN, 0.4f)); - //else DrawRectangleRec(playerBounds, Fade(ORANGE, 0.4f)); - - // Draw enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - // Draw enemies - switch(enemyType[i]) - { - case 0: DrawTexture(shark, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 1: DrawTexture(orca, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 2: DrawTexture(swhale, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 3: DrawTexture(fish, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - default: break; - } - - // Draw enemies bounding boxes - /* - switch(enemyType[i]) - { - case 0: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 1: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 2: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 3: DrawRectangleRec(enemyBounds[i], Fade(GREEN, 0.5f)); break; - default: break; - } - */ - } - } - - // Draw gameplay interface - DrawRectangle(20, 20, 400, 40, Fade(GRAY, 0.4f)); - DrawRectangle(20, 20, foodBar, 40, ORANGE); - DrawRectangleLines(20, 20, 400, 40, BLACK); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); - - if (gameraMode) - { - DrawText("GAMERA MODE", 60, 22, 40, GRAY); - DrawTexture(gframe, 0, 0, Fade(WHITE, 0.5f)); - } - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(gframe); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(shark); - UnloadTexture(orca); - UnloadTexture(swhale); - UnloadTexture(fish); - UnloadTexture(gamera); - - // Unload font texture - UnloadFont(font); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/games/drturtle/05_drturtle_audio.c b/games/drturtle/05_drturtle_audio.c deleted file mode 100644 index 4c3ce4add..000000000 --- a/games/drturtle/05_drturtle_audio.c +++ /dev/null @@ -1,471 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Initialize audio device - InitAudioDevice(); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - Texture2D title = LoadTexture("resources/title.png"); - Texture2D turtle = LoadTexture("resources/turtle.png"); - Texture2D shark = LoadTexture("resources/shark.png"); - Texture2D orca = LoadTexture("resources/orca.png"); - Texture2D swhale = LoadTexture("resources/swhale.png"); - Texture2D fish = LoadTexture("resources/fish.png"); - Texture2D gamera = LoadTexture("resources/gamera.png"); - Texture2D gframe = LoadTexture("resources/gframe.png"); - - // Load game resources: fonts - Font font = LoadFont("resources/komika.png"); - - // Load game resources: sounds - Sound eat = LoadSound("resources/eat.wav"); - Sound die = LoadSound("resources/die.wav"); - Sound growl = LoadSound("resources/gamera.wav"); - - // Load music stream and start playing music - Music music = LoadMusicStream("resources/speeding.ogg"); - PlayMusicStream(music); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - // Define player variables - int playerRail = 1; - Rectangle playerBounds = { 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - bool gameraMode = false; - - // Define enemies variables - Rectangle enemyBounds[MAX_ENEMIES]; - int enemyRail[MAX_ENEMIES]; - int enemyType[MAX_ENEMIES]; - bool enemyActive[MAX_ENEMIES]; - float enemySpeed = 10; - - // Init enemies variables - for (int i = 0; i < MAX_ENEMIES; i++) - { - // Define enemy type (all same probability) - //enemyType[i] = GetRandomValue(0, 3); - - // Probability system for enemies type - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - // Define enemy rail - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - // Define additional game variables - int score = 0; - float distance = 0.0f; - int hiscore = 0; - float hidistance = 0.0f; - int foodBar = 0; - int framesCounter = 0; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateMusicStream(music); // Refill music stream buffers (if required) - - framesCounter++; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= (enemySpeed - 2); - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Enemies activation logic (every 40 frames) - if (framesCounter > 40) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i] == false) - { - enemyActive[i] = true; - i = MAX_ENEMIES; - } - } - - framesCounter = 0; - } - - // Enemies logic - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - enemyBounds[i].x -= enemySpeed; - } - - // Check enemies out of screen - if (enemyBounds[i].x <= 0 - 128) - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - } - } - - if (!gameraMode) enemySpeed += 0.005; - - // Check collision player vs enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - if (CheckCollisionRecs(playerBounds, enemyBounds[i])) - { - if (enemyType[i] < 3) // Bad enemies - { - if (gameraMode) - { - if (enemyType[i] == 0) score += 50; - else if (enemyType[i] == 1) score += 150; - else if (enemyType[i] == 2) score += 300; - - foodBar += 15; - - enemyActive[i] = false; - - // After enemy deactivation, reset enemy parameters to be reused - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - PlaySound(eat); - } - else - { - // Player die logic - PlaySound(die); - - currentScreen = ENDING; - framesCounter = 0; - - // Save hiscore and hidistance for next game - if (score > hiscore) hiscore = score; - if (distance > hidistance) hidistance = distance; - } - } - else // Sweet fish - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - if (!gameraMode) foodBar += 80; - else foodBar += 25; - - score += 10; - - if (foodBar == 400) - { - gameraMode = true; - - PlaySound(growl); - } - - PlaySound(eat); - } - } - } - } - - // Gamera mode logic - if (gameraMode) - { - foodBar--; - - if (foodBar <= 0) - { - gameraMode = false; - enemySpeed -= 2; - if (enemySpeed < 10) enemySpeed = 10; - } - } - - // Update distance counter - distance += 0.5f; - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Reset enemies data - for (int i = 0; i < MAX_ENEMIES; i++) - { - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - //enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - enemySpeed = 10; - - // Reset game variables - score = 0; - distance = 0.0; - foodBar = 0; - gameraMode = false; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, (Color){ 16, 189, 227, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 16, 189, 227, 255}); - } - else - { - DrawTexture(sea, seaScrolling, 0, (Color){ 255, 113, 66, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 255, 113, 66, 255}); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE); - - } break; - case GAMEPLAY: - { - // Draw water lines - for (int i = 0; i < 5; i++) DrawRectangle(0, i*120 + 120, screenWidth, 110, Fade(SKYBLUE, 0.1f)); - - // Draw player - if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - //if (!gameraMode) DrawRectangleRec(playerBounds, Fade(GREEN, 0.4f)); - //else DrawRectangleRec(playerBounds, Fade(ORANGE, 0.4f)); - - // Draw enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - // Draw enemies - switch(enemyType[i]) - { - case 0: DrawTexture(shark, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 1: DrawTexture(orca, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 2: DrawTexture(swhale, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 3: DrawTexture(fish, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - default: break; - } - - // Draw enemies bounding boxes - /* - switch(enemyType[i]) - { - case 0: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 1: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 2: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 3: DrawRectangleRec(enemyBounds[i], Fade(GREEN, 0.5f)); break; - default: break; - } - */ - } - } - - // Draw gameplay interface - DrawRectangle(20, 20, 400, 40, Fade(GRAY, 0.4f)); - DrawRectangle(20, 20, foodBar, 40, ORANGE); - DrawRectangleLines(20, 20, 400, 40, BLACK); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); - - if (gameraMode) - { - DrawText("GAMERA MODE", 60, 22, 40, GRAY); - DrawTexture(gframe, 0, 0, Fade(WHITE, 0.5f)); - } - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(gframe); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(shark); - UnloadTexture(orca); - UnloadTexture(swhale); - UnloadTexture(fish); - UnloadTexture(gamera); - - // Unload font texture - UnloadFont(font); - - // Unload sounds - UnloadSound(eat); - UnloadSound(die); - UnloadSound(growl); - - UnloadMusicStream(music); // Unload music - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/games/drturtle/06_drturtle_final.c b/games/drturtle/06_drturtle_final.c deleted file mode 100644 index 15dcf09c7..000000000 --- a/games/drturtle/06_drturtle_final.c +++ /dev/null @@ -1,495 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include // Used for sinf() - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Initialize audio device - InitAudioDevice(); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - Texture2D title = LoadTexture("resources/title.png"); - Texture2D turtle = LoadTexture("resources/turtle.png"); - Texture2D gamera = LoadTexture("resources/gamera.png"); - Texture2D shark = LoadTexture("resources/shark.png"); - Texture2D orca = LoadTexture("resources/orca.png"); - Texture2D swhale = LoadTexture("resources/swhale.png"); - Texture2D fish = LoadTexture("resources/fish.png"); - Texture2D gframe = LoadTexture("resources/gframe.png"); - - // Load game resources: fonts - Font font = LoadFont("resources/komika.png"); - - // Load game resources: sounds - Sound eat = LoadSound("resources/eat.wav"); - Sound die = LoadSound("resources/die.wav"); - Sound growl = LoadSound("resources/gamera.wav"); - - // Load music stream and start playing music - Music music = LoadMusicStream("resources/speeding.ogg"); - PlayMusicStream(music); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - // Define player variables - int playerRail = 1; - Rectangle playerBounds = { 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - bool gameraMode = false; - - // Define enemies variables - Rectangle enemyBounds[MAX_ENEMIES]; - int enemyRail[MAX_ENEMIES]; - int enemyType[MAX_ENEMIES]; - bool enemyActive[MAX_ENEMIES]; - float enemySpeed = 10; - - // Init enemies variables - for (int i = 0; i < MAX_ENEMIES; i++) - { - // Define enemy type (all same probability) - //enemyType[i] = GetRandomValue(0, 3); - - // Probability system for enemies type - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - // define enemy rail - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - // Define additional game variables - int score = 0; - float distance = 0.0f; - int hiscore = 0; - float hidistance = 0.0f; - int foodBar = 0; - int framesCounter = 0; - - unsigned char blue = 200; - float timeCounter = 0; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateMusicStream(music); // Refill music stream buffers (if required) - - framesCounter++; - - // Sea color tint effect - blue = 210 + 25 * sinf(timeCounter); - timeCounter += 0.01; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= (enemySpeed - 2); - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Enemies activation logic (every 40 frames) - if (framesCounter > 40) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i] == false) - { - enemyActive[i] = true; - i = MAX_ENEMIES; - } - } - - framesCounter = 0; - } - - // Enemies logic - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - enemyBounds[i].x -= enemySpeed; - } - - // Check enemies out of screen - if (enemyBounds[i].x <= 0 - 128) - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - } - } - - if (!gameraMode) enemySpeed += 0.005; - - // Check collision player vs enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - if (CheckCollisionRecs(playerBounds, enemyBounds[i])) - { - if (enemyType[i] < 3) // Bad enemies - { - if (gameraMode) - { - if (enemyType[i] == 0) score += 50; - else if (enemyType[i] == 1) score += 150; - else if (enemyType[i] == 2) score += 300; - - foodBar += 15; - - enemyActive[i] = false; - - // After enemy deactivation, reset enemy parameters to be reused - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - PlaySound(eat); - } - else - { - // Player die logic - PlaySound(die); - - currentScreen = ENDING; - framesCounter = 0; - - // Save hiscore and hidistance for next game - if (score > hiscore) hiscore = score; - if (distance > hidistance) hidistance = distance; - } - } - else // Sweet fish - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - if (!gameraMode) foodBar += 80; - else foodBar += 25; - - score += 10; - - if (foodBar == 400) - { - gameraMode = true; - - PlaySound(growl); - } - - PlaySound(eat); - } - } - } - } - - // Gamera mode logic - if (gameraMode) - { - foodBar--; - - if (foodBar <= 0) - { - gameraMode = false; - enemySpeed -= 2; - if (enemySpeed < 10) enemySpeed = 10; - } - } - - // Update distance counter - distance += 0.5f; - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - gameraMode = false; - - // Reset enemies data - for (int i = 0; i < MAX_ENEMIES; i++) - { - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - //enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - enemySpeed = 10; - - // Reset game variables - score = 0; - distance = 0.0; - foodBar = 0; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, (Color){ 16, 189, blue, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 16, 189, blue, 255}); - } - else - { - DrawTexture(sea, seaScrolling, 0, (Color){ 255, 113, 66, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 255, 113, 66, 255}); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE); - - } break; - case GAMEPLAY: - { - // Draw water lines - for (int i = 0; i < 5; i++) DrawRectangle(0, i*120 + 120, screenWidth, 110, Fade(SKYBLUE, 0.1f)); - - // Draw player - if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - //if (!gameraMode) DrawRectangleRec(playerBounds, Fade(GREEN, 0.4f)); - //else DrawRectangleRec(playerBounds, Fade(ORANGE, 0.4f)); - - // Draw enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - // Draw enemies - switch(enemyType[i]) - { - case 0: DrawTexture(shark, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 1: DrawTexture(orca, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 2: DrawTexture(swhale, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 3: DrawTexture(fish, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - default: break; - } - - // Draw enemies bounding boxes - /* - switch(enemyType[i]) - { - case 0: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 1: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 2: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 3: DrawRectangleRec(enemyBounds[i], Fade(GREEN, 0.5f)); break; - default: break; - } - */ - } - } - - // Draw gameplay interface - DrawRectangle(20, 20, 400, 40, Fade(GRAY, 0.4f)); - DrawRectangle(20, 20, foodBar, 40, ORANGE); - DrawRectangleLines(20, 20, 400, 40, BLACK); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); - - if (gameraMode) - { - DrawText("GAMERA MODE", 60, 22, 40, GRAY); - DrawTexture(gframe, 0, 0, Fade(WHITE, 0.5f)); - } - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(gframe); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(shark); - UnloadTexture(orca); - UnloadTexture(swhale); - UnloadTexture(fish); - UnloadTexture(gamera); - - // Unload font texture - UnloadFont(font); - - // Unload sounds - UnloadSound(eat); - UnloadSound(die); - UnloadSound(growl); - - UnloadMusicStream(music); // Unload music - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/games/drturtle/CMakeLists.txt b/games/drturtle/CMakeLists.txt deleted file mode 100644 index f5778d9cb..000000000 --- a/games/drturtle/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(drturtle) - -# Executable & linking -add_executable(${PROJECT_NAME} 06_drturtle_final.c) -if (NOT TARGET raylib) - find_package(raylib 2.0 REQUIRED) -endif() -target_link_libraries(${PROJECT_NAME} raylib) - -# Resources -# Copy all of the resource files to the destination -file(COPY "resources/" DESTINATION "resources/") diff --git a/games/drturtle/LICENSE.txt b/games/drturtle/LICENSE.txt deleted file mode 100644 index 510604da4..000000000 --- a/games/drturtle/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ - -This game sources are licensed under an unmodified zlib/libpng license, -which is an OSI-certified, BSD-like license: - -Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) - -This software is provided "as-is", without any express or implied warranty. In no event -will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial -applications, and to alter it and redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not claim that you - wrote the original software. If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be misrepresented - as being the original software. - - 3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/games/drturtle/Makefile b/games/drturtle/Makefile deleted file mode 100644 index ce272e478..000000000 --- a/games/drturtle/Makefile +++ /dev/null @@ -1,385 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= drturtle -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= C:\GitHub\raylib - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - # -Wl,--subsystem,windows hides the console window - ifeq ($(BUILD_MODE), RELEASE) - LDFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -SCREENS = drturtle_final_web \ - -# typing 'make' will invoke the default target entry -all: $(SCREENS) - -%: %.c -ifeq ($(PLATFORM),PLATFORM_ANDROID) - $(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$< -else - $(CC) -o $(PROJECT_NAME)$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -endif - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/drturtle/drturtle_final_web.c b/games/drturtle/drturtle_final_web.c deleted file mode 100644 index 0b639e38b..000000000 --- a/games/drturtle/drturtle_final_web.c +++ /dev/null @@ -1,544 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include // Used for sinf() - -#if defined(PLATFORM_WEB) - #include -#endif - -#define MAX_ENEMIES 10 - -typedef enum { TITLE = 0, GAMEPLAY, ENDING } GameScreen; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -const int screenWidth = 1280; -const int screenHeight = 720; - -Texture2D sky; -Texture2D mountains; -Texture2D sea; -Texture2D title; -Texture2D turtle; -Texture2D gamera; -Texture2D shark; -Texture2D orca; -Texture2D swhale; -Texture2D fish; -Texture2D gframe; - -Font font; - -Sound eat; -Sound die; -Sound growl; - -Music music; - -// Define scrolling variables -int backScrolling = 0; -int seaScrolling = 0; - -// Define current screen -GameScreen currentScreen = 0; - -// Define player variables -int playerRail = 1; -Rectangle playerBounds; -bool gameraMode = false; - -// Define enemies variables -Rectangle enemyBounds[MAX_ENEMIES]; -int enemyRail[MAX_ENEMIES]; -int enemyType[MAX_ENEMIES]; -bool enemyActive[MAX_ENEMIES]; -float enemySpeed = 10; - -// Define additional game variables -int score = 0; -float distance = 0.0f; -int hiscore = 0; -float hidistance = 0.0f; -int foodBar = 0; -int framesCounter = 0; - -unsigned char blue = 200; -float timeCounter = 0; - -//---------------------------------------------------------------------------------- -// Module Functions Declaration -//---------------------------------------------------------------------------------- -void UpdateDrawFrame(void); // Update and Draw one frame - -//---------------------------------------------------------------------------------- -// Main Enry Point -//---------------------------------------------------------------------------------- -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Initialize audio device - InitAudioDevice(); - - // Load game resources: textures - sky = LoadTexture("resources/sky.png"); - mountains = LoadTexture("resources/mountains.png"); - sea = LoadTexture("resources/sea.png"); - title = LoadTexture("resources/title.png"); - turtle = LoadTexture("resources/turtle.png"); - gamera = LoadTexture("resources/gamera.png"); - shark = LoadTexture("resources/shark.png"); - orca = LoadTexture("resources/orca.png"); - swhale = LoadTexture("resources/swhale.png"); - fish = LoadTexture("resources/fish.png"); - gframe = LoadTexture("resources/gframe.png"); - - // Load game resources: fonts - font = LoadFont("resources/komika.png"); - - // Load game resources: sounds - eat = LoadSound("resources/eat.wav"); - die = LoadSound("resources/die.wav"); - growl = LoadSound("resources/gamera.wav"); - - // Load music stream and start playing music - music = LoadMusicStream("resources/speeding.ogg"); - PlayMusicStream(music); - - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Init enemies variables - for (int i = 0; i < MAX_ENEMIES; i++) - { - // Define enemy type (all same probability) - //enemyType[i] = GetRandomValue(0, 3); - - // Probability system for enemies type - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - // define enemy rail - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - UpdateDrawFrame(); - } -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(gframe); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(shark); - UnloadTexture(orca); - UnloadTexture(swhale); - UnloadTexture(fish); - UnloadTexture(gamera); - - // Unload font texture - UnloadFont(font); - - // Unload sounds - UnloadSound(eat); - UnloadSound(die); - UnloadSound(growl); - - UnloadMusicStream(music); // Unload music - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//---------------------------------------------------------------------------------- -// Module Functions Definition -//---------------------------------------------------------------------------------- -void UpdateDrawFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - UpdateMusicStream(music); // Refill music stream buffers (if required) - - framesCounter++; - - // Sea color tint effect - blue = 210 + 25 * sinf(timeCounter); - timeCounter += 0.01; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= (enemySpeed - 2); - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Enemies activation logic (every 40 frames) - if (framesCounter > 40) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i] == false) - { - enemyActive[i] = true; - i = MAX_ENEMIES; - } - } - - framesCounter = 0; - } - - // Enemies logic - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - enemyBounds[i].x -= enemySpeed; - } - - // Check enemies out of screen - if (enemyBounds[i].x <= 0 - 128) - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - } - } - - if (!gameraMode) enemySpeed += 0.005; - - // Check collision player vs enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - if (CheckCollisionRecs(playerBounds, enemyBounds[i])) - { - if (enemyType[i] < 3) // Bad enemies - { - if (gameraMode) - { - if (enemyType[i] == 0) score += 50; - else if (enemyType[i] == 1) score += 150; - else if (enemyType[i] == 2) score += 300; - - foodBar += 15; - - enemyActive[i] = false; - - // After enemy deactivation, reset enemy parameters to be reused - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - PlaySound(eat); - } - else - { - // Player die logic - PlaySound(die); - - currentScreen = ENDING; - framesCounter = 0; - - // Save hiscore and hidistance for next game - if (score > hiscore) hiscore = score; - if (distance > hidistance) hidistance = distance; - } - } - else // Sweet fish - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - if (!gameraMode) foodBar += 80; - else foodBar += 25; - - score += 10; - - if (foodBar == 400) - { - gameraMode = true; - - PlaySound(growl); - } - - PlaySound(eat); - } - } - } - } - - // Gamera mode logic - if (gameraMode) - { - foodBar--; - - if (foodBar <= 0) - { - gameraMode = false; - enemySpeed -= 2; - if (enemySpeed < 10) enemySpeed = 10; - } - } - - // Update distance counter - distance += 0.5f; - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - gameraMode = false; - - // Reset enemies data - for (int i = 0; i < MAX_ENEMIES; i++) - { - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - //enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - enemySpeed = 10; - - // Reset game variables - score = 0; - distance = 0.0; - foodBar = 0; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, (Color){ 16, 189, blue, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 16, 189, blue, 255}); - } - else - { - DrawTexture(sea, seaScrolling, 0, (Color){ 255, 113, 66, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 255, 113, 66, 255}); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 1, WHITE); - - } break; - case GAMEPLAY: - { - // Draw water lines - for (int i = 0; i < 5; i++) DrawRectangle(0, i*120 + 120, screenWidth, 110, Fade(SKYBLUE, 0.1f)); - - // Draw player - if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - //if (!gameraMode) DrawRectangleRec(playerBounds, Fade(GREEN, 0.4f)); - //else DrawRectangleRec(playerBounds, Fade(ORANGE, 0.4f)); - - // Draw enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - // Draw enemies - switch(enemyType[i]) - { - case 0: DrawTexture(shark, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 1: DrawTexture(orca, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 2: DrawTexture(swhale, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 3: DrawTexture(fish, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - default: break; - } - - // Draw enemies bounding boxes - /* - switch(enemyType[i]) - { - case 0: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 1: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 2: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 3: DrawRectangleRec(enemyBounds[i], Fade(GREEN, 0.5f)); break; - default: break; - } - */ - } - } - - // Draw gameplay interface - DrawRectangle(20, 20, 400, 40, Fade(GRAY, 0.4f)); - DrawRectangle(20, 20, foodBar, 40, ORANGE); - DrawRectangleLines(20, 20, 400, 40, BLACK); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); - - if (gameraMode) - { - DrawText("GAMERA MODE", 60, 22, 40, GRAY); - DrawTexture(gframe, 0, 0, Fade(WHITE, 0.5f)); - } - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- -} diff --git a/games/drturtle/resources/die.wav b/games/drturtle/resources/die.wav deleted file mode 100644 index 277ae3565..000000000 Binary files a/games/drturtle/resources/die.wav and /dev/null differ diff --git a/games/drturtle/resources/eat.wav b/games/drturtle/resources/eat.wav deleted file mode 100644 index e1c33a4ce..000000000 Binary files a/games/drturtle/resources/eat.wav and /dev/null differ diff --git a/games/drturtle/resources/fish.png b/games/drturtle/resources/fish.png deleted file mode 100644 index dca5956e5..000000000 Binary files a/games/drturtle/resources/fish.png and /dev/null differ diff --git a/games/drturtle/resources/gamera.png b/games/drturtle/resources/gamera.png deleted file mode 100644 index 9c2fea71c..000000000 Binary files a/games/drturtle/resources/gamera.png and /dev/null differ diff --git a/games/drturtle/resources/gamera.wav b/games/drturtle/resources/gamera.wav deleted file mode 100644 index deb79230d..000000000 Binary files a/games/drturtle/resources/gamera.wav and /dev/null differ diff --git a/games/drturtle/resources/gframe.png b/games/drturtle/resources/gframe.png deleted file mode 100644 index 5946589e6..000000000 Binary files a/games/drturtle/resources/gframe.png and /dev/null differ diff --git a/games/drturtle/resources/komika.png b/games/drturtle/resources/komika.png deleted file mode 100644 index 2c2ab7142..000000000 Binary files a/games/drturtle/resources/komika.png and /dev/null differ diff --git a/games/drturtle/resources/mountains.png b/games/drturtle/resources/mountains.png deleted file mode 100644 index f193f5047..000000000 Binary files a/games/drturtle/resources/mountains.png and /dev/null differ diff --git a/games/drturtle/resources/orca.png b/games/drturtle/resources/orca.png deleted file mode 100644 index b580ef072..000000000 Binary files a/games/drturtle/resources/orca.png and /dev/null differ diff --git a/games/drturtle/resources/sea.png b/games/drturtle/resources/sea.png deleted file mode 100644 index 34593536d..000000000 Binary files a/games/drturtle/resources/sea.png and /dev/null differ diff --git a/games/drturtle/resources/shark.png b/games/drturtle/resources/shark.png deleted file mode 100644 index 24a569574..000000000 Binary files a/games/drturtle/resources/shark.png and /dev/null differ diff --git a/games/drturtle/resources/sky.png b/games/drturtle/resources/sky.png deleted file mode 100644 index e75715c92..000000000 Binary files a/games/drturtle/resources/sky.png and /dev/null differ diff --git a/games/drturtle/resources/speeding.ogg b/games/drturtle/resources/speeding.ogg deleted file mode 100644 index eeac47f33..000000000 Binary files a/games/drturtle/resources/speeding.ogg and /dev/null differ diff --git a/games/drturtle/resources/swhale.png b/games/drturtle/resources/swhale.png deleted file mode 100644 index 5652928c0..000000000 Binary files a/games/drturtle/resources/swhale.png and /dev/null differ diff --git a/games/drturtle/resources/title.png b/games/drturtle/resources/title.png deleted file mode 100644 index 9ddd0de30..000000000 Binary files a/games/drturtle/resources/title.png and /dev/null differ diff --git a/games/drturtle/resources/turtle.png b/games/drturtle/resources/turtle.png deleted file mode 100644 index 52ce9691f..000000000 Binary files a/games/drturtle/resources/turtle.png and /dev/null differ diff --git a/games/floppy.c b/games/floppy.c deleted file mode 100644 index 7455a9c86..000000000 --- a/games/floppy.c +++ /dev/null @@ -1,238 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: floppy -* -* Sample game developed by Ian Eito, Albert Martos and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Some Defines -//---------------------------------------------------------------------------------- -#define MAX_TUBES 100 -#define FLOPPY_RADIUS 24 -#define TUBES_WIDTH 80 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef struct Floppy { - Vector2 position; - int radius; - Color color; -} Floppy; - -typedef struct Tubes { - Rectangle rec; - Color color; - bool active; -} Tubes; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static const int screenWidth = 800; -static const int screenHeight = 450; - -static bool gameOver = false; -static bool pause = false; -static int score = 0; -static int hiScore = 0; - -static Floppy floppy = { 0 }; -static Tubes tubes[MAX_TUBES*2] = { 0 }; -static Vector2 tubesPos[MAX_TUBES] = { 0 }; -static int tubesSpeedX = 0; -static bool superfx = false; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: floppy"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Initialize game variables -void InitGame(void) -{ - floppy.radius = FLOPPY_RADIUS; - floppy.position = (Vector2){80, screenHeight/2 - floppy.radius}; - tubesSpeedX = 2; - - for (int i = 0; i < MAX_TUBES; i++) - { - tubesPos[i].x = 400 + 280*i; - tubesPos[i].y = -GetRandomValue(0, 120); - } - - for (int i = 0; i < MAX_TUBES*2; i += 2) - { - tubes[i].rec.x = tubesPos[i/2].x; - tubes[i].rec.y = tubesPos[i/2].y; - tubes[i].rec.width = TUBES_WIDTH; - tubes[i].rec.height = 255; - - tubes[i+1].rec.x = tubesPos[i/2].x; - tubes[i+1].rec.y = 600 + tubesPos[i/2].y - 255; - tubes[i+1].rec.width = TUBES_WIDTH; - tubes[i+1].rec.height = 255; - - tubes[i/2].active = true; - } - - score = 0; - - gameOver = false; - superfx = false; - pause = false; -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - for (int i = 0; i < MAX_TUBES; i++) tubesPos[i].x -= tubesSpeedX; - - for (int i = 0; i < MAX_TUBES*2; i += 2) - { - tubes[i].rec.x = tubesPos[i/2].x; - tubes[i+1].rec.x = tubesPos[i/2].x; - } - - if (IsKeyDown(KEY_SPACE) && !gameOver) floppy.position.y -= 3; - else floppy.position.y += 1; - - // Check Collisions - for (int i = 0; i < MAX_TUBES*2; i++) - { - if (CheckCollisionCircleRec(floppy.position, floppy.radius, tubes[i].rec)) - { - gameOver = true; - pause = false; - } - else if ((tubesPos[i/2].x < floppy.position.x) && tubes[i/2].active && !gameOver) - { - score += 100; - tubes[i/2].active = false; - - superfx = true; - - if (score > hiScore) hiScore = score; - } - } - } - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - DrawCircle(floppy.position.x, floppy.position.y, floppy.radius, DARKGRAY); - - // Draw tubes - for (int i = 0; i < MAX_TUBES; i++) - { - DrawRectangle(tubes[i*2].rec.x, tubes[i*2].rec.y, tubes[i*2].rec.width, tubes[i*2].rec.height, GRAY); - DrawRectangle(tubes[i*2 + 1].rec.x, tubes[i*2 + 1].rec.y, tubes[i*2 + 1].rec.width, tubes[i*2 + 1].rec.height, GRAY); - } - - // Draw flashing fx (one frame only) - if (superfx) - { - DrawRectangle(0, 0, screenWidth, screenHeight, WHITE); - superfx = false; - } - - DrawText(TextFormat("%04i", score), 20, 20, 40, GRAY); - DrawText(TextFormat("HI-SCORE: %04i", hiScore), 20, 70, 20, LIGHTGRAY); - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); - - EndDrawing(); -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} diff --git a/games/gold_fever.c b/games/gold_fever.c deleted file mode 100644 index 30bc9c9e7..000000000 --- a/games/gold_fever.c +++ /dev/null @@ -1,279 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: gold fever -* -* Sample game developed by Ian Eito, Albert Martos and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef struct Player { - Vector2 position; - Vector2 speed; - int radius; -} Player; - -typedef struct Enemy { - Vector2 position; - Vector2 speed; - int radius; - int radiusBounds; - bool moveRight; -} Enemy; - -typedef struct Points { - Vector2 position; - int radius; - int value; - bool active; -} Points; - -typedef struct Home { - Rectangle rec; - bool active; - bool save; - Color color; -} Home; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static const int screenWidth = 800; -static const int screenHeight = 450; - -static bool gameOver = false; -static bool pause = false; -static int score = 0; -static int hiScore = 0; - -static Player player = { 0 }; -static Enemy enemy = { 0 }; -static Points points = { 0 }; -static Home home = { 0 }; -static bool follow = false; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: gold fever"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Initialize game variables -void InitGame(void) -{ - pause = false; - score = 0; - - player.position = (Vector2){50, 50}; - player.radius = 20; - player.speed = (Vector2){5, 5}; - - enemy.position = (Vector2){screenWidth - 50, screenHeight/2}; - enemy.radius = 20; - enemy.radiusBounds = 150; - enemy.speed = (Vector2){3, 3}; - enemy.moveRight = true; - follow = false; - - points.radius = 10; - points.position = (Vector2){GetRandomValue(points.radius, screenWidth - points.radius), GetRandomValue(points.radius, screenHeight - points.radius)}; - points.value = 100; - points.active = true; - - home.rec.width = 50; - home.rec.height = 50; - home.rec.x = GetRandomValue(0, screenWidth - home.rec.width); - home.rec.y = GetRandomValue(0, screenHeight - home.rec.height); - home.active = false; - home.save = false; -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - // Control player - if (IsKeyDown(KEY_RIGHT)) player.position.x += player.speed.x; - if (IsKeyDown(KEY_LEFT)) player.position.x -= player.speed.x; - if (IsKeyDown(KEY_UP)) player.position.y -= player.speed.y; - if (IsKeyDown(KEY_DOWN)) player.position.y += player.speed.y; - - // Wall behaviour player - if (player.position.x - player.radius <= 0) player.position.x = player.radius; - if (player.position.x + player.radius >= screenWidth) player.position.x = screenWidth - player.radius; - if (player.position.y - player.radius <= 0) player.position.y = player.radius; - if (player.position.y + player.radius >= screenHeight) player.position.y = screenHeight - player.radius; - - // IA Enemy - if ( (follow || CheckCollisionCircles(player.position, player.radius, enemy.position, enemy.radiusBounds)) && !home.save) - { - if (player.position.x > enemy.position.x) enemy.position.x += enemy.speed.x; - if (player.position.x < enemy.position.x) enemy.position.x -= enemy.speed.x; - - if (player.position.y > enemy.position.y) enemy.position.y += enemy.speed.y; - if (player.position.y < enemy.position.y) enemy.position.y -= enemy.speed.y; - } - else - { - if (enemy.moveRight) enemy.position.x += enemy.speed.x; - else enemy.position.x -= enemy.speed.x; - } - - // Wall behaviour enemy - if (enemy.position.x - enemy.radius <= 0) enemy.moveRight = true; - if (enemy.position.x + enemy.radius >= screenWidth) enemy.moveRight = false; - - if (enemy.position.x - enemy.radius <= 0) enemy.position.x = enemy.radius; - if (enemy.position.x + enemy.radius >= screenWidth) enemy.position.x = screenWidth - enemy.radius; - if (enemy.position.y - enemy.radius <= 0) enemy.position.y = enemy.radius; - if (enemy.position.y + enemy.radius >= screenHeight) enemy.position.y = screenHeight - enemy.radius; - - // Collisions - if (CheckCollisionCircles(player.position, player.radius, points.position, points.radius) && points.active) - { - follow = true; - points.active = false; - home.active = true; - } - - if (CheckCollisionCircles(player.position, player.radius, enemy.position, enemy.radius) && !home.save) - { - gameOver = true; - - if (hiScore < score) hiScore = score; - } - - if (CheckCollisionCircleRec(player.position, player.radius, home.rec)) - { - follow = false; - - if (!points.active) - { - score += points.value; - points.active = true; - enemy.speed.x += 0.5; - enemy.speed.y += 0.5; - points.position = (Vector2){GetRandomValue(points.radius, screenWidth - points.radius), GetRandomValue(points.radius, screenHeight - points.radius)}; - } - - home.save = true; - } - else home.save = false; - } - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - if (follow) - { - DrawRectangle(0, 0, screenWidth, screenHeight, RED); - DrawRectangle(10, 10, screenWidth - 20, screenHeight - 20, RAYWHITE); - } - - DrawRectangleLines(home.rec.x, home.rec.y, home.rec.width, home.rec.height, BLUE); - - DrawCircleLines(enemy.position.x, enemy.position.y, enemy.radiusBounds, RED); - DrawCircleV(enemy.position, enemy.radius, MAROON); - - DrawCircleV(player.position, player.radius, GRAY); - if (points.active) DrawCircleV(points.position, points.radius, GOLD); - - DrawText(TextFormat("SCORE: %04i", score), 20, 15, 20, GRAY); - DrawText(TextFormat("HI-SCORE: %04i", hiScore), 300, 15, 20, GRAY); - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); - - EndDrawing(); -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} diff --git a/games/gorilas.c b/games/gorilas.c deleted file mode 100644 index 7fd032dcc..000000000 --- a/games/gorilas.c +++ /dev/null @@ -1,566 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: gorilas -* -* Sample game Marc Palau and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include -#include -#include -#include - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Some Defines -//---------------------------------------------------------------------------------- -#define MAX_BUILDINGS 15 -#define MAX_EXPLOSIONS 200 -#define MAX_PLAYERS 2 - -#define BUILDING_RELATIVE_ERROR 30 // Building size random range % -#define BUILDING_MIN_RELATIVE_HEIGHT 20 // Minimum height in % of the screenHeight -#define BUILDING_MAX_RELATIVE_HEIGHT 60 // Maximum height in % of the screenHeight -#define BUILDING_MIN_GRAYSCALE_COLOR 120 // Minimum gray color for the buildings -#define BUILDING_MAX_GRAYSCALE_COLOR 200 // Maximum gray color for the buildings - -#define MIN_PLAYER_POSITION 5 // Minimum x position % -#define MAX_PLAYER_POSITION 20 // Maximum x position % - -#define GRAVITY 9.81f -#define DELTA_FPS 60 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef struct Player { - Vector2 position; - Vector2 size; - - Vector2 aimingPoint; - int aimingAngle; - int aimingPower; - - Vector2 previousPoint; - int previousAngle; - int previousPower; - - Vector2 impactPoint; - - bool isLeftTeam; // This player belongs to the left or to the right team - bool isPlayer; // If is a player or an AI - bool isAlive; -} Player; - -typedef struct Building { - Rectangle rectangle; - Color color; -} Building; - -typedef struct Explosion { - Vector2 position; - int radius; - bool active; -} Explosion; - -typedef struct Ball { - Vector2 position; - Vector2 speed; - int radius; - bool active; -} Ball; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static const int screenWidth = 800; -static const int screenHeight = 450; - -static bool gameOver = false; -static bool pause = false; - -static Player player[MAX_PLAYERS] = { 0 }; -static Building building[MAX_BUILDINGS] = { 0 }; -static Explosion explosion[MAX_EXPLOSIONS] = { 0 }; -static Ball ball = { 0 }; - -static int playerTurn = 0; -static bool ballOnAir = false; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -// Additional module functions -static void InitBuildings(void); -static void InitPlayers(void); -static bool UpdatePlayer(int playerTurn); -static bool UpdateBall(int playerTurn); - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: gorilas"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Initialize game variables -void InitGame(void) -{ - // Init shoot - ball.radius = 10; - ballOnAir = false; - ball.active = false; - - InitBuildings(); - InitPlayers(); - - // Init explosions - for (int i = 0; i < MAX_EXPLOSIONS; i++) - { - explosion[i].position = (Vector2){ 0.0f, 0.0f }; - explosion[i].radius = 30; - explosion[i].active = false; - } -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - if (!ballOnAir) ballOnAir = UpdatePlayer(playerTurn); // If we are aiming - else - { - if (UpdateBall(playerTurn)) // If collision - { - // Game over logic - bool leftTeamAlive = false; - bool rightTeamAlive = false; - - for (int i = 0; i < MAX_PLAYERS; i++) - { - if (player[i].isAlive) - { - if (player[i].isLeftTeam) leftTeamAlive = true; - if (!player[i].isLeftTeam) rightTeamAlive = true; - } - } - - if (leftTeamAlive && rightTeamAlive) - { - ballOnAir = false; - ball.active = false; - - playerTurn++; - - if (playerTurn == MAX_PLAYERS) playerTurn = 0; - } - else - { - gameOver = true; - - // if (leftTeamAlive) left team wins - // if (rightTeamAlive) right team wins - } - } - } - } - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - // Draw buildings - for (int i = 0; i < MAX_BUILDINGS; i++) DrawRectangleRec(building[i].rectangle, building[i].color); - - // Draw explosions - for (int i = 0; i < MAX_EXPLOSIONS; i++) - { - if (explosion[i].active) DrawCircle(explosion[i].position.x, explosion[i].position.y, explosion[i].radius, RAYWHITE); - } - - // Draw players - for (int i = 0; i < MAX_PLAYERS; i++) - { - if (player[i].isAlive) - { - if (player[i].isLeftTeam) DrawRectangle(player[i].position.x - player[i].size.x/2, player[i].position.y - player[i].size.y/2, - player[i].size.x, player[i].size.y, BLUE); - else DrawRectangle(player[i].position.x - player[i].size.x/2, player[i].position.y - player[i].size.y/2, - player[i].size.x, player[i].size.y, RED); - } - } - - // Draw ball - if (ball.active) DrawCircle(ball.position.x, ball.position.y, ball.radius, MAROON); - - // Draw the angle and the power of the aim, and the previous ones - if (!ballOnAir) - { - // Draw shot information - /* - if (player[playerTurn].isLeftTeam) - { - DrawText(TextFormat("Previous Point %i, %i", (int)player[playerTurn].previousPoint.x, (int)player[playerTurn].previousPoint.y), 20, 20, 20, DARKBLUE); - DrawText(TextFormat("Previous Angle %i", player[playerTurn].previousAngle), 20, 50, 20, DARKBLUE); - DrawText(TextFormat("Previous Power %i", player[playerTurn].previousPower), 20, 80, 20, DARKBLUE); - DrawText(TextFormat("Aiming Point %i, %i", (int)player[playerTurn].aimingPoint.x, (int)player[playerTurn].aimingPoint.y), 20, 110, 20, DARKBLUE); - DrawText(TextFormat("Aiming Angle %i", player[playerTurn].aimingAngle), 20, 140, 20, DARKBLUE); - DrawText(TextFormat("Aiming Power %i", player[playerTurn].aimingPower), 20, 170, 20, DARKBLUE); - } - else - { - DrawText(TextFormat("Previous Point %i, %i", (int)player[playerTurn].previousPoint.x, (int)player[playerTurn].previousPoint.y), screenWidth*3/4, 20, 20, DARKBLUE); - DrawText(TextFormat("Previous Angle %i", player[playerTurn].previousAngle), screenWidth*3/4, 50, 20, DARKBLUE); - DrawText(TextFormat("Previous Power %i", player[playerTurn].previousPower), screenWidth*3/4, 80, 20, DARKBLUE); - DrawText(TextFormat("Aiming Point %i, %i", (int)player[playerTurn].aimingPoint.x, (int)player[playerTurn].aimingPoint.y), screenWidth*3/4, 110, 20, DARKBLUE); - DrawText(TextFormat("Aiming Angle %i", player[playerTurn].aimingAngle), screenWidth*3/4, 140, 20, DARKBLUE); - DrawText(TextFormat("Aiming Power %i", player[playerTurn].aimingPower), screenWidth*3/4, 170, 20, DARKBLUE); - } - */ - - // Draw aim - if (player[playerTurn].isLeftTeam) - { - // Previous aiming - DrawTriangle((Vector2){ player[playerTurn].position.x - player[playerTurn].size.x/4, player[playerTurn].position.y - player[playerTurn].size.y/4 }, - (Vector2){ player[playerTurn].position.x + player[playerTurn].size.x/4, player[playerTurn].position.y + player[playerTurn].size.y/4 }, - player[playerTurn].previousPoint, GRAY); - - // Actual aiming - DrawTriangle((Vector2){ player[playerTurn].position.x - player[playerTurn].size.x/4, player[playerTurn].position.y - player[playerTurn].size.y/4 }, - (Vector2){ player[playerTurn].position.x + player[playerTurn].size.x/4, player[playerTurn].position.y + player[playerTurn].size.y/4 }, - player[playerTurn].aimingPoint, DARKBLUE); - } - else - { - // Previous aiming - DrawTriangle((Vector2){ player[playerTurn].position.x - player[playerTurn].size.x/4, player[playerTurn].position.y + player[playerTurn].size.y/4 }, - (Vector2){ player[playerTurn].position.x + player[playerTurn].size.x/4, player[playerTurn].position.y - player[playerTurn].size.y/4 }, - player[playerTurn].previousPoint, GRAY); - - // Actual aiming - DrawTriangle((Vector2){ player[playerTurn].position.x - player[playerTurn].size.x/4, player[playerTurn].position.y + player[playerTurn].size.y/4 }, - (Vector2){ player[playerTurn].position.x + player[playerTurn].size.x/4, player[playerTurn].position.y - player[playerTurn].size.y/4 }, - player[playerTurn].aimingPoint, MAROON); - } - } - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); - - EndDrawing(); -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} - -//-------------------------------------------------------------------------------------- -// Additional module functions -//-------------------------------------------------------------------------------------- -static void InitBuildings(void) -{ - // Horizontal generation - int currentWidth = 0; - - // We make sure the absolute error randomly generated for each building, has as a minimum value the screenWidth. - // This way all the screen will be filled with buildings. Each building will have a different, random width. - - float relativeWidth = 100/(100 - BUILDING_RELATIVE_ERROR); - float buildingWidthMean = (screenWidth*relativeWidth/MAX_BUILDINGS) + 1; // We add one to make sure we will cover the whole screen. - - // Vertical generation - int currentHeighth = 0; - int grayLevel; - - // Creation - for (int i = 0; i < MAX_BUILDINGS; i++) - { - // Horizontal - building[i].rectangle.x = currentWidth; - building[i].rectangle.width = GetRandomValue(buildingWidthMean*(100 - BUILDING_RELATIVE_ERROR/2)/100 + 1, buildingWidthMean*(100 + BUILDING_RELATIVE_ERROR)/100); - - currentWidth += building[i].rectangle.width; - - // Vertical - currentHeighth = GetRandomValue(BUILDING_MIN_RELATIVE_HEIGHT, BUILDING_MAX_RELATIVE_HEIGHT); - building[i].rectangle.y = screenHeight - (screenHeight*currentHeighth/100); - building[i].rectangle.height = screenHeight*currentHeighth/100 + 1; - - // Color - grayLevel = GetRandomValue(BUILDING_MIN_GRAYSCALE_COLOR, BUILDING_MAX_GRAYSCALE_COLOR); - building[i].color = (Color){ grayLevel, grayLevel, grayLevel, 255 }; - } -} - -static void InitPlayers(void) -{ - for (int i = 0; i < MAX_PLAYERS; i++) - { - player[i].isAlive = true; - - // Decide the team of this player - if (i % 2 == 0) player[i].isLeftTeam = true; - else player[i].isLeftTeam = false; - - // Now there is no AI - player[i].isPlayer = true; - - // Set size, by default by now - player[i].size = (Vector2){ 40, 40 }; - - // Set position - if (player[i].isLeftTeam) player[i].position.x = GetRandomValue(screenWidth*MIN_PLAYER_POSITION/100, screenWidth*MAX_PLAYER_POSITION/100); - else player[i].position.x = screenWidth - GetRandomValue(screenWidth*MIN_PLAYER_POSITION/100, screenWidth*MAX_PLAYER_POSITION/100); - - for (int j = 0; j < MAX_BUILDINGS; j++) - { - if (building[j].rectangle.x > player[i].position.x) - { - // Set the player in the center of the building - player[i].position.x = building[j-1].rectangle.x + building[j-1].rectangle.width/2; - // Set the player at the top of the building - player[i].position.y = building[j-1].rectangle.y - player[i].size.y/2; - break; - } - } - - // Set statistics to 0 - player[i].aimingPoint = player[i].position; - player[i].previousAngle = 0; - player[i].previousPower = 0; - player[i].previousPoint = player[i].position; - player[i].aimingAngle = 0; - player[i].aimingPower = 0; - - player[i].impactPoint = (Vector2){ -100, -100 }; - } -} - -static bool UpdatePlayer(int playerTurn) -{ - // If we are aiming at the firing quadrant, we calculate the angle - if (GetMousePosition().y <= player[playerTurn].position.y) - { - // Left team - if (player[playerTurn].isLeftTeam && GetMousePosition().x >= player[playerTurn].position.x) - { - // Distance (calculating the fire power) - player[playerTurn].aimingPower = sqrt(pow(player[playerTurn].position.x - GetMousePosition().x, 2) + pow(player[playerTurn].position.y - GetMousePosition().y, 2)); - // Calculates the angle via arcsin - player[playerTurn].aimingAngle = asin((player[playerTurn].position.y - GetMousePosition().y)/player[playerTurn].aimingPower)*RAD2DEG; - // Point of the screen we are aiming at - player[playerTurn].aimingPoint = GetMousePosition(); - - // Ball fired - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - player[playerTurn].previousPoint = player[playerTurn].aimingPoint; - player[playerTurn].previousPower = player[playerTurn].aimingPower; - player[playerTurn].previousAngle = player[playerTurn].aimingAngle; - ball.position = player[playerTurn].position; - - return true; - } - } - // Right team - else if (!player[playerTurn].isLeftTeam && GetMousePosition().x <= player[playerTurn].position.x) - { - // Distance (calculating the fire power) - player[playerTurn].aimingPower = sqrt(pow(player[playerTurn].position.x - GetMousePosition().x, 2) + pow(player[playerTurn].position.y - GetMousePosition().y, 2)); - // Calculates the angle via arcsin - player[playerTurn].aimingAngle = asin((player[playerTurn].position.y - GetMousePosition().y)/player[playerTurn].aimingPower)*RAD2DEG; - // Point of the screen we are aiming at - player[playerTurn].aimingPoint = GetMousePosition(); - - // Ball fired - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - player[playerTurn].previousPoint = player[playerTurn].aimingPoint; - player[playerTurn].previousPower = player[playerTurn].aimingPower; - player[playerTurn].previousAngle = player[playerTurn].aimingAngle; - ball.position = player[playerTurn].position; - - return true; - } - } - else - { - player[playerTurn].aimingPoint = player[playerTurn].position; - player[playerTurn].aimingPower = 0; - player[playerTurn].aimingAngle = 0; - } - } - else - { - player[playerTurn].aimingPoint = player[playerTurn].position; - player[playerTurn].aimingPower = 0; - player[playerTurn].aimingAngle = 0; - } - - return false; -} - -static bool UpdateBall(int playerTurn) -{ - static int explosionNumber = 0; - - // Activate ball - if (!ball.active) - { - if (player[playerTurn].isLeftTeam) - { - ball.speed.x = cos(player[playerTurn].previousAngle*DEG2RAD)*player[playerTurn].previousPower*3/DELTA_FPS; - ball.speed.y = -sin(player[playerTurn].previousAngle*DEG2RAD)*player[playerTurn].previousPower*3/DELTA_FPS; - ball.active = true; - } - else - { - ball.speed.x = -cos(player[playerTurn].previousAngle*DEG2RAD)*player[playerTurn].previousPower*3/DELTA_FPS; - ball.speed.y = -sin(player[playerTurn].previousAngle*DEG2RAD)*player[playerTurn].previousPower*3/DELTA_FPS; - ball.active = true; - } - } - - ball.position.x += ball.speed.x; - ball.position.y += ball.speed.y; - ball.speed.y += GRAVITY/DELTA_FPS; - - // Collision - if (ball.position.x + ball.radius < 0) return true; - else if (ball.position.x - ball.radius > screenWidth) return true; - else - { - // Player collision - for (int i = 0; i < MAX_PLAYERS; i++) - { - if (CheckCollisionCircleRec(ball.position, ball.radius, (Rectangle){ player[i].position.x - player[i].size.x/2, player[i].position.y - player[i].size.y/2, - player[i].size.x, player[i].size.y })) - { - // We can't hit ourselves - if (i == playerTurn) return false; - else - { - // We set the impact point - player[playerTurn].impactPoint.x = ball.position.x; - player[playerTurn].impactPoint.y = ball.position.y + ball.radius; - - // We destroy the player - player[i].isAlive = false; - return true; - } - } - } - - // Building collision - // NOTE: We only check building collision if we are not inside an explosion - for (int i = 0; i < MAX_BUILDINGS; i++) - { - if (CheckCollisionCircles(ball.position, ball.radius, explosion[i].position, explosion[i].radius - ball.radius)) - { - return false; - } - } - - for (int i = 0; i < MAX_BUILDINGS; i++) - { - if (CheckCollisionCircleRec(ball.position, ball.radius, building[i].rectangle)) - { - // We set the impact point - player[playerTurn].impactPoint.x = ball.position.x; - player[playerTurn].impactPoint.y = ball.position.y + ball.radius; - - // We create an explosion - explosion[explosionNumber].position = player[playerTurn].impactPoint; - explosion[explosionNumber].active = true; - explosionNumber++; - - return true; - } - } - } - - return false; -} diff --git a/games/just_do/CMakeLists.txt b/games/just_do/CMakeLists.txt deleted file mode 100644 index f25b6e379..000000000 --- a/games/just_do/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(just_do) - -# Grab the screens -file(GLOB screen_sources "screens/*.c") - -# Executable & linking -add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c ${screen_sources}) -if (NOT TARGET raylib) - find_package(raylib 2.0 REQUIRED) -endif() -target_link_libraries(${PROJECT_NAME} raylib) - -# Resources -# Copy all of the resource files to the destination -file(COPY "resources/" DESTINATION "resources/") diff --git a/games/just_do/LICENSE.txt b/games/just_do/LICENSE.txt deleted file mode 100644 index 510604da4..000000000 --- a/games/just_do/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ - -This game sources are licensed under an unmodified zlib/libpng license, -which is an OSI-certified, BSD-like license: - -Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) - -This software is provided "as-is", without any express or implied warranty. In no event -will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial -applications, and to alter it and redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not claim that you - wrote the original software. If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be misrepresented - as being the original software. - - 3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/games/just_do/Makefile b/games/just_do/Makefile deleted file mode 100644 index 7e463174f..000000000 --- a/games/just_do/Makefile +++ /dev/null @@ -1,413 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= just_do -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= C:\GitHub\raylib - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - # -Wl,--subsystem,windows hides the console window - ifeq ($(BUILD_MODE), RELEASE) - LDFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -PROJECT_SOURCE_FILES ?= \ - just_do.c \ - screens/screen_logo.c \ - screens/screen_level00.c \ - screens/screen_level01.c \ - screens/screen_level02.c \ - screens/screen_level03.c \ - screens/screen_level04.c \ - screens/screen_level05.c \ - screens/screen_level06.c \ - screens/screen_level07.c \ - screens/screen_level08.c \ - screens/screen_level09.c - -# Define all object files from source files -OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) - -# For Android platform we call a custom Makefile.Android -ifeq ($(PLATFORM),PLATFORM_ANDROID) - MAKEFILE_PARAMS = -f Makefile.Android - export PROJECT_NAME - export PROJECT_SOURCE_FILES -else - MAKEFILE_PARAMS = $(PROJECT_NAME) -endif - -# Default target entry -# NOTE: We call this Makefile target or Makefile.Android target -all: - $(MAKE) $(MAKEFILE_PARAMS) - -# Project target defined by PROJECT_NAME -$(PROJECT_NAME): $(OBJS) - $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) - -# Compile source files -# NOTE: This pattern will compile every module defined on $(OBJS) -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/just_do/Makefile.Android b/games/just_do/Makefile.Android deleted file mode 100644 index 29d437b1b..000000000 --- a/games/just_do/Makefile.Android +++ /dev/null @@ -1,300 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Android project (APK building) -# -# Copyright (c) 2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -# Define required raylib variables -PLATFORM ?= PLATFORM_ANDROID -RAYLIB_PATH ?= ..\.. - -# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version -ANDROID_ARCH ?= ARM -ANDROID_API_VERSION = 21 -ifeq ($(ANDROID_ARCH),ARM) - ANDROID_ARCH_NAME = armeabi-v7a -endif -ifeq ($(ANDROID_ARCH),ARM64) - ANDROID_ARCH_NAME = arm64-v8a -endif - -# Required path variables -# NOTE: JAVA_HOME must be set to JDK -JAVA_HOME ?= C:/JavaJDK -ANDROID_HOME = C:/android-sdk -ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION) -ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1 -ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools - -# Android project configuration variables -PROJECT_NAME ?= raylib_game -PROJECT_LIBRARY_NAME ?= main -PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME) -PROJECT_RESOURCES_PATH ?= resources -PROJECT_SOURCE_FILES ?= raylib_game.c - -# Some source files are placed in directories, when compiling to some -# output directory other than source, that directory must pre-exist. -# Here we get a list of required folders that need to be created on -# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors. -PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES))) - -# Android app configuration variables -APP_LABEL_NAME ?= rGame -APP_COMPANY_NAME ?= raylib -APP_PRODUCT_NAME ?= rgame -APP_VERSION_CODE ?= 1 -APP_VERSION_NAME ?= 1.0 -APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png -APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png -APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png -APP_SCREEN_ORIENTATION ?= landscape -APP_KEYSTORE_PASS ?= raylib - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Library path for libraylib.a/libraylib.so -RAYLIB_LIB_PATH = $(RAYLIB_PATH)\src - -# Shared libs must be added to APK if required -# NOTE: Generated NativeLoader.java automatically load those libraries -ifeq ($(RAYLIB_LIBTYPE),SHARED) - PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so -endif - -# Compiler and archiver -# NOTE: GCC is being deprecated in Android NDK r16 -ifeq ($(ANDROID_ARCH),ARM) - CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang - AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar -endif -ifeq ($(ANDROID_ARCH),ARM64) - CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang - AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar -endif - -# Compiler flags for arquitecture -ifeq ($(ANDROID_ARCH),ARM) - CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -endif -ifeq ($(ANDROID_ARCH),ARM64) - CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769 -endif -# Compilation functions attributes options -CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC -# Compiler options for the linker -CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes -# Preprocessor macro definitions -CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) - -# Paths containing required header files -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue - -# Linker options -LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a -LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -# Force linking of library module to define symbol -LDFLAGS += -u ANativeActivity_onCreate -# Library paths containing required libs -LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME) -L$(ANDROID_TOOLCHAIN)\sysroot\usr\lib - -# Define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl - -# Generate target objects list from PROJECT_SOURCE_FILES -OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES)) - -# Android APK building process... some steps required... -# NOTE: typing 'make' will invoke the default target entry called 'all', -all: create_temp_project_dirs \ - copy_project_required_libs \ - copy_project_resources \ - generate_loader_script \ - generate_android_manifest \ - generate_apk_keystore \ - config_project_package \ - compile_project_code \ - compile_project_class \ - compile_project_class_dex \ - create_project_apk_package \ - sign_project_apk_package \ - zipalign_project_apk_package - -# Create required temp directories for APK building -create_temp_project_dirs: - if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj - if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src - if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) - if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib - if not exist $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) mkdir $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) - if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin - if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res - if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi - if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values - if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets - if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens - $(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir))) - -define create_dir - if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1) -endef - -# Copy required shared libs for integration into APK -# NOTE: If using shared libs they are loaded by generated NativeLoader.java -copy_project_required_libs: -ifeq ($(RAYLIB_LIBTYPE),SHARED) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so -endif -ifeq ($(RAYLIB_LIBTYPE),STATIC) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a -endif - -# Copy project required resources: strings.xml, icon.png, assets -# NOTE: Required strings.xml is generated and game resources are copied to assets folder -# TODO: Review xcopy usage, it can not be found in some systems! -copy_project_resources: - copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y - copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y - copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y - @echo ^ > $(PROJECT_BUILD_PATH)/res/values/strings.xml - @echo ^^$(APP_LABEL_NAME)^^ >> $(PROJECT_BUILD_PATH)/res/values/strings.xml - if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F - -# Generate NativeLoader.java to load required shared libraries -# NOTE: Probably not the bet way to generate this file... but it works. -generate_loader_script: - @echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -ifeq ($(RAYLIB_LIBTYPE),SHARED) - @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -endif - @echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Generate AndroidManifest.xml with all the required options -# NOTE: Probably not the bet way to generate this file... but it works. -generate_android_manifest: - @echo ^ > $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - -# Generate storekey for APK signing: $(PROJECT_NAME).keystore -# NOTE: Configure here your Distinguished Names (-dname) if required! -generate_apk_keystore: - if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA - -# Config project package and resource using AndroidManifest.xml and res/values/strings.xml -# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java -config_project_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar - -# Compile native_app_glue code as static library: obj/libnative_app_glue.a -compile_native_app_glue: - $(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS) - $(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o - -# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so -compile_project_code: $(OBJS) - $(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) - -# Compile all .c files required into object (.o) files -# NOTE: Those files will be linked into a shared library -$(PROJECT_BUILD_PATH)/obj/%.o:%.c - $(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot - -# Compile project .java code into .class (Java bytecode) -compile_project_class: - $(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Compile .class files into Dalvik executable bytecode (.dex) -# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT) -compile_project_class_dex: - $(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj - -# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk -# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so -# NOTE: Use -A resources to define additional directory in which to find raw asset files -create_project_apk_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin - cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS) - -# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk -sign_project_apk_package: - $(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key - -# Create zip-aligned APK package: $(PROJECT_NAME).apk -zipalign_project_apk_package: - $(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk - -# Install $(PROJECT_NAME).apk to default emulator/device -# NOTE: Use -e (emulator) or -d (device) parameters if required -install: - $(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk - -# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64) -check_device_abi: - $(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi - -# Monitorize output log coming from device, only raylib tag -logcat: - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -# Install and monitorize $(PROJECT_NAME).apk to default emulator/device -deploy: - $(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W - -# Clean everything -clean: - del $(PROJECT_BUILD_PATH)\* /f /s /q - rmdir $(PROJECT_BUILD_PATH) /s /q - @echo Cleaning done diff --git a/games/just_do/just_do.c b/games/just_do/just_do.c deleted file mode 100644 index 6a73a2b38..000000000 --- a/games/just_do/just_do.c +++ /dev/null @@ -1,356 +0,0 @@ -/******************************************************************************************* -* -* JUST DO [GLOBAL GAME JAM 2015] -* -* Experimental puzzle game that lets the user try to find a logic -* solution to different shape-color-based situations. -* -* This game has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include "screens/screens.h" // NOTE: Defines global variable: currentScreen - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- -const int screenWidth = 1280; // Moved to screens.h -const int screenHeight = 720; // Moved to screens.h - -// Required variables to manage screen transitions (fade-in, fade-out) -float transAlpha = 0; -bool onTransition = false; -bool transFadeOut = false; -int transFromScreen = -1; -int transToScreen = -1; -int framesCounter = 0; - -//static Sound levelWin; -Music music; - -//---------------------------------------------------------------------------------- -// Local Functions Declaration -//---------------------------------------------------------------------------------- -void TransitionToScreen(int screen); -void UpdateTransition(void); -void DrawTransition(void); - -void UpdateDrawFrame(void); // Update and Draw one frame - -//---------------------------------------------------------------------------------- -// Main entry point -//---------------------------------------------------------------------------------- -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "JUST DO [GGJ15]"); - - // Load global data here (assets that must be available in all screens, i.e. fonts) - InitAudioDevice(); - - levelWin = LoadSound("resources/win.wav"); - music = LoadMusicStream("resources/ambient.ogg"); - - // Setup and Init first screen - currentScreen = LOGO; - InitLogoScreen(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - UpdateDrawFrame(); - } -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload all global loaded data (i.e. fonts) here! - UnloadSound(levelWin); - UnloadMusicStream(music); - - CloseAudioDevice(); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//---------------------------------------------------------------------------------- -// Local Functions Definition -//---------------------------------------------------------------------------------- -void TransitionToScreen(int screen) -{ - onTransition = true; - transFromScreen = currentScreen; - transToScreen = screen; -} - -void UpdateTransition(void) -{ - if (!transFadeOut) - { - transAlpha += 0.02f; - - if (transAlpha >= 1.0) - { - transAlpha = 1.0; - currentScreen = transToScreen; - transFadeOut = true; - framesCounter = 0; - } - } - else // Transition fade out logic - { - transAlpha -= 0.02f; - - if (transAlpha <= 0) - { - transAlpha = 0; - transFadeOut = false; - onTransition = false; - transFromScreen = -1; - transToScreen = -1; - } - } -} - -void DrawTransition(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, transAlpha)); -} - -void UpdateDrawFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - if (currentScreen != LOGO) UpdateMusicStream(music); - - if (!onTransition) - { - if (IsKeyPressed('0')) - { - TransitionToScreen(LEVEL00); - InitLevel00Screen(); - } - else if (IsKeyPressed('1')) - { - TransitionToScreen(LEVEL01); - InitLevel01Screen(); - } - else if (IsKeyPressed('2')) - { - TransitionToScreen(LEVEL02); - InitLevel02Screen(); - } - else if (IsKeyPressed('3')) - { - TransitionToScreen(LEVEL03); - InitLevel03Screen(); - } - else if (IsKeyPressed('4')) - { - TransitionToScreen(LEVEL04); - InitLevel04Screen(); - } - else if (IsKeyPressed('5')) - { - TransitionToScreen(LEVEL05); - InitLevel05Screen(); - } - else if (IsKeyPressed('6')) - { - TransitionToScreen(LEVEL06); - InitLevel06Screen(); - } - else if (IsKeyPressed('7')) - { - TransitionToScreen(LEVEL07); - InitLevel07Screen(); - } - else if (IsKeyPressed('8')) - { - TransitionToScreen(LEVEL08); - InitLevel08Screen(); - } - else if (IsKeyPressed('9')) - { - TransitionToScreen(LEVEL09); - InitLevel08Screen(); - } - - switch(currentScreen) - { - case LOGO: - { - UpdateLogoScreen(); - - if (FinishLogoScreen()) - { - UnloadLogoScreen(); - TransitionToScreen(LEVEL00); - InitLevel00Screen(); - - PlayMusicStream(music); - SetMusicVolume(music, 0.6f); - } - } break; - case LEVEL00: - { - UpdateLevel00Screen(); - - if (FinishLevel00Screen()) - { - UnloadLevel00Screen(); - TransitionToScreen(LEVEL01); - InitLevel01Screen(); - } - } break; - case LEVEL01: - { - UpdateLevel01Screen(); - - if (FinishLevel01Screen()) - { - UnloadLevel01Screen(); - TransitionToScreen(LEVEL02); - InitLevel02Screen(); - } - } break; - case LEVEL02: - { - UpdateLevel02Screen(); - - if (FinishLevel02Screen()) - { - UnloadLevel02Screen(); - TransitionToScreen(LEVEL03); - InitLevel03Screen(); - } - } break; - case LEVEL03: - { - UpdateLevel03Screen(); - - if (FinishLevel03Screen()) - { - UnloadLevel03Screen(); - TransitionToScreen(LEVEL04); - InitLevel04Screen(); - } - } break; - case LEVEL04: - { - UpdateLevel04Screen(); - - if (FinishLevel04Screen()) - { - UnloadLevel04Screen(); - TransitionToScreen(LEVEL05); - InitLevel05Screen(); - } - } break; - case LEVEL05: - { - UpdateLevel05Screen(); - - if (FinishLevel05Screen()) - { - UnloadLevel05Screen(); - TransitionToScreen(LEVEL06); - InitLevel06Screen(); - } - } break; - case LEVEL06: - { - UpdateLevel06Screen(); - - if (FinishLevel06Screen()) - { - UnloadLevel06Screen(); - TransitionToScreen(LEVEL07); - InitLevel07Screen(); - } - } break; - case LEVEL07: - { - UpdateLevel07Screen(); - - if (FinishLevel07Screen()) - { - UnloadLevel07Screen(); - TransitionToScreen(LEVEL08); - InitLevel08Screen(); - } - } break; - case LEVEL08: - { - UpdateLevel08Screen(); - - if (FinishLevel08Screen()) - { - UnloadLevel08Screen(); - TransitionToScreen(LEVEL09); - InitLevel09Screen(); - } - } break; - case LEVEL09: - { - UpdateLevel09Screen(); - - if (FinishLevel09Screen()) - { - UnloadLevel09Screen(); - TransitionToScreen(LEVEL00); - InitLevel00Screen(); - } - } break; - default: break; - } - } - else UpdateTransition(); // Update transition (fade-in, fade-out) - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch(currentScreen) - { - case LOGO: DrawLogoScreen(); break; - case LEVEL00: DrawLevel00Screen(); break; - case LEVEL01: DrawLevel01Screen(); break; - case LEVEL02: DrawLevel02Screen(); break; - case LEVEL03: DrawLevel03Screen(); break; - case LEVEL04: DrawLevel04Screen(); break; - case LEVEL05: DrawLevel05Screen(); break; - case LEVEL06: DrawLevel06Screen(); break; - case LEVEL07: DrawLevel07Screen(); break; - case LEVEL08: DrawLevel08Screen(); break; - case LEVEL09: DrawLevel09Screen(); break; - default: break; - } - - if (onTransition) DrawTransition(); - - EndDrawing(); - //---------------------------------------------------------------------------------- -} diff --git a/games/just_do/resources/ambient.ogg b/games/just_do/resources/ambient.ogg deleted file mode 100644 index af7f836ed..000000000 Binary files a/games/just_do/resources/ambient.ogg and /dev/null differ diff --git a/games/just_do/resources/win.wav b/games/just_do/resources/win.wav deleted file mode 100644 index 72520f993..000000000 Binary files a/games/just_do/resources/win.wav and /dev/null differ diff --git a/games/just_do/screens/screen_level00.c b/games/just_do/screens/screen_level00.c deleted file mode 100644 index e72e3812b..000000000 --- a/games/just_do/screens/screen_level00.c +++ /dev/null @@ -1,167 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level00 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level00 screen global variables -static int framesCounter; -static int finishScreen; - -static Rectangle boundsU, boundsO; - -static bool mouseOverU = false; -static bool mouseOverO = false; -static bool placedU = false; -static bool placedO = false; - -static bool done = false; -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level00 Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Level00 Screen Initialization logic -void InitLevel00Screen(void) -{ - // Initialize Level00 screen variables here! - framesCounter = 0; - finishScreen = 0; - - boundsU = (Rectangle){GetScreenWidth()/2 - 265, -200, MeasureText("U", 160) + 40, 160 }; - boundsO = (Rectangle){GetScreenWidth() - 370, -30, MeasureText("O", 160) + 40, 160 }; -} - -// Level00 Screen Update logic -void UpdateLevel00Screen(void) -{ - // Update Level00 screen variables here! - if (!done) framesCounter++; - - if (!done) - { - if (!placedU) boundsU.y += 2; - - if (boundsU.y >= GetScreenHeight()) boundsU.y = -boundsU.height; - - Vector2 mousePos = GetMousePosition(); - - if (CheckCollisionPointRec(mousePos, boundsU)) - { - mouseOverU = true; - - if (!placedU && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - if ((boundsU.y > GetScreenHeight()/2 - 110) && ((boundsU.y + boundsU.height) < (GetScreenHeight()/2 + 100))) - { - placedU = true; - } - } - } - else mouseOverU = false; - - if (CheckCollisionPointRec(mousePos, boundsO)) - { - mouseOverO = true; - - if (!placedO && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) boundsO.y += 100; - - if (boundsO.y >= (GetScreenHeight()/2 - 130)) placedO = true; - } - else mouseOverO = false; - - if (placedO && placedU) - { - done = true; - PlaySound(levelWin); - } - } - - if (done && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 30) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level00 Screen Draw logic -void DrawLevel00Screen(void) -{ - // Draw Level00 screen - DrawText("U", boundsU.x, boundsU.y + 10, 160, GRAY); - DrawText("J", GetScreenWidth()/2 - MeasureText("JUST DO", 160)/2, GetScreenHeight()/2 - 80, 160, GRAY); - DrawText("ST D", GetScreenWidth()/2 - MeasureText("JUST DO", 160)/2 + 210, GetScreenHeight()/2 - 80, 160, GRAY); - DrawText("O", boundsO.x, boundsO.y + 10, 160, GRAY); - - DrawText("by RAMON SANTAMARIA (@raysan5)", 370, GetScreenHeight()/2 + 100, 30, Fade(LIGHTGRAY, 0.4f)); - - if (mouseOverU && !placedU) DrawRectangleLines(boundsU.x - 20, boundsU.y, boundsU.width, boundsU.height, Fade(LIGHTGRAY, 0.8f)); - //DrawRectangleBordersRec(boundsU, -20, 0, 20, Fade(RED, 0.3f)); - - if (mouseOverO && !placedO) DrawRectangleLines(boundsO.x - 20, boundsO.y, boundsO.width, boundsO.height, Fade(LIGHTGRAY, 0.8f)); - //DrawRectangleBordersRec(boundsO, -20, 0, 20, Fade(RED, 0.3f)); - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); - DrawText("LEVEL 00", GetScreenWidth()/2 - MeasureText("LEVEL 00", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 00", GetScreenWidth()/2 - MeasureText("LEVEL 00", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level00 Screen Unload logic -void UnloadLevel00Screen(void) -{ - // TODO: Unload Level00 screen variables here! -} - -// Level00 Screen should finish? -int FinishLevel00Screen(void) -{ - return finishScreen; -} - -void DrawRectangleBordersRec(Rectangle rec, int offsetX, int offsetY, int borderSize, Color col) -{ - DrawRectangle(rec.x + offsetX, rec.y + offsetY, rec.width, borderSize, col); - DrawRectangle(rec.x + offsetX, rec.y + borderSize + offsetY, borderSize, rec.height - borderSize*2, col); - DrawRectangle(rec.x + rec.width - borderSize + offsetX, rec.y + borderSize + offsetY, borderSize, rec.height - borderSize*2, col); - DrawRectangle(rec.x + offsetX, rec.y + rec.height - borderSize + offsetY, rec.width, borderSize, col); -} \ No newline at end of file diff --git a/games/just_do/screens/screen_level01.c b/games/just_do/screens/screen_level01.c deleted file mode 100644 index 8cb76bf1d..000000000 --- a/games/just_do/screens/screen_level01.c +++ /dev/null @@ -1,163 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level01 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level01 screen global variables -static int framesCounter; -static int finishScreen; - -static Rectangle innerLeftRec, outerLeftRec; -static Rectangle innerRightRec, outerRightRec; - -static bool done = false; -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level01 Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Level01 Screen Initialization logic -void InitLevel01Screen(void) -{ - // Initialize Level01 screen variables here! - framesCounter = 0; - finishScreen = 0; - - outerLeftRec = (Rectangle){ 0, 0, GetScreenWidth()/2, GetScreenHeight() }; - outerRightRec = (Rectangle){ GetScreenWidth()/2, 0, GetScreenWidth()/2, GetScreenHeight() }; - - innerLeftRec = (Rectangle){ GetScreenWidth()/4 - 200, GetScreenHeight()/2 - 200, 400, 400}; - innerRightRec = (Rectangle){ GetScreenWidth()/2 + GetScreenWidth()/4 - 200, GetScreenHeight()/2 - 200, 400, 400}; -} - -// Level01 Screen Update logic -void UpdateLevel01Screen(void) -{ - // Update Level01 screen - framesCounter++; - - if (!done) - { - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - if (CheckCollisionPointRec(GetMousePosition(), innerLeftRec)) - { - if (innerRightRec.width > 0) - { - innerRightRec.x += 20; - innerRightRec.y += 20; - innerRightRec.width -= 40; - innerRightRec.height -= 40; - } - } - else if (CheckCollisionPointRec(GetMousePosition(), innerRightRec)) - { - if (innerLeftRec.width > 0) - { - innerLeftRec.x += 20; - innerLeftRec.y += 20; - innerLeftRec.width -= 40; - innerLeftRec.height -= 40; - } - } - else if (CheckCollisionPointRec(GetMousePosition(), outerLeftRec)) - { - innerLeftRec.x -= 20; - innerLeftRec.y -= 20; - innerLeftRec.width += 40; - innerLeftRec.height += 40; - } - else if (CheckCollisionPointRec(GetMousePosition(), outerRightRec)) - { - innerRightRec.x -= 20; - innerRightRec.y -= 20; - innerRightRec.width += 40; - innerRightRec.height += 40; - } - } - - - if (((innerRightRec.width == 0) && (innerLeftRec.height >= GetScreenHeight())) || - ((innerLeftRec.width == 0) && (innerRightRec.height >= GetScreenHeight()))) - { - done = true; - PlaySound(levelWin); - } - } - - if (done && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level01 Screen Draw logic -void DrawLevel01Screen(void) -{ - // Draw Level01 screen - if (!levelFinished) DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), LIGHTGRAY); - else DrawRectangle(60, 60, GetScreenWidth() - 120, GetScreenHeight() - 120, LIGHTGRAY); - - DrawRectangleRec(outerLeftRec, GRAY); - DrawRectangleRec(innerLeftRec, RAYWHITE); - DrawRectangleRec(outerRightRec, RAYWHITE); - DrawRectangleRec(innerRightRec, GRAY); - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); - DrawText("LEVEL 01", GetScreenWidth()/2 - MeasureText("LEVEL 01", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 01", GetScreenWidth()/2 - MeasureText("LEVEL 01", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level01 Screen Unload logic -void UnloadLevel01Screen(void) -{ - // TODO: Unload Level01 screen variables here! -} - -// Level01 Screen should finish? -int FinishLevel01Screen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/just_do/screens/screen_level02.c b/games/just_do/screens/screen_level02.c deleted file mode 100644 index 584edcef4..000000000 --- a/games/just_do/screens/screen_level02.c +++ /dev/null @@ -1,157 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level02 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level02 screen global variables -static int framesCounter; -static int finishScreen; - -static Vector2 bouncingBallPos; -static float bouncingBallRadius = 40; -static Vector2 bouncingBallSpeed; - -static Vector2 holeCirclePos; -static float holeCircleRadius = 50; - -static bool ballOnHole = false; - -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level02 Screen Functions Definition -//---------------------------------------------------------------------------------- -float Vector2Distance(Vector2 v1, Vector2 v2); - -// Level02 Screen Initialization logic -void InitLevel02Screen(void) -{ - // TODO: Initialize Level02 screen variables here! - framesCounter = 0; - finishScreen = 0; - - bouncingBallPos = (Vector2){ 120, 80 }; - bouncingBallSpeed = (Vector2){ 6, 8 }; - holeCirclePos = (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 }; -} - -// Level02 Screen Update logic -void UpdateLevel02Screen(void) -{ - // Update Level02 screen - framesCounter++; - - if (!ballOnHole) - { - bouncingBallPos.x += bouncingBallSpeed.x; - bouncingBallPos.y += bouncingBallSpeed.y; - - if (((bouncingBallPos.x - bouncingBallRadius) <= 0) || ((bouncingBallPos.x + bouncingBallRadius) >= GetScreenWidth())) bouncingBallSpeed.x *= -1; - if (((bouncingBallPos.y - bouncingBallRadius) <= 0) || ((bouncingBallPos.y + bouncingBallRadius) >= GetScreenHeight())) bouncingBallSpeed.y *= -1; - - Vector2 mousePos = GetMousePosition(); - - if (CheckCollisionPointCircle(mousePos, bouncingBallPos, 120)) - { - bouncingBallPos.x = GetRandomValue(80, 1200); - bouncingBallPos.y = GetRandomValue(80, 650); - } - - if (CheckCollisionPointCircle(mousePos, holeCirclePos, 120)) - { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) - { - holeCirclePos = mousePos; - - if ((holeCirclePos.x - holeCircleRadius) <= 0) holeCirclePos.x = holeCircleRadius; - else if ((holeCirclePos.x + holeCircleRadius) >= GetScreenWidth()) holeCirclePos.x = GetScreenWidth() - holeCircleRadius; - - if ((holeCirclePos.y - holeCircleRadius) <= 0) holeCirclePos.y = holeCircleRadius; - else if ((holeCirclePos.y + holeCircleRadius) >= GetScreenHeight()) holeCirclePos.y = GetScreenHeight() - holeCircleRadius; - } - } - - if (Vector2Distance(bouncingBallPos, holeCirclePos) < 20) - { - ballOnHole = true; - PlaySound(levelWin); - } - } - - if (ballOnHole && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level02 Screen Draw logic -void DrawLevel02Screen(void) -{ - // Draw Level02 screen - - DrawCircleV(holeCirclePos, holeCircleRadius, LIGHTGRAY); - DrawCircleV(bouncingBallPos, bouncingBallRadius, DARKGRAY); - - DrawCircleLines(bouncingBallPos.x, bouncingBallPos.y, 120, Fade(LIGHTGRAY, 0.8f)); - - - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); - DrawText("LEVEL 02", GetScreenWidth()/2 - MeasureText("LEVEL 02", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 02", GetScreenWidth()/2 - MeasureText("LEVEL 02", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level02 Screen Unload logic -void UnloadLevel02Screen(void) -{ - // TODO: Unload Level02 screen variables here! -} - -// Level02 Screen should finish? -int FinishLevel02Screen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/just_do/screens/screen_level03.c b/games/just_do/screens/screen_level03.c deleted file mode 100644 index 7c3aa2863..000000000 --- a/games/just_do/screens/screen_level03.c +++ /dev/null @@ -1,134 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level03 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level03 screen global variables -static int framesCounter; -static int finishScreen; - -static Rectangle holeRec, pieceRec; -static bool showPiece = false; -static bool pieceSelected = false; - -static bool done = false; -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level03 Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Level03 Screen Initialization logic -void InitLevel03Screen(void) -{ - // Initialize Level03 screen variables here! - framesCounter = 0; - finishScreen = 0; - - holeRec = (Rectangle){ GetScreenWidth()/2 - 50, GetScreenHeight()/2 - 50, 100, 100 }; - pieceRec = (Rectangle){ 200, 400, 100, 100 }; -} - -// Level03 Screen Update logic -void UpdateLevel03Screen(void) -{ - // Update Level03 screen variables here! - framesCounter++; - - Vector2 mousePos = GetMousePosition(); - - if (!done) - { - if (CheckCollisionPointRec(mousePos, holeRec)) showPiece = true; - else showPiece = false; - - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) - { - if (CheckCollisionPointRec(mousePos, pieceRec)) - { - pieceSelected = true; - - pieceRec.x = ((int)mousePos.x - 50); - pieceRec.y = ((int)mousePos.y - 50); - } - } - - if ((pieceRec.x == holeRec.x) && !(CheckCollisionPointRec(mousePos, holeRec))) - { - done = true; - PlaySound(levelWin); - } - } - - if (done && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level03 Screen Draw logic -void DrawLevel03Screen(void) -{ - // Draw Level03 screen - DrawRectangleRec(holeRec, GRAY); - DrawRectangleRec(pieceRec, RAYWHITE); - - if (showPiece) DrawRectangleLines(pieceRec.x, pieceRec.y, pieceRec.width, pieceRec.height, Fade(LIGHTGRAY, 0.8f)); - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); - DrawText("LEVEL 03", GetScreenWidth()/2 - MeasureText("LEVEL 03", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 03", GetScreenWidth()/2 - MeasureText("LEVEL 03", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level03 Screen Unload logic -void UnloadLevel03Screen(void) -{ - // TODO: Unload Level03 screen variables here! -} - -// Level03 Screen should finish? -int FinishLevel03Screen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/just_do/screens/screen_level04.c b/games/just_do/screens/screen_level04.c deleted file mode 100644 index 7a8a21f12..000000000 --- a/games/just_do/screens/screen_level04.c +++ /dev/null @@ -1,147 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level04 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level04 screen global variables -static int framesCounter; -static int finishScreen; - -static Vector2 circlesCenter; -static float innerCircleRadius = 40; -static float outerCircleRadius = 300; - -static bool done = false; -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level04 Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Level04 Screen Initialization logic -void InitLevel04Screen(void) -{ - // Initialize Level04 screen variables here! - framesCounter = 0; - finishScreen = 0; - - circlesCenter = (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 }; -} - -// Level04 Screen Update logic -void UpdateLevel04Screen(void) -{ - // Update Level04 screen variables here! - framesCounter++; - - if (!done) - { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) - { - if (CheckCollisionPointCircle(GetMousePosition(), circlesCenter, innerCircleRadius)) - { - innerCircleRadius += 2; - } - else if (CheckCollisionPointCircle(GetMousePosition(), circlesCenter, outerCircleRadius)) - { - outerCircleRadius += 2; - } - else - { - outerCircleRadius -= 2; - - if (outerCircleRadius <= 260) outerCircleRadius = 260; - } - } - else - { - if (!done) - { - innerCircleRadius -= 2; - if (outerCircleRadius > 300) outerCircleRadius -= 2; - } - } - - if (innerCircleRadius >= 270) innerCircleRadius = 270; - else if (innerCircleRadius <= 40) innerCircleRadius = 40; - - if (outerCircleRadius >= 600) outerCircleRadius = 600; - - if (innerCircleRadius >= outerCircleRadius) - { - done = true; - PlaySound(levelWin); - } - } - - if (done && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level04 Screen Draw logic -void DrawLevel04Screen(void) -{ - // Draw Level04 screen here! - //DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GRAY); - DrawCircleV(circlesCenter, outerCircleRadius, GRAY); - DrawCircleV(circlesCenter, innerCircleRadius, RAYWHITE); - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); - DrawText("LEVEL 04", GetScreenWidth()/2 - MeasureText("LEVEL 04", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 04", GetScreenWidth()/2 - MeasureText("LEVEL 04", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level04 Screen Unload logic -void UnloadLevel04Screen(void) -{ - // TODO: Unload Level04 screen variables here! -} - -// Level04 Screen should finish? -int FinishLevel04Screen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/just_do/screens/screen_level05.c b/games/just_do/screens/screen_level05.c deleted file mode 100644 index 5d5d23d61..000000000 --- a/games/just_do/screens/screen_level05.c +++ /dev/null @@ -1,185 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level05 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#define NUM_CIRCLES 10 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level05 screen global variables -static int framesCounter; -static int finishScreen; - -static Vector2 circleCenter; -static float circleRadius[NUM_CIRCLES]; -static bool circleLocked[NUM_CIRCLES]; -static Color circleColor[NUM_CIRCLES]; - -static bool done = false; -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level05 Screen Functions Definition -//---------------------------------------------------------------------------------- -static bool CheckColor(Color col1, Color col2); - -// Level05 Screen Initialization logic -void InitLevel05Screen(void) -{ - // Initialize Level05 screen variables here! - framesCounter = 0; - finishScreen = 0; - - circleCenter = (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 }; - - for (int i = 0; i < NUM_CIRCLES; i++) - { - circleRadius[i] = 760/NUM_CIRCLES*(NUM_CIRCLES - i); - circleLocked[i] = false; - } - - // That's a dirty hack to give sonme coherence to this puzzle... - circleColor[9] = GRAY; - circleColor[8] = RAYWHITE; - circleColor[7] = RAYWHITE; - circleColor[6] = GRAY; - circleColor[5] = RAYWHITE; - circleColor[4] = GRAY; - circleColor[3] = GRAY; - circleColor[2] = GRAY; - circleColor[1] = RAYWHITE; - circleColor[0] = GRAY; -} - -// Level05 Screen Update logic -void UpdateLevel05Screen(void) -{ - // Update Level05 screen variables here! - framesCounter++; - - if (!done) - { - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - for (int i = NUM_CIRCLES - 1; i >= 0; i--) - { - if (CheckCollisionPointCircle(GetMousePosition(), circleCenter, circleRadius[i])) - { - if (i == 0) - { - if (CheckColor(circleColor[8], GRAY)) circleColor[8] = RAYWHITE; - else circleColor[8] = GRAY; - } - else if (i == 2) - { - if (CheckColor(circleColor[5], GRAY)) circleColor[5] = RAYWHITE; - else circleColor[5] = GRAY; - } - else if (i == 3) - { - if (CheckColor(circleColor[6], GRAY)) circleColor[6] = RAYWHITE; - else circleColor[6] = GRAY; - } - else - { - if (CheckColor(circleColor[i], GRAY)) circleColor[i] = RAYWHITE; - else circleColor[i] = GRAY; - } - return; - } - } - } - - // Check all cicles done - for (int i = 0; i < NUM_CIRCLES; i++) - { - done = true; - - if (CheckColor(circleColor[i], RAYWHITE)) - { - done = false; - return; - } - - //if (done) PlaySound(levelWin); - } - } - - if (done && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level05 Screen Draw logic -void DrawLevel05Screen(void) -{ - // Draw Level05 screen - for (int i = 0; i < NUM_CIRCLES; i++) - { - DrawPoly(circleCenter, 64, circleRadius[i], 0.0f, circleColor[i]); - } - - - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); - DrawText("LEVEL 05", GetScreenWidth()/2 - MeasureText("LEVEL 05", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 05", GetScreenWidth()/2 - MeasureText("LEVEL 05", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level05 Screen Unload logic -void UnloadLevel05Screen(void) -{ - // TODO: Unload Level05 screen variables here! -} - -// Level05 Screen should finish? -int FinishLevel05Screen(void) -{ - return finishScreen; -} - -static bool CheckColor(Color col1, Color col2) -{ - return ((col1.r == col2.r) && (col1.g == col2.g) && (col1.b == col2.b) && (col1.a == col2.a)); -} \ No newline at end of file diff --git a/games/just_do/screens/screen_level06.c b/games/just_do/screens/screen_level06.c deleted file mode 100644 index ec72d70c1..000000000 --- a/games/just_do/screens/screen_level06.c +++ /dev/null @@ -1,156 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level06 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level06 screen global variables -static int framesCounter; -static int finishScreen; - -static Rectangle centerRec; - -static Rectangle movingRecs[4]; -static int speedRecs[4]; -static bool stoppedRec[4]; -static int mouseOverNum = -1; - -static bool done = false; -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level06 Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Level06 Screen Initialization logic -void InitLevel06Screen(void) -{ - // Initialize Level06 screen variables here! - framesCounter = 0; - finishScreen = 0; - - centerRec = (Rectangle){ GetScreenWidth()/2 - 100, 0, 200, GetScreenHeight() }; - - for (int i = 0; i < 4; i++) - { - movingRecs[i] = (Rectangle){ GetRandomValue(0, 5)*150, (i*150) + 90, 100, 100 }; - stoppedRec[i] = false; - speedRecs[i] = GetRandomValue(4, 8); - } -} - -// Level06 Screen Update logic -void UpdateLevel06Screen(void) -{ - // Update Level06 screen variables here! - framesCounter++; - - if (!done) - { - for (int i = 0; i < 4; i++) - { - if (!stoppedRec[i]) movingRecs[i].x += speedRecs[i]; - - if (movingRecs[i].x >= GetScreenWidth()) movingRecs[i].x = -movingRecs[i].width; - - if (CheckCollisionPointRec(GetMousePosition(), movingRecs[i])) - { - mouseOverNum = i; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - if (i == 0) stoppedRec[3] = !stoppedRec[3]; - else if (i == 1) stoppedRec[2] = !stoppedRec[2]; - else if (i == 2) stoppedRec[0] = !stoppedRec[0]; - else if (i == 3) stoppedRec[1] = !stoppedRec[1]; - } - } - } - - // Check if all boxes are aligned - if (((movingRecs[0].x > centerRec.x) && ((movingRecs[0].x + movingRecs[0].width) < (centerRec.x + centerRec.width))) && - ((movingRecs[1].x > centerRec.x) && ((movingRecs[1].x + movingRecs[1].width) < (centerRec.x + centerRec.width))) && - ((movingRecs[2].x > centerRec.x) && ((movingRecs[2].x + movingRecs[2].width) < (centerRec.x + centerRec.width))) && - ((movingRecs[3].x > centerRec.x) && ((movingRecs[3].x + movingRecs[3].width) < (centerRec.x + centerRec.width)))) - { - done = true; - PlaySound(levelWin); - } - } - - - if (done && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level06 Screen Draw logic -void DrawLevel06Screen(void) -{ - // Draw Level06 screen - DrawRectangleRec(centerRec, LIGHTGRAY); - - for (int i = 0; i < 4; i++) - { - DrawRectangleRec(movingRecs[i], GRAY); - } - - if (!done && (mouseOverNum >= 0)) DrawRectangleLines(movingRecs[mouseOverNum].x - 5, movingRecs[mouseOverNum].y - 5, movingRecs[mouseOverNum].width + 10, movingRecs[mouseOverNum].height + 10, Fade(LIGHTGRAY, 0.8f)); - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); - DrawText("LEVEL 06", GetScreenWidth()/2 - MeasureText("LEVEL 06", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 06", GetScreenWidth()/2 - MeasureText("LEVEL 06", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level06 Screen Unload logic -void UnloadLevel06Screen(void) -{ - // TODO: Unload Level06 screen variables here! -} - -// Level06 Screen should finish? -int FinishLevel06Screen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/just_do/screens/screen_level07.c b/games/just_do/screens/screen_level07.c deleted file mode 100644 index 2ed4f9440..000000000 --- a/games/just_do/screens/screen_level07.c +++ /dev/null @@ -1,178 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level07 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level07 screen global variables -static int framesCounter; -static int finishScreen; - -static Vector2 leftCirclePos, middleCirclePos, rightCirclePos; -static Vector2 leftBtnPos, middleBtnPos, rightBtnPos; -static float circleRadius = 100; -static float btnRadius = 80; - -static bool leftCircleActive, middleCircleActive, rightCircleActive; -static Color leftCircleColor, middleCircleColor, rightCircleColor; - -static bool done = false; -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level07 Screen Functions Definition -//---------------------------------------------------------------------------------- -static bool CheckColor(Color col1, Color col2); - -// Level07 Screen Initialization logic -void InitLevel07Screen(void) -{ - // Initialize Level07 screen variables here! - framesCounter = 0; - finishScreen = 0; - - leftCirclePos = (Vector2){ GetScreenWidth()/2 - 340, GetScreenHeight()/2 - 100 }; - middleCirclePos = (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 - 100 }; - rightCirclePos = (Vector2){ GetScreenWidth()/2 + 340, GetScreenHeight()/2 - 100 }; - - leftBtnPos = (Vector2){ GetScreenWidth()/2 - 340, GetScreenHeight()/2 + 120 }; - middleBtnPos = (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 + 120 }; - rightBtnPos = (Vector2){ GetScreenWidth()/2 + 340, GetScreenHeight()/2 + 120 }; - - leftCircleActive = false; - middleCircleActive = true; - rightCircleActive = false; - - leftCircleColor = GRAY; - middleCircleColor = GRAY; - rightCircleColor = GRAY; -} - -// Level07 Screen Update logic -void UpdateLevel07Screen(void) -{ - // Update Level07 screen variables here! - framesCounter++; - - if (!done) - { - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - if (CheckCollisionPointCircle(GetMousePosition(), leftBtnPos, btnRadius)) leftCircleActive = !leftCircleActive; - else if (CheckCollisionPointCircle(GetMousePosition(), middleBtnPos, btnRadius)) middleCircleActive = !middleCircleActive; - else if (CheckCollisionPointCircle(GetMousePosition(), rightBtnPos, btnRadius)) rightCircleActive = !rightCircleActive; - - if (rightCircleActive && CheckCollisionPointCircle(GetMousePosition(), leftCirclePos, circleRadius)) - { - if (CheckColor(leftCircleColor, GRAY)) leftCircleColor = LIGHTGRAY; - else leftCircleColor = GRAY; - } - - if (middleCircleActive && CheckCollisionPointCircle(GetMousePosition(), middleCirclePos, circleRadius)) - { - if (CheckColor(middleCircleColor, GRAY)) middleCircleColor = LIGHTGRAY; - else middleCircleColor = GRAY; - } - - if (rightCircleActive && leftCircleActive && CheckCollisionPointCircle(GetMousePosition(), rightCirclePos, circleRadius)) - { - if (CheckColor(rightCircleColor, GRAY)) rightCircleColor = LIGHTGRAY; - else rightCircleColor = GRAY; - } - } - - // Check all cicles done - if (CheckColor(leftCircleColor, LIGHTGRAY) && CheckColor(middleCircleColor, LIGHTGRAY) && CheckColor(rightCircleColor, LIGHTGRAY) && - !leftCircleActive && !middleCircleActive && !rightCircleActive) - { - done = true; - PlaySound(levelWin); - } - } - - if (done && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level07 Screen Draw logic -void DrawLevel07Screen(void) -{ - // Draw Level07 screen here! - DrawCircleV(leftCirclePos, circleRadius, leftCircleColor); - DrawCircleV(middleCirclePos, circleRadius, middleCircleColor); - DrawCircleV(rightCirclePos, circleRadius, rightCircleColor); - - if (leftCircleActive) DrawCircleV(leftBtnPos, btnRadius, GRAY); - else DrawCircleV(leftBtnPos, btnRadius, LIGHTGRAY); - - if (middleCircleActive) DrawCircleV(middleBtnPos, btnRadius, GRAY); - else DrawCircleV(middleBtnPos, btnRadius, LIGHTGRAY); - - if (rightCircleActive) DrawCircleV(rightBtnPos, btnRadius, GRAY); - else DrawCircleV(rightBtnPos, btnRadius, LIGHTGRAY); - - - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); - DrawText("LEVEL 07", GetScreenWidth()/2 - MeasureText("LEVEL 07", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 07", GetScreenWidth()/2 - MeasureText("LEVEL 07", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level07 Screen Unload logic -void UnloadLevel07Screen(void) -{ - // TODO: Unload Level07 screen variables here! -} - -// Level07 Screen should finish? -int FinishLevel07Screen(void) -{ - return finishScreen; -} - -static bool CheckColor(Color col1, Color col2) -{ - return ((col1.r == col2.r) && (col1.g == col2.g) && (col1.b == col2.b) && (col1.a == col2.a)); -} \ No newline at end of file diff --git a/games/just_do/screens/screen_level08.c b/games/just_do/screens/screen_level08.c deleted file mode 100644 index 1caced496..000000000 --- a/games/just_do/screens/screen_level08.c +++ /dev/null @@ -1,157 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level08 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level08 screen global variables -static int framesCounter; -static int finishScreen; - -static Rectangle leftColumnRec, middleColumnRec, rightColumnRec; -static Rectangle movingBox; -static int moveSpeed = 4; - -static bool leftColumnActive, middleColumnActive, rightColumnActive; - -static bool done = false; -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level08 Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Level08 Screen Initialization logic -void InitLevel08Screen(void) -{ - // TODO: Initialize Level08 screen variables here! - framesCounter = 0; - finishScreen = 0; - - movingBox = (Rectangle){ 20, GetScreenHeight()/2 - 20, 40, 40 }; - - leftColumnRec = (Rectangle){ 240, 0, 100, GetScreenHeight() }; - middleColumnRec = (Rectangle){ GetScreenWidth()/2 - 50, 0, 100, GetScreenHeight() }; - rightColumnRec = (Rectangle){ 920, 0, 100, GetScreenHeight() }; - - leftColumnActive = true; - middleColumnActive = false; - rightColumnActive = true; -} - -// Level08 Screen Update logic -void UpdateLevel08Screen(void) -{ - // Update Level08 screen variables here! - framesCounter++; - - if (!done) - { - movingBox.x += moveSpeed; - - if (movingBox.x <= 0) moveSpeed *= -1; - - if ((leftColumnActive && (CheckCollisionRecs(leftColumnRec, movingBox))) || - (middleColumnActive && (CheckCollisionRecs(middleColumnRec, movingBox))) || - (rightColumnActive && (CheckCollisionRecs(rightColumnRec, movingBox)))) moveSpeed *= -1; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - if (CheckCollisionPointRec(GetMousePosition(), leftColumnRec)) - { - middleColumnActive = false; - rightColumnActive = true; - } - else if (CheckCollisionPointRec(GetMousePosition(), middleColumnRec)) - { - rightColumnActive = false; - leftColumnActive = true; - } - else if (CheckCollisionPointRec(GetMousePosition(), rightColumnRec)) - { - leftColumnActive = false; - middleColumnActive = true; - } - } - - if (movingBox.x >= 1100) - { - done = true; - PlaySound(levelWin); - } - } - - if (done && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level08 Screen Draw logic -void DrawLevel08Screen(void) -{ - // Draw Level08 screen - DrawRectangle(1100, GetScreenHeight()/2 - 20, 40, 40, GRAY); - - DrawRectangleRec(movingBox, LIGHTGRAY); - - if (leftColumnActive) DrawRectangleRec(leftColumnRec, GRAY); - if (middleColumnActive) DrawRectangleRec(middleColumnRec, GRAY); - if (rightColumnActive) DrawRectangleRec(rightColumnRec, GRAY); - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); - DrawText("LEVEL 08", GetScreenWidth()/2 - MeasureText("LEVEL 08", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 08", GetScreenWidth()/2 - MeasureText("LEVEL 08", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level08 Screen Unload logic -void UnloadLevel08Screen(void) -{ - // TODO: Unload Level08 screen variables here! -} - -// Level08 Screen should finish? -int FinishLevel08Screen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/just_do/screens/screen_level09.c b/games/just_do/screens/screen_level09.c deleted file mode 100644 index 91b0a6f73..000000000 --- a/games/just_do/screens/screen_level09.c +++ /dev/null @@ -1,199 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level09 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#define NUM_BOXES 21 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level09 screen global variables -static int framesCounter; -static int finishScreen; - -static Rectangle bwRecs[NUM_BOXES]; -static Color bwColors[NUM_BOXES]; -static bool activated[NUM_BOXES]; -static int resetCounter = 0; -static bool enableCounter = 0; - -static bool done = false; -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level09 Screen Functions Definition -//---------------------------------------------------------------------------------- -static bool CheckColor(Color col1, Color col2); - -// Level09 Screen Initialization logic -void InitLevel09Screen(void) -{ - // Initialize Level09 screen variables here! - framesCounter = 0; - finishScreen = 0; - - for (int i = 0; i < NUM_BOXES; i++) - { - bwRecs[i].x = GetScreenWidth()/7*(i%7); - bwRecs[i].y = GetScreenHeight()/3*(i/7); - bwRecs[i].width = GetScreenWidth()/7; - bwRecs[i].height = GetScreenHeight()/3; - - activated[i] = false; - - if (i%2 == 0) bwColors[i] = LIGHTGRAY; - else bwColors[i] = GRAY; - } - - bwColors[10] = RAYWHITE; -} - -// Level09 Screen Update logic -void UpdateLevel09Screen(void) -{ - // Update Level09 screen variables here! - framesCounter++; - if (enableCounter) resetCounter++; - - if (!done) - { - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - for (int i = 0; i < NUM_BOXES; i++) - { - if (CheckCollisionPointRec(GetMousePosition(), bwRecs[i])) - { - if (i == 10) - { - if (CheckColor(bwColors[i], RAYWHITE)) - { - bwColors[i] = LIGHTGRAY; - enableCounter = true; - resetCounter = 0; - activated[1] = true; - } - else - { - bwColors[i] = RAYWHITE; - enableCounter = false; - resetCounter = 5*60; - - for (int i = 0; i < NUM_BOXES; i++) activated[i] = false; - } - } - else if ((i%2 == 1) && enableCounter) - { - if (activated[i]) - { - bwColors[i] = LIGHTGRAY; - if (i != 19) activated[i + 2] = true; - } - } - } - } - } - - if (resetCounter > (4*60 + 10)) - { - for (int i = 0; i < NUM_BOXES; i++) - { - if (i%2 == 0) bwColors[i] = LIGHTGRAY; - else bwColors[i] = GRAY; - - activated[i] = false; - } - - bwColors[10] = RAYWHITE; - enableCounter = false; - resetCounter = 0; - } - - for (int i = 0; i < NUM_BOXES; i++) - { - done = true; - - if (!CheckColor(bwColors[i], LIGHTGRAY)) - { - done = false; - return; - } - - //if (done) PlaySound(levelWin); - } - } - - if (done && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level09 Screen Draw logic -void DrawLevel09Screen(void) -{ - // Draw Level09 screen - for (int i = 0; i < NUM_BOXES; i++) - { - DrawRectangleRec(bwRecs[i], bwColors[i]); - } - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(RAYWHITE, 0.6f)); - DrawText("LEVEL 09", GetScreenWidth()/2 - MeasureText("LEVEL 09", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 09", GetScreenWidth()/2 - MeasureText("LEVEL 09", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level09 Screen Unload logic -void UnloadLevel09Screen(void) -{ - // TODO: Unload Level09 screen variables here! -} - -// Level09 Screen should finish? -int FinishLevel09Screen(void) -{ - return finishScreen; -} - -static bool CheckColor(Color col1, Color col2) -{ - return ((col1.r == col2.r) && (col1.g == col2.g) && (col1.b == col2.b) && (col1.a == col2.a)); -} \ No newline at end of file diff --git a/games/just_do/screens/screen_level10.c b/games/just_do/screens/screen_level10.c deleted file mode 100644 index f42b1e666..000000000 --- a/games/just_do/screens/screen_level10.c +++ /dev/null @@ -1,153 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Level10 Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Level10 screen global variables -static int framesCounter; -static int finishScreen; - -static Rectangle leftColumnRec, middleColumnRec, rightColumnRec; -static Rectangle movingBox; -static int moveSpeed = 4; - -static bool leftColumnActive, middleColumnActive, rightColumnActive; - -static bool done = false; -static int levelTimeSec = 0; -static bool levelFinished = false; - -//---------------------------------------------------------------------------------- -// Level10 Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Level10 Screen Initialization logic -void InitLevel10Screen(void) -{ - // TODO: Initialize Level10 screen variables here! - framesCounter = 0; - finishScreen = 0; - - movingBox = (Rectangle){ 20, GetScreenHeight()/2 - 20, 40, 40 }; - - leftColumnRec = (Rectangle){ 240, 0, 100, GetScreenHeight() }; - middleColumnRec = (Rectangle){ GetScreenWidth()/2 - 50, 0, 100, GetScreenHeight() }; - rightColumnRec = (Rectangle){ 920, 0, 100, GetScreenHeight() }; - - leftColumnActive = true; - middleColumnActive = false; - rightColumnActive = true; -} - -// Level10 Screen Update logic -void UpdateLevel10Screen(void) -{ - // Update Level10 screen variables here! - framesCounter++; - - if (!done) - { - movingBox.x += moveSpeed; - - if (movingBox.x <= 0) moveSpeed *= -1; - - if ((leftColumnActive && (CheckCollisionRecs(leftColumnRec, movingBox))) || - (middleColumnActive && (CheckCollisionRecs(middleColumnRec, movingBox))) || - (rightColumnActive && (CheckCollisionRecs(rightColumnRec, movingBox)))) moveSpeed *= -1; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - if (CheckCollisionPointRec(GetMousePosition(), leftColumnRec)) - { - middleColumnActive = false; - rightColumnActive = true; - } - else if (CheckCollisionPointRec(GetMousePosition(), middleColumnRec)) - { - rightColumnActive = false; - leftColumnActive = true; - } - else if (CheckCollisionPointRec(GetMousePosition(), rightColumnRec)) - { - leftColumnActive = false; - middleColumnActive = true; - } - } - } - - if (movingBox.x >= 1100) done = true; - - if (done && !levelFinished) - { - levelTimeSec = framesCounter/60; - levelFinished = true; - framesCounter = 0; - } - - if (levelFinished) - { - framesCounter++; - - if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; - } -} - -// Level10 Screen Draw logic -void DrawLevel10Screen(void) -{ - // Draw Level10 screen - DrawRectangle(1100, GetScreenHeight()/2 - 20, 40, 40, GRAY); - - DrawRectangleRec(movingBox, LIGHTGRAY); - - if (leftColumnActive) DrawRectangleRec(leftColumnRec, GRAY); - if (middleColumnActive) DrawRectangleRec(middleColumnRec, GRAY); - if (rightColumnActive) DrawRectangleRec(rightColumnRec, GRAY); - - if (levelFinished) - { - DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); - DrawText("LEVEL 08", GetScreenWidth()/2 - MeasureText("LEVEL 08", 30)/2, 20, 30, GRAY); - DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); - } - else DrawText("LEVEL 08", GetScreenWidth()/2 - MeasureText("LEVEL 08", 30)/2, 20, 30, LIGHTGRAY); -} - -// Level10 Screen Unload logic -void UnloadLevel10Screen(void) -{ - // TODO: Unload Level10 screen variables here! -} - -// Level10 Screen should finish? -int FinishLevel10Screen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/just_do/screens/screen_logo.c b/games/just_do/screens/screen_logo.c deleted file mode 100644 index 1c9a9b49d..000000000 --- a/games/just_do/screens/screen_logo.c +++ /dev/null @@ -1,227 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Logo Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Logo screen global variables -static int framesCounter; -static int finishScreen; - -const char msgLogoA[64] = "A simple and easy-to-use library"; -const char msgLogoB[64] = "to enjoy videogames programming"; - -int logoPositionX; -int logoPositionY; - -int raylibLettersCount = 0; - -int topSideRecWidth = 16; -int leftSideRecHeight = 16; - -int bottomSideRecWidth = 16; -int rightSideRecHeight = 16; - -char raylib[8] = " \0"; // raylib text array, max 8 letters - -int logoScreenState = 0; // Tracking animation states (State Machine) -bool msgLogoADone = false; -bool msgLogoBDone = false; - -int lettersCounter = 0; -char msgBuffer[128] = { ' ' }; - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Logo Screen Initialization logic -void InitLogoScreen(void) -{ - // Initialize LOGO screen variables here! - framesCounter = 0; - finishScreen = 0; - - logoPositionX = GetScreenWidth()/2 - 128; - logoPositionY = GetScreenHeight()/2 - 128; -} - -// Logo Screen Update logic -void UpdateLogoScreen(void) -{ - // Update LOGO screen - framesCounter++; // Count frames - - // Update LOGO screen variables - if (logoScreenState == 0) // State 0: Small box blinking - { - framesCounter++; - - if (framesCounter == 120) - { - logoScreenState = 1; - framesCounter = 0; // Reset counter... will be used later... - } - } - else if (logoScreenState == 1) // State 1: Top and left bars growing - { - topSideRecWidth += 4; - leftSideRecHeight += 4; - - if (topSideRecWidth == 256) logoScreenState = 2; - } - else if (logoScreenState == 2) // State 2: Bottom and right bars growing - { - bottomSideRecWidth += 4; - rightSideRecHeight += 4; - - if (bottomSideRecWidth == 256) - { - lettersCounter = 0; - for (int i = 0; i < strlen(msgBuffer); i++) msgBuffer[i] = ' '; - - logoScreenState = 3; - } - } - else if (logoScreenState == 3) // State 3: Letters appearing (one by one) - { - framesCounter++; - - // Every 12 frames, one more letter! - if ((framesCounter%12) == 0) raylibLettersCount++; - - switch (raylibLettersCount) - { - case 1: raylib[0] = 'r'; break; - case 2: raylib[1] = 'a'; break; - case 3: raylib[2] = 'y'; break; - case 4: raylib[3] = 'l'; break; - case 5: raylib[4] = 'i'; break; - case 6: raylib[5] = 'b'; break; - default: break; - } - - if (raylibLettersCount >= 10) - { - // Write raylib description messages - if ((framesCounter%2) == 0) lettersCounter++; - - if (!msgLogoADone) - { - if (lettersCounter <= strlen(msgLogoA)) strncpy(msgBuffer, msgLogoA, lettersCounter); - else - { - for (int i = 0; i < strlen(msgBuffer); i++) msgBuffer[i] = ' '; - - lettersCounter = 0; - msgLogoADone = true; - } - } - else if (!msgLogoBDone) - { - if (lettersCounter <= strlen(msgLogoB)) strncpy(msgBuffer, msgLogoB, lettersCounter); - else - { - msgLogoBDone = true; - framesCounter = 0; - PlaySound(levelWin); - } - } - } - } - - // Wait for 2 seconds (60 frames) before jumping to TITLE screen - if (msgLogoBDone) - { - framesCounter++; - - if (framesCounter > 90) finishScreen = true; - } -} - -// Logo Screen Draw logic -void DrawLogoScreen(void) -{ - // Draw LOGO screen - if (logoScreenState == 0) - { - if ((framesCounter/15)%2) DrawRectangle(logoPositionX, logoPositionY - 60, 16, 16, BLACK); - } - else if (logoScreenState == 1) - { - DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY - 60, 16, leftSideRecHeight, BLACK); - } - else if (logoScreenState == 2) - { - DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY - 60, 16, leftSideRecHeight, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY - 60, 16, rightSideRecHeight, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240 - 60, bottomSideRecWidth, 16, BLACK); - } - else if (logoScreenState == 3) - { - DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 16 - 60, 16, leftSideRecHeight - 32, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16 - 60, 16, rightSideRecHeight - 32, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240 - 60, bottomSideRecWidth, 16, BLACK); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112 - 60, 224, 224, RAYWHITE); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48 - 60, 50, BLACK); - - if (!msgLogoADone) DrawText(msgBuffer, GetScreenWidth()/2 - MeasureText(msgLogoA, 30)/2, logoPositionY + 230, 30, GRAY); - else - { - DrawText(msgLogoA, GetScreenWidth()/2 - MeasureText(msgLogoA, 30)/2, logoPositionY + 230, 30, GRAY); - - if (!msgLogoBDone) DrawText(msgBuffer, GetScreenWidth()/2 - MeasureText(msgLogoB, 30)/2, logoPositionY + 280, 30, GRAY); - else - { - DrawText(msgLogoB, GetScreenWidth()/2 - MeasureText(msgLogoA, 30)/2, logoPositionY + 280, 30, GRAY); - } - } - } -} - -// Logo Screen Unload logic -void UnloadLogoScreen(void) -{ - // TODO: Unload LOGO screen variables here! -} - -// Logo Screen should finish? -int FinishLogoScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/just_do/screens/screens.h b/games/just_do/screens/screens.h deleted file mode 100644 index 13bd8d72d..000000000 --- a/games/just_do/screens/screens.h +++ /dev/null @@ -1,150 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Screens Functions Declarations (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef SCREENS_H -#define SCREENS_H - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum GameScreen { LOGO, LEVEL00, LEVEL01, LEVEL02, LEVEL03, LEVEL04, LEVEL05, LEVEL06, LEVEL07, LEVEL08, LEVEL09 } GameScreen; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -GameScreen currentScreen; -Sound levelWin; - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLogoScreen(void); -void UpdateLogoScreen(void); -void DrawLogoScreen(void); -void UnloadLogoScreen(void); -int FinishLogoScreen(void); - -//---------------------------------------------------------------------------------- -// Level00 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLevel00Screen(void); -void UpdateLevel00Screen(void); -void DrawLevel00Screen(void); -void UnloadLevel00Screen(void); -int FinishLevel00Screen(void); - -//---------------------------------------------------------------------------------- -// Level01 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLevel01Screen(void); -void UpdateLevel01Screen(void); -void DrawLevel01Screen(void); -void UnloadLevel01Screen(void); -int FinishLevel01Screen(void); - -//---------------------------------------------------------------------------------- -// Level02 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLevel02Screen(void); -void UpdateLevel02Screen(void); -void DrawLevel02Screen(void); -void UnloadLevel02Screen(void); -int FinishLevel02Screen(void); - -//---------------------------------------------------------------------------------- -// Level03 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLevel03Screen(void); -void UpdateLevel03Screen(void); -void DrawLevel03Screen(void); -void UnloadLevel03Screen(void); -int FinishLevel03Screen(void); - -//---------------------------------------------------------------------------------- -// Level04 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLevel04Screen(void); -void UpdateLevel04Screen(void); -void DrawLevel04Screen(void); -void UnloadLevel04Screen(void); -int FinishLevel04Screen(void); - -//---------------------------------------------------------------------------------- -// Level05 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLevel05Screen(void); -void UpdateLevel05Screen(void); -void DrawLevel05Screen(void); -void UnloadLevel05Screen(void); -int FinishLevel05Screen(void); - -//---------------------------------------------------------------------------------- -// Level06 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLevel06Screen(void); -void UpdateLevel06Screen(void); -void DrawLevel06Screen(void); -void UnloadLevel06Screen(void); -int FinishLevel06Screen(void); - -//---------------------------------------------------------------------------------- -// Level07 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLevel07Screen(void); -void UpdateLevel07Screen(void); -void DrawLevel07Screen(void); -void UnloadLevel07Screen(void); -int FinishLevel07Screen(void); - -//---------------------------------------------------------------------------------- -// Level08 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLevel08Screen(void); -void UpdateLevel08Screen(void); -void DrawLevel08Screen(void); -void UnloadLevel08Screen(void); -int FinishLevel08Screen(void); - -//---------------------------------------------------------------------------------- -// Level09 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLevel09Screen(void); -void UpdateLevel09Screen(void); -void DrawLevel09Screen(void); -void UnloadLevel09Screen(void); -int FinishLevel09Screen(void); - - -void DrawRectangleBordersRec(Rectangle rec, int offsetX, int offsetY, int borderSize, Color col); - -#ifdef __cplusplus -} -#endif - -#endif // SCREENS_H \ No newline at end of file diff --git a/games/koala_seasons/CMakeLists.txt b/games/koala_seasons/CMakeLists.txt deleted file mode 100644 index 7e500d1ee..000000000 --- a/games/koala_seasons/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(koala_seasons) - -# Grab the screens -file(GLOB screen_sources "screens/*.c") - -# Executable & linking -add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c ${screen_sources}) -if (NOT TARGET raylib) - find_package(raylib 2.0 REQUIRED) -endif() -target_link_libraries(${PROJECT_NAME} raylib) - -# Resources -# Copy all of the resource files to the destination -file(COPY "resources/" DESTINATION "resources/") diff --git a/games/koala_seasons/LICENSE.txt b/games/koala_seasons/LICENSE.txt deleted file mode 100644 index 510604da4..000000000 --- a/games/koala_seasons/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ - -This game sources are licensed under an unmodified zlib/libpng license, -which is an OSI-certified, BSD-like license: - -Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) - -This software is provided "as-is", without any express or implied warranty. In no event -will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial -applications, and to alter it and redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not claim that you - wrote the original software. If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be misrepresented - as being the original software. - - 3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/games/koala_seasons/Makefile b/games/koala_seasons/Makefile deleted file mode 100644 index 18690fe6d..000000000 --- a/games/koala_seasons/Makefile +++ /dev/null @@ -1,406 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= koala_seasons -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= C:\GitHub\raylib - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - # -Wl,--subsystem,windows hides the console window - ifeq ($(BUILD_MODE), RELEASE) - LDFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -PROJECT_SOURCE_FILES ?= \ - koala_seasons.c \ - screens/screen_logo.c \ - screens/screen_title.c \ - screens/screen_gameplay.c \ - screens/screen_ending.c - -# Define all object files from source files -OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) - -# For Android platform we call a custom Makefile.Android -ifeq ($(PLATFORM),PLATFORM_ANDROID) - MAKEFILE_PARAMS = -f Makefile.Android - export PROJECT_NAME - export PROJECT_SOURCE_FILES -else - MAKEFILE_PARAMS = $(PROJECT_NAME) -endif - -# Default target entry -# NOTE: We call this Makefile target or Makefile.Android target -all: - $(MAKE) $(MAKEFILE_PARAMS) - -# Project target defined by PROJECT_NAME -$(PROJECT_NAME): $(OBJS) - $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) - -# Compile source files -# NOTE: This pattern will compile every module defined on $(OBJS) -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/koala_seasons/Makefile.Android b/games/koala_seasons/Makefile.Android deleted file mode 100644 index 29d437b1b..000000000 --- a/games/koala_seasons/Makefile.Android +++ /dev/null @@ -1,300 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Android project (APK building) -# -# Copyright (c) 2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -# Define required raylib variables -PLATFORM ?= PLATFORM_ANDROID -RAYLIB_PATH ?= ..\.. - -# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version -ANDROID_ARCH ?= ARM -ANDROID_API_VERSION = 21 -ifeq ($(ANDROID_ARCH),ARM) - ANDROID_ARCH_NAME = armeabi-v7a -endif -ifeq ($(ANDROID_ARCH),ARM64) - ANDROID_ARCH_NAME = arm64-v8a -endif - -# Required path variables -# NOTE: JAVA_HOME must be set to JDK -JAVA_HOME ?= C:/JavaJDK -ANDROID_HOME = C:/android-sdk -ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION) -ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1 -ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools - -# Android project configuration variables -PROJECT_NAME ?= raylib_game -PROJECT_LIBRARY_NAME ?= main -PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME) -PROJECT_RESOURCES_PATH ?= resources -PROJECT_SOURCE_FILES ?= raylib_game.c - -# Some source files are placed in directories, when compiling to some -# output directory other than source, that directory must pre-exist. -# Here we get a list of required folders that need to be created on -# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors. -PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES))) - -# Android app configuration variables -APP_LABEL_NAME ?= rGame -APP_COMPANY_NAME ?= raylib -APP_PRODUCT_NAME ?= rgame -APP_VERSION_CODE ?= 1 -APP_VERSION_NAME ?= 1.0 -APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png -APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png -APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png -APP_SCREEN_ORIENTATION ?= landscape -APP_KEYSTORE_PASS ?= raylib - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Library path for libraylib.a/libraylib.so -RAYLIB_LIB_PATH = $(RAYLIB_PATH)\src - -# Shared libs must be added to APK if required -# NOTE: Generated NativeLoader.java automatically load those libraries -ifeq ($(RAYLIB_LIBTYPE),SHARED) - PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so -endif - -# Compiler and archiver -# NOTE: GCC is being deprecated in Android NDK r16 -ifeq ($(ANDROID_ARCH),ARM) - CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang - AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar -endif -ifeq ($(ANDROID_ARCH),ARM64) - CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang - AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar -endif - -# Compiler flags for arquitecture -ifeq ($(ANDROID_ARCH),ARM) - CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -endif -ifeq ($(ANDROID_ARCH),ARM64) - CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769 -endif -# Compilation functions attributes options -CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC -# Compiler options for the linker -CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes -# Preprocessor macro definitions -CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) - -# Paths containing required header files -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue - -# Linker options -LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a -LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -# Force linking of library module to define symbol -LDFLAGS += -u ANativeActivity_onCreate -# Library paths containing required libs -LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME) -L$(ANDROID_TOOLCHAIN)\sysroot\usr\lib - -# Define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl - -# Generate target objects list from PROJECT_SOURCE_FILES -OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES)) - -# Android APK building process... some steps required... -# NOTE: typing 'make' will invoke the default target entry called 'all', -all: create_temp_project_dirs \ - copy_project_required_libs \ - copy_project_resources \ - generate_loader_script \ - generate_android_manifest \ - generate_apk_keystore \ - config_project_package \ - compile_project_code \ - compile_project_class \ - compile_project_class_dex \ - create_project_apk_package \ - sign_project_apk_package \ - zipalign_project_apk_package - -# Create required temp directories for APK building -create_temp_project_dirs: - if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj - if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src - if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) - if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib - if not exist $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) mkdir $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) - if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin - if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res - if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi - if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values - if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets - if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens - $(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir))) - -define create_dir - if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1) -endef - -# Copy required shared libs for integration into APK -# NOTE: If using shared libs they are loaded by generated NativeLoader.java -copy_project_required_libs: -ifeq ($(RAYLIB_LIBTYPE),SHARED) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so -endif -ifeq ($(RAYLIB_LIBTYPE),STATIC) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a -endif - -# Copy project required resources: strings.xml, icon.png, assets -# NOTE: Required strings.xml is generated and game resources are copied to assets folder -# TODO: Review xcopy usage, it can not be found in some systems! -copy_project_resources: - copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y - copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y - copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y - @echo ^ > $(PROJECT_BUILD_PATH)/res/values/strings.xml - @echo ^^$(APP_LABEL_NAME)^^ >> $(PROJECT_BUILD_PATH)/res/values/strings.xml - if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F - -# Generate NativeLoader.java to load required shared libraries -# NOTE: Probably not the bet way to generate this file... but it works. -generate_loader_script: - @echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -ifeq ($(RAYLIB_LIBTYPE),SHARED) - @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -endif - @echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Generate AndroidManifest.xml with all the required options -# NOTE: Probably not the bet way to generate this file... but it works. -generate_android_manifest: - @echo ^ > $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - -# Generate storekey for APK signing: $(PROJECT_NAME).keystore -# NOTE: Configure here your Distinguished Names (-dname) if required! -generate_apk_keystore: - if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA - -# Config project package and resource using AndroidManifest.xml and res/values/strings.xml -# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java -config_project_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar - -# Compile native_app_glue code as static library: obj/libnative_app_glue.a -compile_native_app_glue: - $(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS) - $(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o - -# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so -compile_project_code: $(OBJS) - $(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) - -# Compile all .c files required into object (.o) files -# NOTE: Those files will be linked into a shared library -$(PROJECT_BUILD_PATH)/obj/%.o:%.c - $(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot - -# Compile project .java code into .class (Java bytecode) -compile_project_class: - $(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Compile .class files into Dalvik executable bytecode (.dex) -# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT) -compile_project_class_dex: - $(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj - -# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk -# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so -# NOTE: Use -A resources to define additional directory in which to find raw asset files -create_project_apk_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin - cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS) - -# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk -sign_project_apk_package: - $(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key - -# Create zip-aligned APK package: $(PROJECT_NAME).apk -zipalign_project_apk_package: - $(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk - -# Install $(PROJECT_NAME).apk to default emulator/device -# NOTE: Use -e (emulator) or -d (device) parameters if required -install: - $(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk - -# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64) -check_device_abi: - $(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi - -# Monitorize output log coming from device, only raylib tag -logcat: - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -# Install and monitorize $(PROJECT_NAME).apk to default emulator/device -deploy: - $(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W - -# Clean everything -clean: - del $(PROJECT_BUILD_PATH)\* /f /s /q - rmdir $(PROJECT_BUILD_PATH) /s /q - @echo Cleaning done diff --git a/games/koala_seasons/koala_seasons.c b/games/koala_seasons/koala_seasons.c deleted file mode 100644 index aaad52769..000000000 --- a/games/koala_seasons/koala_seasons.c +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************************* -* -* Koala Seasons [emegeme 2015] -* -* Koala Seasons is a runner, you must survive as long as possible jumping from tree to tree -* Ready to start the adventure? How long can you survive? -* -* This game has been created using raylib 1.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include "screens/screens.h" // NOTE: Defines global variable: currentScreen - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- -static const int screenWidth = 1280; -static const int screenHeight = 720; - -static float transAlpha = 0; -static bool onTransition = false; -static bool transFadeOut = false; -static int transFromScreen = -1; -static int transToScreen = -1; -static int framesCounter = 0; - -static Music music; - -//---------------------------------------------------------------------------------- -// Local Functions Declaration -//---------------------------------------------------------------------------------- -void TransitionToScreen(int screen); -void UpdateTransition(void); -void DrawTransition(void); - -void UpdateDrawFrame(void); // Update and Draw one frame - -//---------------------------------------------------------------------------------- -// Main entry point -//---------------------------------------------------------------------------------- -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "KOALA SEASONS"); - - // Load global data here (assets that must be available in all screens, i.e. fonts) - font = LoadFont("resources/graphics/mainfont.png"); - - atlas01 = LoadTexture("resources/graphics/atlas01.png"); - atlas02 = LoadTexture("resources/graphics/atlas02.png"); - -#if defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_ANDROID) - colorBlend = LoadShader(0, "resources/shaders/glsl100/blend_color.fs"); -#else - colorBlend = LoadShader(0, "resources/shaders/glsl330/blend_color.fs"); -#endif - - InitAudioDevice(); - - // Load sounds data - fxJump = LoadSound("resources/audio/jump.ogg"); - fxDash = LoadSound("resources/audio/dash.ogg"); - fxEatLeaves = LoadSound("resources/audio/eat_leaves.ogg"); - fxHitResin = LoadSound("resources/audio/resin_hit.ogg"); - fxWind = LoadSound("resources/audio/wind_sound.ogg"); - fxDieSnake = LoadSound("resources/audio/snake_die.ogg"); - fxDieDingo = LoadSound("resources/audio/dingo_die.ogg"); - fxDieOwl = LoadSound("resources/audio/owl_die.ogg"); - - music = LoadMusicStream("resources/audio/jngl.xm"); - PlayMusicStream(music); - SetMusicVolume(music, 2.0f); - - // Define and init first screen - // NOTE: currentScreen is defined in screens.h as a global variable - currentScreen = TITLE; - InitTitleScreen(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) UpdateDrawFrame(); -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadEndingScreen(); - UnloadTitleScreen(); - UnloadGameplayScreen(); - UnloadLogoScreen(); - - UnloadTexture(atlas01); - UnloadTexture(atlas02); - UnloadFont(font); - - UnloadShader(colorBlend); // Unload color overlay blending shader - - UnloadSound(fxJump); - UnloadSound(fxDash); - UnloadSound(fxEatLeaves); - UnloadSound(fxHitResin); - UnloadSound(fxWind); - UnloadSound(fxDieSnake); - UnloadSound(fxDieDingo); - UnloadSound(fxDieOwl); - - UnloadMusicStream(music); - - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -void TransitionToScreen(int screen) -{ - onTransition = true; - transFromScreen = currentScreen; - transToScreen = screen; -} - -void UpdateTransition(void) -{ - if (!transFadeOut) - { - transAlpha += 0.05f; - - if (transAlpha >= 1.0) - { - transAlpha = 1.0; - currentScreen = transToScreen; - transFadeOut = true; - framesCounter = 0; - } - } - else // Transition fade out logic - { - transAlpha -= 0.05f; - - if (transAlpha <= 0) - { - transAlpha = 0; - transFadeOut = false; - onTransition = false; - transFromScreen = -1; - transToScreen = -1; - } - } -} - -void DrawTransition(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha)); -} - -// Update and Draw one frame -void UpdateDrawFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - if (!onTransition) - { - switch (currentScreen) - { - case LOGO: - { - UpdateLogoScreen(); - - if (FinishLogoScreen()) TransitionToScreen(TITLE); - - } break; - case TITLE: - { - UpdateTitleScreen(); - - // NOTE: FinishTitleScreen() return an int defining the screen to jump to - if (FinishTitleScreen() == 1) - { - UnloadTitleScreen(); - //currentScreen = OPTIONS; - //InitOptionsScreen(); - } - else if (FinishTitleScreen() == 2) - { - UnloadTitleScreen(); - - InitGameplayScreen(); - TransitionToScreen(GAMEPLAY); - } - } break; - case GAMEPLAY: - { - UpdateGameplayScreen(); - - if (FinishGameplayScreen()) - { - UnloadGameplayScreen(); - - InitEndingScreen(); - TransitionToScreen(ENDING); - } - } break; - case ENDING: - { - UpdateEndingScreen(); - - if (FinishEndingScreen()) - { - UnloadEndingScreen(); - - InitGameplayScreen(); - TransitionToScreen(GAMEPLAY); - } - } break; - default: break; - } - } - else UpdateTransition(); - - UpdateMusicStream(music); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(WHITE); - - switch (currentScreen) - { - case LOGO: DrawLogoScreen(); break; - case TITLE: DrawTitleScreen(); break; - case GAMEPLAY: DrawGameplayScreen(); break; - case ENDING: DrawEndingScreen(); break; - default: break; - } - - if (onTransition) DrawTransition(); - - DrawRectangle(GetScreenWidth() - 200, GetScreenHeight() - 50, 200, 40, Fade(WHITE, 0.6f)); - DrawText("ALPHA VERSION", GetScreenWidth() - 180, GetScreenHeight() - 40, 20, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- -} diff --git a/games/koala_seasons/resources/audio/dash.ogg b/games/koala_seasons/resources/audio/dash.ogg deleted file mode 100644 index ef1089bc4..000000000 Binary files a/games/koala_seasons/resources/audio/dash.ogg and /dev/null differ diff --git a/games/koala_seasons/resources/audio/dingo_die.ogg b/games/koala_seasons/resources/audio/dingo_die.ogg deleted file mode 100644 index 230bfca9c..000000000 Binary files a/games/koala_seasons/resources/audio/dingo_die.ogg and /dev/null differ diff --git a/games/koala_seasons/resources/audio/eat_leaves.ogg b/games/koala_seasons/resources/audio/eat_leaves.ogg deleted file mode 100644 index acdc71f27..000000000 Binary files a/games/koala_seasons/resources/audio/eat_leaves.ogg and /dev/null differ diff --git a/games/koala_seasons/resources/audio/jngl.xm b/games/koala_seasons/resources/audio/jngl.xm deleted file mode 100644 index 9136e7501..000000000 Binary files a/games/koala_seasons/resources/audio/jngl.xm and /dev/null differ diff --git a/games/koala_seasons/resources/audio/jump.ogg b/games/koala_seasons/resources/audio/jump.ogg deleted file mode 100644 index a7ccbaccc..000000000 Binary files a/games/koala_seasons/resources/audio/jump.ogg and /dev/null differ diff --git a/games/koala_seasons/resources/audio/owl_die.ogg b/games/koala_seasons/resources/audio/owl_die.ogg deleted file mode 100644 index dc9fa3d78..000000000 Binary files a/games/koala_seasons/resources/audio/owl_die.ogg and /dev/null differ diff --git a/games/koala_seasons/resources/audio/resin_hit.ogg b/games/koala_seasons/resources/audio/resin_hit.ogg deleted file mode 100644 index 6dc1ba5e1..000000000 Binary files a/games/koala_seasons/resources/audio/resin_hit.ogg and /dev/null differ diff --git a/games/koala_seasons/resources/audio/snake_die.ogg b/games/koala_seasons/resources/audio/snake_die.ogg deleted file mode 100644 index efadb1fa8..000000000 Binary files a/games/koala_seasons/resources/audio/snake_die.ogg and /dev/null differ diff --git a/games/koala_seasons/resources/audio/wind_sound.ogg b/games/koala_seasons/resources/audio/wind_sound.ogg deleted file mode 100644 index 16ec4f637..000000000 Binary files a/games/koala_seasons/resources/audio/wind_sound.ogg and /dev/null differ diff --git a/games/koala_seasons/resources/graphics/atlas01.png b/games/koala_seasons/resources/graphics/atlas01.png deleted file mode 100644 index 5b59446a8..000000000 Binary files a/games/koala_seasons/resources/graphics/atlas01.png and /dev/null differ diff --git a/games/koala_seasons/resources/graphics/atlas02.png b/games/koala_seasons/resources/graphics/atlas02.png deleted file mode 100644 index c94370590..000000000 Binary files a/games/koala_seasons/resources/graphics/atlas02.png and /dev/null differ diff --git a/games/koala_seasons/resources/graphics/mainfont.png b/games/koala_seasons/resources/graphics/mainfont.png deleted file mode 100644 index 796b79bea..000000000 Binary files a/games/koala_seasons/resources/graphics/mainfont.png and /dev/null differ diff --git a/games/koala_seasons/resources/shaders/glsl100/base.vs b/games/koala_seasons/resources/shaders/glsl100/base.vs deleted file mode 100644 index 93e8c8609..000000000 --- a/games/koala_seasons/resources/shaders/glsl100/base.vs +++ /dev/null @@ -1,25 +0,0 @@ -#version 100 - -// Input vertex attributes -attribute vec3 vertexPosition; -attribute vec2 vertexTexCoord; -attribute vec4 vertexColor; - -// Input uniform values -uniform mat4 mvp; - -// Output vertex attributes (to fragment shader) -varying vec2 fragTexCoord; -varying vec4 fragColor; - -// NOTE: Add here your custom variables - -void main() -{ - // Send vertex attributes to fragment shader - fragTexCoord = vertexTexCoord; - fragColor = vertexColor; - - // Calculate final vertex position - gl_Position = mvp*vec4(vertexPosition, 1.0); -} \ No newline at end of file diff --git a/games/koala_seasons/resources/shaders/glsl100/blend_color.fs b/games/koala_seasons/resources/shaders/glsl100/blend_color.fs deleted file mode 100644 index ae23f941f..000000000 --- a/games/koala_seasons/resources/shaders/glsl100/blend_color.fs +++ /dev/null @@ -1,63 +0,0 @@ -#version 100 - -precision mediump float; - -// Input vertex attributes (from vertex shader) -varying vec2 fragTexCoord; -varying vec4 fragColor; - -// Input uniform values -uniform sampler2D texture0; -uniform vec4 colDiffuse; - -// NOTE: Add here your custom variables - -vec3 BlendOverlay(vec3 base, vec3 blend) -{ - float red; - float green; - float blue; - - if (base.r < 0.5) red = 2.0*base.r*blend.r; - else red = 1.0 - 2.0*(1.0 - base.r)*(1.0 - blend.r); - - if (base.g < 0.5) green = 2.0*base.g*blend.g; - else green = 1.0 - 2.0 *(1.0 - base.g)*(1.0 - blend.g); - - if (base.b < 0.5) blue = 2.0*base.b*blend.b; - else blue = 1.0 - 2.0 *(1.0 - base.b)*(1.0 - blend.b); - - return vec3(red, green, blue); -} - -void main() -{ - // Blending Overlay - vec4 base = texture2D(texture0, fragTexCoord); - - // No blending shader -> 64 FPS (1280x720) - //gl_FragColor = base*fragColor; - - // Option01 -> 50 FPS (1280x720), 200 FPS (640x360) - vec3 final = BlendOverlay(base.rgb, fragColor.rgb); - gl_FragColor = vec4(final.rgb, base.a*fragColor.a); - - // Option02 (Doesn't work) -> 63 FPS (1280x720) - //float luminance = (base.r*0.2126) + (base.g*0.7152) + (base.b*0.0722); - //gl_FragColor = vec4(tint*luminance, base.a); - - // Option03 (no branches, precalculated ifs) -> 28 FPS (1280x720) - /* - vec4 blend = fragColor; - //if (base.a == 0.0) discard; // No improvement - vec3 br = clamp(sign(base.rgb - vec3(0.5)), vec3(0.0), vec3(1.0)); - vec3 multiply = 2.0 * base.rgb * blend.rgb; - vec3 screen = vec3(1.0) - 2.0 * (vec3(1.0) - base.rgb)*(vec3(1.0) - blend.rgb); - vec3 overlay = mix(multiply, screen, br); - vec3 finalColor = mix(base.rgb, overlay, blend.a); - gl_FragColor = vec4(finalColor, base.a); - */ - - // Option04 (no branches, using built-in functions) -> 38 FPS (1280x720) - //gl_FragColor = vec4(mix(1 - 2*(1 - base.rgb)*(1 - tint), 2*base.rgb*tint, step(0.5, base.rgb)), base.a); -} diff --git a/games/koala_seasons/resources/shaders/glsl330/base.vs b/games/koala_seasons/resources/shaders/glsl330/base.vs deleted file mode 100644 index 4bd31d940..000000000 --- a/games/koala_seasons/resources/shaders/glsl330/base.vs +++ /dev/null @@ -1,25 +0,0 @@ -#version 330 - -// Input vertex attributes -in vec3 vertexPosition; -in vec2 vertexTexCoord; -in vec4 vertexColor; - -// Input uniform values -uniform mat4 mvp; - -// Output vertex attributes (to fragment shader) -out vec2 fragTexCoord; -out vec4 fragColor; - -// NOTE: Add here your custom variables - -void main() -{ - // Send vertex attributes to fragment shader - fragTexCoord = vertexTexCoord; - fragColor = vertexColor; - - // Calculate final vertex position - gl_Position = mvp*vec4(vertexPosition, 1.0); -} \ No newline at end of file diff --git a/games/koala_seasons/resources/shaders/glsl330/blend_color.fs b/games/koala_seasons/resources/shaders/glsl330/blend_color.fs deleted file mode 100644 index de3fd2bc9..000000000 --- a/games/koala_seasons/resources/shaders/glsl330/blend_color.fs +++ /dev/null @@ -1,64 +0,0 @@ -#version 330 - -// Input vertex attributes (from vertex shader) -in vec2 fragTexCoord; -in vec4 fragColor; - -// Input uniform values -uniform sampler2D texture0; -uniform vec4 colDiffuse; - -// Output fragment color -out vec4 finalColor; - -// NOTE: Add here your custom variables - -vec3 BlendOverlay(vec3 base, vec3 blend) -{ - float red; - float green; - float blue; - - if (base.r < 0.5) red = 2.0*base.r*blend.r; - else red = 1.0 - 2.0*(1.0 - base.r)*(1.0 - blend.r); - - if (base.g < 0.5) green = 2.0*base.g*blend.g; - else green = 1.0 - 2.0 *(1.0 - base.g)*(1.0 - blend.g); - - if (base.b < 0.5) blue = 2.0*base.b*blend.b; - else blue = 1.0 - 2.0 *(1.0 - base.b)*(1.0 - blend.b); - - return vec3(red, green, blue); -} - -void main() -{ - // Blending Overlay - vec4 base = texture2D(texture0, fragTexCoord); - - // No blending shader -> 64 FPS (1280x720) - //gl_FragColor = base*tintColor; - - // Option01 -> 50 FPS (1280x720), 200 FPS (640x360) - vec3 final = BlendOverlay(base.rgb, fragColor.rgb); - finalColor = vec4(final.rgb, base.a*fragColor.a); - - // Option02 (Doesn't work) -> 63 FPS (1280x720) - //float luminance = (base.r*0.2126) + (base.g*0.7152) + (base.b*0.0722); - //gl_FragColor = vec4(tintColor.rgb*luminance, base.a); - - // Option03 (no branches, precalculated ifs) -> 28 FPS (1280x720) - /* - vec4 blend = tintColor; - //if (base.a == 0.0) discard; // No improvement - vec3 br = clamp(sign(base.rgb - vec3(0.5)), vec3(0.0), vec3(1.0)); - vec3 multiply = 2.0 * base.rgb * blend.rgb; - vec3 screen = vec3(1.0) - 2.0 * (vec3(1.0) - base.rgb)*(vec3(1.0) - blend.rgb); - vec3 overlay = mix(multiply, screen, br); - vec3 finalColor = mix(base.rgb, overlay, blend.a); - gl_FragColor = vec4(finalColor, base.a); - */ - - // Option04 (no branches, using built-in functions) -> 38 FPS (1280x720) - //gl_FragColor = vec4(mix(1 - 2*(1 - base.rgb)*(1 - tintColor.rgb), 2*base.rgb*tintColor.rgb, step(0.5, base.rgb)), base.a); -} diff --git a/games/koala_seasons/screens/atlas01.h b/games/koala_seasons/screens/atlas01.h deleted file mode 100644 index 0c963d4c3..000000000 --- a/games/koala_seasons/screens/atlas01.h +++ /dev/null @@ -1,86 +0,0 @@ -#define ending_button_replay (Rectangle){ 974, 1403, 123, 123 } -#define ending_button_share (Rectangle){ 954, 1528, 123, 123 } -#define ending_button_shop (Rectangle){ 958, 1653, 123, 123 } -#define ending_button_trophy (Rectangle){ 1479, 386, 123, 123 } -#define ending_goals_board (Rectangle){ 2, 254, 761, 422 } -#define ending_goals_check_plate (Rectangle){ 316, 2006, 36, 34 } -#define ending_goals_check_v (Rectangle){ 1727, 239, 50, 42 } -#define ending_goals_check_x (Rectangle){ 354, 1885, 42, 51 } -#define ending_goals_icon_death (Rectangle){ 1382, 516, 60, 60 } -#define ending_goals_icon_leaves (Rectangle){ 1444, 516, 60, 60 } -#define ending_goals_icon_special (Rectangle){ 1506, 511, 60, 60 } -#define ending_goals_icon_time (Rectangle){ 1568, 511, 60, 60 } -#define ending_paint_back (Rectangle){ 765, 254, 258, 305 } -#define ending_paint_frame (Rectangle){ 103, 1028, 334, 393 } -#define ending_paint_koalabee (Rectangle){ 439, 1060, 219, 216 } -#define ending_paint_koaladingo (Rectangle){ 439, 1278, 219, 216 } -#define ending_paint_koalaeagle (Rectangle){ 405, 1496, 219, 216 } -#define ending_paint_koalafire (Rectangle){ 771, 643, 219, 216 } -#define ending_paint_koalageneric (Rectangle){ 516, 678, 253, 250 } -#define ending_paint_koalaowl (Rectangle){ 661, 1790, 100, 81 } -#define ending_paint_koalasnake (Rectangle){ 774, 861, 219, 216 } -#define ending_plate_frame (Rectangle){ 2, 2, 1052, 250 } -#define ending_plate_headbee (Rectangle){ 1318, 516, 62, 60 } -#define ending_plate_headdingo (Rectangle){ 1481, 182, 56, 70 } -#define ending_plate_headeagle (Rectangle){ 1974, 116, 39, 48 } -#define ending_plate_headowl (Rectangle){ 226, 1885, 68, 52 } -#define ending_plate_headsnake (Rectangle){ 65, 1968, 46, 67 } -#define ending_score_enemyicon (Rectangle){ 661, 1697, 113, 91 } -#define ending_score_frame (Rectangle){ 419, 1714, 119, 123 } -#define ending_score_frameback (Rectangle){ 540, 1714, 119, 123 } -#define ending_score_leavesicon (Rectangle){ 1387, 254, 135, 130 } -#define ending_score_planklarge (Rectangle){ 1056, 132, 525, 48 } -#define ending_score_planksmall (Rectangle){ 1583, 116, 389, 48 } -#define ending_score_seasonicon (Rectangle){ 925, 1265, 135, 136 } -#define ending_score_seasonneedle (Rectangle){ 2032, 2, 12, 45 } -#define gameplay_countdown_1 (Rectangle){ 660, 1302, 110, 216 } -#define gameplay_countdown_2 (Rectangle){ 2, 1750, 110, 216 } -#define gameplay_countdown_3 (Rectangle){ 114, 1728, 110, 216 } -#define gameplay_enemy_bee (Rectangle){ 1025, 486, 250, 60 } -#define gameplay_enemy_dingo (Rectangle){ 755, 1079, 240, 150 } -#define gameplay_enemy_eagle (Rectangle){ 1570, 2, 460, 80 } -#define gameplay_enemy_eagle_death (Rectangle){ 1327, 386, 150, 128 } -#define gameplay_enemy_owl (Rectangle){ 765, 561, 240, 80 } -#define gameplay_enemy_snake (Rectangle){ 1025, 254, 360, 128 } -#define gameplay_fx_eaglealert (Rectangle){ 660, 1060, 93, 240 } -#define gameplay_fx_lightraymid (Rectangle){ 2, 1028, 54, 710 } -#define gameplay_gui_leafcounter_base (Rectangle){ 626, 1520, 178, 175 } -#define gameplay_gui_leafcounter_cell (Rectangle){ 972, 1231, 32, 32 } -#define gameplay_gui_leafcounter_glow (Rectangle){ 806, 1519, 146, 146 } -#define gameplay_gui_leafcounter_pulsel (Rectangle){ 226, 1728, 157, 155 } -#define gameplay_gui_seasonsclock_base (Rectangle){ 772, 1265, 151, 150 } -#define gameplay_gui_seasonsclock_disc (Rectangle){ 103, 1423, 300, 303 } -#define gameplay_koala_dash (Rectangle){ 1079, 1528, 100, 100 } -#define gameplay_koala_die (Rectangle){ 1083, 1630, 100, 100 } -#define gameplay_koala_fly (Rectangle){ 114, 1946, 200, 100 } -#define gameplay_koala_idle (Rectangle){ 1025, 384, 300, 100 } -#define gameplay_koala_jump (Rectangle){ 1083, 1732, 100, 100 } -#define gameplay_koala_menu (Rectangle){ 806, 1667, 150, 100 } -#define gameplay_koala_transform (Rectangle){ 772, 1417, 200, 100 } -#define gameplay_props_burnttree (Rectangle){ 58, 1028, 43, 720 } -#define gameplay_props_fire_spritesheet (Rectangle){ 516, 930, 256, 128 } -#define gameplay_props_ice_sprite (Rectangle){ 385, 1728, 32, 128 } -#define gameplay_props_leaf_big (Rectangle){ 1857, 166, 64, 64 } -#define gameplay_props_leaf_lil (Rectangle){ 1923, 166, 64, 64 } -#define gameplay_props_leaf_mid (Rectangle){ 316, 1940, 64, 64 } -#define gameplay_props_resin_sprite (Rectangle){ 405, 1423, 32, 64 } -#define gameplay_props_whirlwind_spritesheet (Rectangle){ 1056, 2, 512, 128 } -#define particle_dandelion (Rectangle){ 354, 2006, 32, 32 } -#define particle_ecualyptusflower (Rectangle){ 1989, 166, 32, 32 } -#define particle_ecualyptusleaf (Rectangle){ 1989, 200, 32, 32 } -#define particle_hit (Rectangle){ 296, 1885, 56, 53 } -#define particle_icecrystal (Rectangle){ 419, 1839, 32, 32 } -#define particle_planetreeleaf (Rectangle){ 453, 1839, 32, 32 } -#define particle_waterdrop (Rectangle){ 487, 1839, 32, 32 } -#define title_facebook (Rectangle){ 1539, 182, 92, 92 } -#define title_googleplay (Rectangle){ 1524, 276, 92, 92 } -#define title_music_off (Rectangle){ 1790, 166, 65, 66 } -#define title_music_on (Rectangle){ 1277, 486, 39, 66 } -#define title_speaker_off (Rectangle){ 2, 1968, 61, 71 } -#define title_speaker_on (Rectangle){ 1727, 166, 61, 71 } -#define title_textsnow01 (Rectangle){ 1570, 84, 439, 30 } -#define title_textsnow02 (Rectangle){ 1056, 182, 423, 48 } -#define title_textsnow03 (Rectangle){ 755, 1231, 215, 32 } -#define title_textsnow04 (Rectangle){ 1056, 232, 414, 20 } -#define title_titletext (Rectangle){ 2, 678, 512, 348 } -#define title_twitter (Rectangle){ 1633, 166, 92, 92 } diff --git a/games/koala_seasons/screens/atlas02.h b/games/koala_seasons/screens/atlas02.h deleted file mode 100644 index dfae117a4..000000000 --- a/games/koala_seasons/screens/atlas02.h +++ /dev/null @@ -1,40 +0,0 @@ -#define background_fog02 (Rectangle){ 644, 2, 500, 311 } -#define background_transformation (Rectangle){ 2, 364, 500, 400 } -#define ending_background (Rectangle){ 2, 766, 256, 256 } -#define gameplay_back_fx_lightraymid (Rectangle){ 260, 766, 14, 216 } -#define gameplay_back_ground00 (Rectangle){ 1146, 2, 640, 77 } -#define gameplay_back_ground01 (Rectangle){ 1146, 81, 640, 77 } -#define gameplay_back_ground02 (Rectangle){ 1146, 160, 640, 77 } -#define gameplay_back_ground03 (Rectangle){ 1146, 239, 640, 77 } -#define gameplay_back_tree01_layer01 (Rectangle){ 1833, 353, 28, 335 } -#define gameplay_back_tree01_layer02 (Rectangle){ 1998, 338, 28, 335 } -#define gameplay_back_tree01_layer03 (Rectangle){ 660, 315, 28, 335 } -#define gameplay_back_tree02_layer01 (Rectangle){ 690, 315, 26, 332 } -#define gameplay_back_tree02_layer02 (Rectangle){ 718, 315, 26, 332 } -#define gameplay_back_tree02_layer03 (Rectangle){ 746, 315, 26, 332 } -#define gameplay_back_tree03_layer01 (Rectangle){ 2028, 338, 15, 329 } -#define gameplay_back_tree03_layer02 (Rectangle){ 774, 315, 15, 329 } -#define gameplay_back_tree03_layer03 (Rectangle){ 791, 315, 15, 329 } -#define gameplay_back_tree04_layer01 (Rectangle){ 1860, 2, 38, 334 } -#define gameplay_back_tree04_layer02 (Rectangle){ 1900, 2, 38, 334 } -#define gameplay_back_tree04_layer03 (Rectangle){ 1940, 2, 38, 334 } -#define gameplay_back_tree05_layer01 (Rectangle){ 504, 364, 32, 349 } -#define gameplay_back_tree05_layer02 (Rectangle){ 538, 364, 32, 349 } -#define gameplay_back_tree05_layer03 (Rectangle){ 572, 364, 32, 349 } -#define gameplay_back_tree06_layer01 (Rectangle){ 1980, 2, 31, 334 } -#define gameplay_back_tree06_layer02 (Rectangle){ 2013, 2, 31, 334 } -#define gameplay_back_tree06_layer03 (Rectangle){ 1863, 338, 31, 334 } -#define gameplay_back_tree07_layer01 (Rectangle){ 606, 364, 25, 349 } -#define gameplay_back_tree07_layer02 (Rectangle){ 633, 364, 25, 349 } -#define gameplay_back_tree07_layer03 (Rectangle){ 1833, 2, 25, 349 } -#define gameplay_back_tree08_layer01 (Rectangle){ 1896, 338, 32, 331 } -#define gameplay_back_tree08_layer02 (Rectangle){ 1930, 338, 32, 331 } -#define gameplay_back_tree08_layer03 (Rectangle){ 1964, 338, 32, 331 } -#define gameplay_background (Rectangle){ 2, 2, 640, 360 } -#define gameplay_props_owl_branch (Rectangle){ 808, 349, 36, 24 } -#define gameplay_props_tree (Rectangle){ 1788, 2, 43, 720 } -#define particle_dandelion_bw (Rectangle){ 504, 715, 32, 32 } -#define particle_ecualyptusflower_bw (Rectangle){ 808, 315, 32, 32 } -#define particle_icecrystal_bw (Rectangle){ 276, 766, 32, 32 } -#define particle_planetreeleaf_bw (Rectangle){ 538, 715, 32, 32 } -#define particle_waterdrop_bw (Rectangle){ 842, 315, 32, 32 } diff --git a/games/koala_seasons/screens/screen_ending.c b/games/koala_seasons/screens/screen_ending.c deleted file mode 100644 index b345a3b20..000000000 --- a/games/koala_seasons/screens/screen_ending.c +++ /dev/null @@ -1,530 +0,0 @@ -/********************************************************************************************** -* -* raylib - Koala Seasons game -* -* Ending Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include - -#include "atlas01.h" -#include "atlas02.h" - -typedef enum { DELAY, SEASONS, LEAVES, KILLS, REPLAY } EndingCounter; - -typedef struct { - Vector2 position; - Vector2 speed; - float rotation; - float size; - Color color; - float alpha; - bool active; -} Particle; - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Ending screen global variables -static EndingCounter endingCounter; - -static int framesCounter; -static int finishScreen; -static int framesKillsCounter; - -static Rectangle playButton; -static Rectangle shopButton; -static Rectangle trophyButton; -static Rectangle shareButton; - -static Color buttonPlayColor; -static Color buttonShopColor; -static Color buttonTrophyColor; -static Color buttonShareColor; -static Color backgroundColor; - -static int currentScore; -static int seasonsCounter; -static int currentLeavesEnding; -static int finalYears; -static int replayTimer; -static int yearsElapsed; -static int initRotation; - -static float clockRotation; -static float finalRotation; - -static bool replaying; -static bool active[MAX_KILLS]; - -static char initMonthText[32]; -static char finalMonthText[32]; - -static Particle leafParticles[20]; - -static int drawTimer; - -// Death texts -const char textOwl01[32] = "Turned into a pretty"; -const char textOwl02[32] = "owl pellet"; -const char textDingo01[32] = "A dingo took your life"; -const char textFire01[32] = "Kissed by fire"; -const char textSnake01[32] = "Digested alive by a"; -const char textSnake02[32] = "big snake"; -const char textNaturalDeath01[32] = "LIFE KILLED YOU"; -const char textBee01[32] = "You turn out to be"; -const char textBee02[32] = "allergic to bee sting"; -const char textEagle[32] = "KOALA IS DEAD :("; - -static float LinearEaseIn(float t, float b, float c, float d) { return c*t/d + b; } - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Ending Screen Initialization logic -void InitEndingScreen(void) -{ - framesCounter = -10; - finishScreen = 0; - drawTimer = 15; - replayTimer = 0; - replaying = false; - finalYears = initYears + (seasons/4); - yearsElapsed = seasons/4; - - playButton = (Rectangle){ GetScreenWidth()*0.871, GetScreenHeight()*0.096, 123, 123}; - shopButton = (Rectangle){ GetScreenWidth()*0.871, GetScreenHeight()*0.303, 123, 123}; - trophyButton = (Rectangle){ GetScreenWidth()*0.871, GetScreenHeight()*0.513, 123, 123}; - shareButton = (Rectangle){ GetScreenWidth()*0.871, GetScreenHeight()*0.719, 123, 123}; - - buttonPlayColor = WHITE; - buttonShopColor = WHITE; - buttonTrophyColor = WHITE; - buttonShareColor = WHITE; - - currentScore = 0; - seasonsCounter = 0; - currentLeavesEnding = 0; - - endingCounter = DELAY; - - backgroundColor = (Color){ 176, 167, 151, 255}; - - for (int j = 0; j < 20; j++) - { - leafParticles[j].active = false; - leafParticles[j].position = (Vector2){ GetRandomValue(-20, 20), GetRandomValue(-20, 20) }; - leafParticles[j].speed = (Vector2){ (float)GetRandomValue(-500, 500)/100, (float)GetRandomValue(-500, 500)/100 }; - leafParticles[j].size = (float)GetRandomValue(3, 10)/5; - leafParticles[j].rotation = GetRandomValue(0, 360); - leafParticles[j].color = WHITE; - leafParticles[j].alpha = 1; - } - - // Seasons death texts - if (initSeason == 0) - { - sprintf(initMonthText, "SUMMER"); - clockRotation = 225; - initRotation = 225; - } - else if (initSeason == 1) - { - sprintf(initMonthText, "AUTUMN"); - clockRotation = 135; - initRotation = 135; - } - else if (initSeason == 2) - { - sprintf(initMonthText, "WINTER"); - clockRotation = 45; - initRotation = 45; - } - else if (initSeason == 3) - { - sprintf(initMonthText, "SPRING"); - clockRotation = 315; - initRotation = 315; - } - - if (currentSeason == 0) - { - sprintf(finalMonthText, "SUMMER"); - finalRotation = 225 + 360*yearsElapsed; - } - else if (currentSeason == 1) - { - sprintf(finalMonthText, "AUTUMN"); - finalRotation = 135 + 360*yearsElapsed; - } - else if (currentSeason == 2) - { - sprintf(finalMonthText, "WINTER"); - finalRotation = 45 + 360*yearsElapsed; - } - else if (currentSeason == 3) - { - sprintf(finalMonthText, "SPRING"); - finalRotation = 315 + 360*yearsElapsed; - } - - for (int i = 0; i < MAX_KILLS; i++) active[i] = false; -} - -// Ending Screen Update logic -void UpdateEndingScreen(void) -{ - framesCounter += 1*TIME_FACTOR; - - switch (endingCounter) - { - case DELAY: - { - if(framesCounter >= 10) - { - endingCounter = SEASONS; - framesCounter = 0; - } - - } break; - case SEASONS: - { - if (seasons > 0) - { - seasonsCounter = (int)LinearEaseIn((float)framesCounter, 0.0f, (float)(seasons), 90.0f); - clockRotation = LinearEaseIn((float)framesCounter, (float)initRotation, (float)-(finalRotation - initRotation), 90.0f); - - if (framesCounter >= 90) - { - endingCounter = LEAVES; - framesCounter = 0; - } - } - else endingCounter = LEAVES; - -#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)) - if (IsGestureDetected(GESTURE_TAP)) - { - seasonsCounter = seasons; - clockRotation = finalRotation; - framesCounter = 0; - endingCounter = LEAVES; - } -#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)) - if (IsKeyPressed(KEY_ENTER)) - { - seasonsCounter = seasons; - clockRotation = finalRotation; - framesCounter = 0; - endingCounter = LEAVES; - } -#endif - } break; - case LEAVES: - { - if (currentLeaves > 0) - { - if (currentLeavesEnding == currentLeaves) - { - endingCounter = KILLS; - framesCounter = 0; - } - else if (currentLeavesEnding < currentLeaves) - { - if (framesCounter >= 4) - { - currentLeavesEnding += 1; - framesCounter = 0; - } - - for (int i = 0; i < 20; i++) - { - if (!leafParticles[i].active) - { - leafParticles[i].position = (Vector2){ GetScreenWidth()*0.46, GetScreenHeight()*0.32}; - leafParticles[i].alpha = 1.0f; - leafParticles[i].active = true; - } - } - } - } - else endingCounter = KILLS; - -#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)) - if (IsGestureDetected(GESTURE_TAP)) - { - currentLeavesEnding = currentLeaves; - framesCounter = 0; - endingCounter = KILLS; - } -#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)) - if (IsKeyPressed(KEY_ENTER)) - { - currentLeavesEnding = currentLeaves; - framesCounter = 0; - endingCounter = KILLS; - } -#endif - } break; - case KILLS: - { - if (score > 0) - { - if (framesCounter <= 90 && !replaying) - { - currentScore = (int)LinearEaseIn((float)framesCounter, 0.0f, (float)(score), 90.0f); - } - - framesKillsCounter += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_KILLS; i++) - { - if (framesKillsCounter >= drawTimer && active[i] == false) - { - active[i] = true; - framesKillsCounter = 0; - } - } - - if (framesCounter >= 90) - { - endingCounter = REPLAY; - framesCounter = 0; - } - } - else endingCounter = REPLAY; - -#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)) - if (IsGestureDetected(GESTURE_TAP)) - { - currentScore = score; - framesCounter = 0; - for (int i = 0; i < MAX_KILLS; i++) active[i] = true; - endingCounter = REPLAY; - } -#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)) - if (IsKeyPressed(KEY_ENTER)) - { - currentScore = score; - framesCounter = 0; - for (int i = 0; i < MAX_KILLS; i++) active[i] = true; - endingCounter = REPLAY; - } -#endif - } break; - case REPLAY: - { -#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)) - if (IsGestureDetected(GESTURE_TAP)) replaying = true; -#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)) - if (IsKeyPressed(KEY_ENTER)) replaying = true; -#endif - if (replaying) - { - replayTimer += 1*TIME_FACTOR; - - if (replayTimer >= 30) - { - finishScreen = 1; - initSeason = GetRandomValue(0, 3); - } - - buttonPlayColor = GOLD; - } - } break; - } - - for (int i = 0; i < 20; i++) - { - if (leafParticles[i].active == true) - { - leafParticles[i].position.x += leafParticles[i].speed.x; - leafParticles[i].position.y += leafParticles[i].speed.y; - leafParticles[i].rotation += 6; - leafParticles[i].alpha -= 0.03f; - leafParticles[i].size -= 0.004; - - if (leafParticles[i].size <= 0) leafParticles[i].size = 0.0f; - - if (leafParticles[i].alpha <= 0) - { - leafParticles[i].alpha = 0.0f; - leafParticles[i].active = false; - } - } - } - - // Buttons logic -#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)) - if ((IsGestureDetected(GESTURE_TAP)) && CheckCollisionPointRec(GetTouchPosition(0), playButton)) - { - endingCounter = REPLAY; - replaying = true; - } - -#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)) - if (CheckCollisionPointRec(GetMousePosition(), playButton)) - { - buttonPlayColor = GOLD; - if (IsMouseButtonPressed(0)) - { - endingCounter = REPLAY; - replaying = true; - } - } - else buttonPlayColor = WHITE; - - if (CheckCollisionPointRec(GetMousePosition(), shopButton)) buttonShopColor = GOLD; - else buttonShopColor = WHITE; - - if (CheckCollisionPointRec(GetMousePosition(), trophyButton)) buttonTrophyColor = GOLD; - else buttonTrophyColor = WHITE; - - if (CheckCollisionPointRec(GetMousePosition(), shareButton)) buttonShareColor = GOLD; - else buttonShareColor = WHITE; -#endif -} - -// Ending Screen Draw logic -void DrawEndingScreen(void) -{ - for (int x = 0; x < 15; x++) - { - DrawTextureRec(atlas02, ending_background, (Vector2){ending_background.width*(x%5), ending_background.height*(x/5)}, backgroundColor); - } - - // Frames and backgrounds - DrawTexturePro(atlas01, ending_plate_frame, (Rectangle){GetScreenWidth()*0.042, GetScreenHeight()*0.606, ending_plate_frame.width, ending_plate_frame.height}, (Vector2){ 0, 0}, 0, WHITE); - DrawTexturePro(atlas01, ending_paint_back, (Rectangle){GetScreenWidth()*0.133, GetScreenHeight()*0.097, ending_paint_back.width, ending_paint_back.height}, (Vector2){ 0, 0}, 0, WHITE); - - if (killer == 0) DrawTexturePro(atlas01, ending_paint_koalafire, (Rectangle){GetScreenWidth()*0.145, GetScreenHeight()*0.171, ending_paint_koalafire.width, ending_paint_koalafire.height}, (Vector2){ 0, 0}, 0, WHITE); - else if (killer == 1) DrawTexturePro(atlas01, ending_paint_koalasnake, (Rectangle){GetScreenWidth()*0.145, GetScreenHeight()*0.171, ending_paint_koalasnake.width, ending_paint_koalasnake.height}, (Vector2){ 0, 0}, 0, WHITE); - else if (killer == 2) DrawTexturePro(atlas01, ending_paint_koaladingo, (Rectangle){GetScreenWidth()*0.145, GetScreenHeight()*0.171, ending_paint_koaladingo.width, ending_paint_koaladingo.height}, (Vector2){ 0, 0}, 0, WHITE); - else if (killer == 3) DrawTexturePro(atlas01, ending_paint_koalaowl, (Rectangle){GetScreenWidth()*0.2, GetScreenHeight()*0.3, ending_paint_koalaowl.width, ending_paint_koalaowl.height}, (Vector2){ 0, 0}, 0, WHITE); - else if (killer == 4) DrawTexturePro(atlas01, ending_paint_koalageneric, (Rectangle){GetScreenWidth()*0.133, GetScreenHeight()*0.171, ending_paint_koalageneric.width, ending_paint_koalageneric.height}, (Vector2){ 0, 0}, 0, WHITE); - else if (killer == 5) DrawTexturePro(atlas01, ending_paint_koalabee, (Rectangle){GetScreenWidth()*0.145, GetScreenHeight()*0.171, ending_paint_koalabee.width, ending_paint_koalabee.height}, (Vector2){ 0, 0}, 0, WHITE); - else if (killer == 6) DrawTexturePro(atlas01, ending_paint_koalaeagle, (Rectangle){GetScreenWidth()*0.145, GetScreenHeight()*0.171, ending_paint_koalaeagle.width, ending_paint_koalaeagle.height}, (Vector2){ 0, 0}, 0, WHITE); - - DrawTexturePro(atlas01, ending_paint_frame, (Rectangle){GetScreenWidth()*0.102, GetScreenHeight()*0.035, ending_paint_frame.width, ending_paint_frame.height}, (Vector2){ 0, 0}, 0, WHITE); - - // UI Score planks - DrawTexturePro(atlas01, ending_score_planksmall, (Rectangle){GetScreenWidth()*0.521, GetScreenHeight()*0.163, ending_score_planksmall.width, ending_score_planksmall.height}, (Vector2){ 0, 0}, 0, WHITE); - DrawTexturePro(atlas01, ending_score_planklarge, (Rectangle){GetScreenWidth()*0.415, GetScreenHeight()*0.303, ending_score_planklarge.width, ending_score_planklarge.height}, (Vector2){ 0, 0}, 0, WHITE); - DrawTexturePro(atlas01, ending_score_planksmall, (Rectangle){GetScreenWidth()*0.521, GetScreenHeight()*0.440, ending_score_planksmall.width, ending_score_planksmall.height}, (Vector2){ 0, 0}, 0, WHITE); - - // UI Score icons and frames - DrawTexturePro(atlas01, ending_score_seasonicon, (Rectangle){GetScreenWidth()*0.529, GetScreenHeight()*0.096, ending_score_seasonicon.width, ending_score_seasonicon.height}, (Vector2){ 0, 0}, 0, WHITE); - DrawTexturePro(atlas01, ending_score_seasonneedle, (Rectangle){GetScreenWidth()*0.579, GetScreenHeight()*0.189, ending_score_seasonneedle.width, ending_score_seasonneedle.height}, (Vector2){ending_score_seasonneedle.width/2, ending_score_seasonneedle.height*0.9}, clockRotation, WHITE); - DrawTexturePro(atlas01, ending_score_frame, (Rectangle){GetScreenWidth()*0.535, GetScreenHeight()*0.11, ending_score_frame.width, ending_score_frame.height}, (Vector2){ 0, 0}, 0, WHITE); - - DrawTexturePro(atlas01, ending_score_frameback, (Rectangle){GetScreenWidth()*0.430, GetScreenHeight()*0.246, ending_score_frameback.width, ending_score_frameback.height}, (Vector2){ 0, 0}, 0, WHITE); - DrawTexturePro(atlas01, ending_score_frame, (Rectangle){GetScreenWidth()*0.429, GetScreenHeight()*0.244, ending_score_frame.width, ending_score_frame.height}, (Vector2){ 0, 0}, 0, WHITE); - - for (int i = 0; i < 20; i++) - { - if (leafParticles[i].active) - { - DrawTexturePro(atlas01, particle_ecualyptusleaf, - (Rectangle){ leafParticles[i].position.x, leafParticles[i].position.y, particle_ecualyptusleaf.width*leafParticles[i].size, particle_ecualyptusleaf.height*leafParticles[i].size }, - (Vector2){ particle_ecualyptusleaf.width/2*leafParticles[i].size, particle_ecualyptusleaf.height/2*leafParticles[i].size }, leafParticles[i].rotation, Fade(WHITE,leafParticles[i].alpha)); - } - } - - DrawTexturePro(atlas01, ending_score_leavesicon, (Rectangle){GetScreenWidth()*0.421, GetScreenHeight()*0.228, ending_score_leavesicon.width, ending_score_leavesicon.height}, (Vector2){ 0, 0}, 0, WHITE); - - DrawTexturePro(atlas01, ending_score_frameback, (Rectangle){GetScreenWidth()*0.536, GetScreenHeight()*0.383, ending_score_frameback.width, ending_score_frameback.height}, (Vector2){ 0, 0}, 0, WHITE); - DrawTexturePro(atlas01, ending_score_frame, (Rectangle){GetScreenWidth()*0.535, GetScreenHeight()*0.383, ending_score_frame.width, ending_score_frame.height}, (Vector2){ 0, 0}, 0, WHITE); - DrawTexturePro(atlas01, ending_score_enemyicon, (Rectangle){GetScreenWidth()*0.538, GetScreenHeight()*0.414, ending_score_enemyicon.width, ending_score_enemyicon.height}, (Vector2){ 0, 0}, 0, WHITE); - - // UI Buttons - DrawTexturePro(atlas01, ending_button_replay, (Rectangle){GetScreenWidth()*0.871, GetScreenHeight()*0.096, ending_button_replay.width, ending_button_replay.height}, (Vector2){ 0, 0}, 0, buttonPlayColor); - DrawTexturePro(atlas01, ending_button_shop, (Rectangle){GetScreenWidth()*0.871, GetScreenHeight()*0.303, ending_button_shop.width, ending_button_shop.height}, (Vector2){ 0, 0}, 0, buttonShopColor); - DrawTexturePro(atlas01, ending_button_trophy, (Rectangle){GetScreenWidth()*0.871, GetScreenHeight()*0.513, ending_button_trophy.width, ending_button_trophy.height}, (Vector2){ 0, 0}, 0, buttonTrophyColor); - DrawTexturePro(atlas01, ending_button_share, (Rectangle){GetScreenWidth()*0.871, GetScreenHeight()*0.719, ending_button_share.width, ending_button_share.height}, (Vector2){ 0, 0}, 0, buttonShareColor); - - DrawTextEx(font, FormatText("%03i", seasonsCounter), (Vector2){ GetScreenWidth()*0.73f, GetScreenHeight()*0.14f }, font.baseSize, 1, WHITE); - DrawTextEx(font, FormatText("%03i", currentLeavesEnding), (Vector2){ GetScreenWidth()*0.73f, GetScreenHeight()*0.29f }, font.baseSize, 1, WHITE); - DrawTextEx(font, FormatText("%04i", currentScore), (Vector2){ GetScreenWidth()*0.715f, GetScreenHeight()*0.426f }, font.baseSize, 1, WHITE); - - DrawTextEx(font, FormatText("%s %i - %s %i", initMonthText, initYears, finalMonthText, finalYears), (Vector2){ GetScreenWidth()*0.1f, GetScreenHeight()*0.7f }, font.baseSize/2.0f, 1, WHITE); - - for (int i = 0; i < MAX_KILLS; i++) - { - if (active[i]) - { - switch (killHistory[i]) - { - case 1: DrawTextureRec(atlas01, ending_plate_headsnake, (Vector2){GetScreenWidth()*0.448 + ending_plate_headsnake.width*(i%10), GetScreenHeight()*0.682 + (GetScreenHeight()*0.055)*(i/10)}, WHITE); break; - case 2: DrawTextureRec(atlas01, ending_plate_headdingo, (Vector2){GetScreenWidth()*0.448 + ending_plate_headdingo.width*(i%10), GetScreenHeight()*0.682 + (GetScreenHeight()*0.055)*(i/10)}, WHITE); break; - case 3: DrawTextureRec(atlas01, ending_plate_headowl, (Vector2){GetScreenWidth()*0.448 + ending_plate_headowl.width*(i%10), GetScreenHeight()*0.682 + (GetScreenHeight()*0.055)*(i/10)}, WHITE); break; - case 4: DrawTextureRec(atlas01, ending_plate_headbee, (Vector2){GetScreenWidth()*0.448 + ending_plate_headbee.width*(i%10), GetScreenHeight()*0.682 + (GetScreenHeight()*0.055)*(i/10)}, WHITE); break; - case 5: DrawTextureRec(atlas01, ending_plate_headeagle, (Vector2){GetScreenWidth()*0.448 + ending_plate_headeagle.width*(i%10), GetScreenHeight()*0.682 + (GetScreenHeight()*0.055)*(i/10)}, WHITE); break; - default: break; - } - } - } - -/* - DrawText(FormatText("KOALA IS DEAD :("), GetScreenWidth()/2 - MeasureText("YOU'RE DEAD ", 60)/2, GetScreenHeight()/3, 60, RED); - DrawText(FormatText("Score: %02i - HiScore: %02i", score, hiscore),GetScreenWidth()/2 - MeasureText("Score: 00 - HiScore: 00", 60)/2, GetScreenHeight()/3 +100, 60, RED); - DrawText(FormatText("You lived: %02i years", years),GetScreenWidth()/2 - MeasureText("You lived: 00", 60)/2 + 60, GetScreenHeight()/3 +200, 30, RED); - DrawText(FormatText("%02s killed you", killer),GetScreenWidth()/2 - MeasureText("killer killed you", 60)/2 + 90, GetScreenHeight()/3 +270, 30, RED); - //DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, 0.5)); -*/ - - //DrawTextEx(font, FormatText("%02s", killer), (Vector2){ GetScreenWidth()*0.08, GetScreenHeight()*0.78 }, font.baseSize/2, 1, WHITE); - if (killer == 0) DrawTextEx(font, textFire01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.baseSize/2.0f, 1, WHITE); - else if (killer == 2) DrawTextEx(font, textDingo01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.baseSize/2.0f, 1, WHITE); - else if (killer == 1) - { - DrawTextEx(font, textSnake01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.baseSize/2.0f, 1, WHITE); - DrawTextEx(font, textSnake02, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.83f }, font.baseSize/2.0f, 1, WHITE); - } - else if (killer == 3) - { - DrawTextEx(font, textOwl01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.baseSize/2.0f, 1, WHITE); - DrawTextEx(font, textOwl02, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.83f }, font.baseSize/2.0f, 1, WHITE); - } - else if (killer == 4) DrawTextEx(font, textNaturalDeath01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.baseSize/2.0f, 1, WHITE); - else if (killer == 5) - { - DrawTextEx(font, textBee01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.baseSize/2.0f, 1, WHITE); - DrawTextEx(font, textBee02, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.83f }, font.baseSize/2.0f, 1, WHITE); - } - else if (killer == 6) DrawTextEx(font, textEagle, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.baseSize/2.0f, 1, WHITE); -} - -// Ending Screen Unload logic -void UnloadEndingScreen(void) -{ - // ... -} - -// Ending Screen should finish? -int FinishEndingScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/koala_seasons/screens/screen_gameplay.c b/games/koala_seasons/screens/screen_gameplay.c deleted file mode 100644 index 0bbad362d..000000000 --- a/games/koala_seasons/screens/screen_gameplay.c +++ /dev/null @@ -1,3919 +0,0 @@ -/********************************************************************************************** -* -* raylib - Koala Seasons game -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -//---------------------------------------------------------------------------------- -// Defines and Macros -//---------------------------------------------------------------------------------- -#include "raylib.h" -#include "screens.h" - -#include -#include -#include - -#include "atlas01.h" -#include "atlas02.h" - -//#define DEBUG - -#define MAX_ENEMIES 16 -#define MAX_BAMBOO 16 -#define MAX_LEAVES 14 -#define MAX_FIRE 10 -#define MAX_FIRE_FLAMES 20 -#define MAX_ICE 10 -#define MAX_RESIN 10 -#define MAX_WIND 10 -#define MAX_PARTICLES 128 -#define MAX_PARTICLES_RAY 8 -#define MAX_PARTICLES_SPEED 64 -#define MAX_PARTICLES_STORM 512 - -#define SPEED 3*TIME_FACTOR // Speed of koala, trees, enemies, ... -#define JUMP 15*TIME_FACTOR // Jump speed -#define FLYINGMOV 10*TIME_FACTOR // Up and Down speed when final form -#define GRAVITY 1*TIME_FACTOR // Gravity when grabbed to tree -#define ICEGRAVITY 4*TIME_FACTOR // Gravity when grabbed to an icy tree -#define KICKSPEED 3*TIME_FACTOR // Gravity when kicking -#define SEASONCHANGE 1200 // Frames duration per season -#define SEASONTRANSITION SEASONCHANGE/6 // Season transition time - -//SPAWNCHANCE - Chance of spawning things everytime a tree spawns -#define ICESPAWNCHANCE 30 // Chance of spawning ice everytime a tree spawns -#define RESINSPAWNCHANCE 30 // Chance of spawning resin everytime a tree spawns -#define FIRESPAWNCHANCE 30 // Chance of spawning fire everytime a tree spawns -#define WINDSPAWNCHANCE 30 // Chance of spawning wind everytime a tree spawns - -//ENEMYSPAWNCHANCE - Chance of spawning enemies everytime a tree spawns -#define DINGOSPAWNCHANCE 30 // Chance of spawning dingos everytime a tree spawns -#define OWLSPAWNCHANCE 30 // Chance of spawning owls everytime a tree spawns -#define SNAKESPAWNCHANCE 30 // Chance of spawning snakes everytime a tree spawns -#define BEE_SPAWNCHANCE 10 // Chance of spawning bees everytime a tree spawns -#define EAGLE_SPAWNCHANCE 5 // Chance of spawning eagles everytime a tree spawns - -#define EAGLE_TIME_DELAY 600 - -//SCORE - Score increase everytime an enemy is killed -#define DINGOSCORE 100 // Score increase everytime a dingo is killed -#define OWLSCORE 100 // Score increase everytime an owl is killed -#define SNAKESCORE 100 // Score increase everytime a snake is killed -#define BEESCORE 300 // Score increase everytime a bee is killed -#define EAGLESCORE 300 // Score increase everytime an eagle is killed - -#define LEAVESTOTRANSFORM 100 // Number of leaves recquired for the transformation -#define MAXTIMESPAWN 85 // Maximum time for tree spawn -#define MINTIMESPAWN 35 // Minimum time for tree spawn -#define STARTINGMONTH 0 // Starting month (0 = January (summer)) - -#define PROGRESION_START 3600 // Time to start the progresion -#define PROGRESION_DURATION 12000 // Maximum time -#define PROGRESOIN_MAX_SPAWNCHANCE 30 // Maximum spawn chance increase -#define PROGRESION_MAX_SPEED 0.5 // Maximum speed modification by progresion - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum { WINTER, SPRING, SUMMER, FALL, TRANSITION } SeasonState; -typedef enum { JUMPING, KICK, FINALFORM, GRABED, ONWIND } KoalaState; - -typedef struct { - Vector2 position; - Vector2 speed; - float rotation; - float size; - Color color; - float alpha; - float rotPhy; - bool active; -} Particle; - -typedef struct { - Vector2 position; - Vector2 speed; - float rotation; - Vector2 size; - Color color; - float alpha; - bool active; -} ParticleSpeed; - -typedef struct { - Vector2 position; - Color color; - float alpha; - float size; - float rotation; - bool active; // NOTE: Use it to activate/deactive particles - bool fading; - float delayCounter; -} ParticleRay; - -typedef struct { - Vector2 position; - bool active; - int spawnTime; - int maxTime; - Particle particles[MAX_PARTICLES]; -} ParticleSystem; - -// DONE: Rename for coherence: ParticleSystemStorm -typedef struct { - Vector2 position; - bool active; - int spawnTime; - int maxTime; - Particle particles[MAX_PARTICLES_STORM]; -} ParticleSystemStorm; - -typedef struct { - Vector2 position; - bool active; - float alpha; - float scale; - int score; -} PopUpScore; - -typedef struct { - Vector2 position; - bool active; - int spawnTime; - int maxTime; - ParticleSpeed particle[MAX_PARTICLES_SPEED]; -} ParticleSystemSpeed; - -typedef struct { - Vector2 position; - bool active; - int spawnTime; - int maxTime; - ParticleRay particles[MAX_PARTICLES_RAY]; -} ParticleSystemRay; - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- -static float gravity; -static SeasonState season; -static KoalaState state; - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; -static int grabCounter; -static int velocity; -static int speed; -static int bambooTimer; -static int bambooSpawnTime; -static int colorTimer; -static int jumpSpeed; -static int power; -static int maxPower; -static int transCount; -static int posArray[2]; -static int posArrayDingo[2]; -static int enemyVel[MAX_ENEMIES]; -static int beeVelocity; -static int fireSpeed; -static int windCounter; -static int seasonTimer; -static int seasonChange; -static int resinCountjump; -static int resinCountdrag; -static int resinCount; -static int currentMonth; -static int monthTimer; -static int monthChange; -static int initMonth; -static int fireCounter[MAX_FIRE]; -static int fireOffset; -static int beeMov; -static int killCounter; -static int leafType[MAX_LEAVES]; -static int posArrayLeaf[3]; -static int transAniCounter; -static int globalFrameCounter; -static int startCounter; -static int animCounter; -static int startNum = 3; -static int finalFormEnd; -static int randomMessage; -static int parallaxBackOffset; -static int parallaxFrontOffset; - -// Animation Variables -static int thisFrame = 1; -static int currentFrame = 0; -static int thisFrameWind = 1; -static int currentFrameWind = 0; -static int thisFrameBee = 1; -static int thisFrameSnake = 1; -static int thisFrameDingo = 1; -static int thisFrameOwl = 1; -static int thisFrameEagle = 1; -static int curFrameEagle; -static int curFrameBee = 0; -static int curFrameSnake = 0; -static int curFrameDingo = 0; -static int curFrameOwl = 0; -static int curFrame; -static int curFrame1; -static int curFrame2; -static int curFrame3; -static int transitionFramesCounter; -static int thisFrameKoala; -static int curFrameKoala; -static int fogSpeed; -static int fogPosition; -static int progresionDelay; -static int progresionFramesCounter; -static int initLeaves; -static int eagleDelay; - -// Stage data variables -static int jumpCounter; -static int resinCounter; -static int tornadoCounter; -static int dashCounter; -static int superKoalaCounter; - -// Global data variables -static int snakeKillCounter; -static int dingoKillCounter; -static int owlKillCounter; -static int beeKillCounter; -static int eagleKillCounter; -static int globalKillCounter; -static int deathsCounter; - -static float scrollFront; -static float scrollMiddle; -static float scrollBack; -static float scrollSpeed; -static float rightAlpha = 0.5; -static float leftAlpha = 0.5; -static float speedMod; -static float groundPos; -static float transRotation; -static float clockRotation; -static float clockSpeedRotation; -static float numberAlpha; -static float numberScale; -static float fogAlpha; -static float speedIncrease; -static float speedProgresion; -static float progresionSpawnChance; -static float UIfade; -static float filterAlpha; -static float leafGUIglowFade; -static float leafGUIpulseFade; -static float leafGUIpulseScale; -static float clockInitRotation; -static float clockFinalRotation; - -// Game text strings -const char textFinalForm[32] = "THIS ISN'T EVEN MY FINAL FORM!"; -const char textSpring1[32] = "FLOWER POWER!"; -const char textSummer1[32] = "PREPARE FOR THE SUMMER!"; -const char textFall1[32] = "HERE COMES THE FALL!"; -const char textWinter1[32] = "WINTER IS COMING!"; -const char textSpring2[32] = "POLLEN IS IN THE AIR"; -const char textSummer2[32] = "HAPPY NEW YEAR!"; -const char textFall2[32] = "IT'S RAINING RAIN"; -const char textWinter2[32] = "LET IT SNOW!"; - -static bool snakeActive[MAX_ENEMIES]; -static bool dingoActive[MAX_ENEMIES]; -static bool owlActive[MAX_ENEMIES]; -static bool branchActive[MAX_ENEMIES]; -static bool bambooActive[MAX_BAMBOO]; -static bool leafActive[MAX_LEAVES]; -static bool fireActive[MAX_FIRE]; -static bool iceActive[MAX_ICE]; -static bool windActive[MAX_WIND]; -static bool resinActive[MAX_RESIN]; -static bool isHitSnake[MAX_ENEMIES]; -static bool isHitDingo[MAX_ENEMIES]; -static bool isHitOwl[MAX_ENEMIES]; -static bool isHitBee; -static bool isHitEagle; -static bool onFire[MAX_FIRE]; -static bool onIce; -static bool onResin; -static bool playerActive; -static bool play; -static bool transforming; -static bool onWind; -static bool glowing; -static bool beeActive; -static bool eagleActive; -static bool eagleAlert; -static bool alertActive; -static bool alertBeeActive; -static bool coolDown; -static bool leafSide[MAX_LEAVES]; -static bool transBackAnim; -static bool fog; -static bool leafGUIglow; - -static Rectangle player = {0, 0, 0, 0}; -static Rectangle leftButton = {0, 0, 0, 0}; -static Rectangle rightButton = {0, 0, 0, 0}; -static Rectangle powerButton = {0, 0, 0, 0}; -static Rectangle fire[MAX_FIRE]; -static Rectangle ice[MAX_ICE]; -static Rectangle resin[MAX_RESIN]; -static Rectangle wind[MAX_WIND]; -static Rectangle bamboo[MAX_BAMBOO]; -static Rectangle snake[MAX_ENEMIES]; -static Rectangle dingo[MAX_ENEMIES]; -static Rectangle owl[MAX_ENEMIES]; -static Rectangle leaf[MAX_LEAVES]; -static Rectangle powerBar; -static Rectangle backBar; -static Rectangle fireAnimation; -static Rectangle windAnimation; -static Rectangle beeAnimation; -static Rectangle snakeAnimation; -static Rectangle dingoAnimation; -static Rectangle owlAnimation; -static Rectangle bee; -static Rectangle eagle; -static Rectangle eagleAnimation; -static Rectangle koalaAnimationIddle; -static Rectangle koalaAnimationJump; -static Rectangle koalaAnimationFly; -static Rectangle koalaAnimationTransform; -static Rectangle alertRectangle; -static Rectangle beeAlertRectangle; - -static time_t rawtime; -static struct tm *ptm; - -static Color finalColor; -static Color finalColor2; -static Color flyColor; -static Color counterColor; -static Color color00, color01, color02, color03; -static Color initcolor00, initcolor01, initcolor02, initcolor03; -static Color finalcolor00, finalcolor01, finalcolor02, finalcolor03; -static Vector2 zero; -static Vector2 firePos; -static Vector2 branchPos[MAX_ENEMIES]; -static Vector2 textSize; -static Vector2 clockPosition; - -static Particle enemyHit[MAX_ENEMIES]; -static ParticleSystem leafParticles[MAX_LEAVES]; -static ParticleSystem snowParticle; -static ParticleSystem backSnowParticle; -static ParticleSystem dandelionParticle; -static ParticleSystem dandelionBackParticle; -static ParticleSystem planetreeParticle; -static ParticleSystem backPlanetreeParticle; -static ParticleSystem flowerParticle; -static ParticleSystem backFlowerParticle; -static ParticleSystem rainParticle; -static ParticleSystem backRainParticle; -static ParticleSystemStorm rainStormParticle; -static ParticleSystemStorm snowStormParticle; -static ParticleSystemRay rayParticles; -static ParticleSystemRay backRayParticles; -static ParticleSystemSpeed speedFX; -static PopUpScore popupScore[MAX_ENEMIES]; -static PopUpScore popupLeaves[MAX_LEAVES]; -static PopUpScore popupBee; -static PopUpScore popupEagle; - -//---------------------------------------------------------------------------------- -// Module specific Functions Declaration -//---------------------------------------------------------------------------------- -static void BambooSpawn(void); -static void SnakeSpawn(int chance); -static void DingoSpawn(int chance); -static void OwlSpawn(int chance); -static void BeeSpawn(int chance); -static void EagleSpawn(int chance); -static void FireSpawn(int chance); -static void IceSpawn(int chance); -static void ResinSpawn(int chance); -static void WindSpawn(int chance); -static void LeafSpawn(void); - -static void DrawParallaxFront(void); -static void DrawParallaxMiddle(void); -static void DrawParallaxBack(void); -static float LinearEaseIn(float t, float b, float c, float d); - -static Color ColorTransition(Color initialColor, Color finalColor, int framesCounter); -static bool CheckArrayValue(int *array, int arrayLength, int value); - -static void Reset(void); - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitGameplayScreen(void) -{ - // Get current time at the moment of running game - time(&rawtime); - ptm = gmtime(&rawtime); - - currentMonth = ptm->tm_mon; - initMonth = ptm->tm_mon; - years = 1900 + ptm->tm_year; - - Reset(); -} - -// Gameplay Screen Update logic -void UpdateGameplayScreen(void) -{ - //if ((IsKeyPressed(KEY_SPACE) || IsMouseButtonPressed(0)) && playerActive) play = true; - - if (play == false && playerActive) - { - startCounter+= 1*TIME_FACTOR; - - if (startCounter > 20 && startCounter < 110) - { - animCounter+=1*TIME_FACTOR; - numberAlpha -= 0.033f*TIME_FACTOR; - numberScale -= 0.0825f*TIME_FACTOR; - - if (animCounter <= 30) startNum = 3; - else if (animCounter > 30 && animCounter <= 60) startNum = 2; - else startNum = 1; - } - else if (startCounter >= 110) play = true; - - if (numberAlpha <= 0) numberAlpha = 1; - if (numberScale <= 0) numberScale = 2.5f; - - textSize = MeasureTextEx(font, FormatText("%01i", startNum), font.baseSize*numberScale, 2); - } - - if (playerActive) finishScreen = 0; - - if (play && playerActive) - { - seasonTimer += speedMod*TIME_FACTOR; - monthTimer += speedMod*TIME_FACTOR; - eagleDelay += speedMod*TIME_FACTOR; - - globalFrameCounter++; - - if (monthTimer >= monthChange) - { - if (currentMonth == 10) - { - clockInitRotation = 225; - clockFinalRotation = clockInitRotation + 90; - rainChance = GetRandomValue(0, 100); - clockSpeedRotation = 0; - seasons++; - } - else if (currentMonth == 1) - { - clockInitRotation = 315; - clockFinalRotation = clockInitRotation + 90; - rainChance = GetRandomValue(0, 100); - clockSpeedRotation = 0; - seasons++; - } - else if (currentMonth == 4) - { - clockInitRotation = 45; - clockFinalRotation = clockInitRotation + 90; - rainChance = GetRandomValue(0, 100); - clockSpeedRotation = 0; - seasons++; - } - else if (currentMonth == 7) - { - clockInitRotation = 135; - clockFinalRotation = clockInitRotation + 90; - rainChance = GetRandomValue(0, 100); - clockSpeedRotation = 0; - seasons++; - } - - currentMonth++; - monthTimer = 0; - - //EagleSpawn(); - } - - if (currentMonth > 11) - { - currentMonth = 0; - years++; - } - - if ((currentMonth == 11) || (currentMonth == 0) || ((currentMonth == 1) && (monthTimer <= SEASONTRANSITION))) - { - dandelionParticle.active = true; - dandelionBackParticle.active = true; - rayParticles.active = true; - backRayParticles.active = true; - - transitionFramesCounter = 0; - randomMessage = GetRandomValue(0, 10); - - fog = false; - - initcolor00 = color00; // Summer Color - initcolor01 = color01; - initcolor02 = color02; - initcolor03 = color03; - finalcolor00 = (Color){242, 113, 62, 255}; // Fall Autum - finalcolor01 = (Color){190, 135, 114, 255}; - finalcolor02 = (Color){144, 130, 101, 255}; - finalcolor03 = (Color){214, 133, 58, 255}; - season = SUMMER; - currentSeason = 0; - } - else if ((currentMonth == 2) || (currentMonth == 3) || ((currentMonth == 4) && (monthTimer <= SEASONTRANSITION))) - { - if ((rainChance <= 40) && (rainChance > 24)) - { - //rainParticle.active = true; - rainStormParticle.active = true; - backRainParticle.active = false; - fog = true; - } - else if (rainChance <= 24) - { - //rainParticle.active = true; - rainStormParticle.active = true; - backRainParticle.active = false; - fog = true; - } - else - { - planetreeParticle.active = true; - backPlanetreeParticle.active = true; - fog = false; - } - - transitionFramesCounter = 0; - randomMessage = GetRandomValue(0, 10); - - initcolor00 = color00; // Fall Color - initcolor01 = color01; - initcolor02 = color02; - initcolor03 = color03; - finalcolor00 = (Color){130, 130, 181, 255}; // Winter Autum - finalcolor01 = (Color){145, 145, 166, 255}; - finalcolor02 = (Color){104, 142, 144, 255}; - finalcolor03 = (Color){57, 140, 173, 255}; - - season = FALL; - currentSeason = 1; - } - else if ((currentMonth == 5) || (currentMonth == 6) || ((currentMonth == 7) && (monthTimer <= SEASONTRANSITION))) - { - if (rainChance <= 40) - { - //rainParticle.active = true; - snowStormParticle.active = true; - backSnowParticle.active = true; - fog = true; - } - else - { - snowParticle.active = true; - backSnowParticle.active = true; - fog = false; - } - - transitionFramesCounter = 0; - randomMessage = GetRandomValue(0, 10); - - initcolor00 = color00; // Winter Color - initcolor01 = color01; - initcolor02 = color02; - initcolor03 = color03; - finalcolor00 = (Color){196, 176, 49, 255}; // Spring Autum - finalcolor01 = (Color){178, 163, 67, 255}; - finalcolor02 = (Color){133, 143, 90, 255}; - finalcolor03 = (Color){133, 156, 42, 255}; - - season = WINTER; - currentSeason = 2; - } - else if ((currentMonth == 8) || (currentMonth == 9) || ((currentMonth == 10) && (monthTimer <= SEASONTRANSITION))) - { - flowerParticle.active = true; - backFlowerParticle.active = true; - - transitionFramesCounter = 0; - randomMessage = GetRandomValue(0, 9); - - fog = false; - - initcolor00 = color00; // Spring Color - initcolor01 = color01; - initcolor02 = color02; - initcolor03 = color03; - finalcolor00 = (Color){129, 172, 86, 255}; // Summer Autum - finalcolor01 = (Color){145, 165, 125, 255}; - finalcolor02 = (Color){161, 130, 73, 255}; - finalcolor03 = (Color){198, 103, 51, 255}; - - season = SPRING; - currentSeason = 3; - } - else - { - flowerParticle.active = false; - backFlowerParticle.active = false; - snowParticle.active = false; - backSnowParticle.active = false; - planetreeParticle.active = false; - backPlanetreeParticle.active = false; - dandelionParticle.active = false; - dandelionBackParticle.active = false; - rainParticle.active = false; - rainStormParticle.active = false; - backRainParticle.active = false; - rayParticles.active = false; - backRayParticles.active = false; - snowStormParticle.active = false; - - fog = false; - - transitionFramesCounter += speedMod*TIME_FACTOR; - - if (transitionFramesCounter <= SEASONTRANSITION) - { - color00 = ColorTransition(initcolor00, finalcolor00, transitionFramesCounter); - color01 = ColorTransition(initcolor01, finalcolor01, transitionFramesCounter); - color02 = ColorTransition(initcolor02, finalcolor02, transitionFramesCounter); - color03 = ColorTransition(initcolor03, finalcolor03, transitionFramesCounter); - } - - season = TRANSITION; - } - - // Update scrolling values - if (!transforming) - { - scrollFront -= scrollSpeed; - scrollMiddle -= (scrollSpeed*0.75f); - scrollBack -= scrollSpeed/2; - - fogPosition -= fogSpeed; - - groundPos -= speed; - clockRotation += clockSpeedRotation; - } - - player.y += gravity; - bambooTimer += (speedMod*TIME_FACTOR); - speed = SPEED*speedMod; - - if (player.x >= GetScreenWidth()*0.6 && state != FINALFORM) - { - speedIncrease = (player.x - GetScreenWidth()*0.6f)/GetScreenWidth(); - } - else if (player.x < GetScreenWidth()*0.6 && state != FINALFORM) - { - speedIncrease = 0; - } - - if (state != FINALFORM) speedMod = 1.2 + speedIncrease + speedProgresion; - - progresionDelay++; - - if (progresionDelay >= PROGRESION_START) - { - progresionFramesCounter++; - - if (progresionFramesCounter < PROGRESION_DURATION) - { - speedProgresion = LinearEaseIn((float)progresionFramesCounter, 0.0f, (float)PROGRESION_MAX_SPEED, (float)PROGRESION_DURATION); - progresionSpawnChance = LinearEaseIn((float)progresionFramesCounter, 0.0f, (float)PROGRESOIN_MAX_SPAWNCHANCE, (float)PROGRESION_DURATION); - } - } - - if (scrollFront <= -GetScreenWidth()) scrollFront = 0; - if (scrollMiddle <= -GetScreenWidth()) scrollMiddle = 0; - if (scrollBack <= -GetScreenWidth()) scrollBack = 0; - if (groundPos <= -GetScreenWidth()) groundPos = 0; - if (fogPosition <= -GetScreenWidth()) fogPosition = 0; - - if (fogAlpha > 0 && !fog) fogAlpha -= 0.03f*speedMod; - else if (fog && fogAlpha < 1) fogAlpha += 0.03f*speedMod; - - if (filterAlpha > 0 && !fog) filterAlpha -= 0.02f*speedMod; - else if (fog && filterAlpha < 0.15f) filterAlpha += 0.02f*speedMod; - - //if (state != FINALFORM) clockSpeedRotation = (float)((90/(float)seasonChange)*speedMod)*1.75; - clockSpeedRotation += speedMod*TIME_FACTOR; - - if (clockSpeedRotation <= (SEASONCHANGE)) clockRotation = (float)LinearEaseIn((float)clockSpeedRotation, clockInitRotation, 90.0f, (float)(SEASONCHANGE)); - else clockRotation = clockFinalRotation; - - if (CheckCollisionCircleRec(clockPosition, gameplay_gui_seasonsclock_disc.width, player)) - { - if (UIfade > 0.4f) UIfade -= 0.01f*TIME_FACTOR; - } - else - { - if (UIfade < 1) UIfade += 0.01f*TIME_FACTOR; - } - - //---------------------------------------------------------------------------------- - // Animations - //---------------------------------------------------------------------------------- - - // Wind Animation - thisFrameWind += 1*TIME_FACTOR; - - if (thisFrameWind >= 12) - { - currentFrameWind++; - thisFrameWind = 0; - } - - if (currentFrameWind > 3) currentFrameWind = 0; - - windAnimation.x = gameplay_props_whirlwind_spritesheet.x + windAnimation.width*currentFrameWind; - - // Fire Animation - thisFrame += 1*TIME_FACTOR; - - if (thisFrame >= 8) - { - curFrame++; - curFrame1++; - curFrame2++; - curFrame3++; - - thisFrame = 0; - } - - if (curFrame > 3) curFrame = 0; - if (curFrame1 > 3) curFrame1 = 0; - if (curFrame2 > 3) curFrame2 = 0; - if (curFrame3 > 3) curFrame3 = 0; - - if (!transforming) - { - // Eagle Animation - curFrameEagle += 1*TIME_FACTOR; - - if (curFrameEagle >= 6*TIME_FACTOR) - { - thisFrameEagle ++; - curFrameEagle = 0; - } - - if (thisFrameEagle > 1) thisFrameEagle = 0; - - eagleAnimation.x = gameplay_enemy_eagle.x + eagleAnimation.width*thisFrameEagle; - - // Bee Animation - curFrameBee += 1*TIME_FACTOR; - - if (curFrameBee >= 3*TIME_FACTOR) - { - thisFrameBee ++; - curFrameBee = 0; - } - - if (thisFrameBee > 3) thisFrameBee = 0; - - beeAnimation.x = gameplay_enemy_bee.x + beeAnimation.width*thisFrameBee; - - // Snake Animation - thisFrameSnake += 1*TIME_FACTOR; - - if (thisFrameSnake >= 24*TIME_FACTOR) - { - curFrameSnake ++; - thisFrameSnake = 0; - } - - if (curFrameSnake > 1) curFrameSnake = 0; - - snakeAnimation.x = gameplay_enemy_snake.x + snakeAnimation.width*curFrameSnake; - - // Dingo Animation - curFrameDingo += 1*TIME_FACTOR; - - if (curFrameDingo >= 24*TIME_FACTOR) - { - thisFrameDingo ++; - curFrameDingo = 0; - } - - if (thisFrameDingo > 1) thisFrameDingo = 0; - - dingoAnimation.x = gameplay_enemy_dingo.x + dingoAnimation.width*thisFrameDingo; - - // Owl Animation - curFrameOwl += 1*TIME_FACTOR; - - if (curFrameOwl >= 24*TIME_FACTOR) - { - thisFrameOwl ++; - curFrameOwl = 0; - } - - if (thisFrameOwl > 1) thisFrameOwl = 0; - - owlAnimation.x = gameplay_enemy_owl.x + owlAnimation.width*thisFrameOwl; - - // Alert Animation - if (alertActive) - { - if (eagleAlert) - { - alertRectangle.x -= 100*TIME_FACTOR; - alertRectangle.width += 100*TIME_FACTOR; - alertRectangle.height += 5*TIME_FACTOR; - alertRectangle.y -= 5*TIME_FACTOR; - - if (alertRectangle.height >= 100) eagleAlert = false; - } - else - { - alertRectangle.height -= 1*TIME_FACTOR; - alertRectangle.y += 1*TIME_FACTOR; - - if (alertRectangle.height <= 0) - { - eagleAlert = true; - eagleActive = true; - alertActive = false; - } - } - } - - // Eagle Logic - if (eagleActive == true && !isHitEagle) - { - eagle.x -= 10*speed*TIME_FACTOR; - - if (CheckCollisionRecs(eagle, player) && (state != FINALFORM) && (state != KICK)) - { - velocity = 8; - jumpSpeed = 2; - play = false; - playerActive = false; - killer = 6; - } - else if (CheckCollisionRecs(eagle, player) && (state == FINALFORM) && (state != KICK)) - { - isHitEagle = true; - beeVelocity = 8; - killHistory[killCounter] = 5; - killCounter++; - - score += EAGLESCORE; - eagleKillCounter++; - globalKillCounter++; - - popupEagle.position = (Vector2){ eagle.x, eagle.y }; - popupEagle.scale = 1.0f; - popupEagle.alpha = 1.0f; - popupEagle.score = EAGLESCORE; - popupEagle.active = true; - } - } - else if (isHitEagle) - { - if ((eagle.y + eagle.height) > GetScreenHeight()) - { - eagleActive = false; - isHitEagle = false; - } - - eagle.x += 2*TIME_FACTOR; - beeVelocity -= 1*TIME_FACTOR*TIME_FACTOR; - eagle.y -= beeVelocity*TIME_FACTOR; - } - - if (eagle.x + eagle.width <= 0) eagleActive = false; - - // Bee Alert Animation - if (alertBeeActive) - { - - beeAlertRectangle.x -= 100*TIME_FACTOR; - beeAlertRectangle.width += 100*TIME_FACTOR; - beeAlertRectangle.height += 2.5*TIME_FACTOR; - beeAlertRectangle.y += 1.25*TIME_FACTOR; - - if (beeAlertRectangle.height >= 100) - { - beeActive = true; - alertBeeActive = false; - } - } - - // Bee Logic - if (beeActive == true && !isHitBee) - { - bee.x -= 3*speed; - beeMov = sin(2*PI/400*bee.x) * 5; - bee.y += beeMov*TIME_FACTOR; - - if (CheckCollisionRecs(bee, player) && (state != FINALFORM) && (state != KICK)) - { - velocity = 8; - jumpSpeed = 2; - play = false; - playerActive = false; - killer = 5; - } - else if (CheckCollisionRecs(bee, player) && (state == FINALFORM)) - { - isHitBee = true; - beeVelocity = 8; - killHistory[killCounter] = 4; - killCounter++; - - score += BEESCORE; - beeKillCounter++; - globalKillCounter++; - - popupBee.position = (Vector2){ bee.x, bee.y }; - popupBee.scale = 1.0f; - popupBee.alpha = 1.0f; - popupBee.score = BEESCORE; - popupBee.active = true; - } - } - else if (isHitBee) - { - if ((bee.y + bee.height) > GetScreenHeight()) - { - beeActive = false; - isHitBee = false; - } - - bee.x += 2*TIME_FACTOR; - beeVelocity -= 1*TIME_FACTOR*TIME_FACTOR; - bee.y -= beeVelocity*TIME_FACTOR; - } - - if (bee.x + bee.width <= 0) beeActive = false; - } - - // Power bar logic - powerBar.width = power; - - if (power >= maxPower) power = maxPower; - - if (currentLeaves >= LEAVESTOTRANSFORM && !coolDown) - { - flyColor = ORANGE; - - if (leafGUIglow) - { - leafGUIglowFade += 0.01f*TIME_FACTOR; - if (leafGUIglowFade >= 1) leafGUIglow = false; - } - else - { - leafGUIglowFade -= 0.01f*TIME_FACTOR; - if (leafGUIglowFade <= 0) leafGUIglow = true; - } - - leafGUIpulseFade -= 0.01f*TIME_FACTOR; - leafGUIpulseScale += 0.005F*TIME_FACTOR; - - if (leafGUIpulseFade <= 0) - { - leafGUIpulseFade = 1; - leafGUIpulseScale = 1; - } - -#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)) - if ((IsGestureDetected(GESTURE_TAP) && CheckCollisionPointRec(GetTouchPosition(0), powerButton)) && (state != FINALFORM)) - { - state = FINALFORM; - transforming = true; - //currentLeaves -= LEAVESTOTRANSFORM; - initLeaves = currentLeaves; - curFrameKoala = 0; - thisFrameKoala = 0; - superKoalaCounter++; - } -#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)) - - if ((IsKeyPressed(KEY_ENTER) || (CheckCollisionPointRec(GetMousePosition(), powerButton) && IsMouseButtonPressed(0))) && (state != FINALFORM)) - { - state = FINALFORM; - transforming = true; - //currentLeaves -= LEAVESTOTRANSFORM; - initLeaves = currentLeaves; - curFrameKoala = 0; - thisFrameKoala = 0; - superKoalaCounter++; - } -#endif - } -#if defined(DEBUG) - if ((currentLeaves < LEAVESTOTRANSFORM) && (IsKeyPressed(KEY_ENTER))) currentLeaves += LEAVESTOTRANSFORM; -#endif - if (coolDown) - { - power += 20; - - if (power >= maxPower) coolDown = false; - } - - colorTimer += 1*TIME_FACTOR; - - if (colorTimer > 10) - { - finalColor.r = GetRandomValue(0, 255); - finalColor.g = GetRandomValue(0, 255); - finalColor.b = GetRandomValue(0, 255); - colorTimer = 0; - } - - // Ice logic - for (int i = 0; i < MAX_ICE; i++) - { - if (!iceActive[i]) ice[i].x = -100; - - if (ice[i].x <= - ice[i].width) iceActive[i] = false; - - if (CheckCollisionRecs(ice[i], player) && (state == GRABED)) onIce = true; - } - - // Resin logic - for (int i = 0; i < MAX_RESIN; i++) - { - if (!resinActive[i]) resin[i].x = -100; - - if (resin[i].x <= -resin[i].width) resinActive[i] = false; - - if (CheckCollisionRecs(resin[i], player) && resinCount >= 30*TIME_FACTOR && state != FINALFORM) - { - if (!onResin) - { - PlaySound(fxHitResin); - resinCounter++; - } - - onResin = true; - grabCounter = 10; - - //gravity = 0; - state = GRABED; - } - } - - // Wind logic - for (int i = 0; i < MAX_WIND; i++) - { - if (!windActive[i]) wind[i].x = -500; - - else wind[i].x -= 9*speedMod*TIME_FACTOR; - - if (wind[i].x <= - wind[i].width) windActive[i] = false; - - if (CheckCollisionRecs(wind[i], player) && state != ONWIND && (windCounter >= 35) && state != FINALFORM) - { - state = ONWIND; - windCounter = 0; - velocity = JUMP; - grabCounter = 0; - jumpSpeed = 10; - rightAlpha = 1; - onIce = false; - onResin = false; - resinCountjump = 0; - resinCountdrag = 0; - tornadoCounter++; - } - } - - // Fire logic - for (int i = 0; i < MAX_FIRE; i++) - { - //fire[i].x -= speed; - - if (fireActive[i] == false) fire[i].x = -200; - - if (fire[i].x <= (player.x + player.width) && !onFire[i]) - { - onFire[i] = true; - } - - if (onFire[i] && fire[i].y > -50 && !transforming) - { - fireCounter[i]++; - fire[i].y -= fireSpeed*TIME_FACTOR; - fireCounter[i] = 0; - //fire[i].height += fireSpeed; - } - - if (fire[i].x <= -fire[i].width) - { - fireActive[i] = false; - onFire[i] = false; - } - - if (CheckCollisionRecs(player, fire[i])) - { - if (state != FINALFORM) - { - velocity = 8; - jumpSpeed = 2; - play = false; - playerActive = false; - killer = 0; - } - } - - for (int k = 0; k < MAX_ENEMIES; k++) - { - if (CheckCollisionRecs(fire[i], snake[k]) && !isHitSnake[k]) - { - isHitSnake[k] = true; - enemyVel[k] = 8; - } - } - } - - // Bamboo logic - for (int i = 0; i < MAX_BAMBOO; i++) - { - if (bambooActive[i]) - { - bamboo[i].x -= speed; - - if ((CheckCollisionRecs(player, bamboo[i])) && (state != FINALFORM)) - { - if (grabCounter >= 10) - { - player.x = bamboo[i].x - 25; - state = GRABED; - } - } - - if ((CheckCollisionRecs(player, bamboo[i])) && (state == FINALFORM)) - { - if (power <= 1) - { - state = JUMPING; - velocity = JUMP; - jumpSpeed = 6; - scrollSpeed = 1.6f; - speedMod = 1.2f; - coolDown = true; - flyColor = GRAY; - speedFX.active = false; - } - } - - for (int k = 0; k < MAX_ENEMIES; k++) - { - if ((CheckCollisionRecs(snake[k], bamboo[i])) && snakeActive[k] && !isHitSnake[k]) snake[k].x = bamboo[i].x - 15; - if ((CheckCollisionRecs(dingo[k], bamboo[i])) && dingoActive[k] && !isHitDingo[k]) dingo[k].x = bamboo[i].x - 15; - if ((CheckCollisionRecs(owl[k], bamboo[i])) && owlActive[k] && !isHitOwl[k]) owl[k].x = bamboo[i].x - 22; - if ((CheckCollisionRecs((Rectangle){branchPos[k].x, branchPos[k].y, gameplay_props_owl_branch.width, gameplay_props_owl_branch.height}, bamboo[i])) && branchActive[k]) branchPos[k].x = bamboo[i].x -24; - } - - for (int j = 0; j < MAX_LEAVES; j++) - { - if ((CheckCollisionRecs(leaf[j], bamboo[i])) && leafActive[j]) - { - if (leafSide[j])leaf[j].x = bamboo[i].x + 18; - else leaf[j].x = bamboo[i].x - 18; - } - - //else leaf[j].x -= speed; - } - - for (int z = 0; z < MAX_FIRE; z++) - { - if ((CheckCollisionRecs(fire[z], bamboo[i])) && fireActive[z]) fire[z].x = bamboo[i].x - 5; - //else fire[z].x -= speed; - } - - for (int n = 0; n < MAX_ICE; n++) - { - if ((CheckCollisionRecs(ice[n], bamboo[i])) && iceActive[n]) ice[n].x = bamboo[i].x; - } - - for (int m = 0; m < MAX_RESIN; m++) - { - if ((CheckCollisionRecs(resin[m], bamboo[i])) && resinActive[m]) resin[m].x = bamboo[i].x; - } - - if (bamboo[i].x <= -(bamboo[i].width + 30)) - { - bambooActive[i] = false; - } - } - } - - // Enemy logic - for (int k = 0; k < MAX_ENEMIES; k++) - { - //if (snakeActive[k] && !isHitSnake[k])snake[k].x -= speed; - - if (snake[k].x <= -snake[k].width) snakeActive[k] = false; - if (dingo[k].x <= -dingo[k].width) dingoActive[k] = false; - if (owl[k].x <= -owl[k].width) owlActive[k] = false; - if (branchPos[k].x <= -owl[k].width) branchActive[k] = false; - - if (!snakeActive[k]) snake[k].x = -500; - if (!dingoActive[k]) dingo[k].x = -500; - if (!owlActive[k]) owl[k].x = -500; - - if (CheckCollisionRecs(player, snake[k]) && (state != KICK) && !isHitSnake[k]) - { - if (state != FINALFORM) - { - velocity = 8; - jumpSpeed = 2; - enemyVel[k] = 8; - play = false; - playerActive = false; - killer = 1; - } - else if (state == FINALFORM) - { - isHitSnake[k] = true; - enemyVel[k] = 8; - killHistory[killCounter] = 1; - killCounter++; - - snakeKillCounter++; - globalKillCounter++; - score += SNAKESCORE; - - PlaySound(fxDieSnake); - - enemyHit[k].position = (Vector2){ snake[k].x, snake[k].y }; - enemyHit[k].speed = (Vector2){ 0, 0 }; - enemyHit[k].size = (float)GetRandomValue(0, 10)/30; - enemyHit[k].rotation = 0.0f; - //enemyHit[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; - enemyHit[k].alpha = 1.0f; - enemyHit[k].active = true; - - popupScore[k].position = (Vector2){ snake[k].x,snake[k].y }; - popupScore[k].scale = 1.0f; - popupScore[k].alpha = 1.0f; - popupScore[k].score = SNAKESCORE; - popupScore[k].active = true; - } - } - - if (CheckCollisionRecs(player, dingo[k]) && (state != KICK) && !isHitDingo[k]) - { - if (state != FINALFORM) - { - velocity = 8; - jumpSpeed = 2; - play = false; - enemyVel[k] = 8; - playerActive = false; - killer = 2; - } - else if (state == FINALFORM) - { - isHitDingo[k] = true; - enemyVel[k] = 8; - killHistory[killCounter] = 2; - killCounter++; - - score += DINGOSCORE; - dingoKillCounter++; - globalKillCounter++; - - enemyHit[k].position = (Vector2){ dingo[k].x,dingo[k].y }; - enemyHit[k].speed = (Vector2){ 0, 0 }; - enemyHit[k].size = (float)GetRandomValue(5, 10)/30; - enemyHit[k].rotation = 0.0f; - //enemyHit[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; - enemyHit[k].alpha = 1.0f; - enemyHit[k].active = true; - - popupScore[k].position = (Vector2){ dingo[k].x,dingo[k].y }; - popupScore[k].scale = 1.0f; - popupScore[k].alpha = 1.0f; - popupScore[k].score = DINGOSCORE; - popupScore[k].active = true; - } - } - - if (CheckCollisionRecs(player, owl[k]) && (state != KICK) && !isHitOwl[k]) - { - if (state != FINALFORM) - { - velocity = 8; - enemyVel[k] = 8; - jumpSpeed = 2; - play = false; - playerActive = false; - killer = 3; - } - else if (state == FINALFORM) - { - isHitOwl[k] = true; - enemyVel[k] = 8; - killHistory[killCounter] = 3; - killCounter++; - - score += OWLSCORE; - owlKillCounter++; - globalKillCounter++; - - enemyHit[k].position = (Vector2){ owl[k].x, owl[k].y }; - enemyHit[k].speed = (Vector2){ owl[k].x, owl[k].y }; - enemyHit[k].size = (float)GetRandomValue(5, 10)/30; - enemyHit[k].rotation = 0.0f; - //enemyHit[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; - enemyHit[k].alpha = 1.0f; - enemyHit[k].active = true; - - popupScore[k].position = (Vector2){ owl[k].x,owl[k].y }; - popupScore[k].scale = 1.0f; - popupScore[k].alpha = 1.0f; - popupScore[k].score = OWLSCORE; - popupScore[k].active = true; - } - } - - if (isHitSnake[k]) - { - if ((snake[k].y + snake[k].height) > GetScreenHeight()) - { - snakeActive[k] = false; - isHitSnake[k] = false; - } - - snake[k].x += 2*TIME_FACTOR; - enemyVel[k] -= 1*TIME_FACTOR*TIME_FACTOR; - snake[k].y -= enemyVel[k]*TIME_FACTOR; - } - - if (isHitDingo[k]) - { - if ((dingo[k].y) > GetScreenHeight()) - { - dingoActive[k] = false; - isHitDingo[k] = false; - } - - dingo[k].x += 2*TIME_FACTOR; - enemyVel[k] -= 1*TIME_FACTOR*TIME_FACTOR; - dingo[k].y -= enemyVel[k]*TIME_FACTOR; - } - - if (isHitOwl[k]) - { - if ((owl[k].y) > GetScreenHeight()) - { - owlActive[k] = false; - isHitOwl[k] = false; - } - - owl[k].x += 2*TIME_FACTOR; - enemyVel[k] -= 1*TIME_FACTOR*TIME_FACTOR; - owl[k].y -= enemyVel[k]; - } - } - - // Leaves logic - for (int j = 0; j < MAX_LEAVES; j++) - { - //leaf[j].x -= speed; - - leafParticles[j].position = (Vector2){ leaf[j].x, leaf[j].y}; - - - if (leaf[j].x <= -leaf[j].width) leafActive[j] = false; - - if (CheckCollisionRecs(player, leaf[j]) && leafActive[j]) - { - popupLeaves[j].position = (Vector2){ leaf[j].x, leaf[j].y }; - popupLeaves[j].scale = 1.0f; - popupLeaves[j].alpha = 1.0f; - popupLeaves[j].active = true; - - PlaySound(fxEatLeaves); - - if (leafType[j] == 0) - { - currentLeaves++; - popupLeaves[j].score = 1; - } - - else if (leafType[j] == 1) - { - currentLeaves += 2; - popupLeaves[j].score = 2; - } - - else if (leafType[j] == 2) - { - currentLeaves += 3; - popupLeaves[j].score = 3; - } - - else if (leafType[j] == 3) - { - currentLeaves += 4; - popupLeaves[j].score = 4; - } - - leafActive[j] = false; - leafParticles[j].active = true; - - for (int h = 0; h < 32; h++) - { - leafParticles[j].particles[h].active = true; - leafParticles[j].particles[h].position = (Vector2){ leafParticles[j].position.x, leafParticles[j].position.y}; - leafParticles[j].particles[h].speed = (Vector2){ (float)GetRandomValue(-400, 400)/100, (float)GetRandomValue(-400, 400)/100 }; - leafParticles[j].particles[h].size = (float)GetRandomValue(4, 8)/10; - leafParticles[j].particles[h].rotation = GetRandomValue(-180, 180); - //enemyHit[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; - leafParticles[j].particles[h].alpha = 1.0f; - } - } - } - - //---------------------------------------------------------------------------------- - // Particles Logic - //---------------------------------------------------------------------------------- - - // Leaf particles logic - for (int i = 0; i < MAX_LEAVES; i++) - { - - if (leafParticles[i].active == true) - { - - for (int j = 0; j < 32; j++) - { - //enemyHit[i].speed.y -= 1; - - leafParticles[i].particles[j].position.x += leafParticles[i].particles[j].speed.x*TIME_FACTOR; - leafParticles[i].particles[j].position.y += leafParticles[i].particles[j].speed.y; - - //if (((enemyHitPosition.x + enemyHit[i].position.x + enemyHit[i].size) >= screenWidth) || ((enemyHitPosition.x + enemyHit[i].position.x - enemyHit[i].size) <= 0)) enemyHit[i].speed.x *= -1; - //if (((enemyHitPosition.y + enemyHit[i].position.y + enemyHit[i].size) >= screenHeight) || ((enemyHitPosition.y + enemyHit[i].position.y - enemyHit[i].size) <= 0)) enemyHit[i].speed.y *= -1; - - leafParticles[i].particles[j].rotation += 6*TIME_FACTOR; - leafParticles[i].particles[j].alpha -= 0.03f*TIME_FACTOR; - leafParticles[i].particles[j].size -= 0.004*TIME_FACTOR; - - if (leafParticles[i].particles[j].size <= 0) leafParticles[i].particles[j].size = 0.0f; - - if (leafParticles[i].particles[j].alpha <= 0) - { - leafParticles[i].particles[j].alpha = 0.0f; - leafParticles[i].particles[j].active = false; - leafParticles[i].active = false; - } - } - } - - if (popupLeaves[i].active) - { - //mouseTail[i].position.y += gravity; - popupLeaves[i].alpha -= 0.02f; - popupLeaves[i].scale += 0.1f; - popupLeaves[i].position.y -= 3.0f; - popupLeaves[i].position.x -= speed; - - if (popupLeaves[i].alpha <= 0.0f) popupLeaves[i].active = false; - } - } - - // Enemy Particles - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyHit[i].active) - { - //mouseTail[i].position.y += gravity; - enemyHit[i].alpha -= 0.1f*TIME_FACTOR; - enemyHit[i].size += 0.1f*TIME_FACTOR; - - if (enemyHit[i].alpha <= 0.0f) enemyHit[i].active = false; - } - - if (popupScore[i].active) - { - //mouseTail[i].position.y += gravity; - popupScore[i].alpha -= 0.02f; - popupScore[i].scale += 0.2f; - popupScore[i].position.y -= 4.0f; - popupScore[i].position.x -= speed; - - if (popupScore[i].alpha <= 0.0f) popupScore[i].active = false; - } - } - - if (popupBee.active) - { - //mouseTail[i].position.y += gravity; - popupBee.alpha -= 0.02f; - popupBee.scale += 0.2f; - popupBee.position.y -= 4.0f; - popupBee.position.x -= speed; - - if (popupBee.alpha <= 0.0f) popupBee.active = false; - } - - if (popupEagle.active) - { - //mouseTail[i].position.y += gravity; - popupEagle.alpha -= 0.02f; - popupEagle.scale += 0.2f; - popupEagle.position.y -= 4.0f; - popupEagle.position.x -= speed; - - if (popupEagle.alpha <= 0.0f) popupEagle.active = false; - } - - if (state != FINALFORM) - { - // Snow Particle - if (snowParticle.active) - { - snowParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (!snowParticle.particles[i].active && (snowParticle.spawnTime >= snowParticle.maxTime)) - { - snowParticle.particles[i].active = true; - snowParticle.particles[i].position = (Vector2){ GetRandomValue(0, GetScreenWidth() + 200), -10 }; - snowParticle.spawnTime = 0; - snowParticle.maxTime = GetRandomValue(5, 20); - } - } - } - - if (backSnowParticle.active) - { - snowParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (!backSnowParticle.particles[i].active && (backSnowParticle.spawnTime >= backSnowParticle.maxTime)) - { - backSnowParticle.particles[i].active = true; - backSnowParticle.particles[i].position = (Vector2){ GetRandomValue(0, GetScreenWidth() + 200), -10 }; - backSnowParticle.spawnTime = 0; - backSnowParticle.maxTime = GetRandomValue(3, 10); - } - } - } - - // Autumn leaves particles - if (planetreeParticle.active) - { - planetreeParticle.spawnTime += 1*TIME_FACTOR; - backPlanetreeParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (!planetreeParticle.particles[i].active && (planetreeParticle.spawnTime >= planetreeParticle.maxTime)) - { - planetreeParticle.particles[i].active = true; - planetreeParticle.particles[i].position = (Vector2){ GetRandomValue(0, GetScreenWidth() + 200), -10 }; - planetreeParticle.spawnTime = 0; - planetreeParticle.maxTime = GetRandomValue(5, 20); - } - - if (!backPlanetreeParticle.particles[i].active && (backPlanetreeParticle.spawnTime >= backPlanetreeParticle.maxTime)) - { - backPlanetreeParticle.particles[i].active = true; - backPlanetreeParticle.particles[i].position = (Vector2){ GetRandomValue(0, GetScreenWidth() + 200), -10 }; - backPlanetreeParticle.spawnTime = 0; - backPlanetreeParticle.maxTime = GetRandomValue(3, 10); - } - } - } - - // Dandelion particle - if (dandelionParticle.active) - { - dandelionParticle.spawnTime += 1*TIME_FACTOR; - dandelionBackParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (!dandelionParticle.particles[i].active && (dandelionParticle.spawnTime >= dandelionParticle.maxTime)) - { - dandelionParticle.particles[i].active = true; - dandelionParticle.particles[i].position = (Vector2){ GetRandomValue(0, GetScreenWidth() + 200), -10 }; - dandelionParticle.spawnTime = 0; - dandelionParticle.maxTime = GetRandomValue(5, 20); - } - - if (!dandelionBackParticle.particles[i].active && (dandelionBackParticle.spawnTime >= dandelionBackParticle.maxTime)) - { - dandelionBackParticle.particles[i].active = true; - dandelionBackParticle.particles[i].position = (Vector2){ GetRandomValue(0, GetScreenWidth() + 200), -10 }; - dandelionBackParticle.spawnTime = 0; - dandelionBackParticle.maxTime = GetRandomValue(3, 10); - } - } - } - - // Flower Particle - if (flowerParticle.active) - { - - flowerParticle.spawnTime += 1*TIME_FACTOR; - backFlowerParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (!flowerParticle.particles[i].active && (flowerParticle.spawnTime >= flowerParticle.maxTime)) - { - flowerParticle.particles[i].active = true; - flowerParticle.particles[i].position = (Vector2){ GetRandomValue(0, GetScreenWidth() + 200), -10 }; - flowerParticle.spawnTime = 0; - flowerParticle.maxTime = GetRandomValue(5, 20); - } - - if (!backFlowerParticle.particles[i].active && (backFlowerParticle.spawnTime >= backFlowerParticle.maxTime)) - { - backFlowerParticle.particles[i].active = true; - backFlowerParticle.particles[i].position = (Vector2){ GetRandomValue(0, GetScreenWidth() + 200), -10 }; - backFlowerParticle.spawnTime = 0; - backFlowerParticle.maxTime = GetRandomValue(3, 10); - } - } - } - - // Rain Particle - if (rainParticle.active) - { - rainParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (!rainParticle.particles[i].active && (rainParticle.spawnTime >= rainParticle.maxTime)) - { - rainParticle.particles[i].active = true; - rainParticle.particles[i].position = (Vector2){ GetRandomValue(0, GetScreenWidth() + 200), -10 }; - rainParticle.spawnTime = 0; - rainParticle.maxTime = GetRandomValue(1, 8); - } - } - } - - // BackRain Particles - if (backRainParticle.active) - { - backRainParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (!backRainParticle.particles[i].active && (backRainParticle.spawnTime >= backRainParticle.maxTime)) - { - backRainParticle.particles[i].active = true; - backRainParticle.particles[i].position = (Vector2){ GetRandomValue(0, GetScreenWidth() + 200), -10 }; - backRainParticle.spawnTime = 0; - backRainParticle.maxTime = GetRandomValue(1, 8); - } - } - } - - // Storm Particles - if (rainStormParticle.active) - { - rainStormParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_PARTICLES_STORM; i++) - { - if (!rainStormParticle.particles[i].active && (rainStormParticle.spawnTime >= rainStormParticle.maxTime)) - { - for (int j = 0; j < 16; j++) - { - rainStormParticle.particles[i+j].active = true; - rainStormParticle.particles[i+j].position = (Vector2){ GetRandomValue(100, GetScreenWidth() + 1000), GetRandomValue(-10,-20) }; - } - - rainStormParticle.spawnTime = 0; - rainStormParticle.maxTime = 4; - } - } - } - - // Snow Storm Particles - if (snowStormParticle.active) - { - snowStormParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_PARTICLES_STORM; i++) - { - if (!snowStormParticle.particles[i].active && (snowStormParticle.spawnTime >= snowStormParticle.maxTime)) - { - snowStormParticle.particles[i].active = true; - snowStormParticle.particles[i].position = (Vector2){ GetRandomValue(100, GetScreenWidth() + 800), -10 }; - snowStormParticle.spawnTime = 0; - snowStormParticle.maxTime = GetRandomValue(1, 2); - } - } - } - - } - - // Speed Particles - if (speedFX.active) - { - speedFX.spawnTime++; - - for (int i = 0; i < MAX_PARTICLES_SPEED; i++) - { - if (!speedFX.particle[i].active && (speedFX.spawnTime >= speedFX.maxTime)) - { - speedFX.particle[i].active = true; - speedFX.particle[i].alpha = 0.7f; - speedFX.particle[i].size = (Vector2){ GetScreenWidth(), GetRandomValue(5, 30) }; - speedFX.particle[i].position = (Vector2){ GetScreenWidth(), GetRandomValue(0, GetScreenHeight() - 10) }; - speedFX.spawnTime = 0; - speedFX.maxTime = GetRandomValue(1, 10); - //i = MAX_PARTICLES; - } - } - } - - for (int i = 0; i < MAX_PARTICLES_SPEED; i++) - { - if (speedFX.particle[i].active) - { - speedFX.particle[i].position.x -= 40; - speedFX.particle[i].alpha -= 0.015f; - speedFX.particle[i].size.y -= 0.1f; - - if (speedFX.particle[i].size.y <= 0) speedFX.particle[i].active = false; - } - } - - // Ray Particles - if (rayParticles.active) - { - rayParticles.spawnTime += 1*TIME_FACTOR; - backRayParticles.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_PARTICLES_RAY; i++) - { - if (!rayParticles.particles[i].active && (rayParticles.spawnTime >= rayParticles.maxTime)) - { - //printf("PARTICLEEES"); - rayParticles.particles[i].active = true; - rayParticles.particles[i].alpha = 0.0f; - rayParticles.particles[i].size = (float)(GetRandomValue(10, 20)/10); - rayParticles.particles[i].position = (Vector2){ GetRandomValue(300, GetScreenWidth() + 200), 0 }; - rayParticles.particles[i].rotation = -35; - rayParticles.spawnTime = 0; - rayParticles.particles[i].delayCounter = 0; - rayParticles.maxTime = GetRandomValue(20, 50); - } - - if (!backRayParticles.particles[i].active && (backRayParticles.spawnTime >= backRayParticles.maxTime)) - { - backRayParticles.particles[i].active = true; - backRayParticles.particles[i].alpha = 0.0f; - backRayParticles.particles[i].size = (float)(GetRandomValue(5, 15)/10); - backRayParticles.particles[i].position = (Vector2){ GetRandomValue(300, GetScreenWidth() + 200), 0 }; - backRayParticles.particles[i].rotation = -35; - backRayParticles.spawnTime = 0; - backRayParticles.particles[i].delayCounter = 0; - backRayParticles.maxTime = GetRandomValue(20, 50); - } - } - } - - // Particles Logic - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (snowParticle.particles[i].active) - { - snowParticle.particles[i].position.y += 2*speedMod*TIME_FACTOR; - snowParticle.particles[i].position.x -= 4*speedMod*TIME_FACTOR; - snowParticle.particles[i].rotation += 0.5*TIME_FACTOR; - - if (snowParticle.particles[i].position.y >= GetScreenHeight()) snowParticle.particles[i].active = false; - } - - if (backSnowParticle.particles[i].active) - { - backSnowParticle.particles[i].position.y += (int)1.5f*speedMod*TIME_FACTOR; - backSnowParticle.particles[i].position.x -= 5*speedMod*TIME_FACTOR; - backSnowParticle.particles[i].rotation += 0.5*TIME_FACTOR; - - if (backSnowParticle.particles[i].position.y >= GetScreenHeight()) backSnowParticle.particles[i].active = false; - } - - if (planetreeParticle.particles[i].active) - { - planetreeParticle.particles[i].position.y += 4*speedMod*TIME_FACTOR; - planetreeParticle.particles[i].position.x -= 5*speedMod*TIME_FACTOR; - planetreeParticle.particles[i].rotation += 0.5*TIME_FACTOR; - - if (planetreeParticle.particles[i].position.y >= GetScreenHeight()) planetreeParticle.particles[i].active = false; - } - - if (backPlanetreeParticle.particles[i].active) - { - backPlanetreeParticle.particles[i].position.y += 3*speedMod*TIME_FACTOR; - backPlanetreeParticle.particles[i].position.x -= 5*speedMod*TIME_FACTOR; - backPlanetreeParticle.particles[i].rotation += 0.5*TIME_FACTOR; - - if (backPlanetreeParticle.particles[i].position.y >= GetScreenHeight()) backPlanetreeParticle.particles[i].active = false; - } - - if (dandelionParticle.particles[i].active) - { - dandelionParticle.particles[i].position.y += 3*speedMod*TIME_FACTOR; - dandelionParticle.particles[i].position.x -= 5*speedMod*TIME_FACTOR; - dandelionParticle.particles[i].rotation = -(30*sin(2*PI/120*globalFrameCounter + dandelionParticle.particles[i].rotPhy) + 30); - - if (dandelionParticle.particles[i].position.y >= GetScreenHeight()) dandelionParticle.particles[i].active = false; - } - - if (dandelionBackParticle.particles[i].active) - { - dandelionBackParticle.particles[i].position.y += (int)1.5f*speedMod*TIME_FACTOR; - dandelionBackParticle.particles[i].position.x -= 5*speedMod*TIME_FACTOR; - dandelionBackParticle.particles[i].rotation = 30*sin(2*PI/120*globalFrameCounter + dandelionParticle.particles[i].rotPhy) + 30; - - if (dandelionBackParticle.particles[i].position.y >= GetScreenHeight()) dandelionBackParticle.particles[i].active = false; - } - - if (flowerParticle.particles[i].active) - { - flowerParticle.particles[i].position.y += 2.5f*speedMod*TIME_FACTOR; - flowerParticle.particles[i].position.x -= 4*speedMod*TIME_FACTOR; - flowerParticle.particles[i].rotation += 0.5*TIME_FACTOR; - - if (flowerParticle.particles[i].position.y >= GetScreenHeight()) flowerParticle.particles[i].active = false; - } - - if (backFlowerParticle.particles[i].active) - { - backFlowerParticle.particles[i].position.y += 2.5f*speedMod*TIME_FACTOR; - backFlowerParticle.particles[i].position.x -= 5*speedMod*TIME_FACTOR; - backFlowerParticle.particles[i].rotation += 0.5*TIME_FACTOR; - - if (backFlowerParticle.particles[i].position.y >= GetScreenHeight()) backFlowerParticle.particles[i].active = false; - } - - if (rainParticle.particles[i].active) - { - rainParticle.particles[i].position.y += 8*speedMod*TIME_FACTOR; - rainParticle.particles[i].position.x -= 10*speedMod*TIME_FACTOR; - //rainParticle.particles[i].rotation += 0.5; - - if (rainParticle.particles[i].position.y >= GetScreenHeight()) rainParticle.particles[i].active = false; - } - - if (backRainParticle.particles[i].active) - { - backRainParticle.particles[i].position.y += 6*speedMod*TIME_FACTOR; - backRainParticle.particles[i].position.x -= 6*speedMod*TIME_FACTOR; - //rainParticle.particles[i].rotation += 0.5; - - if (backRainParticle.particles[i].position.y >= GetScreenHeight()) backRainParticle.particles[i].active = false; - } - } - - for (int i = 0; i < MAX_PARTICLES_STORM; i++) - { - if (rainStormParticle.particles[i].active) - { - rainStormParticle.particles[i].position.y += 12*speedMod*TIME_FACTOR; - rainStormParticle.particles[i].position.x -= 15*speedMod*TIME_FACTOR; - //rainParticle.particles[i].rotation += 0.5; - - if (rainStormParticle.particles[i].position.y >= GetScreenHeight()) rainStormParticle.particles[i].active = false; - if (rainStormParticle.active == false)rainStormParticle.particles[i].alpha -= 0.01; - } - } - - for (int i = 0; i < MAX_PARTICLES_STORM; i++) - { - if (snowStormParticle.particles[i].active) - { - snowStormParticle.particles[i].position.y += 12*speedMod*TIME_FACTOR; - snowStormParticle.particles[i].position.x -= 15*speedMod*TIME_FACTOR; - snowStormParticle.particles[i].rotation += 0.5*TIME_FACTOR; - if (snowStormParticle.particles[i].position.y >= GetScreenHeight()) snowStormParticle.particles[i].active = false; - } - } - - for (int i = 0; i < MAX_PARTICLES_RAY; i++) - { - if (rayParticles.particles[i].active) - { - rayParticles.particles[i].position.x -= 0.5*speedMod*TIME_FACTOR; - //printf("RAY X: %i", rayParticles.particles[i].position.x); - - if (rayParticles.particles[i].fading) - { - rayParticles.particles[i].alpha -= 0.01f; - - if (rayParticles.particles[i].alpha <= 0) - { - rayParticles.particles[i].alpha = 0; - rayParticles.particles[i].delayCounter += 1; - if (rayParticles.particles[i].delayCounter >= 30) - { - rayParticles.particles[i].active = false; - rayParticles.particles[i].delayCounter = 0; - rayParticles.particles[i].fading = false; - } - } - } - else - { - rayParticles.particles[i].alpha += 0.01f; - - if (rayParticles.particles[i].alpha >= 0.5f) - { - rayParticles.particles[i].alpha = 0.5f; - rayParticles.particles[i].delayCounter += 1*TIME_FACTOR; - if (rayParticles.particles[i].delayCounter >= 30) - { - rayParticles.particles[i].delayCounter = 0; - rayParticles.particles[i].fading = true; - } - } - } - } - - if (backRayParticles.particles[i].active) - { - backRayParticles.particles[i].position.x -= 0.5*speedMod*TIME_FACTOR; - - if (backRayParticles.particles[i].fading) - { - backRayParticles.particles[i].alpha -= 0.01f; - - if (backRayParticles.particles[i].alpha <= 0) - { - backRayParticles.particles[i].alpha = 0; - backRayParticles.particles[i].delayCounter += 1; - - if (backRayParticles.particles[i].delayCounter >= 30) - { - backRayParticles.particles[i].active = false; - backRayParticles.particles[i].delayCounter = 0; - backRayParticles.particles[i].fading = false; - } - } - } - else - { - backRayParticles.particles[i].alpha += 0.01f; - - if (backRayParticles.particles[i].alpha >= 0.5f) - { - backRayParticles.particles[i].alpha = 0.5f; - backRayParticles.particles[i].delayCounter +=1; - - if (backRayParticles.particles[i].delayCounter >= 30) - { - backRayParticles.particles[i].delayCounter = 0; - backRayParticles.particles[i].fading = true; - } - } - } - } - } - - // Player States - switch (state) - { - case GRABED: - { - onWind = false; - windCounter += 1*TIME_FACTOR; - resinCount += 1*TIME_FACTOR; - //speedMod = 1; - - thisFrameKoala += 1*TIME_FACTOR; - - if (thisFrameKoala >= 24) - { - curFrameKoala += 1; - thisFrameKoala = 0; - } - - if (curFrameKoala > 2) curFrameKoala = 0; - - koalaAnimationIddle.x = gameplay_koala_idle.x + koalaAnimationIddle.width*curFrameKoala; - - if (!onResin) - { -#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)) - if (((IsGestureDetected(GESTURE_TAP) || (GetGestureDetected() == GESTURE_DOUBLETAP)) && CheckCollisionPointRec(GetTouchPosition(0), rightButton))) - { - state = JUMPING; - velocity = JUMP; - grabCounter = 0; - jumpSpeed = 6; - rightAlpha = 1; - onIce = false; - onResin = false; - thisFrameKoala = 0; - PlaySound(fxJump); - - jumpCounter++; - } - - if (((IsGestureDetected(GESTURE_TAP) || (GetGestureDetected() == GESTURE_DOUBLETAP)) && CheckCollisionPointRec(GetTouchPosition(0), leftButton))) - { - if(!onIce)gravity = KICKSPEED; - else gravity = ICEGRAVITY; - PlaySound(fxDash); - - state = KICK; - grabCounter = 0; - leftAlpha = 1; - onResin = false; - dashCounter++; - //thisFrameKoala = 0; - } - else - { - if(!onIce)gravity = GRAVITY; - else gravity = ICEGRAVITY; - //thisFrameKoala = 0; - } -#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)) - - if (IsKeyPressed(KEY_SPACE) || (CheckCollisionPointRec(GetMousePosition(), rightButton) && IsMouseButtonPressed(0))) - { - state = JUMPING; - velocity = JUMP; - grabCounter = 0; - jumpSpeed = 6; - rightAlpha = 1; - onIce = false; - onResin = false; - thisFrameKoala = 0; - PlaySound(fxJump); - jumpCounter++; - } - - if (IsKeyPressed(KEY_DOWN) || (CheckCollisionPointRec(GetMousePosition(), leftButton) && IsMouseButtonPressed(0))) - { - if(!onIce)gravity = KICKSPEED; - else gravity = ICEGRAVITY; - PlaySound(fxDash); - - state = KICK; - grabCounter = 0; - leftAlpha = 1; - onResin = false; - dashCounter++; - //thisFrameKoala = 0; - } - else - { - if(!onIce)gravity = GRAVITY; - else gravity = ICEGRAVITY; - //thisFrameKoala = 0; - } -#endif - } - else - { -#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)) - if (((IsGestureDetected(GESTURE_TAP) || (GetGestureDetected() == GESTURE_DOUBLETAP)) && CheckCollisionPointRec(GetTouchPosition(0), rightButton))) - { - resinCountjump++; - - if (resinCountjump >= 2) - { - //thisFrameKoala = 0; - - state = JUMPING; - velocity = JUMP; - grabCounter = 0; - jumpSpeed = 6; - rightAlpha = 1; - onIce = false; - onResin = false; - resinCountjump = 0; - resinCountdrag = 0; - resinCount = 0; - jumpCounter++; - } - } - - if (((IsGestureDetected(GESTURE_TAP) || (GetGestureDetected() == GESTURE_DOUBLETAP)) && CheckCollisionPointRec(GetTouchPosition(0), leftButton))) - { - resinCountdrag ++; - - if (resinCountdrag >= 2) - { - //thisFrameKoala = 0; - gravity = KICKSPEED; - state = KICK; - grabCounter = 0; - leftAlpha = 1; - onResin = false; - resinCountjump = 0; - resinCountdrag = 0; - resinCount = 0; - dashCounter++; - } - } - else - { - gravity = 0; - } -#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)) - if (IsKeyPressed(KEY_SPACE) || (CheckCollisionPointRec(GetMousePosition(), rightButton) && IsMouseButtonPressed(0))) - { - resinCountjump++; - - if (resinCountjump >= 2) - { - //thisFrameKoala = 0; - - state = JUMPING; - velocity = JUMP; - grabCounter = 0; - jumpSpeed = 6; - rightAlpha = 1; - onIce = false; - onResin = false; - resinCountjump = 0; - resinCountdrag = 0; - resinCount = 0; - jumpCounter++; - } - } - - if (IsKeyPressed(KEY_DOWN) || (CheckCollisionPointRec(GetMousePosition(), leftButton) && IsMouseButtonPressed(0))) - { - resinCountdrag ++; - - if (resinCountdrag >= 2) - { - //thisFrameKoala = 0; - gravity = KICKSPEED; - state = KICK; - grabCounter = 0; - leftAlpha = 1; - onResin = false; - resinCountjump = 0; - resinCountdrag = 0; - resinCount = 0; - dashCounter++; - } - } - else - { - gravity = 0; - } -#endif - } - } break; - case JUMPING: - { - player.x += jumpSpeed*TIME_FACTOR; - velocity -= 1*TIME_FACTOR*TIME_FACTOR; - player.y -= velocity; - framesCounter += 1*TIME_FACTOR; - grabCounter+= 1*TIME_FACTOR; - - } break; - case KICK: - { - gravity += 1*TIME_FACTOR*TIME_FACTOR; - player.y += gravity; - player.x -= speed; - grabCounter += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (CheckCollisionRecs(player, snake[i]) && !isHitSnake[i] && snakeActive[i]) - { - state = JUMPING; - velocity = JUMP; - enemyVel[i] = 8; - grabCounter = 3; - gravity = KICKSPEED; - isHitSnake[i] = true; - jumpSpeed = -3; - score += SNAKESCORE; - killHistory[killCounter] = 1; - killCounter++; - PlaySound(fxDieSnake); - snakeKillCounter++; - globalKillCounter++; - - enemyHit[i].position = (Vector2){ snake[i].x, snake[i].y }; - enemyHit[i].speed = (Vector2){ snake[i].x, snake[i].y }; - enemyHit[i].size = (float)GetRandomValue(5, 10)/30; - enemyHit[i].rotation = 0.0f; - //enemyHit[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; - enemyHit[i].alpha = 1.0f; - enemyHit[i].active = true; - - popupScore[i].position = (Vector2){ snake[i].x,snake[i].y }; - popupScore[i].scale = 1.0f; - popupScore[i].alpha = 1.0f; - popupScore[i].score = SNAKESCORE; - popupScore[i].active = true; - } - - if (CheckCollisionRecs(player, dingo[i]) && !isHitDingo[i] && dingoActive[i]) - { - state = JUMPING; - velocity = JUMP; - enemyVel[i] = 8*TIME_FACTOR; - grabCounter = 3*TIME_FACTOR; - gravity = KICKSPEED; - isHitDingo[i] = true; - jumpSpeed = -3; - score += DINGOSCORE; - killHistory[killCounter] = 2; - killCounter++; - PlaySound(fxDieDingo); - dingoKillCounter++; - globalKillCounter++; - - enemyHit[i].position = (Vector2){ dingo[i].x, dingo[i].y }; - enemyHit[i].speed = (Vector2){ dingo[i].x, dingo[i].y }; - enemyHit[i].size = (float)GetRandomValue(5, 10)/30; - enemyHit[i].rotation = 0.0f; - enemyHit[i].alpha = 1.0f; - enemyHit[i].active = true; - - popupScore[i].position = (Vector2){ dingo[i].x,dingo[i].y }; - popupScore[i].scale = 1.0f; - popupScore[i].alpha = 1.0f; - popupScore[i].score = DINGOSCORE; - popupScore[i].active = true; - } - - if (CheckCollisionRecs(player, owl[i]) && !isHitOwl[i] && owlActive[i]) - { - state = JUMPING; - velocity = JUMP; - enemyVel[i] = 8; - grabCounter = 3; - gravity = KICKSPEED; - isHitOwl[i] = true; - jumpSpeed = -3; - score += OWLSCORE; - killHistory[killCounter] = 3; - killCounter++; - PlaySound(fxDieOwl); - owlKillCounter++; - globalKillCounter++; - - enemyHit[i].position = (Vector2){ owl[i].x, owl[i].y }; - enemyHit[i].speed = (Vector2){ owl[i].x, owl[i].y }; - enemyHit[i].size = (float)GetRandomValue(5, 10)/30; - enemyHit[i].rotation = 0.0f; - enemyHit[i].alpha = 1.0f; - enemyHit[i].active = true; - - popupScore[i].position = (Vector2){ owl[i].x,owl[i].y }; - popupScore[i].scale = 1.0f; - popupScore[i].alpha = 1.0f; - popupScore[i].score = OWLSCORE; - popupScore[i].active = true; - } - } - - if (CheckCollisionRecs(player, bee) && !isHitBee && beeActive) - { - state = JUMPING; - velocity = JUMP; - beeVelocity = 8; - grabCounter = 3; - gravity = KICKSPEED; - isHitBee = true; - jumpSpeed = -3; - score += BEESCORE; - killHistory[killCounter] = 4; - killCounter++; - beeKillCounter++; - globalKillCounter++; - - popupBee.position = (Vector2){ bee.x, bee.y }; - popupBee.scale = 1.0f; - popupBee.alpha = 1.0f; - popupBee.score = BEESCORE; - popupBee.active = true; - } - - if (CheckCollisionRecs(player, eagle) && !isHitEagle && eagleActive) - { - state = JUMPING; - velocity = JUMP; - beeVelocity = 8; - grabCounter = 3; - gravity = KICKSPEED; - isHitEagle = true; - jumpSpeed = -3; - score += EAGLESCORE; - killHistory[killCounter] = 5; - killCounter++; - eagleKillCounter++; - globalKillCounter++; - - popupEagle.position = (Vector2){ eagle.x, eagle.y }; - popupEagle.scale = 1.0f; - popupEagle.alpha = 1.0f; - popupEagle.score = EAGLESCORE; - popupEagle.active = true; - } - } break; - case FINALFORM: - { - if (transforming) - { - speedMod = 0; - transCount += 1*TIME_FACTOR; - transRotation += 1*TIME_FACTOR; - transAniCounter += 1*TIME_FACTOR; - - thisFrameKoala += 1*TIME_FACTOR; - - currentLeaves = LinearEaseIn((float)transCount, (float)initLeaves, (float)-LEAVESTOTRANSFORM, 120.0f); - - if (thisFrameKoala >= 24) - { - curFrameKoala += 1; - thisFrameKoala = 0; - } - - if (curFrameKoala <= 1) koalaAnimationTransform.x = gameplay_koala_transform.x + koalaAnimationTransform.width*curFrameKoala; - - if (transAniCounter >= 5) - { - transBackAnim = !transBackAnim; - transAniCounter = 0; - } - - if (transBackAnim) - { - finalColor = RED; - finalColor2 = WHITE; - } - else - { - finalColor = WHITE; - finalColor2 = RED; - } - - if (transCount >= 120) - { - transforming = false; - thisFrameKoala = 0; - curFrameKoala = 0; - speedFX.active = true; - transCount = 0; - bambooTimer += 15*TIME_FACTOR; - } - } - else if (!transforming) - { - speedMod = 5; - scrollSpeed = 3.2f*TIME_FACTOR; - power -= 1*TIME_FACTOR; - - thisFrameKoala += 1*TIME_FACTOR; - - if (thisFrameKoala >= 12) - { - curFrameKoala ++; - thisFrameKoala = 0; - } - - if (curFrameKoala > 1) curFrameKoala = 0; - if (curFrameKoala <= 1) koalaAnimationFly.x = gameplay_koala_fly.x + koalaAnimationFly.width*curFrameKoala; - if (player.x > GetScreenWidth()/3) player.x -= 2; - if (player.x < GetScreenWidth()/3) player.x++; - - if (power <= maxPower/5) - { - finalFormEnd += 1*TIME_FACTOR; - if (finalFormEnd >= 5) - { - transBackAnim = !transBackAnim; - finalFormEnd = 0; - } - - if (transBackAnim) - { - finalColor = RED; - } - - if (!transBackAnim) - { - finalColor = WHITE; - } - } - else finalColor = WHITE; - -#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)) - if ((IsGestureDetected(GESTURE_HOLD) || (GetGestureDetected() == GESTURE_DRAG)) && CheckCollisionPointRec(GetTouchPosition(0), leftButton)) player.y += FLYINGMOV; - if ((IsGestureDetected(GESTURE_HOLD) || (GetGestureDetected() == GESTURE_DRAG)) && CheckCollisionPointRec(GetTouchPosition(0), rightButton)) player.y -= FLYINGMOV; -#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)) - if (IsKeyDown(KEY_DOWN) || (CheckCollisionPointRec(GetMousePosition(), leftButton) && IsMouseButtonDown(0))) player.y += FLYINGMOV; - if (IsKeyDown(KEY_UP) || (CheckCollisionPointRec(GetMousePosition(), rightButton) && IsMouseButtonDown(0))) player.y -= FLYINGMOV; -#endif - } - - gravity = 0; - grabCounter ++; - - } break; - case ONWIND: - { - player.x -= jumpSpeed*TIME_FACTOR; - velocity -= 2*TIME_FACTOR; - player.y -= velocity; - framesCounter += 1*TIME_FACTOR; - grabCounter += 1*TIME_FACTOR; - - } break; - default: break; - } - - if (player.x <= (-player.width)) - { - play = false; - playerActive = false; - killer = 4; - } - - if ((player.y + player.height) >= GetScreenHeight()) - { - if (state == FINALFORM) player.y = GetScreenHeight() - player.height; - else - { - play = false; - playerActive = false; - killer = 4; - } - } - - if ((player.y) <= 0 && state == FINALFORM) player.y = 0; - if (player.x >= (GetScreenWidth() - player.width)) player.x = (GetScreenWidth() - player.width); - if (player.y <= -32) player.y = -32; - - if (bambooTimer > bambooSpawnTime) - { - if (!transforming) - { - BambooSpawn(); - - if (state != FINALFORM && eagleDelay >= EAGLE_TIME_DELAY)EagleSpawn(EAGLE_SPAWNCHANCE); - - switch (season) - { - case WINTER: - IceSpawn(ICESPAWNCHANCE); - OwlSpawn(OWLSPAWNCHANCE + (int)progresionSpawnChance); - break; - case SPRING: - ResinSpawn(RESINSPAWNCHANCE); - if (state != FINALFORM)BeeSpawn(BEE_SPAWNCHANCE); - DingoSpawn(DINGOSPAWNCHANCE + (int)progresionSpawnChance); - break; - case SUMMER: - FireSpawn(FIRESPAWNCHANCE); - SnakeSpawn(SNAKESPAWNCHANCE + (int)progresionSpawnChance); - break; - case FALL: - WindSpawn(WINDSPAWNCHANCE); - SnakeSpawn(SNAKESPAWNCHANCE + (int)progresionSpawnChance); - break; - default: break; - } - - LeafSpawn(); - } - - bambooTimer = 0; - bambooSpawnTime = GetRandomValue(MINTIMESPAWN, MAXTIMESPAWN); - } - } - else if (!play && !playerActive) - { - if (score > hiscore) hiscore = score; - - player.x -= jumpSpeed; - velocity -= 1*TIME_FACTOR; - player.y -= velocity; - - if (player.y >= GetScreenHeight()) - { - deathsCounter++; - finishScreen = 1; - } - } -} - -// Gameplay Screen Draw logic -void DrawGameplayScreen(void) -{ - BeginShaderMode(colorBlend); - - DrawTexturePro(atlas02, gameplay_background, (Rectangle){0, 0, gameplay_background.width*2, gameplay_background.height*2}, (Vector2){0, 0}, 0, color02); - - // Draw parallax - DrawParallaxBack(); - DrawParallaxMiddle(); - - // Draw particles (only if active) - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (backSnowParticle.particles[i].active) DrawTexturePro(atlas02, particle_icecrystal_bw, - (Rectangle){ backSnowParticle.particles[i].position.x, backSnowParticle.particles[i].position.y, particle_icecrystal_bw.width*backSnowParticle.particles[i].size, particle_icecrystal_bw.height*backSnowParticle.particles[i].size }, - (Vector2){ particle_icecrystal_bw.width*backSnowParticle.particles[i].size/2, particle_icecrystal_bw.height*backSnowParticle.particles[i].size/2 }, backSnowParticle.particles[i].rotation, - Fade((Color){144, 214, 255, 255}, backSnowParticle.particles[i].alpha)); - - if (backPlanetreeParticle.particles[i].active) DrawTexturePro(atlas02, particle_planetreeleaf_bw, - (Rectangle){ backPlanetreeParticle.particles[i].position.x, backPlanetreeParticle.particles[i].position.y, particle_planetreeleaf_bw.width*backPlanetreeParticle.particles[i].size, particle_planetreeleaf_bw.height*backPlanetreeParticle.particles[i].size }, - (Vector2){ particle_planetreeleaf_bw.width*backPlanetreeParticle.particles[i].size/2, particle_planetreeleaf_bw.height*backPlanetreeParticle.particles[i].size/2 }, backPlanetreeParticle.particles[i].rotation, - Fade((Color){179, 86, 6, 255}, backPlanetreeParticle.particles[i].alpha)); - - if (dandelionBackParticle.particles[i].active) DrawTexturePro(atlas02, particle_dandelion_bw, - (Rectangle){ dandelionBackParticle.particles[i].position.x, dandelionBackParticle.particles[i].position.y, particle_dandelion_bw.width*dandelionBackParticle.particles[i].size, particle_dandelion_bw.height*dandelionBackParticle.particles[i].size }, - (Vector2){ particle_dandelion_bw.width*dandelionBackParticle.particles[i].size/2, particle_dandelion_bw.height*dandelionBackParticle.particles[i].size/2 }, dandelionBackParticle.particles[i].rotation, - Fade((Color){202, 167, 126, 255}, dandelionBackParticle.particles[i].alpha)); - - if (backFlowerParticle.particles[i].active) DrawTexturePro(atlas02, particle_ecualyptusflower_bw, - (Rectangle){ backFlowerParticle.particles[i].position.x, backFlowerParticle.particles[i].position.y, particle_ecualyptusflower_bw.width*backFlowerParticle.particles[i].size, particle_ecualyptusflower_bw.height*backFlowerParticle.particles[i].size }, - (Vector2){ particle_ecualyptusflower_bw.width*backFlowerParticle.particles[i].size/2, particle_ecualyptusflower_bw.height*backFlowerParticle.particles[i].size/2 }, backFlowerParticle.particles[i].rotation, - Fade((Color){218, 84, 108, 255}, backFlowerParticle.particles[i].alpha)); - - if (backRainParticle.particles[i].active) DrawTexturePro(atlas02, particle_waterdrop_bw, - (Rectangle){ backRainParticle.particles[i].position.x, backRainParticle.particles[i].position.y, particle_waterdrop_bw.width*backRainParticle.particles[i].size, particle_waterdrop_bw.height*backRainParticle.particles[i].size }, - (Vector2){ particle_waterdrop_bw.width*backRainParticle.particles[i].size/2, particle_waterdrop_bw.height*backRainParticle.particles[i].size/2 }, backRainParticle.particles[i].rotation, - Fade((Color){144, 183, 187, 255}, backRainParticle.particles[i].alpha)); - } - - for (int i = 0; i < MAX_PARTICLES_RAY; i++) - { - if (backRayParticles.particles[i].active) DrawTexturePro(atlas02, gameplay_back_fx_lightraymid, - (Rectangle){ backRayParticles.particles[i].position.x, backRayParticles.particles[i].position.y, gameplay_back_fx_lightraymid.width*backRayParticles.particles[i].size, gameplay_back_fx_lightraymid.height*backRayParticles.particles[i].size }, - (Vector2){ gameplay_back_fx_lightraymid.width*backRayParticles.particles[i].size/2, gameplay_back_fx_lightraymid.height*backRayParticles.particles[i].size/2 }, backRayParticles.particles[i].rotation, - Fade(backRayParticles.particles[i].color, backRayParticles.particles[i].alpha)); - } - - DrawParallaxFront(); - - for (int i = 0; i < MAX_BAMBOO; i++) - { - if (bambooActive[i]) - { - DrawTexturePro(atlas02, gameplay_props_tree, (Rectangle){bamboo[i].x, bamboo[i].y, 43, 720}, (Vector2){0, 0}, 0, color03); - } - } - - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (branchActive[i]) - { - DrawTexturePro(atlas02, gameplay_props_owl_branch, (Rectangle){branchPos[i].x, branchPos[i].y, 36, 20}, (Vector2){0, 0}, 0, color03); - } - } - - EndShaderMode(); - - for (int i = 0; i < MAX_FIRE; i++) - { - DrawTexturePro(atlas01, (Rectangle){gameplay_props_burnttree.x, gameplay_props_burnttree.y + fire[i].y + gameplay_props_burnttree.height/14, gameplay_props_burnttree.width, gameplay_props_burnttree.height}, - (Rectangle){fire[i].x + 5, fire[i].y + gameplay_props_burnttree.height/14, gameplay_props_burnttree.width, gameplay_props_burnttree.height}, (Vector2){0, 0}, 0, WHITE); - DrawTextureRec(atlas01, fireAnimation, (Vector2){fire[i].x, GetScreenHeight() - gameplay_props_burnttree.height/7}, WHITE); - - for(int j = MAX_FIRE_FLAMES; j > -2; j--) - { - if ((fire[i].y - 25 <= (j*43)) && fireActive[i]) - { - if (j%2 > 0) - { - DrawTextureRec(atlas01, fireAnimation, (Vector2){fire[i].x + fireOffset - 10, 40*j}, WHITE); - fireAnimation.x = gameplay_props_fire_spritesheet.x + fireAnimation.width*curFrame1; - } - else if (j%2 + 1 == 1) - { - DrawTextureRec(atlas01, fireAnimation, (Vector2){fire[i].x - fireOffset , 40*j}, WHITE); - fireAnimation.x = gameplay_props_fire_spritesheet.x + fireAnimation.width*curFrame2; - } - else - { - DrawTextureRec(atlas01, fireAnimation, (Vector2){fire[i].x - fireOffset , 40*j}, WHITE); - fireAnimation.x = gameplay_props_fire_spritesheet.x + fireAnimation.width*curFrame3; - } - } - } - } - - for (int i = 0; i < MAX_ICE; i++) - { - if (iceActive[i]) for (int k = 0; k < GetScreenHeight(); k += (GetScreenHeight()/6)) DrawTexturePro(atlas01, gameplay_props_ice_sprite, (Rectangle){ice[i].x - 5, ice[i].y+k, gameplay_props_ice_sprite.width, gameplay_props_ice_sprite.height}, (Vector2){0,0}, 0, WHITE); - } - - BeginShaderMode(colorBlend); - - DrawTexturePro(atlas02, gameplay_back_ground00, (Rectangle){(int)groundPos + GetScreenWidth(), 637, gameplay_back_ground00.width*2, gameplay_back_ground00.height*2}, (Vector2){0,0}, 0, color00); - DrawTexturePro(atlas02, gameplay_back_ground00, (Rectangle){(int)groundPos, 637, gameplay_back_ground00.width*2, gameplay_back_ground00.height*2}, (Vector2){0,0}, 0, color00); - - EndShaderMode(); - - for (int i = 0; i < MAX_RESIN; i++) - { - if (resinActive[i]) DrawTextureRec(atlas01, gameplay_props_resin_sprite,(Vector2){ resin[i].x - resin[i].width/3, resin[i].y - resin[i].height/5}, WHITE); - } - - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (snakeActive[i]) - { - if (!isHitSnake[i])DrawTextureRec(atlas01, snakeAnimation, (Vector2){snake[i].x - snake[i].width, snake[i].y - snake[i].height/2}, WHITE); - else DrawTextureRec(atlas01, (Rectangle){gameplay_enemy_snake.x + snakeAnimation.width*2, gameplay_enemy_snake.y, snakeAnimation.width, snakeAnimation.height}, (Vector2){snake[i].x - snake[i].width/2, snake[i].y - snake[i].height/2}, WHITE); - } - - if (dingoActive[i]) - { - if (!isHitDingo[i]) DrawTextureRec(atlas01, dingoAnimation, (Vector2){dingo[i].x - dingo[i].width/2, dingo[i].y - dingo[i].height/4}, WHITE); - else DrawTextureRec(atlas01, (Rectangle){gameplay_enemy_dingo.x + dingoAnimation.width*2, gameplay_enemy_dingo.y, dingoAnimation.width, dingoAnimation.height}, (Vector2){dingo[i].x - dingo[i].width/2, dingo[i].y - dingo[i].height/4}, WHITE); - } - - if (owlActive[i]) - { - if (!isHitOwl[i])DrawTextureRec(atlas01, owlAnimation, (Vector2){owl[i].x - owl[i].width*0.7, owl[i].y - owl[i].height*0.1}, WHITE); - else DrawTextureRec(atlas01, (Rectangle){gameplay_enemy_owl.x + owlAnimation.width*2, gameplay_enemy_owl.y, owlAnimation.width, owlAnimation.height}, (Vector2){owl[i].x - owl[i].width/2, owl[i].y - owl[i].height/6}, WHITE); - } - - if (enemyHit[i].active) - { - DrawTexturePro(atlas01, particle_hit, - (Rectangle){ enemyHit[i].position.x, enemyHit[i].position.y, particle_hit.width*enemyHit[i].size, particle_hit.height*enemyHit[i].size }, - (Vector2){ particle_hit.width*enemyHit[i].size/2, particle_hit.height*enemyHit[i].size/2 }, enemyHit[i].rotation, - Fade(enemyHit[i].color, enemyHit[i].alpha)); - } - } - - // Only one bee / eagle / alert at the same time - - for (int i = 0; i < MAX_LEAVES; i++) - { - if (leafActive[i]) - { - if (leafSide[i]) - { - if (leafType[i] == 0) DrawTextureRec(atlas01, (Rectangle){ gameplay_props_leaf_lil.x, gameplay_props_leaf_lil.y, -gameplay_props_leaf_lil.width, gameplay_props_leaf_lil.height }, (Vector2){ leaf[i].x, leaf[i].y - 15 }, WHITE); - else if (leafType[i] == 1) DrawTextureRec(atlas01, (Rectangle){ gameplay_props_leaf_lil.x, gameplay_props_leaf_lil.y, -gameplay_props_leaf_lil.width, gameplay_props_leaf_lil.height }, (Vector2){leaf[i].x, leaf[i].y + 10 }, WHITE); - else if (leafType[i] == 2) DrawTextureRec(atlas01, (Rectangle){ gameplay_props_leaf_mid.x, gameplay_props_leaf_mid.y, -gameplay_props_leaf_mid.width, gameplay_props_leaf_mid.height }, (Vector2){leaf[i].x, leaf[i].y - 15 }, WHITE); - else if (leafType[i] == 3) DrawTextureRec(atlas01, (Rectangle){ gameplay_props_leaf_big.x, gameplay_props_leaf_big.y, -gameplay_props_leaf_big.width, gameplay_props_leaf_big.height }, (Vector2){leaf[i].x, leaf[i].y - 15 }, WHITE); - } - else - { - if (leafType[i] == 0) DrawTextureRec(atlas01, gameplay_props_leaf_lil, (Vector2){ leaf[i].x - 25, leaf[i].y - 15 }, WHITE); - else if (leafType[i] == 1) DrawTextureRec(atlas01, gameplay_props_leaf_lil, (Vector2){leaf[i].x - 25, leaf[i].y + 10 }, WHITE); - else if (leafType[i] == 2) DrawTextureRec(atlas01, gameplay_props_leaf_mid, (Vector2){leaf[i].x - 25, leaf[i].y - 15 }, WHITE); - else if (leafType[i] == 3) DrawTextureRec(atlas01, gameplay_props_leaf_big, (Vector2){leaf[i].x - 25, leaf[i].y - 15 }, WHITE); - } -#if defined(DEBUG) - DrawRectangle(leaf[i].x, leaf[i].y, 64, 64, Fade(GREEN, 0.5f)); -#endif - } - - if (leafParticles[i].active) - { - for (int j = 0; j < 32; j++) - { - DrawTexturePro(atlas01, particle_ecualyptusleaf, - (Rectangle){ leafParticles[i].particles[j].position.x, leafParticles[i].particles[j].position.y, particle_ecualyptusleaf.width*leafParticles[i].particles[j].size, particle_ecualyptusleaf.height*leafParticles[i].particles[j].size }, - (Vector2){ particle_ecualyptusleaf.width/2*leafParticles[i].particles[j].size, particle_ecualyptusleaf.height/2*leafParticles[i].particles[j].size }, leafParticles[i].particles[j].rotation, Fade(WHITE,leafParticles[i].particles[j].alpha)); - } - } - } - - if (beeActive && !isHitBee) DrawTextureRec(atlas01, beeAnimation, (Vector2){bee.x, bee.y - gameplay_enemy_bee.height/2}, WHITE); - else if (beeActive && isHitBee) DrawTexturePro(atlas01, (Rectangle){gameplay_enemy_bee.x + beeAnimation.width*4, gameplay_enemy_bee.y, beeAnimation.width, gameplay_enemy_bee.height}, - (Rectangle){bee.x, bee.y, beeAnimation.width, gameplay_enemy_bee.height}, (Vector2){0, 0}, 0, WHITE); - - if (eagleActive && !isHitEagle) DrawTextureRec(atlas01, eagleAnimation, (Vector2){eagle.x, eagle.y}, WHITE); - else if (eagleActive && isHitEagle) DrawTextureRec(atlas01, gameplay_enemy_eagle_death, (Vector2){eagle.x, eagle.y}, WHITE); - - if (alertActive) DrawTexturePro(atlas01, gameplay_fx_eaglealert, alertRectangle, (Vector2){0, 0}, 0, Fade(RED, 0.7f)); - if (alertBeeActive) DrawTexturePro(atlas01, gameplay_fx_eaglealert, beeAlertRectangle, (Vector2){0, 0}, 0, Fade(ORANGE, 0.7f)); - - if (transforming) - { - for (int i = 0; i < 8; i++) - { - DrawTexturePro(atlas02, background_transformation, - (Rectangle){player.x + player.width/2 , player.y + player.height/2, background_transformation.width*4, background_transformation.height*4}, - (Vector2){0, background_transformation.height*2}, 45*i, Fade(finalColor, 0.7f)); - } - - for (int i = 0; i < 8; i++) - { - DrawTexturePro(atlas02, background_transformation, - (Rectangle){player.x + player.width/2 , player.y + player.height/2, background_transformation.width*4, background_transformation.height}, - (Vector2){0, background_transformation.height/2}, 22.5 + 45*i, Fade(finalColor2, 0.7f)); - } - } - - if (playerActive && play) - { - switch(state) - { - case GRABED: DrawTextureRec(atlas01, koalaAnimationIddle, (Vector2){player.x - player.width, player.y - gameplay_koala_idle.height/4}, WHITE); break; - case JUMPING: DrawTexturePro(atlas01, gameplay_koala_jump, (Rectangle){player.x - player.width, player.y - gameplay_koala_jump.height/4, gameplay_koala_jump.width, gameplay_koala_jump.height}, (Vector2){0, 0}, 0, WHITE); break; - case KICK:DrawTexturePro(atlas01, gameplay_koala_dash, (Rectangle){player.x - player.width, player.y - gameplay_koala_jump.height/4, gameplay_koala_dash.width, gameplay_koala_dash.height}, (Vector2){0, 0}, 0, WHITE); break; - case FINALFORM: - { - if (transforming)DrawTexturePro(atlas01, koalaAnimationTransform, (Rectangle){player.x - player.width, player.y - gameplay_koala_transform.height/4, gameplay_koala_transform.width/2, gameplay_koala_transform.height}, (Vector2){0, 0}, 0, finalColor); - else DrawTexturePro(atlas01, koalaAnimationFly, (Rectangle){player.x - gameplay_koala_fly.width/3, player.y - gameplay_koala_fly.height/4, gameplay_koala_fly.width/2, gameplay_koala_fly.height}, (Vector2){0, 0}, 0, finalColor);//DrawTextureRec((koalaFly), (Rectangle){0, 0, 128, 128}, (Vector2){player.x - 50, player.y - 40}, WHITE); - - } break; - case ONWIND: DrawTexturePro(atlas01, gameplay_koala_jump, (Rectangle){player.x - player.width, player.y - gameplay_koala_jump.height/4, gameplay_koala_jump.width, gameplay_koala_jump.height}, (Vector2) { 0, 0}, 0, WHITE); break; - default: break; - } - } - else if (play == false && playerActive) DrawTextureRec(atlas01, (Rectangle){gameplay_koala_idle.x, gameplay_koala_idle.y, gameplay_koala_idle.width/3, gameplay_koala_idle.height}, (Vector2){player.x - player.width, player.y - gameplay_koala_idle.height/4}, WHITE); - else DrawTexturePro(atlas01, gameplay_koala_die, (Rectangle){player.x - player.width, player.y - gameplay_koala_die.height/4, gameplay_koala_die.width, gameplay_koala_die.height}, (Vector2) { 0, 0}, 0, WHITE); - - for (int i = 0; i < MAX_WIND; i++) - { - if (windActive[i]) DrawTextureRec(atlas01, windAnimation, (Vector2){wind[i].x - 14, wind[i].y - 14}, WHITE); - } - - if (playerActive && !play) - { - if (initSeason == 0) DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade((Color){216, 200, 39, 255}, 0.4)); - else if (initSeason == 1) DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade((Color){155, 70, 22, 255}, 0.4)); - else if (initSeason == 2) DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade((Color){17, 129, 162, 255}, 0.4)); - else DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade((Color){82, 174, 7, 255}, 0.4)); - } - - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (snowParticle.particles[i].active) DrawTexturePro(atlas01, particle_icecrystal, - (Rectangle){ snowParticle.particles[i].position.x, snowParticle.particles[i].position.y, particle_icecrystal.width*snowParticle.particles[i].size, particle_icecrystal.height*snowParticle.particles[i].size }, - (Vector2){ particle_icecrystal.width*snowParticle.particles[i].size/2, particle_icecrystal.height*snowParticle.particles[i].size/2 }, snowParticle.particles[i].rotation, - Fade(snowParticle.particles[i].color, snowParticle.particles[i].alpha)); - - if (planetreeParticle.particles[i].active) DrawTexturePro(atlas01, particle_planetreeleaf, - (Rectangle){ planetreeParticle.particles[i].position.x, planetreeParticle.particles[i].position.y, particle_planetreeleaf.width*planetreeParticle.particles[i].size, particle_planetreeleaf.height*planetreeParticle.particles[i].size }, - (Vector2){ particle_planetreeleaf.width*planetreeParticle.particles[i].size/2, particle_planetreeleaf.height*planetreeParticle.particles[i].size/2 }, planetreeParticle.particles[i].rotation, - Fade(planetreeParticle.particles[i].color, planetreeParticle.particles[i].alpha)); - - if (dandelionParticle.particles[i].active) DrawTexturePro(atlas01, particle_dandelion, - (Rectangle){ dandelionParticle.particles[i].position.x, dandelionParticle.particles[i].position.y, particle_dandelion.width*dandelionParticle.particles[i].size, particle_dandelion.height*dandelionParticle.particles[i].size }, - (Vector2){ particle_dandelion.width*dandelionParticle.particles[i].size/2, particle_dandelion.height*dandelionParticle.particles[i].size/2 }, dandelionParticle.particles[i].rotation, - Fade(dandelionParticle.particles[i].color, dandelionParticle.particles[i].alpha)); - - if (flowerParticle.particles[i].active) DrawTexturePro(atlas01, particle_ecualyptusflower, - (Rectangle){ flowerParticle.particles[i].position.x, flowerParticle.particles[i].position.y, particle_ecualyptusflower.width*flowerParticle.particles[i].size, particle_ecualyptusflower.height*flowerParticle.particles[i].size }, - (Vector2){ particle_ecualyptusflower.width*flowerParticle.particles[i].size/2, particle_ecualyptusflower.height*flowerParticle.particles[i].size/2 }, flowerParticle.particles[i].rotation, - Fade(flowerParticle.particles[i].color, flowerParticle.particles[i].alpha)); - - if (rainParticle.particles[i].active) DrawTexturePro(atlas01, particle_waterdrop, - (Rectangle){ rainParticle.particles[i].position.x, rainParticle.particles[i].position.y, particle_waterdrop.width*rainParticle.particles[i].size, particle_waterdrop.height*rainParticle.particles[i].size }, - (Vector2){ particle_waterdrop.width*rainParticle.particles[i].size/2, particle_waterdrop.height*rainParticle.particles[i].size/2 }, rainParticle.particles[i].rotation, - Fade(rainParticle.particles[i].color, rainParticle.particles[i].alpha)); - } - - // Draw Speed Particles - for (int i = 0; i < MAX_PARTICLES_SPEED; i++) - { - if (speedFX.particle[i].active) DrawRectangle(speedFX.particle[i].position.x, speedFX.particle[i].position.y, speedFX.particle[i].size.x, speedFX.particle[i].size.y , Fade(WHITE, speedFX.particle[i].alpha)); - } - - for (int i = 0; i < MAX_PARTICLES_STORM; i++) - { - if (rainStormParticle.particles[i].active) DrawTexturePro(atlas01, particle_waterdrop, - (Rectangle){ rainStormParticle.particles[i].position.x, rainStormParticle.particles[i].position.y, particle_waterdrop.width*rainStormParticle.particles[i].size, particle_waterdrop.height*rainStormParticle.particles[i].size }, - (Vector2){ particle_waterdrop.width*rainStormParticle.particles[i].size/2, particle_waterdrop.height*rainStormParticle.particles[i].size/2 }, rainStormParticle.particles[i].rotation, - Fade(rainStormParticle.particles[i].color, rainStormParticle.particles[i].alpha)); - } - - for (int i = 0; i < MAX_PARTICLES_STORM; i++) - { - if (snowStormParticle.particles[i].active) DrawTexturePro(atlas01, particle_icecrystal, - (Rectangle){ snowStormParticle.particles[i].position.x, snowStormParticle.particles[i].position.y, particle_icecrystal.width*snowStormParticle.particles[i].size, particle_icecrystal.height*snowStormParticle.particles[i].size }, - (Vector2){ particle_icecrystal.width*snowStormParticle.particles[i].size/2, particle_icecrystal.height*snowStormParticle.particles[i].size/2 }, snowStormParticle.particles[i].rotation, - Fade(snowStormParticle.particles[i].color, snowStormParticle.particles[i].alpha)); - } - - for (int i = 0; i < MAX_PARTICLES_RAY; i++) - { - if (rayParticles.particles[i].active) DrawTexturePro(atlas01, gameplay_fx_lightraymid, - (Rectangle){ rayParticles.particles[i].position.x, rayParticles.particles[i].position.y, gameplay_fx_lightraymid.width*rayParticles.particles[i].size, gameplay_fx_lightraymid.height*rayParticles.particles[i].size }, - (Vector2){ gameplay_fx_lightraymid.width*rayParticles.particles[i].size/2, gameplay_fx_lightraymid.height*rayParticles.particles[i].size/2 }, rayParticles.particles[i].rotation, - Fade(rayParticles.particles[i].color, rayParticles.particles[i].alpha)); - } - - if (fogAlpha != 0) - { - DrawTexturePro(atlas02, background_fog02, (Rectangle){ fogPosition, GetScreenHeight()*0.6, GetScreenWidth(), background_fog02.height}, (Vector2){ 0 , 0 }, 0, Fade(WHITE, fogAlpha)); - DrawTexturePro(atlas02, background_fog02, (Rectangle){ fogPosition+GetScreenWidth(), GetScreenHeight()*0.6, GetScreenWidth(), background_fog02.height}, (Vector2){ 0 , 0 }, 0, Fade(WHITE, fogAlpha)); - } - - if (filterAlpha != 0 && state != FINALFORM) DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(SKYBLUE, filterAlpha)); - - DrawTexturePro(atlas01, gameplay_gui_leafcounter_base, (Rectangle){ 0, 0, gameplay_gui_leafcounter_base.width, gameplay_gui_leafcounter_base.height}, (Vector2){ 0 , 0 }, 0, WHITE); - - DrawTexturePro(atlas01, gameplay_gui_seasonsclock_disc, (Rectangle) {GetScreenWidth(), 0, gameplay_gui_seasonsclock_disc.width, gameplay_gui_seasonsclock_disc.height}, (Vector2) {gameplay_gui_seasonsclock_disc.width/2, gameplay_gui_seasonsclock_disc.height/2}, // Draw a part of a texture defined by a rectangle with 'pro' parameters - clockRotation, Fade(WHITE, UIfade)); - - DrawTexturePro(atlas01, gameplay_gui_seasonsclock_base, (Rectangle){ (GetScreenWidth() - gameplay_gui_seasonsclock_base.width ), 0, gameplay_gui_seasonsclock_base.width, gameplay_gui_seasonsclock_base.height}, (Vector2){ 0 , 0 }, 0, Fade(WHITE, UIfade)); - - for (int i = 0; i < 20; i++) - { - if (((currentLeaves/5) > i) && (state != FINALFORM)) DrawTexturePro(atlas01, gameplay_gui_leafcounter_cell, (Rectangle) {87, 83, gameplay_gui_leafcounter_cell.width, gameplay_gui_leafcounter_cell.height}, (Vector2) {gameplay_gui_leafcounter_cell.width/4, 69}, i*(-18), WHITE); - else if ((power/18 >= i) && (state == FINALFORM)) DrawTexturePro(atlas01, gameplay_gui_leafcounter_cell, (Rectangle) {87, 83, gameplay_gui_leafcounter_cell.width, gameplay_gui_leafcounter_cell.height}, (Vector2) {gameplay_gui_leafcounter_cell.width/4, 69}, i*(-18), WHITE); - } - - if ((currentLeaves >= LEAVESTOTRANSFORM) && (state != FINALFORM)) - { - DrawTexturePro(atlas01, gameplay_gui_leafcounter_pulsel, - (Rectangle){ 85, 84, gameplay_gui_leafcounter_pulsel.width*leafGUIpulseScale, gameplay_gui_leafcounter_pulsel.height*leafGUIpulseScale}, - (Vector2){ gameplay_gui_leafcounter_pulsel.width*leafGUIpulseScale/2 , gameplay_gui_leafcounter_pulsel.height*leafGUIpulseScale/2 }, 0, Fade((Color){126, 248, 25, 255}, leafGUIpulseFade)); - - DrawTexturePro(atlas01, gameplay_gui_leafcounter_glow, - (Rectangle){ 84, 83, gameplay_gui_leafcounter_glow.width, gameplay_gui_leafcounter_glow.height}, - (Vector2){ gameplay_gui_leafcounter_glow.width/2 , gameplay_gui_leafcounter_glow.height/2 }, 0, Fade(WHITE, leafGUIglowFade)); - } - - if ((play == false) && playerActive) - { - if (startNum == 3) DrawTexturePro(atlas01, gameplay_countdown_3, - (Rectangle){ GetScreenWidth()/2, GetScreenHeight()/2, gameplay_countdown_3.width*numberScale, gameplay_countdown_3.height*numberScale}, - (Vector2){ gameplay_countdown_3.width*numberScale/2 , gameplay_countdown_3.height*numberScale/2 }, 0, Fade(RED, numberAlpha)); - else if (startNum == 2) DrawTexturePro(atlas01, gameplay_countdown_2, - (Rectangle){ GetScreenWidth()/2, GetScreenHeight()/2, gameplay_countdown_2.width*numberScale, gameplay_countdown_2.height*numberScale}, - (Vector2){ gameplay_countdown_2.width*numberScale/2 , gameplay_countdown_2.height*numberScale/2 }, 0, Fade(RED, leafGUIpulseFade)); - else if (startNum == 1) DrawTexturePro(atlas01, gameplay_countdown_1, - (Rectangle){ GetScreenWidth()/2, GetScreenHeight()/2, gameplay_countdown_1.width*numberScale, gameplay_countdown_1.height*numberScale}, - (Vector2){ gameplay_countdown_1.width*numberScale/2 , gameplay_countdown_1.height*numberScale/2 }, 0, Fade(RED, leafGUIpulseFade)); - } - - // Draw text elements - //-------------------------- - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (popupScore[i].active) - { - DrawTextEx(font, FormatText("%i", popupScore[i].score), popupScore[i].position, font.baseSize/4*popupScore[i].scale, -5, Fade((Color){255, 73, 73, 255}, popupScore[i].alpha)); - } - } - - if (popupBee.active) DrawTextEx(font, FormatText("%i", popupBee.score), popupBee.position, font.baseSize/4*popupBee.scale, -5, Fade((Color){255, 73, 73, 255}, popupBee.alpha)); - if (popupEagle.active) DrawTextEx(font, FormatText("%i", popupEagle.score), popupEagle.position, font.baseSize/4*popupEagle.scale, -5, Fade((Color){255, 73, 73, 255}, popupEagle.alpha)); - - for (int i = 0; i < MAX_LEAVES; i++) - { - if (popupLeaves[i].active) DrawTextEx(font, FormatText("+ %i", popupLeaves[i].score), popupLeaves[i].position, font.baseSize/4*popupLeaves[i].scale, -5, Fade((Color){139, 179, 0, 255}, popupLeaves[i].alpha)); - } - - - DrawTextEx(font, FormatText("%03i", currentLeaves), (Vector2){ 47, 50 }, font.baseSize, -8, counterColor); - - if (transforming) DrawTextEx(font, textFinalForm, (Vector2){ GetScreenWidth()/2 - MeasureText(textFinalForm, 40)/2, GetScreenHeight()/4}, font.baseSize, -5, (Color){246, 133, 133, 255}); - - if ((currentMonth == 7) && (transitionFramesCounter >= SEASONTRANSITION/2)) - { - if (randomMessage <= 4) DrawTextEx(font, textSpring1, (Vector2){GetScreenWidth()/2 - MeasureText(textSpring1, 40)/2, GetScreenHeight()/3}, font.baseSize, -5, (Color){185, 222, 105, 255}); - else DrawTextEx(font, textSpring2, (Vector2){GetScreenWidth()/2 - MeasureText(textSpring2, 40)/2, GetScreenHeight()/3}, font.baseSize, -5, (Color){185, 222, 105, 255}); - } - else if ((currentMonth == 10) && (transitionFramesCounter >= SEASONTRANSITION/2)) - { - if (randomMessage <= 4) DrawTextEx(font, textSummer1, (Vector2){GetScreenWidth()/2 - MeasureText(textSummer1, 40)/2, GetScreenHeight()/3}, font.baseSize, -5, (Color){253, 200, 108, 255}); - else DrawTextEx(font, textSummer2, (Vector2){GetScreenWidth()/2 - MeasureText(textSummer2, 40)/2, GetScreenHeight()/3}, font.baseSize, -5, (Color){253, 200, 108, 255}); - } - else if ((currentMonth == 1) && (transitionFramesCounter >= SEASONTRANSITION/2)) - { - if (randomMessage <= 4) DrawTextEx(font, textFall1, (Vector2){GetScreenWidth()/2 - MeasureText(textFall1, 40)/2, GetScreenHeight()/3}, font.baseSize, -5, (Color){255, 149, 107, 255}); - else DrawTextEx(font, textFall2, (Vector2){GetScreenWidth()/2 - MeasureText(textFall2, 40)/2, GetScreenHeight()/3}, font.baseSize, -5, (Color){255, 149, 107, 255}); - } - else if (currentMonth == 4 && transitionFramesCounter >= SEASONTRANSITION/2) - { - if (randomMessage <= 4) DrawTextEx(font, textWinter1, (Vector2){GetScreenWidth()/2 - MeasureText(textWinter1, 40)/2, GetScreenHeight()/3}, font.baseSize, -5, (Color){133, 249, 253, 255}); - else DrawTextEx(font, textWinter2, (Vector2){GetScreenWidth()/2 - MeasureText(textWinter2, 40)/2, GetScreenHeight()/3}, font.baseSize, -5, (Color){133, 249, 253, 255}); - } - -#if defined(DEBUG) - DrawRectangle(player.x, player.y, player.width, player.height, Fade(WHITE, 0.5)); - - for (int i = 0; i < MAX_WIND; i++) - { - if (windActive[i]) DrawRectangleRec(wind[i], Fade (GRAY, 0.4)); - } - - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (owlActive[i]) DrawRectangleRec(owl[i], Fade(BLACK, 0.5f)); - if (dingoActive[i]) DrawRectangleRec(dingo[i], Fade(BLACK, 0.5f)); - if (snakeActive[i]) DrawRectangleRec(snake[i], BLACK); - } - - if (beeActive) DrawRectangleRec(bee, Fade(BLACK, 0.5f)); - if (eagleActive) DrawRectangleRec(eagle, Fade(BLACK, 0.5f)); - - switch (season) - { - case WINTER: - { - if (currentMonth == 5) DrawText("June", GetScreenWidth() - 140, GetScreenHeight() - 20, 20, RED); - if (currentMonth == 6) DrawText("July", GetScreenWidth() - 140, GetScreenHeight() - 20, 20, RED); - - } break; - case SPRING: - { - if (currentMonth == 8) DrawText("September", GetScreenWidth() - 140, GetScreenHeight() - 20, 20, RED); - if (currentMonth == 9) DrawText("October", GetScreenWidth() - 140, GetScreenHeight() - 20, 20, RED); - - } break; - case SUMMER: - { - if (currentMonth == 11) DrawText("December", GetScreenWidth() - 140, GetScreenHeight() - 20, 20, RED); - if (currentMonth == 0) DrawText("January", GetScreenWidth() - 140, GetScreenHeight() - 20, 20, RED); - - } break; - case FALL: - { - if (currentMonth == 2) DrawText("March", GetScreenWidth() - 140, GetScreenHeight() - 20, 20, RED); - if (currentMonth == 3) DrawText("April", GetScreenWidth() - 140, GetScreenHeight() - 20, 20, RED); - - } break; - case TRANSITION: - { - if (currentMonth == 4) DrawText("May", GetScreenWidth() - 140, GetScreenHeight() - 20, 20, RED); - - } break; - default: break; - } - - DrawText(FormatText("Score: %02i", score), 140, GetScreenHeight() - 20, 20, RED); - DrawText(FormatText("HighScore: %02i", hiscore), 600, GetScreenHeight() - 20, 20, RED); - DrawText(FormatText("SeasonChange: %03i", seasonTimer), 300, GetScreenHeight() - 20, 20, RED); -#endif -} - -// Gameplay Screen Unload logic -void UnloadGameplayScreen(void) -{ - // ... -} - -// Gameplay Screen should finish? -int FinishGameplayScreen(void) -{ - return finishScreen; -} - -// Tree Spawn -static void BambooSpawn(void) -{ - int counter = 0; - - for (int k = 0; k < MAX_ENEMIES; k++) - { - if ((!bambooActive[k]) && (counter < 1)) - { - bamboo[k].y = 0; - bamboo[k].x = GetScreenWidth(); - bambooActive[k] = true; - counter++; - } - } -} - -//Snake Spawn -static void SnakeSpawn(int chance) -{ - int position; - int counter = 0; - - for (int z = 0; z < 2; z++) posArray[z] = -1; - - if (GetRandomValue(0, 100) <= chance) - { - for (int k = 0; k < MAX_ENEMIES; k++) - { - if ((!snakeActive[k]) && (counter < 1)) - { - position = GetRandomValue(0, 4); - - if (counter == 0) posArray[counter] = position; - - snake[k].x = GetScreenWidth() - 15; - snake[k].y = 25 + GetScreenHeight()/5*position; - snakeActive[k] = true; - isHitSnake[k] = false; - counter++; - } - } - } -} - -// Dingo Spawn -static void DingoSpawn(int chance) -{ - int position; - int counter = 0; - - for (int z = 0; z < 2; z++) posArrayDingo[z] = -1; - - if (GetRandomValue(0, 100) <= chance) - { - for(int k = 0; k < MAX_ENEMIES; k++) - { - if ((!dingoActive[k]) && (counter < 1)) - { - position = GetRandomValue(1, 3); - - if (counter == 0) posArray[counter] = position; - - dingo[k].x = GetScreenWidth() - 15; - dingo[k].y = 25 + GetScreenHeight()/5*position; - dingoActive[k] = true; - isHitDingo[k] = false; - counter++; - } - } - } -} - -// Owl Spawn -static void OwlSpawn(int chance) -{ - int position; - int counter = 0; - - for (int z = 0; z < 2; z++) posArray[z] = -1; - - if (GetRandomValue(0, 100) <= chance) - { - for (int k = 0; k < MAX_ENEMIES; k++) - { - if ((!owlActive[k]) && (!branchActive[k]) && (counter < 1)) - { - position = GetRandomValue(1, 3); - - if (counter == 0) posArray[counter] = position; - - owl[k].x = GetScreenWidth() - 15; - owl[k].y = 25 + GetScreenHeight()/5*position; - owlActive[k] = true; - branchPos[k].x = owl[k].x; - branchPos[k].y = owl[k].y + 64; - branchActive[k] = true; - counter++; - } - } - } -} - -// Leaf spawn function -static void LeafSpawn(void) -{ - int counter = 0; - int maxLeavesCounter = GetRandomValue(0, 2); - - for (int z = 0; z < 2; z++) posArrayLeaf[z] = -1; - - for (int k = 0; k < MAX_LEAVES; k++) - { - if ((!leafActive[k]) && (counter <= maxLeavesCounter)) - { - int leafPosition = GetRandomValue(0, 4); - int leafTypeSelection = GetRandomValue(0,99); - int leafSideSelection = GetRandomValue(0,1); - leafSide[k] = leafSideSelection; - - if (counter == 0) - { - while (CheckArrayValue(posArray, 2, leafPosition)) leafPosition = GetRandomValue(0, 4); - posArrayLeaf[counter] = leafPosition; - } - else if (counter == 1) - { - while(leafPosition == posArrayLeaf[counter - 1] || CheckArrayValue(posArray, 2, leafPosition)) leafPosition = GetRandomValue(0, 4); - posArrayLeaf[counter] = leafPosition; - } - else if (counter == 2) - { - while((leafPosition == posArrayLeaf[counter - 1] || (leafPosition == posArrayLeaf[counter - 2])) || CheckArrayValue(posArray, 2, leafPosition)) leafPosition = GetRandomValue(0, 4); - posArrayLeaf[counter] = leafPosition; - } - - leaf[k].y = 30 + GetScreenHeight()/5*leafPosition; - leaf[k].x = GetScreenWidth() - 18; - leafActive[k] = true; - - if (leafTypeSelection <= 24) leafType[k] = 0; - else if ((leafTypeSelection > 24) && leafTypeSelection <= 50) leafType[k] = 1; - else if ((leafTypeSelection > 50) && leafTypeSelection <= 75) leafType[k] = 2; - else leafType[k] = 3; - - counter++; - } - } -} - -static void FireSpawn(int chance) -{ - int counter = 0; - - if (GetRandomValue(0, 100) <= chance) - { - for (int k = 0; k < MAX_FIRE; k++) - { - if ((!fireActive[k]) && (counter < 1)) - { - fire[k].y = GetScreenHeight() - 30; - fire[k].x = GetScreenWidth() - 5; - //fire[k].height = 30; - fireActive[k] = true; - onFire[k] = false; - counter++; - } - } - } -} - -static void IceSpawn(int chance) -{ - int counter = 0; - - if (GetRandomValue(0, 100) <= chance) - { - for (int k = 0; k < MAX_ICE; k++) - { - if ((!iceActive[k]) && (counter < 1)) - { - ice[k].y = 0; - ice[k].x = GetScreenWidth() + 5; - iceActive[k] = true; - counter++; - } - } - } -} - -static void ResinSpawn(int chance) -{ - int counter = 0; - - if (GetRandomValue(0, 100) <= chance) - { - for (int k = 0; k < MAX_RESIN; k++) - { - if ((!resinActive[k]) && (counter < 1)) - { - int resPosition = GetRandomValue(0, 4); - - while (CheckArrayValue(posArray, 2, resPosition)) resPosition = GetRandomValue(0, 4); - - resin[k].y = 25 + GetScreenHeight()/5*resPosition; - resin[k].x = GetScreenWidth() + 5; - resinActive[k] = true; - counter++; - } - } - } -} - -static void WindSpawn(int chance) -{ - int counter = 0; - - if (GetRandomValue(0, 100) <= chance) - { - for (int k = 0; k < MAX_WIND ; k++) - { - if ((!windActive[k]) && (counter < 1)) - { - int resPosition = GetRandomValue(0, 4); - - while (CheckArrayValue(posArray, 2, resPosition)) resPosition = GetRandomValue(0, 4); - - wind[k].y = 25 + GetScreenHeight()/5*resPosition; - wind[k].x = GetScreenWidth() + 5; - windActive[k] = true; - counter++; - } - } - } -} - -// Spawn bee enemy -static void BeeSpawn(int chance) -{ - if ((GetRandomValue(0, 100) <= chance) && !beeActive && !alertBeeActive) - { - bee.x = GetScreenWidth(); - bee.y = GetRandomValue(40, GetScreenHeight() - bee.height - 40); - beeAlertRectangle = (Rectangle){GetScreenWidth(), bee.y + gameplay_enemy_bee.height/2, 0, 0}; - beeActive = false; - alertBeeActive = true; - } -} - -// Spawn eagle enemy -static void EagleSpawn(int chance) -{ - if ((GetRandomValue(0, 100) <= chance) && !eagleActive && !alertActive) - { - eagleDelay = 0; - eagle.x = GetScreenWidth(); - eagle.y = player.y; - alertRectangle = (Rectangle){GetScreenWidth(), eagle.y + gameplay_enemy_eagle.height/2, 0, 0}; - eagleActive = false; - eagleAlert = true; - alertActive = true; - } -} - -// Check if the array contains a value -static bool CheckArrayValue(int *array, int arrayLength, int value) -{ - for (int n = 0; n < arrayLength; n++) - { - if (array[n] == value) return 1; - } - - return 0; -} - -// Scroll functions -// Front parallax drawing -static void DrawParallaxFront(void) -{ - Rectangle ground01 = gameplay_back_ground01; - - DrawTexturePro(atlas02, gameplay_back_tree01_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset, 60, gameplay_back_tree01_layer01.width*2, gameplay_back_tree01_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree02_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + 140, 60, gameplay_back_tree02_layer01.width*2, gameplay_back_tree02_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree03_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + 140*2, 55, gameplay_back_tree02_layer01.width*2, gameplay_back_tree02_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree04_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + 140*3, 60, gameplay_back_tree04_layer01.width*2, gameplay_back_tree04_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree05_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + 140*4, 60, gameplay_back_tree05_layer01.width*2, gameplay_back_tree05_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree06_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + 140*5, 55, gameplay_back_tree06_layer01.width*2, gameplay_back_tree06_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree07_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + 140*6, 60, gameplay_back_tree07_layer01.width*2, gameplay_back_tree07_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree08_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + 140*7, 60, gameplay_back_tree08_layer01.width*2, gameplay_back_tree08_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_ground01, (Rectangle){(int)scrollFront, 559, ground01.width*2, ground01.height*2}, (Vector2){0,0}, 0, color01); - DrawTexturePro(atlas02, (Rectangle){ground01.x, ground01.y + ground01.height, ground01.width, -ground01.height}, (Rectangle){(int)scrollFront, -33, ground01.width*2, ground01.height*2}, (Vector2){0,0}, 0, color01); - - DrawTexturePro(atlas02, gameplay_back_tree01_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + GetScreenWidth(), 60, gameplay_back_tree01_layer01.width*2, gameplay_back_tree01_layer01.height*2},(Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree02_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + GetScreenWidth() + 140, 60, gameplay_back_tree02_layer01.width*2, gameplay_back_tree02_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree03_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + GetScreenWidth() + 140*2, 55, gameplay_back_tree03_layer01.width*2, gameplay_back_tree03_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree04_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + GetScreenWidth() + 140*3, 60, gameplay_back_tree04_layer01.width*2, gameplay_back_tree04_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree05_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + GetScreenWidth() + 140*4, 60, gameplay_back_tree05_layer01.width*2, gameplay_back_tree05_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree06_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + GetScreenWidth() + 140*5, 55, gameplay_back_tree06_layer01.width*2, gameplay_back_tree06_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree07_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset + GetScreenWidth() + 140*6, 60, gameplay_back_tree07_layer01.width*2, gameplay_back_tree07_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree08_layer01, (Rectangle){(int)scrollFront + parallaxFrontOffset+ GetScreenWidth() + 140*7, 60, gameplay_back_tree08_layer01.width*2, gameplay_back_tree08_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_ground01, (Rectangle){(int)scrollFront + GetScreenWidth(), 559, ground01.width*2, ground01.height*2}, (Vector2){0,0}, 0, color01); - DrawTexturePro(atlas02, (Rectangle){ground01.x, ground01.y + ground01.height, ground01.width, -ground01.height}, (Rectangle){(int)scrollFront+ GetScreenWidth(), -33, ground01.width*2, ground01.height*2}, (Vector2){0,0}, 0, color01); -} - -// Middle parallax drawing -static void DrawParallaxMiddle(void) -{ - Rectangle ground02 = gameplay_back_ground02; - - DrawTexturePro(atlas02, gameplay_back_tree01_layer02, (Rectangle){(int)scrollMiddle, 67, gameplay_back_tree01_layer02.width*2, gameplay_back_tree01_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree02_layer02, (Rectangle){(int)scrollMiddle + 140, 67, gameplay_back_tree02_layer02.width*2, gameplay_back_tree02_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree03_layer02, (Rectangle){(int)scrollMiddle + 140*2, 67, gameplay_back_tree03_layer02.width*2, gameplay_back_tree03_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree04_layer02, (Rectangle){(int)scrollMiddle + 140*3, 67, gameplay_back_tree04_layer02.width*2, gameplay_back_tree04_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree05_layer02, (Rectangle){(int)scrollMiddle + 140*4, 67, gameplay_back_tree05_layer02.width*2, gameplay_back_tree05_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree06_layer02, (Rectangle){(int)scrollMiddle + 140*5, 67, gameplay_back_tree06_layer02.width*2, gameplay_back_tree06_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree07_layer02, (Rectangle){(int)scrollMiddle + 140*6, 67, gameplay_back_tree07_layer02.width*2, gameplay_back_tree07_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree08_layer02, (Rectangle){(int)scrollMiddle + 140*7, 67, gameplay_back_tree08_layer02.width*2, gameplay_back_tree08_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_ground02, (Rectangle){(int)scrollMiddle, 509, ground02.width*2, ground02.height*2}, (Vector2){0,0}, 0, color01); - DrawTexturePro(atlas02, (Rectangle){ground02.x, ground02.y + ground02.height, ground02.width, -ground02.height}, (Rectangle){(int)scrollMiddle, 19, ground02.width*2, ground02.height*2}, (Vector2){0,0}, 0, color01); - - DrawTexturePro(atlas02, gameplay_back_tree02_layer02, (Rectangle){(int)scrollMiddle + GetScreenWidth() + 140, 67, gameplay_back_tree02_layer02.width*2, gameplay_back_tree02_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree03_layer02, (Rectangle){(int)scrollMiddle + GetScreenWidth() + 140*2, 67, gameplay_back_tree03_layer02.width*2, gameplay_back_tree03_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree04_layer02, (Rectangle){(int)scrollMiddle + GetScreenWidth() + 140*3, 67, gameplay_back_tree04_layer02.width*2, gameplay_back_tree04_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree05_layer02, (Rectangle){(int)scrollMiddle + GetScreenWidth() + 140*4, 67, gameplay_back_tree05_layer02.width*2, gameplay_back_tree05_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree06_layer02, (Rectangle){(int)scrollMiddle + GetScreenWidth() + 140*5, 67, gameplay_back_tree06_layer02.width*2, gameplay_back_tree06_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree07_layer02, (Rectangle){(int)scrollMiddle + GetScreenWidth() + 140*6, 67, gameplay_back_tree07_layer02.width*2, gameplay_back_tree07_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree08_layer02, (Rectangle){(int)scrollMiddle + GetScreenWidth() + 140*7, 67, gameplay_back_tree08_layer02.width*2, gameplay_back_tree08_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree01_layer02, (Rectangle){(int)scrollMiddle+ GetScreenWidth(), 67, gameplay_back_tree01_layer02.width*2, gameplay_back_tree01_layer02.height*2},(Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_ground02, (Rectangle){(int)scrollMiddle + GetScreenWidth(), 509, ground02.width*2, ground02.height*2},(Vector2){0,0}, 0, color01); - DrawTexturePro(atlas02, (Rectangle){ground02.x, ground02.y + ground02.height, ground02.width, -ground02.height}, (Rectangle){(int)scrollMiddle+ GetScreenWidth(), 19, ground02.width*2, ground02.height*2}, (Vector2){0,0}, 0, color01); -} - -// Back parallax drawing -static void DrawParallaxBack(void) -{ - Rectangle ground03 = gameplay_back_ground03; - - DrawTexturePro(atlas02, gameplay_back_tree01_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset, 67, gameplay_back_tree01_layer03.width*2, gameplay_back_tree01_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree02_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + 140, 67, gameplay_back_tree02_layer03.width*2, gameplay_back_tree02_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree03_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + 140*2, 67, gameplay_back_tree03_layer03.width*2, gameplay_back_tree03_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree04_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + 140*3, 67, gameplay_back_tree04_layer03.width*2, gameplay_back_tree04_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree05_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + 140*4, 67, gameplay_back_tree05_layer03.width*2, gameplay_back_tree05_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree06_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + 140*5, 67, gameplay_back_tree06_layer03.width*2, gameplay_back_tree06_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree07_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + 140*6, 67, gameplay_back_tree07_layer03.width*2, gameplay_back_tree07_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree08_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + 140*7, 67, gameplay_back_tree08_layer03.width*2, gameplay_back_tree08_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_ground03, (Rectangle){(int)scrollBack, 469, ground03.width*2, ground03.height*2}, (Vector2){0,0}, 0, color01); - DrawTexturePro(atlas02, (Rectangle){ground03.x, ground03.y + ground03.height, ground03.width, -ground03.height}, (Rectangle){(int)scrollBack, 67, ground03.width*2, ground03.height*2}, (Vector2){0,0}, 0, color01); - - DrawTexturePro(atlas02, gameplay_back_tree01_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset+ GetScreenWidth(), 67, gameplay_back_tree01_layer03.width*2, gameplay_back_tree01_layer03.height*2},(Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree02_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + GetScreenWidth() + 140, 67, gameplay_back_tree02_layer03.width*2, gameplay_back_tree02_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree03_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + GetScreenWidth() + 140*2, 67, gameplay_back_tree03_layer03.width*2, gameplay_back_tree03_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree04_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + GetScreenWidth() + 140*3, 67, gameplay_back_tree04_layer03.width*2, gameplay_back_tree04_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree05_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + GetScreenWidth() + 140*4, 67, gameplay_back_tree05_layer03.width*2, gameplay_back_tree05_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree06_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + GetScreenWidth() + 140*5, 67, gameplay_back_tree06_layer03.width*2, gameplay_back_tree06_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree07_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + GetScreenWidth() + 140*6, 67, gameplay_back_tree07_layer03.width*2, gameplay_back_tree07_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree08_layer03, (Rectangle){(int)scrollBack + parallaxBackOffset + GetScreenWidth() + 140*7, 67, gameplay_back_tree08_layer03.width*2, gameplay_back_tree08_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_ground03, (Rectangle){(int)scrollBack + GetScreenWidth(), 469, ground03.width*2, ground03.height*2}, (Vector2){0,0}, 0, color01); - DrawTexturePro(atlas02, (Rectangle){ground03.x, ground03.y + ground03.height, ground03.width, -ground03.height}, (Rectangle){(int)scrollBack+ GetScreenWidth(), 67, ground03.width*2, ground03.height*2}, (Vector2){0,0}, 0, color01); -} - -// Linear easing animation -static float LinearEaseIn(float t, float b, float c, float d) { return c*t/d + b; } - -// Transition from one color to another -static Color ColorTransition(Color initialColor, Color finalColor, int framesCounter) -{ - Color currentColor; - - currentColor.r = (unsigned char)LinearEaseIn((float)framesCounter, (float)initialColor.r, (float)(finalColor.r - initialColor.r), (float)(SEASONTRANSITION)); - currentColor.g = (unsigned char)LinearEaseIn((float)framesCounter, (float)initialColor.g, (float)(finalColor.g - initialColor.g), (float)(SEASONTRANSITION)); - currentColor.b = (unsigned char)LinearEaseIn((float)framesCounter, (float)initialColor.b, (float)(finalColor.b - initialColor.b), (float)(SEASONTRANSITION)); - currentColor.a = 255; - - return currentColor; -} - -static void Reset(void) -{ - framesCounter = 0; - finishScreen = 0; - grabCounter = 10; - bambooTimer = 0; - bambooSpawnTime = 0; - gravity = 5; - speed = 3; - score = 0; - hiscore = 0; - power = 360; - resinCount = 0; - rightAlpha = 0.5; - leftAlpha = 0.5; - speedMod = 1.2f; - transCount = 0; - windCounter = 0; - maxPower = 360; - playerActive = true; - scrollFront = 0; - scrollMiddle = 0; - scrollBack = 0; - scrollSpeed = 1.6f*TIME_FACTOR; - groundPos = 0; - resinCountjump = 0; - resinCountdrag = 0; - colorTimer = 0; - play = false; - onIce = false; - onResin = false; - jumpSpeed = 6; - transforming = false; - eagleAlert = false; - alertActive = false; - fireSpeed = 4; - seasonTimer = 0; - seasonChange = SEASONCHANGE; - monthChange = seasonChange/3; - glowing = true; - currentFrame = 0; - curFrame = 0; - curFrame1 = 1; - curFrame2 = 2; - curFrame3 = 3; - curFrameBee = 0; - fireOffset = 20; - beeMov = 0; - killCounter = 0; - currentLeaves = 0; - clockRotation = 0; - flyColor = GRAY; - globalFrameCounter = 0; - startCounter = 0; - numberAlpha = 1; - numberScale = 2.5f; - startNum = 3; - animCounter = 0; - finalFormEnd = 0; - randomMessage = 0; - years = 0; - UIfade = 1; - fogAlpha = 0; - seasons = 0; - fog = false; - clockSpeedRotation = 0; - eagleDelay = 0; - - parallaxBackOffset = GetRandomValue (10, 100); - parallaxFrontOffset = GetRandomValue (100, 200); - - progresionDelay = 0; - progresionFramesCounter = 0; - speedProgresion = 0; - - jumpCounter = 0; - resinCounter = 0; - tornadoCounter = 0; - dashCounter = 0; - superKoalaCounter = 0; - - fogSpeed = 2; - - leafGUIglow = true; - leafGUIglowFade = 0; - leafGUIpulseFade = 1; - leafGUIpulseScale = 1; - - //initMonth = ptm->tm_mon; - initYears = 1900 + ptm->tm_year; - - //initMonth = STARTINGMONTH; - - if (initSeason == 0) - { - initMonth = 11; - clockRotation = 225; - clockInitRotation = 225; - clockFinalRotation = clockInitRotation + 90; - color00 = (Color){129, 172, 86, 255}; // Summer Color - color01 = (Color){145, 165, 125, 255}; - color02 = (Color){161, 130, 73, 255}; - color03 = (Color){198, 103, 51, 255}; - } - else if (initSeason == 1) - { - initMonth = 2; - clockRotation = 315; - clockInitRotation = 315; - clockFinalRotation = clockInitRotation + 90; - color00 = (Color){242, 113, 62, 255}; // Fall Color - color01 = (Color){190, 135, 114, 255}; - color02 = (Color){144, 130, 101, 255}; - color03 = (Color){214, 133, 58, 255}; - } - else if (initSeason == 2) - { - initMonth = 5; - clockRotation = 45; - clockInitRotation = 45; - clockFinalRotation = clockInitRotation + 90; - color00 = (Color){130, 130, 181, 255}; // Winter Color - color01 = (Color){145, 145, 166, 255}; - color02 = (Color){104, 142, 144, 255}; - color03 = (Color){57, 140, 173, 255}; - } - else if (initSeason == 3) - { - initMonth = 8; - clockRotation = 135; - clockInitRotation = 135; - clockFinalRotation = clockInitRotation + 90; - color00 = (Color){196, 176, 49, 255}; // Spring Color - color01 = (Color){178, 163, 67, 255}; - color02 = (Color){133, 143, 90, 255}; - color03 = (Color){133, 156, 42, 255}; - } - - currentMonth = initMonth; - - leftButton.x = 0; - leftButton.y = 200; - leftButton.width = GetScreenWidth()/2; - leftButton.height = GetScreenHeight(); - - rightButton.x = GetScreenWidth()/2; - rightButton.y = 200; - rightButton.width = GetScreenWidth()/2; - rightButton.height = GetScreenHeight(); - - powerButton.x = 0; - powerButton.y = 0; - powerButton.width = GetScreenWidth()/2; - powerButton.height = 200; - - finalColor.r = GetRandomValue(0, 255); - finalColor.g = GetRandomValue(0, 255); - finalColor.b = GetRandomValue(0, 255); - finalColor.a = 255; - - backBar.x = 20; - backBar.y = 22; - backBar.width = maxPower + 4; - backBar.height = 24; - powerBar.x = 22; - powerBar.y = 23; - powerBar.width = power; - powerBar.height = 22; - - fireAnimation.x = gameplay_props_fire_spritesheet.x; - fireAnimation.y = gameplay_props_fire_spritesheet.y; - fireAnimation.width = gameplay_props_fire_spritesheet.width/4; - fireAnimation.height = gameplay_props_fire_spritesheet.height; - - windAnimation.x = gameplay_props_whirlwind_spritesheet.x; - windAnimation.y = gameplay_props_whirlwind_spritesheet.y; - windAnimation.width = gameplay_props_whirlwind_spritesheet.width/4; - windAnimation.height = gameplay_props_whirlwind_spritesheet.height; - - beeAnimation.x = gameplay_enemy_bee.x; - beeAnimation.y = gameplay_enemy_bee.y; - beeAnimation.width = gameplay_enemy_bee.width/5; - beeAnimation.height = gameplay_enemy_bee.height; - - eagleAnimation.x = gameplay_enemy_eagle.x; - eagleAnimation.y = gameplay_enemy_eagle.y; - eagleAnimation.width = gameplay_enemy_eagle.width/2; - eagleAnimation.height = gameplay_enemy_eagle.height; - - snakeAnimation.x = gameplay_enemy_snake.x; - snakeAnimation.y = gameplay_enemy_snake.y; - snakeAnimation.width = gameplay_enemy_snake.width/3; - snakeAnimation.height = gameplay_enemy_snake.height; - - dingoAnimation.x = gameplay_enemy_dingo.x; - dingoAnimation.y = gameplay_enemy_dingo.y; - dingoAnimation.width = gameplay_enemy_dingo.width/3; - dingoAnimation.height = gameplay_enemy_dingo.height; - - owlAnimation.x = gameplay_enemy_owl.x; - owlAnimation.y = gameplay_enemy_owl.y; - owlAnimation.width = gameplay_enemy_owl.width/3; - owlAnimation.height = gameplay_enemy_owl.height; - - koalaAnimationIddle = gameplay_koala_idle; - koalaAnimationIddle.width = gameplay_koala_idle.width/3; - koalaAnimationJump = gameplay_koala_jump; - koalaAnimationFly = gameplay_koala_fly; - koalaAnimationFly.width = gameplay_koala_fly.width/2; - koalaAnimationTransform = gameplay_koala_transform; - koalaAnimationTransform.width = gameplay_koala_transform.width/2; - - snowParticle.position = (Vector2){ 0, 0 }; - snowParticle.active = false; - snowStormParticle.position = (Vector2){ 0, 0 }; - snowStormParticle.active = false; - backSnowParticle.position = (Vector2){ 0, 0 }; - backSnowParticle.active = false; - planetreeParticle.position = (Vector2){ 0, 0 }; - planetreeParticle.active = false; - backPlanetreeParticle.position = (Vector2){ 0, 0 }; - backPlanetreeParticle.active = false; - dandelionParticle.active = false; - dandelionBackParticle.position = (Vector2){ 0, 0}; - flowerParticle.position = (Vector2){ 0, 0 }; - flowerParticle.active = false; - backFlowerParticle.position = (Vector2){ 0, 0 }; - backFlowerParticle.active = false; - rainParticle.position = (Vector2){ 0, 0 }; - rainParticle.active = false; - rainStormParticle.position = (Vector2){ 0, 0 }; - rainStormParticle.active = false; - backRainParticle.position = (Vector2){ 0, 0 }; - backRainParticle.active = false; - rayParticles.position = (Vector2){ 0, 0 }; - rayParticles.active = false; - backRayParticles.position = (Vector2){ 0, 0 }; - backRayParticles.active = false; - speedFX.active = false; - - clockPosition = (Vector2){GetScreenWidth(), 0}; - - for (int j = 0; j < MAX_PARTICLES; j++) - { - snowParticle.particles[j].active = false; - snowParticle.particles[j].position = (Vector2){ 0, 0 }; - snowParticle.particles[j].size = (float)GetRandomValue(3, 9)/10; - snowParticle.particles[j].rotation = GetRandomValue(0, 360); - snowParticle.particles[j].color = WHITE; - snowParticle.particles[j].alpha = 1.0f; - - backSnowParticle.particles[j].active = false; - backSnowParticle.particles[j].position = (Vector2){ 0, 0 }; - backSnowParticle.particles[j].size = (float)GetRandomValue(2, 8)/10; - backSnowParticle.particles[j].rotation = GetRandomValue(0, 360); - backSnowParticle.particles[j].color = WHITE; - backSnowParticle.particles[j].alpha = 0.7f; - - planetreeParticle.particles[j].active = false; - planetreeParticle.particles[j].position = (Vector2){ 0, 0 }; - planetreeParticle.particles[j].size = (float)GetRandomValue(3, 9)/10; - planetreeParticle.particles[j].rotation = GetRandomValue(0, 360); - planetreeParticle.particles[j].color = WHITE; - planetreeParticle.particles[j].alpha = 1.0f; - - backPlanetreeParticle.particles[j].active = false; - backPlanetreeParticle.particles[j].position = (Vector2){ 0, 0 }; - backPlanetreeParticle.particles[j].size = (float)GetRandomValue(2, 8)/10; - backPlanetreeParticle.particles[j].rotation = GetRandomValue(0, 360); - backPlanetreeParticle.particles[j].color = WHITE; - backPlanetreeParticle.particles[j].alpha = 0.7f; - - dandelionParticle.particles[j].active = false; - dandelionParticle.particles[j].position = (Vector2){ 0, 0 }; - dandelionParticle.particles[j].size = (float)GetRandomValue(3, 9)/10; - dandelionParticle.particles[j].rotation = 0; - dandelionParticle.particles[j].color = WHITE; - dandelionParticle.particles[j].alpha = 1; - dandelionParticle.particles[j].rotPhy = GetRandomValue(0 , 180); - - dandelionBackParticle.particles[j].active = false; - dandelionBackParticle.particles[j].position = (Vector2){ 0, 0 }; - dandelionBackParticle.particles[j].size = (float)GetRandomValue(2, 8)/10; - dandelionBackParticle.particles[j].rotation = 0; - dandelionBackParticle.particles[j].color = WHITE; - dandelionBackParticle.particles[j].alpha = 0.7f; - dandelionBackParticle.particles[j].rotPhy = GetRandomValue(0 , 180); - - flowerParticle.particles[j].active = false; - flowerParticle.particles[j].position = (Vector2){ 0, 0 }; - flowerParticle.particles[j].size = (float)GetRandomValue(3, 9)/10; - flowerParticle.particles[j].rotation = GetRandomValue(0, 360); - flowerParticle.particles[j].color = WHITE; - flowerParticle.particles[j].alpha = 1.0f; - - backFlowerParticle.particles[j].active = false; - backFlowerParticle.particles[j].position = (Vector2){ 0, 0 }; - backFlowerParticle.particles[j].size = (float)GetRandomValue(2, 8)/10; - backFlowerParticle.particles[j].rotation = GetRandomValue(0, 360); - backFlowerParticle.particles[j].color = WHITE; - backFlowerParticle.particles[j].alpha = 0.7f; - - rainParticle.particles[j].active = false; - rainParticle.particles[j].position = (Vector2){ 0, 0 }; - rainParticle.particles[j].size = (float)GetRandomValue(3, 9)/10; - rainParticle.particles[j].rotation = -20; - rainParticle.particles[j].color = WHITE; - rainParticle.particles[j].alpha = 1.0f; - - backRainParticle.particles[j].active = false; - backRainParticle.particles[j].position = (Vector2){ 0, 0 }; - backRainParticle.particles[j].size = (float)GetRandomValue(2, 8)/10; - backRainParticle.particles[j].rotation = -20; - backRainParticle.particles[j].color = WHITE; - backRainParticle.particles[j].alpha = 0.7f; - - } - - for (int j = 0; j < MAX_PARTICLES_SPEED; j++) - { - speedFX.particle[j].position = (Vector2){ 0, 0 }; - speedFX.particle[j].color = WHITE; - speedFX.particle[j].alpha = 1.0f; - speedFX.particle[j].size = (Vector2){GetScreenWidth(), GetRandomValue(10, 50)/10}; - speedFX.particle[j].rotation = 0.0f; - speedFX.particle[j].active = false; - } - - for (int j = 0; j < MAX_PARTICLES_STORM; j++) - { - rainStormParticle.particles[j].active = false; - rainStormParticle.particles[j].position = (Vector2){ 0, 0 }; - rainStormParticle.particles[j].size = (float)GetRandomValue(3, 9)/10; - rainStormParticle.particles[j].rotation = -40; - rainStormParticle.particles[j].color = WHITE; - rainStormParticle.particles[j].alpha = 1.0f; - } - - for (int j = 0; j < MAX_PARTICLES_STORM; j++) - { - snowStormParticle.particles[j].active = false; - snowStormParticle.particles[j].position = (Vector2){ 0, 0 }; - snowStormParticle.particles[j].size = (float)GetRandomValue(2, 8)/10; - snowStormParticle.particles[j].rotation = 40; - snowStormParticle.particles[j].color = WHITE; - snowStormParticle.particles[j].alpha = 1.0f; - } - - for (int i = 0; i < MAX_PARTICLES_RAY; i++) - { - rayParticles.particles[i].position = (Vector2){ 0, 0 }; - rayParticles.particles[i].color.r = 255; - rayParticles.particles[i].color.g = 255; - rayParticles.particles[i].color.b = 182; - rayParticles.particles[i].color.a = 255; - rayParticles.particles[i].alpha = 0.0f; - rayParticles.particles[i].size = (float)(GetRandomValue(30, 70)/10); - rayParticles.particles[i].rotation = 0.0f; - rayParticles.particles[i].active = false; - rayParticles.particles[i].fading = false; - rayParticles.particles[i].delayCounter = 0; - - backRayParticles.particles[i].position = (Vector2){ 0, 0 }; - backRayParticles.particles[i].color.r = 255; - backRayParticles.particles[i].color.g = 255; - backRayParticles.particles[i].color.b = 182; - backRayParticles.particles[i].color.a = 255; - backRayParticles.particles[i].alpha = 0.0f; - backRayParticles.particles[i].size = (float)(GetRandomValue(10, 20)/10); - backRayParticles.particles[i].rotation = 0.0f; - backRayParticles.particles[i].active = false; - backRayParticles.particles[i].fading = false; - backRayParticles.particles[i].delayCounter = 0; - } - - for (int i = 0; i < MAX_KILLS; i++) killHistory[i] = 0; - - for (int i = 0; i < MAX_BAMBOO; i++) - { - bamboo[i].x = 150 + 200*i; - bamboo[i].y = 0; - bamboo[i].width = 50; - bamboo[i].height = GetScreenHeight(); - if (i > 5) bambooActive[i] = false; - else bambooActive[i] = true; - } - - for (int i = 0; i < MAX_FIRE; i++) - { - fire[i].x = -200; - fire[i].y = GetScreenHeight() - 30; - fire[i].width = 30; - fire[i].height = 720; - fireActive[i] = false; - onFire[i] = false; - fireCounter[i] = 0; - } - - for (int i = 0; i < MAX_ICE; i++) - { - ice[i].x = -100; - ice[i].y = 0; - ice[i].width = 10; - ice[i].height = GetScreenHeight(); - iceActive[i] = false; - } - - for (int i = 0; i < MAX_RESIN; i++) - { - resin[i].x = -100; - resin[i].y = 0; - resin[i].width = 32; - resin[i].height = 50; - resinActive[i] = false; - } - - for (int i = 0; i < MAX_WIND; i++) - { - wind[i].x = -100; - wind[i].y = 0; - wind[i].width = 70; - wind[i].height = 100; - windActive[i] = false; - } - - for (int i = 0; i < MAX_ENEMIES; i++) - { - snake[i].x = 0; - snake[i].y = 0; - snake[i].width = 50; - snake[i].height = 60; - snakeActive[i] = false; - isHitSnake[i] = false; - - dingo[i].x = -100; - dingo[i].y = 0; - dingo[i].width = 64; - dingo[i].height = 90; - dingoActive[i] = false; - isHitDingo[i] = false; - - owl[i].x = -100; - owl[i].y = 0; - owl[i].width = 40; - owl[i].height = 60; - owlActive[i] = false; - branchActive[i] = false; - isHitOwl[i] = false; - - branchPos[i].x = owl[i].x; - branchPos[i].y = owl[i].y; - - enemyHit[i].position = (Vector2){ GetRandomValue(-20, 20), GetRandomValue(-20, 20) }; - enemyHit[i].speed = (Vector2){ (float)GetRandomValue(-500, 500)/100, (float)GetRandomValue(-500, 500)/100 }; - enemyHit[i].size = (float)GetRandomValue(1, 45)/30; - enemyHit[i].rotation = GetRandomValue(0, 360); - enemyHit[i].color = RED; - enemyHit[i].alpha = 1.0f; - enemyHit[i].active = false; - - popupScore[i].position = (Vector2){ GetRandomValue(-20, 20), GetRandomValue(-20, 20) }; - popupScore[i].scale = (float)GetRandomValue(1, 45)/30; - popupScore[i].alpha = 1.0f; - popupScore[i].active = false; - } - - for (int i = 0; i < MAX_LEAVES; i++) - { - leaf[i].x = 0; - leaf[i].y = 0; - leaf[i].width = 30; - leaf[i].height = 30; - leafActive[i] = false; - leafType[i] = -1; - - leafParticles[i].position = (Vector2){ 0, 0 }; - leafParticles[i].active = false; - - popupLeaves[i].position = (Vector2){ GetRandomValue(-20, 20), GetRandomValue(-20, 20) }; - popupLeaves[i].scale = (float)GetRandomValue(1, 45)/30; - popupLeaves[i].alpha = 1.0f; - popupLeaves[i].score = 0; - popupLeaves[i].active = false; - - for (int j = 0; j < 32; j++) - { - - leafParticles[i].particles[j].active = false; - leafParticles[i].particles[j].position = (Vector2){ GetRandomValue(-20, 20), GetRandomValue(-20, 20) }; - leafParticles[i].particles[j].speed = (Vector2){ (float)GetRandomValue(-500, 500)/100, (float)GetRandomValue(-500, 500)/100 }; - leafParticles[i].particles[j].size = (float)GetRandomValue(3, 10)/5; - leafParticles[i].particles[j].rotation = GetRandomValue(0, 360); - leafParticles[i].particles[j].color = WHITE; - leafParticles[i].particles[j].alpha = 1.0f; - } - } - - player.x = GetScreenWidth()*0.26f; - player.y = 100; - player.width = 35; - player.height = 60; - - bee.x = -200; - bee.y = 0; - bee.width = 50; - bee.height = 32; - beeActive = false; - - popupBee.position = (Vector2){ GetRandomValue(-20, 20), GetRandomValue(-20, 20) }; - popupBee.scale = (float)GetRandomValue(1, 45)/30; - popupBee.alpha = 1.0f; - popupBee.active = false; - - eagle.x = -128; - eagle.y = 0; - eagle.width = 200; - eagle.height = 80; - eagleActive = false; - - popupEagle.position = (Vector2){ GetRandomValue(-20, 20), GetRandomValue(-20, 20) }; - popupEagle.scale = (float)GetRandomValue(1, 45)/30; - popupEagle.alpha = 1.0f; - popupEagle.active = false; - - counterColor.r = 255; - counterColor.g = 224; - counterColor.b = 185; - counterColor.a = 255; - - zero.x = 0; - zero.y = 0; - - firePos.x = -200; - firePos.y = 0; - - textSize = MeasureTextEx(font, "3", font.baseSize*5, 2); -} diff --git a/games/koala_seasons/screens/screen_logo.c b/games/koala_seasons/screens/screen_logo.c deleted file mode 100644 index 55785c3a5..000000000 --- a/games/koala_seasons/screens/screen_logo.c +++ /dev/null @@ -1,227 +0,0 @@ -/********************************************************************************************** -* -* raylib - Standard Game template -* -* Logo Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Logo screen global variables -static int framesCounter; -static int finishScreen; - -const char msgLogoA[64] = "A simple and easy-to-use library"; -const char msgLogoB[64] = "to enjoy videogames programming"; - -int logoPositionX; -int logoPositionY; - -int raylibLettersCount = 0; - -int topSideRecWidth = 16; -int leftSideRecHeight = 16; - -int bottomSideRecWidth = 16; -int rightSideRecHeight = 16; - -char raylib[8] = " \0"; // raylib text array, max 8 letters - -int logoScreenState = 0; // Tracking animation states (State Machine) -bool msgLogoADone = false; -bool msgLogoBDone = false; - -int lettersCounter = 0; -char msgBuffer[128] = { ' ' }; - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Logo Screen Initialization logic -void InitLogoScreen(void) -{ - // Initialize LOGO screen variables here! - framesCounter = 0; - finishScreen = 0; - - logoPositionX = GetScreenWidth()/2 - 128; - logoPositionY = GetScreenHeight()/2 - 128; -} - -// Logo Screen Update logic -void UpdateLogoScreen(void) -{ - // Update LOGO screen - framesCounter++; // Count frames - - // Update LOGO screen variables - if (logoScreenState == 0) // State 0: Small box blinking - { - framesCounter++; - - if (framesCounter == 120) - { - logoScreenState = 1; - framesCounter = 0; // Reset counter... will be used later... - } - } - else if (logoScreenState == 1) // State 1: Top and left bars growing - { - topSideRecWidth += 4; - leftSideRecHeight += 4; - - if (topSideRecWidth == 256) logoScreenState = 2; - } - else if (logoScreenState == 2) // State 2: Bottom and right bars growing - { - bottomSideRecWidth += 4; - rightSideRecHeight += 4; - - if (bottomSideRecWidth == 256) - { - lettersCounter = 0; - for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = ' '; - - logoScreenState = 3; - } - } - else if (logoScreenState == 3) // State 3: Letters appearing (one by one) - { - framesCounter++; - - // Every 12 frames, one more letter! - if ((framesCounter%12) == 0) raylibLettersCount++; - - switch (raylibLettersCount) - { - case 1: raylib[0] = 'r'; break; - case 2: raylib[1] = 'a'; break; - case 3: raylib[2] = 'y'; break; - case 4: raylib[3] = 'l'; break; - case 5: raylib[4] = 'i'; break; - case 6: raylib[5] = 'b'; break; - default: break; - } - - if (raylibLettersCount >= 10) - { - // Write raylib description messages - if ((framesCounter%2) == 0) lettersCounter++; - - if (!msgLogoADone) - { - if (lettersCounter <= (int)strlen(msgLogoA)) strncpy(msgBuffer, msgLogoA, lettersCounter); - else - { - for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = ' '; - - lettersCounter = 0; - msgLogoADone = true; - } - } - else if (!msgLogoBDone) - { - if (lettersCounter <= (int)strlen(msgLogoB)) strncpy(msgBuffer, msgLogoB, lettersCounter); - else - { - msgLogoBDone = true; - framesCounter = 0; - //PlaySound(levelWin); - } - } - } - } - - // Wait for 2 seconds (60 frames) before jumping to TITLE screen - if (msgLogoBDone) - { - framesCounter++; - - if (framesCounter > 150) finishScreen = true; - } -} - -// Logo Screen Draw logic -void DrawLogoScreen(void) -{ - // Draw LOGO screen - if (logoScreenState == 0) - { - if ((framesCounter/15)%2) DrawRectangle(logoPositionX, logoPositionY - 60, 16, 16, BLACK); - } - else if (logoScreenState == 1) - { - DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY - 60, 16, leftSideRecHeight, BLACK); - } - else if (logoScreenState == 2) - { - DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY - 60, 16, leftSideRecHeight, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY - 60, 16, rightSideRecHeight, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240 - 60, bottomSideRecWidth, 16, BLACK); - } - else if (logoScreenState == 3) - { - DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 16 - 60, 16, leftSideRecHeight - 32, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16 - 60, 16, rightSideRecHeight - 32, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240 - 60, bottomSideRecWidth, 16, BLACK); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112 - 60, 224, 224, RAYWHITE); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48 - 60, 50, BLACK); - - if (!msgLogoADone) DrawText(msgBuffer, GetScreenWidth()/2 - MeasureText(msgLogoA, 30)/2, logoPositionY + 230, 30, GRAY); - else - { - DrawText(msgLogoA, GetScreenWidth()/2 - MeasureText(msgLogoA, 30)/2, logoPositionY + 230, 30, GRAY); - - if (!msgLogoBDone) DrawText(msgBuffer, GetScreenWidth()/2 - MeasureText(msgLogoB, 30)/2, logoPositionY + 280, 30, GRAY); - else - { - DrawText(msgLogoB, GetScreenWidth()/2 - MeasureText(msgLogoA, 30)/2, logoPositionY + 280, 30, GRAY); - } - } - } -} - -// Logo Screen Unload logic -void UnloadLogoScreen(void) -{ - // TODO: Unload LOGO screen variables here! -} - -// Logo Screen should finish? -int FinishLogoScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/koala_seasons/screens/screen_title.c b/games/koala_seasons/screens/screen_title.c deleted file mode 100644 index 21a4df51d..000000000 --- a/games/koala_seasons/screens/screen_title.c +++ /dev/null @@ -1,1066 +0,0 @@ -/********************************************************************************************** -* -* raylib - Koala Seasons game -* -* Title Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include - -#include "atlas01.h" -#include "atlas02.h" - -#define MAX_DURATION 120 -#define MAX_particle 128 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -typedef struct { - Vector2 position; - Vector2 speed; - float rotation; - float size; - Color color; - float alpha; - float rotPhy; - bool active; -} Particle; - -typedef struct { - Vector2 position; - Color color; - float alpha; - float size; - float rotation; - bool active; // NOTE: Use it to activate/deactive particle - bool fading; - float delayCounter; -} RayParticleTitle; - -typedef struct { - Vector2 position; - bool active; - int spawnTime; - int maxTime; - Particle particle[1024]; -} Stormparticleystem; - -typedef struct { - Vector2 position; - bool active; - int spawnTime; - int maxTime; - Particle particle[MAX_particle]; -} particleystemTitle; - -typedef struct { - Vector2 position; - bool active; - int spawnTime; - int maxTime; - RayParticleTitle particle[20]; -} RayparticleystemTitle; - -// Title screen global variables -static int framesCounter; -static int finishScreen; -static int globalFrameCounter; -static int currentFrame; -static int thisFrame; -static int parallaxBackOffset; -static int parallaxFrontOffset; - -static float currentValue1; -static float currentValue2; -static float initValue1; -static float initValue2; -static float finishValue1; -static float finishValue2; -static float duration; - -static Vector2 fontSize; - -static bool soundActive; -static bool musicActive; - -static Rectangle koalaMenu; - -static Rectangle bamboo[5]; -static Rectangle player = {0, 0, 0, 0}; -static Rectangle soundButton; -static Rectangle speakerButton; - -static Color color00, color01, color02, color03; - -static particleystemTitle snowParticle; -static particleystemTitle backSnowParticle; -static particleystemTitle dandelionParticle; -static particleystemTitle dandelionBackParticle; -static particleystemTitle planetreeParticle; -static particleystemTitle backPlanetreeParticle; -static particleystemTitle flowerParticle; -static particleystemTitle backFlowerParticle; -static particleystemTitle rainParticle; -static particleystemTitle backRainParticle; -static RayparticleystemTitle rayparticle; -static RayparticleystemTitle backRayparticle; -static Stormparticleystem rainStormParticle; -static Stormparticleystem snowStormParticle; - -const char pressToPlay[16] = "Press to play"; - -//---------------------------------------------------------------------------------- -// Title Screen Functions Definition -//---------------------------------------------------------------------------------- -static void DrawParallaxFront(void); -static void DrawParallaxMiddle(void); -static void DrawParallaxBack(void); - -static float BounceEaseOut(float t,float b , float c, float d); - -// Title Screen Initialization logic -void InitTitleScreen(void) -{ - framesCounter = 0; - finishScreen = 0; - initValue1 = -100; - finishValue1 = 100; - initValue2 = 700; - finishValue2 = finishValue1 + 220; - duration = MAX_DURATION; - initSeason = GetRandomValue(0, 3); - soundActive = true; - musicActive = true; - - parallaxBackOffset = GetRandomValue(10, 100); - parallaxFrontOffset = GetRandomValue(100, 200); - - rainChance = GetRandomValue(0, 100); - - snowParticle.position = (Vector2){ 0, 0 }; - snowParticle.active = false; - backSnowParticle.position = (Vector2){ 0, 0 }; - backSnowParticle.active = false; - planetreeParticle.position = (Vector2){ 0, 0 }; - planetreeParticle.active = false; - backPlanetreeParticle.position = (Vector2){ 0, 0 }; - backPlanetreeParticle.active = false; - dandelionParticle.active = false; - dandelionBackParticle.position = (Vector2){ 0, 0}; - flowerParticle.position = (Vector2){ 0, 0 }; - flowerParticle.active = false; - backFlowerParticle.position = (Vector2){ 0, 0 }; - backFlowerParticle.active = false; - rayparticle.position = (Vector2){ 0, 0 }; - rayparticle.active = false; - backRayparticle.position = (Vector2){ 0, 0 }; - backRayparticle.active = false; - rainStormParticle.position = (Vector2){ 0, 0 }; - rainStormParticle.active = false; - snowStormParticle.position = (Vector2){ 0, 0 }; - snowStormParticle.active = false; - - soundButton = (Rectangle){ GetScreenWidth()*0.85, GetScreenHeight()*0.7, title_music_on.width, title_music_on.height }; - speakerButton = (Rectangle){ GetScreenWidth()*0.85, GetScreenHeight()*0.85, title_speaker_on.width, title_speaker_on.height }; - - for (int j = 0; j < MAX_particle; j++) - { - snowParticle.particle[j].active = false; - snowParticle.particle[j].position = (Vector2){ 0, 0 }; - snowParticle.particle[j].size = (float)GetRandomValue(3, 9)/10; - snowParticle.particle[j].rotation = GetRandomValue(0, 360); - snowParticle.particle[j].color = WHITE; - snowParticle.particle[j].alpha = 1.0f; - - backSnowParticle.particle[j].active = false; - backSnowParticle.particle[j].position = (Vector2){ 0, 0 }; - backSnowParticle.particle[j].size = (float)GetRandomValue(2, 8)/10; - backSnowParticle.particle[j].rotation = GetRandomValue(0, 360); - backSnowParticle.particle[j].color = WHITE; - backSnowParticle.particle[j].alpha = 0.7f; - - planetreeParticle.particle[j].active = false; - planetreeParticle.particle[j].position = (Vector2){ 0, 0 }; - planetreeParticle.particle[j].size = (float)GetRandomValue(3, 9)/10; - planetreeParticle.particle[j].rotation = GetRandomValue(0, 360); - planetreeParticle.particle[j].color = WHITE; - planetreeParticle.particle[j].alpha = 1.0f; - - backPlanetreeParticle.particle[j].active = false; - backPlanetreeParticle.particle[j].position = (Vector2){ 0, 0 }; - backPlanetreeParticle.particle[j].size = (float)GetRandomValue(2, 8)/10; - backPlanetreeParticle.particle[j].rotation = GetRandomValue(0, 360); - backPlanetreeParticle.particle[j].color = WHITE; - backPlanetreeParticle.particle[j].alpha = 0.7f; - - dandelionParticle.particle[j].active = false; - dandelionParticle.particle[j].position = (Vector2){ 0, 0 }; - dandelionParticle.particle[j].size = (float)GetRandomValue(3, 9)/10; - dandelionParticle.particle[j].rotation = 0; - dandelionParticle.particle[j].color = WHITE; - dandelionParticle.particle[j].alpha = 1; - dandelionParticle.particle[j].rotPhy = GetRandomValue(0 , 180); - - dandelionBackParticle.particle[j].active = false; - dandelionBackParticle.particle[j].position = (Vector2){ 0, 0 }; - dandelionBackParticle.particle[j].size = (float)GetRandomValue(2, 8)/10; - dandelionBackParticle.particle[j].rotation = 0; - dandelionBackParticle.particle[j].color = WHITE; - dandelionBackParticle.particle[j].alpha = 0.7f; - dandelionBackParticle.particle[j].rotPhy = GetRandomValue(0 , 180); - - flowerParticle.particle[j].active = false; - flowerParticle.particle[j].position = (Vector2){ 0, 0 }; - flowerParticle.particle[j].size = (float)GetRandomValue(3, 9)/10; - flowerParticle.particle[j].rotation = GetRandomValue(0, 360); - flowerParticle.particle[j].color = WHITE; - flowerParticle.particle[j].alpha = 1.0f; - - backFlowerParticle.particle[j].active = false; - backFlowerParticle.particle[j].position = (Vector2){ 0, 0 }; - backFlowerParticle.particle[j].size = (float)GetRandomValue(2, 8)/10; - backFlowerParticle.particle[j].rotation = GetRandomValue(0, 360); - backFlowerParticle.particle[j].color = WHITE; - backFlowerParticle.particle[j].alpha = 0.7f; - - rainParticle.particle[j].active = false; - rainParticle.particle[j].position = (Vector2){ 0, 0 }; - rainParticle.particle[j].size = (float)GetRandomValue(3, 9)/10; - rainParticle.particle[j].rotation = -20; - rainParticle.particle[j].color = WHITE; - rainParticle.particle[j].alpha = 1.0f; - - backRainParticle.particle[j].active = false; - backRainParticle.particle[j].position = (Vector2){ 0, 0 }; - backRainParticle.particle[j].size = (float)GetRandomValue(2, 8)/10; - backRainParticle.particle[j].rotation = -20; - backRainParticle.particle[j].color = WHITE; - backRainParticle.particle[j].alpha = 0.7f; - } - - for (int j = 0; j < 1024; j++) - { - rainStormParticle.particle[j].active = false; - rainStormParticle.particle[j].position = (Vector2){ 0, 0 }; - rainStormParticle.particle[j].size = (float)GetRandomValue(3, 9)/10; - rainStormParticle.particle[j].rotation = -40; - rainStormParticle.particle[j].color = WHITE; - rainStormParticle.particle[j].alpha = 1.0f; - } - - for (int j = 0; j < 256; j++) - { - snowStormParticle.particle[j].active = false; - snowStormParticle.particle[j].position = (Vector2){ 0, 0 }; - snowStormParticle.particle[j].size = (float)GetRandomValue(4, 8)/10; - snowStormParticle.particle[j].rotation = 40; - snowStormParticle.particle[j].color = WHITE; - snowStormParticle.particle[j].alpha = 1.0f; - } - - for (int i = 0; i < 20; i++) - { - rayparticle.particle[i].position = (Vector2){ 0, 0 }; - rayparticle.particle[i].color.r = 255; - rayparticle.particle[i].color.g = 255; - rayparticle.particle[i].color.b = 182; - rayparticle.particle[i].color.a = 255; - rayparticle.particle[i].alpha = 0.0f; - rayparticle.particle[i].size = (float)GetRandomValue(15, 20)/10; - rayparticle.particle[i].rotation = 0.0f; - rayparticle.particle[i].active = false; - rayparticle.particle[i].fading = false; - rayparticle.particle[i].delayCounter = 0; - - backRayparticle.particle[i].position = (Vector2){ 0, 0 }; - backRayparticle.particle[i].color.r = 255; - backRayparticle.particle[i].color.g = 255; - backRayparticle.particle[i].color.b = 182; - backRayparticle.particle[i].color.a = 255; - backRayparticle.particle[i].alpha = 0.0f; - backRayparticle.particle[i].size = (float)GetRandomValue(5, 10)/10; - backRayparticle.particle[i].rotation = 0.0f; - backRayparticle.particle[i].active = false; - backRayparticle.particle[i].fading = false; - backRayparticle.particle[i].delayCounter = 0; - } - - for (int i = 0; i < 5; i++) - { - bamboo[i].x = 150 + 200*i; - bamboo[i].y = 0; - bamboo[i].width = 30; - bamboo[i].height = GetScreenHeight(); - } - - player.x = 350; - player.y = 100; - player.width = 35; - player.height = 60; - - koalaMenu.x = gameplay_koala_menu.x; - koalaMenu.y = gameplay_koala_menu.y; - koalaMenu.width = gameplay_koala_menu.width/2; - koalaMenu.height = gameplay_koala_menu.height; - - fontSize = MeasureTextEx(font, "PRESS TO PLAY", font.baseSize, 2); -} - -// Title Screen Update logic -void UpdateTitleScreen(void) -{ - framesCounter += 1*TIME_FACTOR; - globalFrameCounter += 1*TIME_FACTOR; - - if (framesCounter < duration) - { - currentValue1 = BounceEaseOut((float)framesCounter, initValue1, (finishValue1 - initValue1), duration); - currentValue2 = BounceEaseOut((float)framesCounter, initValue2, (finishValue2 - initValue2), duration); - } - - thisFrame += 1*TIME_FACTOR; - - if (thisFrame >= 40) - { - currentFrame++; - thisFrame = 0; - } - - if (currentFrame > 1) currentFrame = 0; - - koalaMenu.x = gameplay_koala_menu.x + koalaMenu.width*currentFrame; - - if (initSeason == 0) - { - dandelionParticle.active = true; - dandelionBackParticle.active = true; - rayparticle.active = true; - backRayparticle.active = true; - - rainParticle.active = false; - rainStormParticle.active = false; - backRainParticle.active = false; - - color00 = (Color){129, 172, 86, 255}; // Summer Color - color01 = (Color){145, 165, 125, 255}; - color02 = (Color){161, 130, 73, 255}; - color03 = (Color){198, 103, 51, 255}; - } - else if (initSeason == 1) - { - if (rainChance > 40) - { - planetreeParticle.active = true; - backPlanetreeParticle.active = true; - rainParticle.active = false; - backRainParticle.active = false; - } - else if (rainChance <= 40 && rainChance > 15) - { - rainStormParticle.active = true; - backRainParticle.active = false; - } - else if (rainChance <= 15) - { - rainStormParticle.active = true; - backRainParticle.active = false; - } - - color00 = (Color){242, 113, 62, 255}; // Fall Color - color01 = (Color){190, 135, 114, 255}; - color02 = (Color){144, 130, 101, 255}; - color03 = (Color){214, 133, 58, 255}; - - } - else if (initSeason == 2) - { - - if (rainChance > 40) - { - snowParticle.active = true; - backSnowParticle.active = true; - } - else - { - snowStormParticle.active = true; - backSnowParticle.active = true; - } - - rainParticle.active = false; - rainStormParticle.active = false; - backRainParticle.active = false; - - color00 = (Color){130, 130, 181, 255}; // Winter Color - color01 = (Color){145, 145, 166, 255}; - color02 = (Color){104, 142, 144, 255}; - color03 = (Color){57, 140, 173, 255}; - } - else if (initSeason == 3) - { - flowerParticle.active = true; - backFlowerParticle.active = true; - - rainParticle.active = false; - rainStormParticle.active = false; - backRainParticle.active = false; - - color00 = (Color){196, 176, 49, 255}; // Spring Color - color01 = (Color){178, 163, 67, 255}; - color02 = (Color){133, 143, 90, 255}; - color03 = (Color){133, 156, 42, 255}; - } - - // Snow Particle - if (snowParticle.active) - { - snowParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_particle; i++) - { - if (!snowParticle.particle[i].active && snowParticle.spawnTime >= snowParticle.maxTime) - { - snowParticle.particle[i].active = true; - snowParticle.particle[i].position = (Vector2){GetRandomValue(0, GetScreenWidth() + 200), -10}; - snowParticle.spawnTime = 0; - snowParticle.maxTime = GetRandomValue (5, 20); - } - } - } - - if (backSnowParticle.active) - { - backSnowParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_particle; i++) - { - if (!backSnowParticle.particle[i].active && backSnowParticle.spawnTime >= backSnowParticle.maxTime) - { - backSnowParticle.particle[i].active = true; - backSnowParticle.particle[i].position = (Vector2){GetRandomValue(0, GetScreenWidth() + 200), -10}; - backSnowParticle.spawnTime = 0; - backSnowParticle.maxTime = GetRandomValue (3, 10); - } - } - } - - // Autumn leaves particle - if (planetreeParticle.active) - { - planetreeParticle.spawnTime += 1*TIME_FACTOR; - backPlanetreeParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_particle; i++) - { - if (!planetreeParticle.particle[i].active && planetreeParticle.spawnTime >= planetreeParticle.maxTime) - { - planetreeParticle.particle[i].active = true; - planetreeParticle.particle[i].position = (Vector2){GetRandomValue(0, GetScreenWidth() + 200), -10}; - planetreeParticle.spawnTime = 0; - planetreeParticle.maxTime = GetRandomValue (5, 20); - } - - if (!backPlanetreeParticle.particle[i].active && backPlanetreeParticle.spawnTime >= backPlanetreeParticle.maxTime) - { - backPlanetreeParticle.particle[i].active = true; - backPlanetreeParticle.particle[i].position = (Vector2){GetRandomValue(0, GetScreenWidth() + 200), -10}; - backPlanetreeParticle.spawnTime = 0; - backPlanetreeParticle.maxTime = GetRandomValue (3, 10); - } - } - } - - // Dandelion particle - if (dandelionParticle.active) - { - dandelionParticle.spawnTime += 1*TIME_FACTOR; - dandelionBackParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_particle; i++) - { - if (!dandelionParticle.particle[i].active && dandelionParticle.spawnTime >= dandelionParticle.maxTime) - { - dandelionParticle.particle[i].active = true; - dandelionParticle.particle[i].position = (Vector2){GetRandomValue(0, GetScreenWidth() + 200), -10}; - dandelionParticle.spawnTime = 0; - dandelionParticle.maxTime = GetRandomValue (5, 20); - } - - if (!dandelionBackParticle.particle[i].active && dandelionBackParticle.spawnTime >= dandelionBackParticle.maxTime) - { - dandelionBackParticle.particle[i].active = true; - dandelionBackParticle.particle[i].position = (Vector2){GetRandomValue(0, GetScreenWidth() + 200), -10}; - dandelionBackParticle.spawnTime = 0; - dandelionBackParticle.maxTime = GetRandomValue (3, 10); - } - } - } - - // Flower Particle - if (flowerParticle.active) - { - - flowerParticle.spawnTime += 1*TIME_FACTOR; - backFlowerParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_particle; i++) - { - if (!flowerParticle.particle[i].active && flowerParticle.spawnTime >= flowerParticle.maxTime) - { - flowerParticle.particle[i].active = true; - flowerParticle.particle[i].position = (Vector2){GetRandomValue(0, GetScreenWidth() + 200), -10}; - flowerParticle.spawnTime = 0; - flowerParticle.maxTime = GetRandomValue (5, 20); - } - - if (!backFlowerParticle.particle[i].active && backFlowerParticle.spawnTime >= backFlowerParticle.maxTime) - { - backFlowerParticle.particle[i].active = true; - backFlowerParticle.particle[i].position = (Vector2){GetRandomValue(0, GetScreenWidth() + 200), -10}; - backFlowerParticle.spawnTime = 0; - backFlowerParticle.maxTime = GetRandomValue (3, 10); - } - } - } - - // Storm particle - if (rainStormParticle.active) - { - - rainStormParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < 1024; i++) - { - if (!rainStormParticle.particle[i].active && rainStormParticle.spawnTime >= rainStormParticle.maxTime) - { - for (int j = 0; j < 16; j++) - { - rainStormParticle.particle[i+j].active = true; - rainStormParticle.particle[i+j].position = (Vector2){GetRandomValue(100, GetScreenWidth() + 1000), GetRandomValue(-10,-20)}; - } - - rainStormParticle.spawnTime = 0; - rainStormParticle.maxTime = 4; - } - } - } - - // Snow Storm particle - if (snowStormParticle.active) - { - snowStormParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < 256; i++) - { - if (!snowStormParticle.particle[i].active && snowStormParticle.spawnTime >= snowStormParticle.maxTime) - { - snowStormParticle.particle[i].active = true; - snowStormParticle.particle[i].position = (Vector2){GetRandomValue(100, GetScreenWidth() + 800), -10}; - snowStormParticle.spawnTime = 0; - snowStormParticle.maxTime = GetRandomValue (1, 2); - } - } - } - - if (rayparticle.active) - { - rayparticle.spawnTime += 1*TIME_FACTOR; - backRayparticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < 20; i++) - { - if (!rayparticle.particle[i].active && rayparticle.spawnTime >= rayparticle.maxTime) - { - //printf("PARTICLEEES"); - rayparticle.particle[i].active = true; - rayparticle.particle[i].alpha = 0.0f; - rayparticle.particle[i].size = (float)(GetRandomValue(10, 20)/10); - rayparticle.particle[i].position = (Vector2){GetRandomValue(300, GetScreenWidth() + 200), 0}; - rayparticle.particle[i].rotation = -35; - rayparticle.spawnTime = 0; - rayparticle.particle[i].delayCounter = 0; - rayparticle.maxTime = GetRandomValue (20, 50); - } - - if (!backRayparticle.particle[i].active && backRayparticle.spawnTime >= backRayparticle.maxTime) - { - backRayparticle.particle[i].active = true; - backRayparticle.particle[i].alpha = 0.0f; - backRayparticle.particle[i].size = (float)(GetRandomValue(5, 15)/10); - backRayparticle.particle[i].position = (Vector2){GetRandomValue(300, GetScreenWidth() + 200), 0}; - backRayparticle.particle[i].rotation = -35; - backRayparticle.spawnTime = 0; - backRayparticle.particle[i].delayCounter = 0; - backRayparticle.maxTime = GetRandomValue (20, 50); - } - } - } - - if (rainParticle.active) - { - rainParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_particle; i++) - { - if (!rainParticle.particle[i].active && rainParticle.spawnTime >= rainParticle.maxTime) - { - rainParticle.particle[i].active = true; - rainParticle.particle[i].position = (Vector2){GetRandomValue(0, GetScreenWidth() + 200), -10}; - rainParticle.spawnTime = 0; - rainParticle.maxTime = GetRandomValue (1, 8); - } - } - } - - if (backRainParticle.active) - { - backRainParticle.spawnTime += 1*TIME_FACTOR; - - for (int i = 0; i < MAX_particle; i++) - { - - if (!backRainParticle.particle[i].active && backRainParticle.spawnTime >= backRainParticle.maxTime) - { - backRainParticle.particle[i].active = true; - backRainParticle.particle[i].position = (Vector2){GetRandomValue(0, GetScreenWidth() + 200), -10}; - backRainParticle.spawnTime = 0; - backRainParticle.maxTime = GetRandomValue (3, 10); - } - } - } - - // particle Logic - for (int i = 0; i < MAX_particle; i++) - { - if (snowParticle.particle[i].active) - { - snowParticle.particle[i].position.y += 2*TIME_FACTOR; - snowParticle.particle[i].position.x -= 2*TIME_FACTOR; - snowParticle.particle[i].rotation += 0.5*TIME_FACTOR; - if (snowParticle.particle[i].position.y >= GetScreenHeight()) snowParticle.particle[i].active = false; - } - - if (backSnowParticle.particle[i].active) - { - backSnowParticle.particle[i].position.y += 4*TIME_FACTOR; - backSnowParticle.particle[i].position.x -= 3*TIME_FACTOR; - backSnowParticle.particle[i].rotation += 0.5*TIME_FACTOR; - if (backSnowParticle.particle[i].position.y >= GetScreenHeight()) backSnowParticle.particle[i].active = false; - } - - if (planetreeParticle.particle[i].active) - { - planetreeParticle.particle[i].position.y += 4*TIME_FACTOR; - planetreeParticle.particle[i].position.x -= 2*TIME_FACTOR; - planetreeParticle.particle[i].rotation += 0.5*TIME_FACTOR; - if (planetreeParticle.particle[i].position.y >= GetScreenHeight()) planetreeParticle.particle[i].active = false; - } - - if (backPlanetreeParticle.particle[i].active) - { - backPlanetreeParticle.particle[i].position.y += 4*TIME_FACTOR; - backPlanetreeParticle.particle[i].position.x -= 3*TIME_FACTOR; - backPlanetreeParticle.particle[i].rotation += 0.5*TIME_FACTOR; - if (backPlanetreeParticle.particle[i].position.y >= GetScreenHeight()) backPlanetreeParticle.particle[i].active = false; - } - - if (dandelionParticle.particle[i].active) - { - dandelionParticle.particle[i].position.y += 2.5*TIME_FACTOR; - dandelionParticle.particle[i].position.x -= 2*TIME_FACTOR; - dandelionParticle.particle[i].rotation = -(30*sin(2*PI/120*globalFrameCounter + dandelionParticle.particle[i].rotPhy) + 30); - if (dandelionParticle.particle[i].position.y >= GetScreenHeight()) dandelionParticle.particle[i].active = false; - } - - if (dandelionBackParticle.particle[i].active) - { - dandelionBackParticle.particle[i].position.y += 2*TIME_FACTOR; - dandelionBackParticle.particle[i].position.x -= 3*TIME_FACTOR; - dandelionBackParticle.particle[i].rotation = -(30*sin(2*PI/120*globalFrameCounter + dandelionParticle.particle[i].rotPhy) + 30); - if (dandelionBackParticle.particle[i].position.y >= GetScreenHeight()) dandelionBackParticle.particle[i].active = false; - } - - if (flowerParticle.particle[i].active) - { - flowerParticle.particle[i].position.y += 2.5*TIME_FACTOR; - flowerParticle.particle[i].position.x -= 2*TIME_FACTOR; - flowerParticle.particle[i].rotation += 0.5*TIME_FACTOR; - if (flowerParticle.particle[i].position.y >= GetScreenHeight()) flowerParticle.particle[i].active = false; - } - - if (backFlowerParticle.particle[i].active) - { - backFlowerParticle.particle[i].position.y += 2*TIME_FACTOR; - backFlowerParticle.particle[i].position.x -= 3*TIME_FACTOR; - backFlowerParticle.particle[i].rotation += 0.5*TIME_FACTOR; - if (backFlowerParticle.particle[i].position.y >= GetScreenHeight()) backFlowerParticle.particle[i].active = false; - } - - if (rainParticle.particle[i].active) - { - rainParticle.particle[i].position.y += 4*TIME_FACTOR; - rainParticle.particle[i].position.x -= 5*TIME_FACTOR; - //rainParticle.particle[i].rotation += 0.5; - if (rainParticle.particle[i].position.y >= GetScreenHeight()) rainParticle.particle[i].active = false; - } - - if (backRainParticle.particle[i].active) - { - backRainParticle.particle[i].position.y += 3*TIME_FACTOR; - backRainParticle.particle[i].position.x -= 3*TIME_FACTOR; - //rainParticle.particle[i].rotation += 0.5; - if (backRainParticle.particle[i].position.y >= GetScreenHeight()) backRainParticle.particle[i].active = false; - } - } - - for (int i = 0; i < 1024; i++) - { - if (rainStormParticle.particle[i].active) - { - rainStormParticle.particle[i].position.y += 12*TIME_FACTOR; - rainStormParticle.particle[i].position.x -= 15*TIME_FACTOR; - //rainParticle.particle[i].rotation += 0.5; - if (rainStormParticle.particle[i].position.y >= GetScreenHeight()) rainStormParticle.particle[i].active = false; - if (rainStormParticle.active == false)rainStormParticle.particle[i].alpha -= 0.01; - } - } - - for (int i = 0; i < 256; i++) - { - if (snowStormParticle.particle[i].active) - { - snowStormParticle.particle[i].position.y += 12; - snowStormParticle.particle[i].position.x -= 15; - snowStormParticle.particle[i].rotation += 0.5; - if (snowStormParticle.particle[i].position.y >= GetScreenHeight()) snowStormParticle.particle[i].active = false; - } - } - - for (int i = 0; i < 20; i++) - { - if (rayparticle.particle[i].active) - { - rayparticle.particle[i].position.x -= 0.5*TIME_FACTOR; - - if (rayparticle.particle[i].fading) - { - rayparticle.particle[i].alpha -= 0.01f; - - if (rayparticle.particle[i].alpha <= 0) - { - rayparticle.particle[i].alpha = 0; - rayparticle.particle[i].delayCounter++; - if (rayparticle.particle[i].delayCounter >= 30) - { - rayparticle.particle[i].active = false; - rayparticle.particle[i].delayCounter = 0; - rayparticle.particle[i].fading = false; - } - } - } - else - { - rayparticle.particle[i].alpha += 0.01f; - - if (rayparticle.particle[i].alpha >= 0.5f) - { - rayparticle.particle[i].alpha = 0.5f; - rayparticle.particle[i].delayCounter++; - - if (rayparticle.particle[i].delayCounter >= 30) - { - rayparticle.particle[i].delayCounter = 0; - rayparticle.particle[i].fading = true; - } - } - } - } - - if (backRayparticle.particle[i].active) - { - backRayparticle.particle[i].position.x -= 0.5; - - if (backRayparticle.particle[i].fading) - { - backRayparticle.particle[i].alpha -= 0.01f; - if (backRayparticle.particle[i].alpha <= 0) - { - backRayparticle.particle[i].alpha = 0; - backRayparticle.particle[i].delayCounter++; - if (backRayparticle.particle[i].delayCounter >= 30) - { - backRayparticle.particle[i].active = false; - backRayparticle.particle[i].delayCounter = 0; - backRayparticle.particle[i].fading = false; - } - } - } - else - { - backRayparticle.particle[i].alpha += 0.01f; - if (backRayparticle.particle[i].alpha >= 0.5f) - { - backRayparticle.particle[i].alpha = 0.5f; - backRayparticle.particle[i].delayCounter++; - if (backRayparticle.particle[i].delayCounter >= 30) - { - backRayparticle.particle[i].delayCounter = 0; - backRayparticle.particle[i].fading = true; - } - } - } - } - } - - // Press enter to change to GAMEPLAY screen -#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)) - if (((IsGestureDetected(GESTURE_TAP) || (GetGestureDetected() == GESTURE_DOUBLETAP)) && framesCounter >= duration)) - { - //finishScreen = 1; // OPTIONS - finishScreen = 2; // GAMEPLAY - } -#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)) - if ((IsKeyPressed(KEY_ENTER) && framesCounter >= duration)) - { - //finishScreen = 1; // OPTIONS - finishScreen = 2; // GAMEPLAY - } -#endif -} - -// Title Screen Draw logic -void DrawTitleScreen(void) -{ - BeginShaderMode(colorBlend); - - DrawTexturePro(atlas02, gameplay_background, (Rectangle){0, 0, gameplay_background.width*2, gameplay_background.height*2}, (Vector2){0, 0}, 0, color02); - - // Draw parallax - DrawParallaxBack(); - DrawParallaxMiddle(); - - for (int i = 0; i < MAX_particle; i++) - { - if (backSnowParticle.particle[i].active) DrawTexturePro(atlas02, particle_icecrystal_bw, - (Rectangle){ backSnowParticle.particle[i].position.x, backSnowParticle.particle[i].position.y, particle_icecrystal_bw.width*backSnowParticle.particle[i].size, particle_icecrystal_bw.height*backSnowParticle.particle[i].size }, - (Vector2){ particle_icecrystal_bw.width*backSnowParticle.particle[i].size/2, particle_icecrystal_bw.height*backSnowParticle.particle[i].size/2 }, backSnowParticle.particle[i].rotation, - Fade((Color){144, 214, 255, 255}, backSnowParticle.particle[i].alpha)); - - if (backPlanetreeParticle.particle[i].active) DrawTexturePro(atlas02, particle_planetreeleaf_bw, - (Rectangle){ backPlanetreeParticle.particle[i].position.x, backPlanetreeParticle.particle[i].position.y, particle_planetreeleaf_bw.width*backPlanetreeParticle.particle[i].size, particle_planetreeleaf_bw.height*backPlanetreeParticle.particle[i].size }, - (Vector2){ particle_planetreeleaf_bw.width*backPlanetreeParticle.particle[i].size/2, particle_planetreeleaf_bw.height*backPlanetreeParticle.particle[i].size/2 }, backPlanetreeParticle.particle[i].rotation, - Fade((Color){179, 86, 6, 255}, backPlanetreeParticle.particle[i].alpha)); - - if (dandelionBackParticle.particle[i].active) DrawTexturePro(atlas02, particle_dandelion_bw, - (Rectangle){ dandelionBackParticle.particle[i].position.x, dandelionBackParticle.particle[i].position.y, particle_dandelion_bw.width*dandelionBackParticle.particle[i].size, particle_dandelion_bw.height*dandelionBackParticle.particle[i].size }, - (Vector2){ particle_dandelion_bw.width*dandelionBackParticle.particle[i].size/2, particle_dandelion_bw.height*dandelionBackParticle.particle[i].size/2 }, dandelionBackParticle.particle[i].rotation, - Fade((Color){202, 167, 126, 255}, dandelionBackParticle.particle[i].alpha)); - - if (backFlowerParticle.particle[i].active) DrawTexturePro(atlas02, particle_ecualyptusflower_bw, - (Rectangle){ backFlowerParticle.particle[i].position.x, backFlowerParticle.particle[i].position.y, particle_ecualyptusflower_bw.width*backFlowerParticle.particle[i].size, particle_ecualyptusflower_bw.height*backFlowerParticle.particle[i].size }, - (Vector2){ particle_ecualyptusflower_bw.width*backFlowerParticle.particle[i].size/2, particle_ecualyptusflower_bw.height*backFlowerParticle.particle[i].size/2 }, backFlowerParticle.particle[i].rotation, - Fade((Color){218, 84, 108, 255}, backFlowerParticle.particle[i].alpha)); - - if (backRainParticle.particle[i].active) DrawTexturePro(atlas02, particle_waterdrop_bw, - (Rectangle){ backRainParticle.particle[i].position.x, backRainParticle.particle[i].position.y, particle_waterdrop_bw.width*backRainParticle.particle[i].size, particle_waterdrop_bw.height*backRainParticle.particle[i].size }, - (Vector2){ particle_waterdrop_bw.width*backRainParticle.particle[i].size/2, particle_waterdrop_bw.height*backRainParticle.particle[i].size/2 }, backRainParticle.particle[i].rotation, - Fade((Color){144, 183, 187, 255}, backRainParticle.particle[i].alpha)); - } - - for (int i = 0; i < 20; i++) - { - if (backRayparticle.particle[i].active) DrawTexturePro(atlas02, gameplay_back_fx_lightraymid, - (Rectangle){ backRayparticle.particle[i].position.x, backRayparticle.particle[i].position.y, gameplay_back_fx_lightraymid.width*backRayparticle.particle[i].size, gameplay_back_fx_lightraymid.height*backRayparticle.particle[i].size }, - (Vector2){ gameplay_back_fx_lightraymid.width*backRayparticle.particle[i].size/2, gameplay_back_fx_lightraymid.height*backRayparticle.particle[i].size/2 }, backRayparticle.particle[i].rotation, - Fade(GOLD, backRayparticle.particle[i].alpha)); - } - - DrawParallaxFront(); - - for (int i = 0; i < 5; i++) - { - DrawTexturePro(atlas02, gameplay_props_tree, (Rectangle){bamboo[i].x, bamboo[i].y, 43, 720}, (Vector2){0, 0}, 0, color03); - //DrawRectangleRec(bamboo[i], Fade(LIME, 0.5)); - } - - EndShaderMode(); - - DrawTextureRec(atlas01, koalaMenu, (Vector2){player.x - player.width, player.y - 40}, WHITE); - - BeginShaderMode(colorBlend); - - DrawTexturePro(atlas02, gameplay_back_ground00, (Rectangle){0, 637, gameplay_back_ground00.width*2, gameplay_back_ground00.height*2}, (Vector2){0,0}, 0, color00); - - EndShaderMode(); - - DrawTexturePro(atlas01, (Rectangle){title_titletext.x, title_titletext.y, title_titletext.width, 230}, (Rectangle){GetScreenWidth()*0.49F - title_titletext.width/2, currentValue1, title_titletext.width, 235}, (Vector2){0, 0}, 0, WHITE); - DrawTexturePro(atlas01, (Rectangle){title_titletext.x, title_titletext.y + 232, title_titletext.width, 116}, (Rectangle){GetScreenWidth()*0.49F - title_titletext.width/2, currentValue2, title_titletext.width, 116}, (Vector2){0, 0}, 0, WHITE); - - if ((framesCounter/60)%2 && framesCounter >= duration) DrawTextEx(font, pressToPlay, (Vector2){ GetScreenWidth()/2 - fontSize.x/2, GetScreenHeight()/2 + fontSize.y*2 }, font.baseSize, 2, (Color){247, 239, 209, 255}); - - for (int i = 0; i < MAX_particle; i++) - { - if (snowParticle.particle[i].active) DrawTexturePro(atlas01, particle_icecrystal, - (Rectangle){ snowParticle.particle[i].position.x, snowParticle.particle[i].position.y, particle_icecrystal.width*snowParticle.particle[i].size, particle_icecrystal.height*snowParticle.particle[i].size }, - (Vector2){ particle_icecrystal.width*snowParticle.particle[i].size/2, particle_icecrystal.height*snowParticle.particle[i].size/2 }, snowParticle.particle[i].rotation, - Fade(snowParticle.particle[i].color, snowParticle.particle[i].alpha)); - - if (planetreeParticle.particle[i].active) DrawTexturePro(atlas01, particle_planetreeleaf, - (Rectangle){ planetreeParticle.particle[i].position.x, planetreeParticle.particle[i].position.y, particle_planetreeleaf.width*planetreeParticle.particle[i].size, particle_planetreeleaf.height*planetreeParticle.particle[i].size }, - (Vector2){ particle_planetreeleaf.width*planetreeParticle.particle[i].size/2, particle_planetreeleaf.height*planetreeParticle.particle[i].size/2 }, planetreeParticle.particle[i].rotation, - Fade(planetreeParticle.particle[i].color, planetreeParticle.particle[i].alpha)); - - if (dandelionParticle.particle[i].active) DrawTexturePro(atlas01, particle_dandelion, - (Rectangle){ dandelionParticle.particle[i].position.x, dandelionParticle.particle[i].position.y, particle_dandelion.width*dandelionParticle.particle[i].size, particle_dandelion.height*dandelionParticle.particle[i].size }, - (Vector2){ particle_dandelion.width*dandelionParticle.particle[i].size/2, particle_dandelion.height*dandelionParticle.particle[i].size/2 }, dandelionParticle.particle[i].rotation, - Fade(dandelionParticle.particle[i].color, dandelionParticle.particle[i].alpha)); - - if (flowerParticle.particle[i].active) DrawTexturePro(atlas01, particle_ecualyptusflower, - (Rectangle){ flowerParticle.particle[i].position.x, flowerParticle.particle[i].position.y, particle_ecualyptusflower.width*flowerParticle.particle[i].size, particle_ecualyptusflower.height*flowerParticle.particle[i].size }, - (Vector2){ particle_ecualyptusflower.width*flowerParticle.particle[i].size/2, particle_ecualyptusflower.height*flowerParticle.particle[i].size/2 }, flowerParticle.particle[i].rotation, - Fade(flowerParticle.particle[i].color, flowerParticle.particle[i].alpha)); - - if (rainParticle.particle[i].active) DrawTexturePro(atlas01, particle_waterdrop, - (Rectangle){ rainParticle.particle[i].position.x, rainParticle.particle[i].position.y, particle_waterdrop.width*rainParticle.particle[i].size, particle_waterdrop.height*rainParticle.particle[i].size }, - (Vector2){ particle_waterdrop.width*rainParticle.particle[i].size/2, particle_waterdrop.height*rainParticle.particle[i].size/2 }, rainParticle.particle[i].rotation, - Fade(rainParticle.particle[i].color, rainParticle.particle[i].alpha)); - } - - for (int i = 0; i < 1024; i++) - { - if (rainStormParticle.particle[i].active) DrawTexturePro(atlas01, particle_waterdrop, - (Rectangle){ rainStormParticle.particle[i].position.x, rainStormParticle.particle[i].position.y, particle_waterdrop.width*rainStormParticle.particle[i].size, particle_waterdrop.height*rainStormParticle.particle[i].size }, - (Vector2){ particle_waterdrop.width*rainStormParticle.particle[i].size/2, particle_waterdrop.height*rainStormParticle.particle[i].size/2 }, rainStormParticle.particle[i].rotation, - Fade(rainStormParticle.particle[i].color, rainStormParticle.particle[i].alpha)); - } - - for (int i = 0; i < 256; i++) - { - if (snowStormParticle.particle[i].active) DrawTexturePro(atlas01, particle_icecrystal, - (Rectangle){ snowStormParticle.particle[i].position.x, snowStormParticle.particle[i].position.y, particle_icecrystal.width*snowStormParticle.particle[i].size, particle_icecrystal.height*snowStormParticle.particle[i].size }, - (Vector2){ particle_icecrystal.width*snowStormParticle.particle[i].size/2, particle_icecrystal.height*snowStormParticle.particle[i].size/2 }, snowStormParticle.particle[i].rotation, - Fade(snowStormParticle.particle[i].color, snowStormParticle.particle[i].alpha)); - } - - - for (int i = 0; i < 20; i++) - { - if (rayparticle.particle[i].active) DrawTexturePro(atlas01, gameplay_fx_lightraymid, - (Rectangle){ rayparticle.particle[i].position.x, rayparticle.particle[i].position.y, gameplay_fx_lightraymid.width*rayparticle.particle[i].size, gameplay_fx_lightraymid.height*rayparticle.particle[i].size }, - (Vector2){ gameplay_fx_lightraymid.width*rayparticle.particle[i].size/2, gameplay_fx_lightraymid.height*rayparticle.particle[i].size/2 }, rayparticle.particle[i].rotation, - Fade(rayparticle.particle[i].color, rayparticle.particle[i].alpha)); - } - - /* - DrawTexturePro(atlas01, title_twitter, (Rectangle){ GetScreenWidth()*0.85, GetScreenHeight()*0.1, title_twitter.width, title_twitter.height}, (Vector2){0,0}, 0, WHITE); - DrawTexturePro(atlas01, title_facebook, (Rectangle){ GetScreenWidth()*0.85, GetScreenHeight()*0.3, title_facebook.width, title_facebook.height}, (Vector2){0,0}, 0, WHITE); - DrawTexturePro(atlas01, title_googleplay, (Rectangle){ GetScreenWidth()*0.85, GetScreenHeight()*0.5, title_googleplay.width, title_googleplay.height}, (Vector2){0,0}, 0, WHITE); - - if (soundActive)DrawTexturePro(atlas01, title_music_on, (Rectangle){soundButton.x, soundButton.y, title_music_on.width, title_music_on.height}, (Vector2){0,0}, 0, WHITE); - else DrawTexturePro(atlas01, title_music_off, (Rectangle){soundButton.x, soundButton.y, title_music_off.width, title_music_off.height}, (Vector2){0,0}, 0, WHITE); - - if (musicActive)DrawTexturePro(atlas01, title_speaker_on, (Rectangle){speakerButton.x, speakerButton.y, title_speaker_on.width, title_speaker_on.height}, (Vector2){0,0}, 0, WHITE); - else DrawTexturePro(atlas01, title_speaker_off, (Rectangle){speakerButton.x, speakerButton.y, title_speaker_off.width, title_speaker_off.height}, (Vector2){0,0}, 0, WHITE); - */ -} - -// Title Screen Unload logic -void UnloadTitleScreen(void) -{ - // ... -} - -// Title Screen should finish? -int FinishTitleScreen(void) -{ - return finishScreen; -} - -static void DrawParallaxFront(void) -{ - Rectangle ground01 = gameplay_back_ground01; - - //DrawTexturePro(atlas02, gameplay_back_tree01_layer03, (Rectangle){0, 21, gameplay_back_tree01_layer03.width*2, gameplay_back_tree01_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree01_layer01, (Rectangle){(int)parallaxFrontOffset, 60, gameplay_back_tree01_layer01.width*2, gameplay_back_tree01_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree02_layer01, (Rectangle){(int)parallaxFrontOffset + 140, 60, gameplay_back_tree02_layer01.width*2, gameplay_back_tree02_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree03_layer01, (Rectangle){(int)parallaxFrontOffset + 140*2, 55, gameplay_back_tree02_layer01.width*2, gameplay_back_tree02_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree04_layer01, (Rectangle){(int)parallaxFrontOffset + 140*3, 60, gameplay_back_tree04_layer01.width*2, gameplay_back_tree04_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree05_layer01, (Rectangle){(int)parallaxFrontOffset + 140*4, 60, gameplay_back_tree05_layer01.width*2, gameplay_back_tree05_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree06_layer01, (Rectangle){(int)parallaxFrontOffset + 140*5, 55, gameplay_back_tree06_layer01.width*2, gameplay_back_tree06_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree07_layer01, (Rectangle){(int)parallaxFrontOffset + 140*6, 60, gameplay_back_tree07_layer01.width*2, gameplay_back_tree07_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree08_layer01, (Rectangle){(int)parallaxFrontOffset + 140*7, 60, gameplay_back_tree08_layer01.width*2, gameplay_back_tree08_layer01.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_ground01, (Rectangle){0, 559, ground01.width*2, ground01.height*2}, (Vector2){0,0}, 0, color01); - DrawTexturePro(atlas02, (Rectangle){ground01.x, ground01.y + ground01.height, ground01.width, -ground01.height}, (Rectangle){0, -33, ground01.width*2, ground01.height*2}, (Vector2){0,0}, 0, color01); -} - -static void DrawParallaxMiddle(void) -{ - Rectangle ground02 = gameplay_back_ground02; - - //DrawTexturePro(atlas02, gameplay_back_tree02_layer03, (Rectangle){0, 67, gameplay_back_tree02_layer03.width*2, gameplay_back_tree02_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree01_layer02, (Rectangle){(int)0, 67, gameplay_back_tree01_layer02.width*2, gameplay_back_tree01_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree02_layer02, (Rectangle){(int)140, 67, gameplay_back_tree02_layer02.width*2, gameplay_back_tree02_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree03_layer02, (Rectangle){(int)140*2, 67, gameplay_back_tree03_layer02.width*2, gameplay_back_tree03_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree04_layer02, (Rectangle){(int)140*3, 67, gameplay_back_tree04_layer02.width*2, gameplay_back_tree04_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree05_layer02, (Rectangle){(int)140*4, 67, gameplay_back_tree05_layer02.width*2, gameplay_back_tree05_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree06_layer02, (Rectangle){(int)140*5, 67, gameplay_back_tree06_layer02.width*2, gameplay_back_tree06_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree07_layer02, (Rectangle){(int)140*6, 67, gameplay_back_tree07_layer02.width*2, gameplay_back_tree07_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree08_layer02, (Rectangle){(int)140*7, 67, gameplay_back_tree08_layer02.width*2, gameplay_back_tree08_layer02.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_ground02, (Rectangle){0, 509, ground02.width*2, ground02.height*2}, (Vector2){0,0}, 0, color01); - DrawTexturePro(atlas02, (Rectangle){ground02.x, ground02.y + ground02.height, ground02.width, -ground02.height}, (Rectangle){0, 19, ground02.width*2, ground02.height*2}, (Vector2){0,0}, 0, color01); -} - -static void DrawParallaxBack(void) -{ - Rectangle ground03 = gameplay_back_ground03; - - //DrawTexturePro(atlas02, gameplay_back_tree02_layer03, (Rectangle){0, 67, gameplay_back_tree02_layer03.width*2, gameplay_back_tree02_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree01_layer03, (Rectangle){(int)parallaxBackOffset, 67, gameplay_back_tree01_layer03.width*2, gameplay_back_tree01_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree02_layer03, (Rectangle){(int)parallaxBackOffset + 140, 67, gameplay_back_tree02_layer03.width*2, gameplay_back_tree02_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree03_layer03, (Rectangle){(int)parallaxBackOffset + 140*2, 67, gameplay_back_tree03_layer03.width*2, gameplay_back_tree03_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree04_layer03, (Rectangle){(int)parallaxBackOffset + 140*3, 67, gameplay_back_tree04_layer03.width*2, gameplay_back_tree04_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree05_layer03, (Rectangle){(int)parallaxBackOffset + 140*4, 67, gameplay_back_tree05_layer03.width*2, gameplay_back_tree05_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree06_layer03, (Rectangle){(int)parallaxBackOffset + 140*5, 67, gameplay_back_tree06_layer03.width*2, gameplay_back_tree06_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree07_layer03, (Rectangle){(int)parallaxBackOffset + 140*6, 67, gameplay_back_tree07_layer03.width*2, gameplay_back_tree07_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_tree08_layer03, (Rectangle){(int)parallaxBackOffset + 140*7, 67, gameplay_back_tree08_layer03.width*2, gameplay_back_tree08_layer03.height*2}, (Vector2){0,0}, 0, color02); - DrawTexturePro(atlas02, gameplay_back_ground03, (Rectangle){0, 469, ground03.width*2, ground03.height*2}, (Vector2){0,0}, 0, color01); - DrawTexturePro(atlas02, (Rectangle){ground03.x, ground03.y + ground03.height, ground03.width, -ground03.height}, (Rectangle){0, 67, ground03.width*2, ground03.height*2}, (Vector2){0,0}, 0, color01); -} - -static float BounceEaseOut(float t,float b , float c, float d) -{ - if ((t/=d) < (1/2.75f)) { - return c*(7.5625f*t*t) + b; - } else if (t < (2/2.75f)) { - float postFix = t-=(1.5f/2.75f); - return c*(7.5625f*(postFix)*t + .75f) + b; - } else if (t < (2.5/2.75)) { - float postFix = t-=(2.25f/2.75f); - return c*(7.5625f*(postFix)*t + .9375f) + b; - } else { - float postFix = t-=(2.625f/2.75f); - return c*(7.5625f*(postFix)*t + .984375f) + b; - } -} \ No newline at end of file diff --git a/games/koala_seasons/screens/screens.h b/games/koala_seasons/screens/screens.h deleted file mode 100644 index 36d308404..000000000 --- a/games/koala_seasons/screens/screens.h +++ /dev/null @@ -1,125 +0,0 @@ -/********************************************************************************************** -* -* raylib - Koala Seasons game -* -* Screens Functions Declarations (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef SCREENS_H -#define SCREENS_H - -#define GAME_FPS 60.0 -#define TIME_FACTOR 60.0/GAME_FPS - -#define MAX_KILLS 128 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum GameScreen { LOGO, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -GameScreen currentScreen; - -// NOTE: This is all the data used in the game -Font font; -Shader colorBlend; -Texture2D atlas01; -Texture2D atlas02; - -Sound fxJump; -Sound fxDash; -Sound fxEatLeaves; -Sound fxDieSnake; -Sound fxDieDingo; -Sound fxDieOwl; -Sound fxHitResin; -Sound fxWind; - -// Global Variables (required by ending screen and gameplay screen) -int score; -int hiscore; -int killHistory[MAX_KILLS]; -int killer; -int seasons; -int years; -int currentLeaves; -int currentSeason; -int initSeason; -int initYears; -int rainChance; - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLogoScreen(void); -void UpdateLogoScreen(void); -void DrawLogoScreen(void); -void UnloadLogoScreen(void); -int FinishLogoScreen(void); - -//---------------------------------------------------------------------------------- -// Title Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitTitleScreen(void); -void UpdateTitleScreen(void); -void DrawTitleScreen(void); -void UnloadTitleScreen(void); -int FinishTitleScreen(void); - -//---------------------------------------------------------------------------------- -// Options Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitOptionsScreen(void); -void UpdateOptionsScreen(void); -void DrawOptionsScreen(void); -void UnloadOptionsScreen(void); -int FinishOptionsScreen(void); - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitGameplayScreen(void); -void UpdateGameplayScreen(void); -void DrawGameplayScreen(void); -void UnloadGameplayScreen(void); -int FinishGameplayScreen(void); - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitEndingScreen(void); -void UpdateEndingScreen(void); -void DrawEndingScreen(void); -void UnloadEndingScreen(void); -int FinishEndingScreen(void); - -#ifdef __cplusplus -} -#endif - -#endif // SCREENS_H \ No newline at end of file diff --git a/games/light_my_ritual/CMakeLists.txt b/games/light_my_ritual/CMakeLists.txt deleted file mode 100644 index a35a34e06..000000000 --- a/games/light_my_ritual/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(light_my_ritual) - -# Grab the screens -file(GLOB screen_sources "screens/*.c") - -# Executable & linking -add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c ${screen_sources}) -if (NOT TARGET raylib) - find_package(raylib 2.0 REQUIRED) -endif() -target_link_libraries(${PROJECT_NAME} raylib) - -# Resources -# Copy all of the resource files to the destination -file(COPY "resources/" DESTINATION "resources/") diff --git a/games/light_my_ritual/LICENSE.txt b/games/light_my_ritual/LICENSE.txt deleted file mode 100644 index 510604da4..000000000 --- a/games/light_my_ritual/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ - -This game sources are licensed under an unmodified zlib/libpng license, -which is an OSI-certified, BSD-like license: - -Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) - -This software is provided "as-is", without any express or implied warranty. In no event -will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial -applications, and to alter it and redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not claim that you - wrote the original software. If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be misrepresented - as being the original software. - - 3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/games/light_my_ritual/Makefile b/games/light_my_ritual/Makefile deleted file mode 100644 index 5afa857de..000000000 --- a/games/light_my_ritual/Makefile +++ /dev/null @@ -1,405 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= light_my_ritual -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= C:\GitHub\raylib - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - # -Wl,--subsystem,windows hides the console window - ifeq ($(BUILD_MODE), RELEASE) - LDFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -PROJECT_SOURCE_FILES ?= \ - light_my_ritual.c \ - screens/screen_logo_raylib.c \ - screens/screen_title.c \ - screens/screen_gameplay.c - -# Define all object files from source files -OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) - -# For Android platform we call a custom Makefile.Android -ifeq ($(PLATFORM),PLATFORM_ANDROID) - MAKEFILE_PARAMS = -f Makefile.Android - export PROJECT_NAME - export PROJECT_SOURCE_FILES -else - MAKEFILE_PARAMS = $(PROJECT_NAME) -endif - -# Default target entry -# NOTE: We call this Makefile target or Makefile.Android target -all: - $(MAKE) $(MAKEFILE_PARAMS) - -# Project target defined by PROJECT_NAME -$(PROJECT_NAME): $(OBJS) - $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) - -# Compile source files -# NOTE: This pattern will compile every module defined on $(OBJS) -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/light_my_ritual/Makefile.Android b/games/light_my_ritual/Makefile.Android deleted file mode 100644 index 29d437b1b..000000000 --- a/games/light_my_ritual/Makefile.Android +++ /dev/null @@ -1,300 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Android project (APK building) -# -# Copyright (c) 2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -# Define required raylib variables -PLATFORM ?= PLATFORM_ANDROID -RAYLIB_PATH ?= ..\.. - -# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version -ANDROID_ARCH ?= ARM -ANDROID_API_VERSION = 21 -ifeq ($(ANDROID_ARCH),ARM) - ANDROID_ARCH_NAME = armeabi-v7a -endif -ifeq ($(ANDROID_ARCH),ARM64) - ANDROID_ARCH_NAME = arm64-v8a -endif - -# Required path variables -# NOTE: JAVA_HOME must be set to JDK -JAVA_HOME ?= C:/JavaJDK -ANDROID_HOME = C:/android-sdk -ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION) -ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1 -ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools - -# Android project configuration variables -PROJECT_NAME ?= raylib_game -PROJECT_LIBRARY_NAME ?= main -PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME) -PROJECT_RESOURCES_PATH ?= resources -PROJECT_SOURCE_FILES ?= raylib_game.c - -# Some source files are placed in directories, when compiling to some -# output directory other than source, that directory must pre-exist. -# Here we get a list of required folders that need to be created on -# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors. -PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES))) - -# Android app configuration variables -APP_LABEL_NAME ?= rGame -APP_COMPANY_NAME ?= raylib -APP_PRODUCT_NAME ?= rgame -APP_VERSION_CODE ?= 1 -APP_VERSION_NAME ?= 1.0 -APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png -APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png -APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png -APP_SCREEN_ORIENTATION ?= landscape -APP_KEYSTORE_PASS ?= raylib - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Library path for libraylib.a/libraylib.so -RAYLIB_LIB_PATH = $(RAYLIB_PATH)\src - -# Shared libs must be added to APK if required -# NOTE: Generated NativeLoader.java automatically load those libraries -ifeq ($(RAYLIB_LIBTYPE),SHARED) - PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so -endif - -# Compiler and archiver -# NOTE: GCC is being deprecated in Android NDK r16 -ifeq ($(ANDROID_ARCH),ARM) - CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang - AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar -endif -ifeq ($(ANDROID_ARCH),ARM64) - CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang - AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar -endif - -# Compiler flags for arquitecture -ifeq ($(ANDROID_ARCH),ARM) - CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -endif -ifeq ($(ANDROID_ARCH),ARM64) - CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769 -endif -# Compilation functions attributes options -CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC -# Compiler options for the linker -CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes -# Preprocessor macro definitions -CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) - -# Paths containing required header files -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue - -# Linker options -LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a -LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -# Force linking of library module to define symbol -LDFLAGS += -u ANativeActivity_onCreate -# Library paths containing required libs -LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME) -L$(ANDROID_TOOLCHAIN)\sysroot\usr\lib - -# Define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl - -# Generate target objects list from PROJECT_SOURCE_FILES -OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES)) - -# Android APK building process... some steps required... -# NOTE: typing 'make' will invoke the default target entry called 'all', -all: create_temp_project_dirs \ - copy_project_required_libs \ - copy_project_resources \ - generate_loader_script \ - generate_android_manifest \ - generate_apk_keystore \ - config_project_package \ - compile_project_code \ - compile_project_class \ - compile_project_class_dex \ - create_project_apk_package \ - sign_project_apk_package \ - zipalign_project_apk_package - -# Create required temp directories for APK building -create_temp_project_dirs: - if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj - if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src - if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) - if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib - if not exist $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) mkdir $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) - if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin - if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res - if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi - if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values - if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets - if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens - $(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir))) - -define create_dir - if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1) -endef - -# Copy required shared libs for integration into APK -# NOTE: If using shared libs they are loaded by generated NativeLoader.java -copy_project_required_libs: -ifeq ($(RAYLIB_LIBTYPE),SHARED) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so -endif -ifeq ($(RAYLIB_LIBTYPE),STATIC) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a -endif - -# Copy project required resources: strings.xml, icon.png, assets -# NOTE: Required strings.xml is generated and game resources are copied to assets folder -# TODO: Review xcopy usage, it can not be found in some systems! -copy_project_resources: - copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y - copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y - copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y - @echo ^ > $(PROJECT_BUILD_PATH)/res/values/strings.xml - @echo ^^$(APP_LABEL_NAME)^^ >> $(PROJECT_BUILD_PATH)/res/values/strings.xml - if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F - -# Generate NativeLoader.java to load required shared libraries -# NOTE: Probably not the bet way to generate this file... but it works. -generate_loader_script: - @echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -ifeq ($(RAYLIB_LIBTYPE),SHARED) - @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -endif - @echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Generate AndroidManifest.xml with all the required options -# NOTE: Probably not the bet way to generate this file... but it works. -generate_android_manifest: - @echo ^ > $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - -# Generate storekey for APK signing: $(PROJECT_NAME).keystore -# NOTE: Configure here your Distinguished Names (-dname) if required! -generate_apk_keystore: - if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA - -# Config project package and resource using AndroidManifest.xml and res/values/strings.xml -# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java -config_project_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar - -# Compile native_app_glue code as static library: obj/libnative_app_glue.a -compile_native_app_glue: - $(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS) - $(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o - -# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so -compile_project_code: $(OBJS) - $(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) - -# Compile all .c files required into object (.o) files -# NOTE: Those files will be linked into a shared library -$(PROJECT_BUILD_PATH)/obj/%.o:%.c - $(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot - -# Compile project .java code into .class (Java bytecode) -compile_project_class: - $(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Compile .class files into Dalvik executable bytecode (.dex) -# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT) -compile_project_class_dex: - $(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj - -# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk -# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so -# NOTE: Use -A resources to define additional directory in which to find raw asset files -create_project_apk_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin - cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS) - -# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk -sign_project_apk_package: - $(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key - -# Create zip-aligned APK package: $(PROJECT_NAME).apk -zipalign_project_apk_package: - $(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk - -# Install $(PROJECT_NAME).apk to default emulator/device -# NOTE: Use -e (emulator) or -d (device) parameters if required -install: - $(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk - -# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64) -check_device_abi: - $(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi - -# Monitorize output log coming from device, only raylib tag -logcat: - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -# Install and monitorize $(PROJECT_NAME).apk to default emulator/device -deploy: - $(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W - -# Clean everything -clean: - del $(PROJECT_BUILD_PATH)\* /f /s /q - rmdir $(PROJECT_BUILD_PATH) /s /q - @echo Cleaning done diff --git a/games/light_my_ritual/light_my_ritual.c b/games/light_my_ritual/light_my_ritual.c deleted file mode 100644 index 73e40485e..000000000 --- a/games/light_my_ritual/light_my_ritual.c +++ /dev/null @@ -1,281 +0,0 @@ -/******************************************************************************************* -* -* LIGHT MY RITUAL [GLOBAL GAME JAM 2016] -* -* Preparing a ritual session is not that easy. -* You must light all the candles before the astral alignment finishes... -* but dark creatures move in the shadows to put out all your lights! -* Be fast! Be smart! Light my ritual! -* -* This game has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include "screens/screens.h" // NOTE: Defines global variable: currentScreen - -#include - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- -const int screenWidth = 1280; -const int screenHeight = 720; - -// Required variables to manage screen transitions (fade-in, fade-out) -float transAlpha = 0; -bool onTransition = false; -bool transFadeOut = false; -int transFromScreen = -1; -int transToScreen = -1; - -static Music music; - -//---------------------------------------------------------------------------------- -// Local Functions Declaration -//---------------------------------------------------------------------------------- -void TransitionToScreen(int screen); -void ChangeToScreen(int screen); // No transition effect -void UpdateTransition(void); -void DrawTransition(void); - -void UpdateDrawFrame(void); // Update and Draw one frame - -//---------------------------------------------------------------------------------- -// Main entry point -//---------------------------------------------------------------------------------- -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "LIGHT MY RITUAL! [GGJ16]"); - - // Global data loading (assets that must be available in all screens, i.e. fonts) - InitAudioDevice(); - - Image image = LoadImage("resources/lights_map.png"); // Load image in CPU memory (RAM) - - lightsMap = GetImageData(image); // Get image pixels data as an array of Color - lightsMapWidth = image.width; - lightsMapHeight = image.height; - - UnloadImage(image); // Unload image from CPU memory (RAM) - - font = LoadFont("resources/font_arcadian.png"); - //doors = LoadTexture("resources/textures/doors.png"); - //sndDoor = LoadSound("resources/audio/door.ogg"); - - music = LoadMusicStream("resources/audio/ambient.ogg"); - PlayMusicStream(music); - SetMusicVolume(music, 1.0f); - - // Setup and Init first screen - currentScreen = LOGO_RL; - //InitTitleScreen(); - //InitGameplayScreen(); - rlInitLogoScreen(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - UpdateDrawFrame(); - } -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - switch (currentScreen) - { - case LOGO_RL: rlUnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - default: break; - } - - // Unload all global loaded data (i.e. fonts) here! - UnloadFont(font); - //UnloadSound(sndDoor); - - UnloadMusicStream(music); - - free(lightsMap); - - CloseAudioDevice(); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -void TransitionToScreen(int screen) -{ - onTransition = true; - transFromScreen = currentScreen; - transToScreen = screen; -} - -void ChangeToScreen(int screen) -{ - switch (currentScreen) - { - case LOGO_RL: rlUnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - default: break; - } - - switch (screen) - { - case LOGO_RL: rlInitLogoScreen(); break; - case TITLE: InitTitleScreen(); break; - case GAMEPLAY: InitGameplayScreen(); break; - default: break; - } - - currentScreen = screen; -} - -void UpdateTransition(void) -{ - if (!transFadeOut) - { - transAlpha += 0.05f; - - if (transAlpha >= 1.0) - { - transAlpha = 1.0; - - switch (transFromScreen) - { - case LOGO_RL: rlUnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - default: break; - } - - switch (transToScreen) - { - case LOGO_RL: - { - rlInitLogoScreen(); - currentScreen = LOGO_RL; - } break; - case TITLE: - { - InitTitleScreen(); - currentScreen = TITLE; - } break; - case GAMEPLAY: - { - InitGameplayScreen(); - currentScreen = GAMEPLAY; - } break; - default: break; - } - - transFadeOut = true; - } - } - else // Transition fade out logic - { - transAlpha -= 0.05f; - - if (transAlpha <= 0) - { - transAlpha = 0; - transFadeOut = false; - onTransition = false; - transFromScreen = -1; - transToScreen = -1; - } - } -} - -void DrawTransition(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha)); -} - -// Update and draw game frame -void UpdateDrawFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - if (!onTransition) - { - switch(currentScreen) - { - case LOGO_RL: - { - rlUpdateLogoScreen(); - - if (rlFinishLogoScreen()) TransitionToScreen(TITLE); - - } break; - case TITLE: - { - UpdateTitleScreen(); - - if (FinishTitleScreen() == 1) - { - StopMusicStream(music); - TransitionToScreen(GAMEPLAY); - } - - } break; - case GAMEPLAY: - { - UpdateGameplayScreen(); - - if (FinishGameplayScreen() == 1) ChangeToScreen(LOGO_RL); - else if (FinishGameplayScreen() == 2) TransitionToScreen(TITLE); - - } break; - default: break; - } - } - else - { - // Update transition (fade-in, fade-out) - UpdateTransition(); - } - - if (currentScreen != GAMEPLAY) UpdateMusicStream(music); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch(currentScreen) - { - case LOGO_RL: rlDrawLogoScreen(); break; - case TITLE: DrawTitleScreen(); break; - case GAMEPLAY: DrawGameplayScreen(); break; - default: break; - } - - if (onTransition) DrawTransition(); - - //DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- -} - diff --git a/games/light_my_ritual/resources/audio/ambient.ogg b/games/light_my_ritual/resources/audio/ambient.ogg deleted file mode 100644 index 5828c5161..000000000 Binary files a/games/light_my_ritual/resources/audio/ambient.ogg and /dev/null differ diff --git a/games/light_my_ritual/resources/audio/light_off.wav b/games/light_my_ritual/resources/audio/light_off.wav deleted file mode 100644 index d2203e721..000000000 Binary files a/games/light_my_ritual/resources/audio/light_off.wav and /dev/null differ diff --git a/games/light_my_ritual/resources/audio/light_on.wav b/games/light_my_ritual/resources/audio/light_on.wav deleted file mode 100644 index 38b7ca58d..000000000 Binary files a/games/light_my_ritual/resources/audio/light_on.wav and /dev/null differ diff --git a/games/light_my_ritual/resources/audio/ritual.ogg b/games/light_my_ritual/resources/audio/ritual.ogg deleted file mode 100644 index 4674ff7b6..000000000 Binary files a/games/light_my_ritual/resources/audio/ritual.ogg and /dev/null differ diff --git a/games/light_my_ritual/resources/audio/start.wav b/games/light_my_ritual/resources/audio/start.wav deleted file mode 100644 index 66ce7ac16..000000000 Binary files a/games/light_my_ritual/resources/audio/start.wav and /dev/null differ diff --git a/games/light_my_ritual/resources/font_arcadian.png b/games/light_my_ritual/resources/font_arcadian.png deleted file mode 100644 index 7abcc197f..000000000 Binary files a/games/light_my_ritual/resources/font_arcadian.png and /dev/null differ diff --git a/games/light_my_ritual/resources/lights_map.png b/games/light_my_ritual/resources/lights_map.png deleted file mode 100644 index 362094cd8..000000000 Binary files a/games/light_my_ritual/resources/lights_map.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/back_title.png b/games/light_my_ritual/resources/textures/back_title.png deleted file mode 100644 index c6cf96984..000000000 Binary files a/games/light_my_ritual/resources/textures/back_title.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/background.png b/games/light_my_ritual/resources/textures/background.png deleted file mode 100644 index 78dd3e212..000000000 Binary files a/games/light_my_ritual/resources/textures/background.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/book.png b/games/light_my_ritual/resources/textures/book.png deleted file mode 100644 index c0bfbdb37..000000000 Binary files a/games/light_my_ritual/resources/textures/book.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/circle_level_i_off.png b/games/light_my_ritual/resources/textures/circle_level_i_off.png deleted file mode 100644 index 4fe966189..000000000 Binary files a/games/light_my_ritual/resources/textures/circle_level_i_off.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/circle_level_i_on.png b/games/light_my_ritual/resources/textures/circle_level_i_on.png deleted file mode 100644 index 3ac21705c..000000000 Binary files a/games/light_my_ritual/resources/textures/circle_level_i_on.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/circle_level_ii_off.png b/games/light_my_ritual/resources/textures/circle_level_ii_off.png deleted file mode 100644 index d97b7df17..000000000 Binary files a/games/light_my_ritual/resources/textures/circle_level_ii_off.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/circle_level_ii_on.png b/games/light_my_ritual/resources/textures/circle_level_ii_on.png deleted file mode 100644 index c4a1d710f..000000000 Binary files a/games/light_my_ritual/resources/textures/circle_level_ii_on.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/circle_level_iii_off.png b/games/light_my_ritual/resources/textures/circle_level_iii_off.png deleted file mode 100644 index fe92c4f90..000000000 Binary files a/games/light_my_ritual/resources/textures/circle_level_iii_off.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/circle_level_iii_on.png b/games/light_my_ritual/resources/textures/circle_level_iii_on.png deleted file mode 100644 index 2c986595e..000000000 Binary files a/games/light_my_ritual/resources/textures/circle_level_iii_on.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/enemy.png b/games/light_my_ritual/resources/textures/enemy.png deleted file mode 100644 index 7f51ab59a..000000000 Binary files a/games/light_my_ritual/resources/textures/enemy.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/foreground_level_i.png b/games/light_my_ritual/resources/textures/foreground_level_i.png deleted file mode 100644 index 58a5797a9..000000000 Binary files a/games/light_my_ritual/resources/textures/foreground_level_i.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/foreground_level_ii.png b/games/light_my_ritual/resources/textures/foreground_level_ii.png deleted file mode 100644 index b9e30648c..000000000 Binary files a/games/light_my_ritual/resources/textures/foreground_level_ii.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/foreground_level_iii.png b/games/light_my_ritual/resources/textures/foreground_level_iii.png deleted file mode 100644 index 054aa8dcf..000000000 Binary files a/games/light_my_ritual/resources/textures/foreground_level_iii.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/light.png b/games/light_my_ritual/resources/textures/light.png deleted file mode 100644 index 98829c76a..000000000 Binary files a/games/light_my_ritual/resources/textures/light.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/light_glow.png b/games/light_my_ritual/resources/textures/light_glow.png deleted file mode 100644 index a0bc845b7..000000000 Binary files a/games/light_my_ritual/resources/textures/light_glow.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/light_ray.png b/games/light_my_ritual/resources/textures/light_ray.png deleted file mode 100644 index 68c9e766b..000000000 Binary files a/games/light_my_ritual/resources/textures/light_ray.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/msg_ritual.png b/games/light_my_ritual/resources/textures/msg_ritual.png deleted file mode 100644 index fa256cc70..000000000 Binary files a/games/light_my_ritual/resources/textures/msg_ritual.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/player.png b/games/light_my_ritual/resources/textures/player.png deleted file mode 100644 index 637f1a253..000000000 Binary files a/games/light_my_ritual/resources/textures/player.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/time_over.png b/games/light_my_ritual/resources/textures/time_over.png deleted file mode 100644 index 971334ab2..000000000 Binary files a/games/light_my_ritual/resources/textures/time_over.png and /dev/null differ diff --git a/games/light_my_ritual/resources/textures/title.png b/games/light_my_ritual/resources/textures/title.png deleted file mode 100644 index a1a0c86eb..000000000 Binary files a/games/light_my_ritual/resources/textures/title.png and /dev/null differ diff --git a/games/light_my_ritual/screens/screen_gameplay.c b/games/light_my_ritual/screens/screen_gameplay.c deleted file mode 100644 index 09124402e..000000000 --- a/games/light_my_ritual/screens/screen_gameplay.c +++ /dev/null @@ -1,825 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include - -#define MAX_LIGHTS_I 8 -#define MAX_LIGHTS_II 12 -#define MAX_LIGHTS_III 20 - -#define MAX_ENEMIES 8 - -#define MAX_PLAYER_ENERGY 40.0f -#define ENERGY_REFILL_RATIO 0.2f - -#define GAMEPAD_SENSITIVITY 4.0f // More sensitivity, more speed :P - -#define LIGHT_ANIM_FRAMES 7 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef struct Player { - Vector2 position; - Vector2 speed; - int radius; - Color color; - float lightEnergy; -} Player; - -typedef struct Enemy { - Vector2 position; - Vector2 targetPos; // light target position - int targetNum; // light target number - float speed; // scalar value - int radius; - int active; - int awakeFramesDelay; - int framesCounter; - Color color; -} Enemy; - -typedef struct LightSpot { - Vector2 position; - int radius; - int requiredEnergy; - bool active; - Color color; - - int framesCounter; - int currentFrame; - Rectangle frameRec; -} LightSpot; - -typedef enum { LEVEL_I, LEVEL_II, LEVEL_III, LEVEL_FINISHED } LightedLevel; - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; - -//static Texture2D background; - -static bool pause; - -static Player player; - -static LightSpot lightsI[MAX_LIGHTS_I]; -static LightSpot lightsII[MAX_LIGHTS_II]; -static LightSpot lightsIII[MAX_LIGHTS_III]; - -static Enemy enemies[MAX_ENEMIES]; - -static int ritualLevel; -static int previousLightedLevel; -static int currentLightedLevel; - -static Vector2 lighterPosition; - -static int maxLightEnergy; -static int currentLightEnergy; - -static float ritualTime; -static bool startRitual; -static float alphaRitual; - -static bool timeOver; -static int nextStarsAlignment; - -static Texture2D background; -static Texture2D foregroundI; -static Texture2D foregroundII; -static Texture2D foregroundIII; -static Texture2D texPlayer; -static Texture2D texEnemy; -static Texture2D texLight; -static Texture2D lightGlow; -static Texture2D lightRay; -static Texture2D book; -static Texture2D texRitual; -static Texture2D texTimeOver; -static Texture2D circleIoff, circleIIoff, circleIIIoff; -static Texture2D circleIon, circleIIon, circleIIIon; - -static Rectangle lightOff, lightOn; - -static Sound fxLightOn, fxLightOff; - -static Music music; - -// Debug variables -static bool enemiesStopped; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static bool ColorEqual(Color col1, Color col2); // Check if two colors are equal -static Vector2 Vector2Subtract(Vector2 v1, Vector2 v2); -static void Vector2Normalize(Vector2 *v); -static void EnemyReset(Enemy *enemy); - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitGameplayScreen(void) -{ - framesCounter = 0; - finishScreen = 0; - pause = false; - - // Textures loading - background = LoadTexture("resources/textures/background.png"); - foregroundI = LoadTexture("resources/textures/foreground_level_i.png"); - foregroundII = LoadTexture("resources/textures/foreground_level_ii.png"); - foregroundIII = LoadTexture("resources/textures/foreground_level_iii.png"); - texPlayer = LoadTexture("resources/textures/player.png"); - texEnemy = LoadTexture("resources/textures/enemy.png"); - texLight = LoadTexture("resources/textures/light.png"); - lightGlow = LoadTexture("resources/textures/light_glow.png"); - lightRay = LoadTexture("resources/textures/light_ray.png"); - book = LoadTexture("resources/textures/book.png"); - texRitual = LoadTexture("resources/textures/msg_ritual.png"); - texTimeOver = LoadTexture("resources/textures/time_over.png"); - - circleIoff = LoadTexture("resources/textures/circle_level_i_off.png"); - circleIIoff = LoadTexture("resources/textures/circle_level_ii_off.png"); - circleIIIoff = LoadTexture("resources/textures/circle_level_iii_off.png"); - circleIon = LoadTexture("resources/textures/circle_level_i_on.png"); - circleIIon = LoadTexture("resources/textures/circle_level_ii_on.png"); - circleIIIon = LoadTexture("resources/textures/circle_level_iii_on.png"); - - lightOff = (Rectangle){ 0, 0, 64, 64 }; - lightOn = (Rectangle){ 64, 0, 64, 64 }; - - fxLightOn = LoadSound("resources/audio/light_on.wav"); - fxLightOff = LoadSound("resources/audio/light_off.wav"); - - // Initialize player - player.position = (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 - 40 }; - player.radius = 20; - player.speed = (Vector2){5, 5}; - player.color = WHITE; - - // Initialize lights positions based on lights map image data - int kI = 0, kII = 0, kIII = 0; - for (int y = 0; y < lightsMapHeight; y++) - { - for (int x = 0; x < lightsMapWidth; x++) - { - if (ColorEqual(lightsMap[y*lightsMapWidth + x], (Color){ 255, 0, 0, 255 })) - { - // Store light position I - lightsI[kI].position.x = (float)x*10; - lightsI[kI].position.y = (float)y*10; - kI++; - - //printf("Light %02i position: %i, %i\n", kI, (int)lightsI[kI - 1].position.x, (int)lightsI[kI - 1].position.y); - } - else if (ColorEqual(lightsMap[y*lightsMapWidth + x], (Color){ 0, 255, 0, 255 })) - { - // Store light position II - lightsII[kII].position.x = (float)x*10; - lightsII[kII].position.y = (float)y*10; - kII++; - } - else if (ColorEqual(lightsMap[y*lightsMapWidth + x], (Color){ 0, 0, 255, 255 })) - { - // Store light position III - lightsIII[kIII].position.x = (float)x*10; - lightsIII[kIII].position.y = (float)y*10; - kIII++; - } - } - } - - // Initialize lights I - for (int i = 0; i < MAX_LIGHTS_I; i++) - { - lightsI[i].radius = 12; - lightsI[i].requiredEnergy = GetRandomValue(3, 9); - lightsI[i].active = false; - lightsI[i].color = GOLD; - - lightsI[i].framesCounter = 0; - lightsI[i].currentFrame = 0; - lightsI[i].frameRec = (Rectangle){ 0, 0, 64, 64 }; - } - - // Initialize lights II - for (int i = 0; i < MAX_LIGHTS_II; i++) - { - lightsII[i].radius = 8; - lightsII[i].requiredEnergy = GetRandomValue(3, 8); - lightsII[i].active = false; - lightsII[i].color = GOLD; - - lightsII[i].framesCounter = 0; - lightsII[i].currentFrame = 0; - lightsII[i].frameRec = (Rectangle){ 0, 0, 64, 64 }; - } - - // Initialize lights III - for (int i = 0; i < MAX_LIGHTS_III; i++) - { - lightsIII[i].radius = 8; - lightsIII[i].requiredEnergy = GetRandomValue(4, 10); - lightsIII[i].active = false; - lightsIII[i].color = GOLD; - - lightsIII[i].framesCounter = 0; - lightsIII[i].currentFrame = 0; - lightsIII[i].frameRec = (Rectangle){ 0, 0, 64, 64 }; - } - - // Initialize ritual level - ritualLevel = 0; - currentLightedLevel = LEVEL_I; - lighterPosition = (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 }; - - // Initialize enemies - for (int i = 0; i < MAX_ENEMIES; i++) EnemyReset(&enemies[i]); - - // Initialize max light energy (depends on lights randomness) - maxLightEnergy = 0; - - for (int i = 0; i < MAX_LIGHTS_I; i++) maxLightEnergy += lightsI[i].requiredEnergy; - for (int i = 0; i < MAX_LIGHTS_II; i++) maxLightEnergy += lightsII[i].requiredEnergy; - for (int i = 0; i < MAX_LIGHTS_III; i++) maxLightEnergy += lightsIII[i].requiredEnergy; - - //printf("Max light energy: %i\n", maxLightEnergy); - - // Initialize ritual variables - ritualTime = 0.0f; - startRitual = false;; - alphaRitual = 0.0f; - - timeOver = false; - nextStarsAlignment = GetRandomValue(500, 1000); - - enemiesStopped = false; - - music = LoadMusicStream("resources/audio/ritual.ogg"); - PlayMusicStream(music); -} - -// Gameplay Screen Update logic -void UpdateGameplayScreen(void) -{ - if (IsKeyPressed('P')) pause = !pause; - - if (!pause && (currentLightedLevel != LEVEL_FINISHED) && !timeOver) - { - framesCounter++; // Time starts counting to awake enemies - - // Player movement logic - if (IsKeyDown(KEY_RIGHT)) player.position.x += player.speed.x; - else if (IsKeyDown(KEY_LEFT)) player.position.x -= player.speed.x; - - if (IsKeyDown(KEY_UP)) player.position.y -= player.speed.y; - else if (IsKeyDown(KEY_DOWN)) player.position.y += player.speed.y; - - // Debug key to stop enemies - if (IsKeyPressed(KEY_S)) enemiesStopped = !enemiesStopped; - - /* - if (IsGamepadAvailable(GAMEPAD_PLAYER1)) - { - Vector2 movement = GetGamepadMovement(GAMEPAD_PLAYER1); - - player.position.x += movement.x*GAMEPAD_SENSITIVITY; - player.position.y += movement.y*GAMEPAD_SENSITIVITY; - } - */ - - // Player light energy filling logic - if (CheckCollisionCircles(player.position, player.radius, lighterPosition, 50)) - { - player.lightEnergy += ENERGY_REFILL_RATIO; - player.color = (Color){ 255, 255, 100, 255 }; - } - else player.color = WHITE; - - if (player.lightEnergy > MAX_PLAYER_ENERGY) player.lightEnergy = MAX_PLAYER_ENERGY; - - // Player vs lights collision detection (depends on lighted level) - if (currentLightedLevel == LEVEL_I) - { - for (int i = 0; i < MAX_LIGHTS_I; i++) - { - // Check player vs lightI collision - if (CheckCollisionCircles(player.position, player.radius, lightsI[i].position, lightsI[i].radius)) - { - if (!lightsI[i].active && (player.lightEnergy >= lightsI[i].requiredEnergy)) - { - lightsI[i].active = true; - lightsI[i].currentFrame = 1; - player.lightEnergy -= lightsI[i].requiredEnergy; - - PlaySound(fxLightOn); - } - } - } - } - else if (currentLightedLevel == LEVEL_II) - { - for (int i = 0; i < MAX_LIGHTS_II; i++) - { - if (CheckCollisionCircles(player.position, player.radius, lightsII[i].position, lightsII[i].radius)) - { - if (!lightsII[i].active && (player.lightEnergy >= lightsII[i].requiredEnergy)) - { - lightsII[i].active = true; - player.lightEnergy -= lightsII[i].requiredEnergy; - - PlaySound(fxLightOn); - } - } - } - } - else if (currentLightedLevel == LEVEL_III) - { - for (int i = 0; i < MAX_LIGHTS_III; i++) - { - if (CheckCollisionCircles(player.position, player.radius, lightsIII[i].position, lightsIII[i].radius)) - { - if (!lightsIII[i].active && (player.lightEnergy >= lightsIII[i].requiredEnergy)) - { - lightsIII[i].active = true; - player.lightEnergy -= lightsIII[i].requiredEnergy; - - PlaySound(fxLightOn); - } - } - } - } - - // Lights animation (it doesn't depend on currentLightedLevel) - for (int i = 0; i < MAX_LIGHTS_I; i++) - { - // Light animation - if (lightsI[i].active) - { - lightsI[i].framesCounter++; - - if (lightsI[i].framesCounter > 10) - { - lightsI[i].currentFrame++; - - if (lightsI[i].currentFrame > LIGHT_ANIM_FRAMES - 1) lightsI[i].currentFrame = 1; - - lightsI[i].framesCounter = 0; - } - } - - lightsI[i].frameRec.x = lightsI[i].currentFrame*texLight.width/LIGHT_ANIM_FRAMES; - } - - for (int i = 0; i < MAX_LIGHTS_II; i++) - { - // Light animation - if (lightsII[i].active) - { - lightsII[i].framesCounter++; - - if (lightsII[i].framesCounter > 10) - { - lightsII[i].currentFrame++; - - if (lightsII[i].currentFrame > LIGHT_ANIM_FRAMES - 1) lightsII[i].currentFrame = 1; - - lightsII[i].framesCounter = 0; - } - } - - lightsII[i].frameRec.x = lightsII[i].currentFrame*texLight.width/LIGHT_ANIM_FRAMES; - } - - for (int i = 0; i < MAX_LIGHTS_III; i++) - { - // Light animation - if (lightsIII[i].active) - { - lightsIII[i].framesCounter++; - - if (lightsIII[i].framesCounter > 10) - { - lightsIII[i].currentFrame++; - - if (lightsIII[i].currentFrame > LIGHT_ANIM_FRAMES - 1) lightsIII[i].currentFrame = 1; - - lightsIII[i].framesCounter = 0; - } - } - - lightsIII[i].frameRec.x = lightsIII[i].currentFrame*texLight.width/LIGHT_ANIM_FRAMES; - } - - // Enemies logic - if (!enemiesStopped) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (!enemies[i].active) enemies[i].framesCounter++; - - if (enemies[i].framesCounter > enemies[i].awakeFramesDelay) enemies[i].active = true; - - if (enemies[i].active) - { - // Move to the target - Vector2 dir = Vector2Subtract(enemies[i].targetPos, enemies[i].position); - Vector2Normalize(&dir); - - enemies[i].position.x += dir.x*enemies[i].speed; - enemies[i].position.y += dir.y*enemies[i].speed; - - if (currentLightedLevel == LEVEL_I) - { - if (CheckCollisionCircles(enemies[i].position, enemies[i].radius, enemies[i].targetPos, lightsI[enemies[i].targetNum].radius)) - { - lightsI[enemies[i].targetNum].active = false; - lightsI[enemies[i].targetNum].framesCounter = 0; - lightsI[enemies[i].targetNum].currentFrame = 0; - lightsI[enemies[i].targetNum].frameRec = (Rectangle){ 0, 0, 64, 64 }; - - EnemyReset(&enemies[i]); - - PlaySound(fxLightOff); - } - } - else if (currentLightedLevel == LEVEL_II) - { - if (CheckCollisionCircles(enemies[i].position, enemies[i].radius, enemies[i].targetPos, lightsII[enemies[i].targetNum].radius)) - { - lightsII[enemies[i].targetNum].active = false; - lightsII[enemies[i].targetNum].framesCounter = 0; - lightsII[enemies[i].targetNum].currentFrame = 0; - lightsII[enemies[i].targetNum].frameRec = (Rectangle){ 0, 0, 64, 64 }; - - EnemyReset(&enemies[i]); - - PlaySound(fxLightOff); - } - } - else if (currentLightedLevel == LEVEL_III) - { - if (CheckCollisionCircles(enemies[i].position, enemies[i].radius, enemies[i].targetPos, lightsIII[enemies[i].targetNum].radius)) - { - lightsIII[enemies[i].targetNum].active = false; - lightsIII[enemies[i].targetNum].framesCounter = 0; - lightsIII[enemies[i].targetNum].currentFrame = 0; - lightsIII[enemies[i].targetNum].frameRec = (Rectangle){ 0, 0, 64, 64 }; - - EnemyReset(&enemies[i]); - - PlaySound(fxLightOff); - } - } - } - } - } - - // Check current light energy (for right bar) - currentLightEnergy = 0; - - for (int i = 0; i < MAX_LIGHTS_I; i++) if (lightsI[i].active) currentLightEnergy += lightsI[i].requiredEnergy; - for (int i = 0; i < MAX_LIGHTS_II; i++) if (lightsII[i].active) currentLightEnergy += lightsII[i].requiredEnergy; - for (int i = 0; i < MAX_LIGHTS_III; i++) if (lightsIII[i].active) currentLightEnergy += lightsIII[i].requiredEnergy; - - // Check current lighted level - // Check ending conditions: all lights off, ritual level reached - previousLightedLevel = currentLightedLevel; - - currentLightedLevel = LEVEL_I; - - bool lightedLevel = true; - for (int i = 0; i < MAX_LIGHTS_I; i++) if (!lightsI[i].active) lightedLevel = false; - if (lightedLevel) currentLightedLevel = LEVEL_II; - - for (int i = 0; i < MAX_LIGHTS_II; i++) if (!lightsII[i].active) lightedLevel = false; - if (lightedLevel) currentLightedLevel = LEVEL_III; - - for (int i = 0; i < MAX_LIGHTS_III; i++) if (!lightsIII[i].active) lightedLevel = false; - if (lightedLevel) - { - currentLightedLevel = LEVEL_FINISHED; - - for (int i = 0; i < MAX_ENEMIES; i++) enemies[i].active = false; - } - - if (currentLightedLevel != previousLightedLevel) for (int i = 0; i < MAX_ENEMIES; i++) EnemyReset(&enemies[i]); - - ritualTime = (float)framesCounter/60; - - // Check game over condition (time run out) - if ((99.0f - ritualTime) <= 0.0f) - { - ritualTime = 99.0f; - timeOver = true; - } - } - - if (startRitual) - { - alphaRitual += 0.02f; - - SetMusicVolume(music, 1.0f - alphaRitual); - - if (alphaRitual > 1.0f) finishScreen = 1; - } - - UpdateMusicStream(music); -} - -// Gameplay Screen Draw logic -void DrawGameplayScreen(void) -{ - DrawTexture(background, 0, 0, WHITE); - - // DrawText("STARS ARE ALIGNED! NO TIME TO LOOSE! LIGHT MY RITUAL!", - - // Draw foreground and circles - if ((currentLightedLevel == LEVEL_FINISHED) || (currentLightedLevel == LEVEL_III)) DrawTexture(foregroundIII, 0, 0, WHITE); - else if (currentLightedLevel == LEVEL_II) DrawTexture(foregroundII, 0, 0, WHITE); - else if (currentLightedLevel == LEVEL_I) DrawTexture(foregroundI, 0, 0, WHITE); - - // Draw lighted circles (depends on current lighted level) - switch (currentLightedLevel) - { - case LEVEL_FINISHED: - { - DrawTexture(circleIIIon, GetScreenWidth()/2 - circleIIIon.width/2, GetScreenHeight()/2 - circleIIIon.height/2, WHITE); - DrawTexture(circleIIon, GetScreenWidth()/2 - circleIIon.width/2, GetScreenHeight()/2 - circleIIon.height/2, WHITE); - DrawTexture(circleIon, GetScreenWidth()/2 - circleIon.width/2, GetScreenHeight()/2 - circleIon.height/2, WHITE); - } break; - case LEVEL_III: - { - DrawTexture(circleIIIoff, GetScreenWidth()/2 - circleIIIoff.width/2, GetScreenHeight()/2 - circleIIIoff.height/2, WHITE); - DrawTexture(circleIIon, GetScreenWidth()/2 - circleIIon.width/2, GetScreenHeight()/2 - circleIIon.height/2, WHITE); - DrawTexture(circleIon, GetScreenWidth()/2 - circleIon.width/2, GetScreenHeight()/2 - circleIon.height/2, WHITE); - } break; - case LEVEL_II: - { - DrawTexture(circleIIoff, GetScreenWidth()/2 - circleIIoff.width/2, GetScreenHeight()/2 - circleIIoff.height/2, WHITE); - DrawTexture(circleIon, GetScreenWidth()/2 - circleIon.width/2, GetScreenHeight()/2 - circleIon.height/2, WHITE); - } break; - case LEVEL_I: - { - DrawTexture(circleIoff, GetScreenWidth()/2 - circleIoff.width/2, GetScreenHeight()/2 - circleIoff.height/2, WHITE); - } break; - default: break; - } - - // Draw lights (depends on current lighted level) - switch (currentLightedLevel) - { - case LEVEL_FINISHED: - case LEVEL_III: - { - for (int i = 0; i < MAX_LIGHTS_III; i++) - { - //if (lightsIII[i].active) DrawCircleV(lightsIII[i].position, lightsIII[i].radius, GOLD); - //else DrawCircleLines(lightsIII[i].position.x, lightsIII[i].position.y, lightsIII[i].radius, GRAY); - DrawTextureRec(texLight, lightsIII[i].frameRec, (Vector2){ lightsIII[i].position.x - 32, lightsIII[i].position.y - 32 }, WHITE); - } - - for (int i = 0; i < MAX_LIGHTS_III; i++) if (lightsIII[i].active) DrawTexture(lightGlow, lightsIII[i].position.x - lightGlow.width/2, lightsIII[i].position.y - lightGlow.height/2, Fade(WHITE, 0.3f)); - for (int i = 0; i < MAX_LIGHTS_III; i++) DrawText(FormatText("%02i", lightsIII[i].requiredEnergy), lightsIII[i].position.x - 10, lightsIII[i].position.y + 14, 20, lightsIII[i].active ? GRAY : YELLOW); - } - case LEVEL_II: - { - for (int i = 0; i < MAX_LIGHTS_II; i++) - { - //if (lightsII[i].active) DrawCircleV(lightsII[i].position, lightsII[i].radius, GOLD); - //else DrawCircleLines(lightsI[i].position.x, lightsI[i].position.y, lightsI[i].radius, GRAY); - DrawTextureRec(texLight, lightsII[i].frameRec, (Vector2){ lightsII[i].position.x - 32, lightsII[i].position.y - 32 }, WHITE); - } - - for (int i = 0; i < MAX_LIGHTS_II; i++) if (lightsII[i].active) DrawTexture(lightGlow, lightsII[i].position.x - lightGlow.width/2, lightsII[i].position.y - lightGlow.height/2, Fade(WHITE, 0.3f)); - for (int i = 0; i < MAX_LIGHTS_II; i++) DrawText(FormatText("%02i", lightsII[i].requiredEnergy), lightsII[i].position.x - 10, lightsII[i].position.y + 14, 20, lightsII[i].active ? GRAY : YELLOW); - } - case LEVEL_I: - { - for (int i = 0; i < MAX_LIGHTS_I; i++) - { - //if (lightsI[i].active) DrawCircleV(lightsI[i].position, lightsI[i].radius, GOLD); - //else DrawCircleLines(lightsI[i].position.x, lightsI[i].position.y, lightsI[i].radius, GRAY); - DrawTextureRec(texLight, lightsI[i].frameRec, (Vector2){ lightsI[i].position.x - 32, lightsI[i].position.y - 32 }, WHITE); - } - - for (int i = 0; i < MAX_LIGHTS_I; i++) if (lightsI[i].active) DrawTexture(lightGlow, lightsI[i].position.x - lightGlow.width/2, lightsI[i].position.y - lightGlow.height/2, Fade(WHITE, 0.3f)); - for (int i = 0; i < MAX_LIGHTS_I; i++) DrawText(FormatText("%02i", lightsI[i].requiredEnergy), lightsI[i].position.x - 10, lightsI[i].position.y + 14, 20, lightsI[i].active ? GRAY : YELLOW); - } - default: break; - } - - // Draw main lighter - DrawTexture(book, GetScreenWidth()/2 - book.width/2, GetScreenHeight()/2, WHITE); - DrawTexture(lightRay, GetScreenWidth()/2 - lightRay.width/2, 0, Fade(WHITE, 0.5f)); - - // Draw player - //DrawCircleV(player.position, player.radius, player.color); - DrawTexture(texPlayer, player.position.x - 32, player.position.y - 32, player.color); - - if (currentLightedLevel != LEVEL_FINISHED) - { - // Draw enemies (depends on current lighted level) - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemies[i].active) - { - //DrawCircleV(enemies[i].position, enemies[i].radius, enemies[i].color); - DrawTextureRec(texEnemy, (Rectangle){ 0, 0, 64, 64 }, (Vector2){ enemies[i].position.x - 32, enemies[i].position.y - 32 }, WHITE); - } - } - - // Draw time left for ritual - DrawTextEx(font, FormatText("%02.2f", (99.0f - ritualTime)), (Vector2){ 560, 20 }, font.baseSize, 0, WHITE); - - // Draw light energy bar - DrawRectangle(20, 30, 400, 20, GRAY); - DrawRectangle(20, 30, (400*player.lightEnergy)/MAX_PLAYER_ENERGY, 20, GOLD); - DrawRectangleLines(20, 30, 400, 20, LIGHTGRAY); - DrawText(FormatText("%03.0f", player.lightEnergy), 430, 30, 20, WHITE); - - // Draw level lighted bar (for completion) - DrawRectangle(GetScreenWidth() - 40, 30, 20, 660, GRAY); - DrawRectangle(GetScreenWidth() - 40, 30 + 660 - 660*currentLightEnergy/maxLightEnergy, 20, 660*currentLightEnergy/maxLightEnergy, YELLOW); - DrawRectangleLines(GetScreenWidth() - 40, 30, 20, 660, LIGHTGRAY); - - // Show message: "You run out of light!!!" if player.lightEnergy <= 0 - if (player.lightEnergy < 2) - { - if ((framesCounter/20)%2) DrawTextEx(font, "YOU'RE RUNNING OUT OF LIGHT!", (Vector2){ 20, 60 }, font.baseSize/2, 0, WHITE); - } - } - else if (!timeOver) // LEVEL_FINISHED - { - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, 0.4f)); - - // Wait some time before jumping to ending: raylib - DrawTexture(texRitual, GetScreenWidth()/2 - texRitual.width/2, 100, WHITE); - DrawTextEx(font, FormatText("BEST LIGHTING TIME: %02.2f", ritualTime), (Vector2){ 320, 340 }, 50, 0, WHITE); - DrawTextEx(font, "PRESS ENTER to START the RITUAL", (Vector2){ 160, 480 }, 60, 0, WHITE); - - if (IsKeyPressed(KEY_ENTER)) startRitual = true; - } - - if (timeOver) - { - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, 0.4f)); - - DrawTexture(texTimeOver, GetScreenWidth()/2 - texTimeOver.width/2, 140, WHITE); - DrawTextEx(font, FormatText("NEXT STARS ALIGNMENT IN %i YEARS", nextStarsAlignment), (Vector2){ 200, 360 }, 50, 0, WHITE); - DrawTextEx(font, "PRESS ENTER to GO HOME...", (Vector2){ 260, 480 }, 60, 0, WHITE); - - if (IsKeyPressed(KEY_ENTER)) finishScreen = 2; - } - - if (startRitual) DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, alphaRitual)); - - if (pause) DrawTextEx(font, "RITUAL PAUSED", (Vector2){ GetScreenWidth()/2 - MeasureText("RITUAL PAUSED", 40)/2, 110 }, 50, 0, WHITE); -} - -// Gameplay Screen Unload logic -void UnloadGameplayScreen(void) -{ - // Unload GAMEPLAY screen variables here! - UnloadTexture(background); - UnloadTexture(foregroundI); - UnloadTexture(foregroundII); - UnloadTexture(foregroundIII); - UnloadTexture(texPlayer); - UnloadTexture(texEnemy); - UnloadTexture(texLight); - UnloadTexture(lightGlow); - UnloadTexture(lightRay); - UnloadTexture(book); - UnloadTexture(texRitual); - UnloadTexture(texTimeOver); - - // Unload circles - UnloadTexture(circleIoff); - UnloadTexture(circleIIoff); - UnloadTexture(circleIIIoff); - UnloadTexture(circleIon); - UnloadTexture(circleIIon); - UnloadTexture(circleIIIon); - - // Unload sounds - UnloadSound(fxLightOn); - UnloadSound(fxLightOff); - - UnloadMusicStream(music); -} - -// Gameplay Screen should finish? -int FinishGameplayScreen(void) -{ - return finishScreen; -} - -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Check two colors if equal -static bool ColorEqual(Color col1, Color col2) -{ - return ((col1.r == col2.r) && (col1.g == col2.g) && (col1.b == col2.b) && (col1.a == col2.a)); -} - -// Substract two vectors -static Vector2 Vector2Subtract(Vector2 v1, Vector2 v2) -{ - Vector2 result; - - result.x = v1.x - v2.x; - result.y = v1.y - v2.y; - - return result; -} - -// Normalize provided vector -static void Vector2Normalize(Vector2 *v) -{ - float length, ilength; - - length = sqrt(v->x*v->x + v->y*v->y); - - if (length == 0) length = 1.0f; - - ilength = 1.0f/length; - - v->x *= ilength; - v->y *= ilength; -} - -// Reset enemy parameters -// NOTE: Depends on currentLightedLevel -static void EnemyReset(Enemy *enemy) -{ - enemy->active = false; - enemy->framesCounter = 0; - enemy->color = RED; - enemy->radius = 10; - - int side = GetRandomValue(0, 1); - - if (side) enemy->position = (Vector2){ GetRandomValue(50, 150), GetRandomValue(50, GetScreenHeight() - 50) }; - else enemy->position = (Vector2){ GetRandomValue(GetScreenWidth() - 150, GetScreenWidth() - 50), GetRandomValue(50, GetScreenHeight() - 50) }; - - // TODO: Choose only active lights - // TODO: if currentLightedLevel has no active lights, choose light from a lower level! - - if (currentLightedLevel == LEVEL_I) - { - enemy->targetNum = GetRandomValue(0, MAX_LIGHTS_I - 1); // LEVEL_I - enemy->targetPos = lightsI[enemy->targetNum].position; - enemy->speed = (float)GetRandomValue(15, 20)/10.0f; - enemy->awakeFramesDelay = GetRandomValue(90, 400); - } - else if (currentLightedLevel == LEVEL_II) - { - enemy->targetNum = GetRandomValue(0, MAX_LIGHTS_II - 1); // LEVEL_II - enemy->targetPos = lightsII[enemy->targetNum].position; - enemy->speed = (float)GetRandomValue(10, 20)/10.0f; - enemy->awakeFramesDelay = GetRandomValue(240, 800); - } - else if (currentLightedLevel == LEVEL_III) - { - enemy->targetNum = GetRandomValue(0, MAX_LIGHTS_III - 1); // LEVEL_III - enemy->targetPos = lightsIII[enemy->targetNum].position; - enemy->speed = (float)GetRandomValue(8, 18)/10.0f; - enemy->awakeFramesDelay = GetRandomValue(180, 1200); - } -} diff --git a/games/light_my_ritual/screens/screen_logo_raylib.c b/games/light_my_ritual/screens/screen_logo_raylib.c deleted file mode 100644 index 87a2282e4..000000000 --- a/games/light_my_ritual/screens/screen_logo_raylib.c +++ /dev/null @@ -1,211 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Logo Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#define LOGO_RECS_SIDE 16 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Logo screen global variables -static int framesCounter; -static int finishScreen; - -static int logoPositionX; -static int logoPositionY; - -static int lettersCount; - -static int topSideRecWidth; -static int leftSideRecHeight; - -static int bottomSideRecWidth; -static int rightSideRecHeight; - -static char raylib[8]; // raylib text array, max 8 letters -static int state; // Tracking animation states (State Machine) -static float alpha = 1.0f; // Useful for fading - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Logo Screen Initialization logic -void rlInitLogoScreen(void) -{ - // Initialize LOGO screen variables here! - finishScreen = 0; - framesCounter = 0; - lettersCount = 0; - - logoPositionX = GetScreenWidth()/2 - 128; - logoPositionY = GetScreenHeight()/2 - 128; - - topSideRecWidth = LOGO_RECS_SIDE; - leftSideRecHeight = LOGO_RECS_SIDE; - bottomSideRecWidth = LOGO_RECS_SIDE; - rightSideRecHeight = LOGO_RECS_SIDE; - - for (int i = 0; i < 8; i++) raylib[i] = '\0'; - - state = 0; - alpha = 1.0f; -} - -// Logo Screen Update logic -void rlUpdateLogoScreen(void) -{ - // Update LOGO screen variables here! - if (state == 0) // State 0: Small box blinking - { - framesCounter++; - - if (framesCounter == 80) - { - state = 1; - framesCounter = 0; // Reset counter... will be used later... - } - } - else if (state == 1) // State 1: Top and left bars growing - { - topSideRecWidth += 8; - leftSideRecHeight += 8; - - if (topSideRecWidth == 256) state = 2; - } - else if (state == 2) // State 2: Bottom and right bars growing - { - bottomSideRecWidth += 8; - rightSideRecHeight += 8; - - if (bottomSideRecWidth == 256) state = 3; - } - else if (state == 3) // State 3: Letters appearing (one by one) - { - framesCounter++; - - if (framesCounter/10) // Every 12 frames, one more letter! - { - lettersCount++; - framesCounter = 0; - } - - switch (lettersCount) - { - case 1: raylib[0] = 'r'; break; - case 2: raylib[1] = 'a'; break; - case 3: raylib[2] = 'y'; break; - case 4: raylib[3] = 'l'; break; - case 5: raylib[4] = 'i'; break; - case 6: raylib[5] = 'b'; break; - default: break; - } - - // When all letters have appeared... - if (lettersCount >= 10) - { - state = 4; - framesCounter = 0; - } - } - else if (state == 4) - { - framesCounter++; - - if (framesCounter > 100) - { - alpha -= 0.02f; - - if (alpha <= 0.0f) - { - alpha = 0.0f; - finishScreen = 1; - } - } - } -} - -// Logo Screen Draw logic -void rlDrawLogoScreen(void) -{ - if (state == 0) - { - if ((framesCounter/10)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK); - } - else if (state == 1) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - } - else if (state == 2) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK); - } - else if (state == 3) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - } - else if (state == 4) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - - if (framesCounter > 20) DrawText("powered by", logoPositionX, logoPositionY - 27, 20, Fade(DARKGRAY, alpha)); - } -} - -// Logo Screen Unload logic -void rlUnloadLogoScreen(void) -{ - // Unload LOGO screen variables here! -} - -// Logo Screen should finish? -int rlFinishLogoScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/light_my_ritual/screens/screen_title.c b/games/light_my_ritual/screens/screen_title.c deleted file mode 100644 index bcf53f518..000000000 --- a/games/light_my_ritual/screens/screen_title.c +++ /dev/null @@ -1,105 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Title Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Title screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D background; -static Texture2D title; -static float titleAlpha = 0.0f; - -static Sound fxStart; - -//---------------------------------------------------------------------------------- -// Title Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Title Screen Initialization logic -void InitTitleScreen(void) -{ - // Initialize TITLE screen variables here! - framesCounter = 0; - finishScreen = 0; - - background = LoadTexture("resources/textures/back_title.png"); - title = LoadTexture("resources/textures/title.png"); - - fxStart = LoadSound("resources/audio/start.wav"); -} - -// Title Screen Update logic -void UpdateTitleScreen(void) -{ - // Update TITLE screen variables here! - framesCounter++; - - titleAlpha += 0.005f; - - if (titleAlpha >= 1.0f) titleAlpha = 1.0f; - - // Press enter to change to ATTIC screen - if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) - { - PlaySound(fxStart); - finishScreen = 1; - } -} - -// Title Screen Draw logic -void DrawTitleScreen(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), (Color){ 26, 26, 26, 255 }); - - DrawTexture(background, GetScreenWidth()/2 - background.width/2, 0, WHITE); - DrawTexture(title, GetScreenWidth()/2 - title.width/2, 30, Fade(WHITE, titleAlpha)); - - DrawText("(c) Developed by Ramon Santamaria (@raysan5)", 20, GetScreenHeight() - 40, 20, LIGHTGRAY); - - if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawTextEx(font, "PRESS ENTER to START LIGHTING", (Vector2){ 230, 450 }, font.baseSize, -2, WHITE); -} - -// Title Screen Unload logic -void UnloadTitleScreen(void) -{ - // Unload TITLE screen variables here! - UnloadTexture(background); - UnloadTexture(title); - - UnloadSound(fxStart); -} - -// Title Screen should finish? -int FinishTitleScreen(void) -{ - return finishScreen; -} diff --git a/games/light_my_ritual/screens/screens.h b/games/light_my_ritual/screens/screens.h deleted file mode 100644 index fc17c268d..000000000 --- a/games/light_my_ritual/screens/screens.h +++ /dev/null @@ -1,78 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Screens Functions Declarations (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef SCREENS_H -#define SCREENS_H - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum GameScreen { LOGO_RL = 0, TITLE, GAMEPLAY } GameScreen; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -GameScreen currentScreen; -Font font; - -Color *lightsMap; -int lightsMapWidth, lightsMapHeight; - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -//---------------------------------------------------------------------------------- -// raylib Logo Screen Functions Declaration -//---------------------------------------------------------------------------------- -void rlInitLogoScreen(void); -void rlUpdateLogoScreen(void); -void rlDrawLogoScreen(void); -void rlUnloadLogoScreen(void); -int rlFinishLogoScreen(void); - -//---------------------------------------------------------------------------------- -// Title Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitTitleScreen(void); -void UpdateTitleScreen(void); -void DrawTitleScreen(void); -void UnloadTitleScreen(void); -int FinishTitleScreen(void); - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitGameplayScreen(void); -void UpdateGameplayScreen(void); -void DrawGameplayScreen(void); -void UnloadGameplayScreen(void); -int FinishGameplayScreen(void); - -#ifdef __cplusplus -} -#endif - -#endif // SCREENS_H \ No newline at end of file diff --git a/games/missile_commander.c b/games/missile_commander.c deleted file mode 100644 index 0d7886c70..000000000 --- a/games/missile_commander.c +++ /dev/null @@ -1,532 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: missile commander -* -* Sample game Marc Palau and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include -#include -#include -#include - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Some Defines -//---------------------------------------------------------------------------------- -#define MAX_MISSILES 100 -#define MAX_INTERCEPTORS 30 -#define MAX_EXPLOSIONS 100 -#define LAUNCHERS_AMOUNT 3 // Not a variable, should not be changed -#define BUILDINGS_AMOUNT 6 // Not a variable, should not be changed - -#define LAUNCHER_SIZE 80 -#define BUILDING_SIZE 60 -#define EXPLOSION_RADIUS 40 - -#define MISSILE_SPEED 1 -#define MISSILE_LAUNCH_FRAMES 80 -#define INTERCEPTOR_SPEED 10 -#define EXPLOSION_INCREASE_TIME 90 // In frames -#define EXPLOSION_TOTAL_TIME 210 // In frames - -#define EXPLOSION_COLOR (Color){ 125, 125, 125, 125 } - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef struct Missile { - Vector2 origin; - Vector2 position; - Vector2 objective; - Vector2 speed; - - bool active; -} Missile; - -typedef struct Interceptor { - Vector2 origin; - Vector2 position; - Vector2 objective; - Vector2 speed; - - bool active; -} Interceptor; - -typedef struct Explosion { - Vector2 position; - float radiusMultiplier; - int frame; - bool active; -} Explosion; - -typedef struct Launcher { - Vector2 position; - bool active; -} Launcher; - -typedef struct Building { - Vector2 position; - bool active; -} Building; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static int screenWidth = 800; -static int screenHeight = 450; - -static int framesCounter = 0; -static bool gameOver = false; -static bool pause = false; -static int score = 0; - -static Missile missile[MAX_MISSILES] = { 0 }; -static Interceptor interceptor[MAX_INTERCEPTORS] = { 0 }; -static Explosion explosion[MAX_EXPLOSIONS] = { 0 }; -static Launcher launcher[LAUNCHERS_AMOUNT] = { 0 }; -static Building building[BUILDINGS_AMOUNT] = { 0 }; -static int explosionIndex = 0; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -// Additional module functions -static void UpdateOutgoingFire(); -static void UpdateIncomingFire(); - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: missile commander"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//-------------------------------------------------------------------------------------- -// Game Module Functions Definition -//-------------------------------------------------------------------------------------- - -// Initialize game variables -void InitGame(void) -{ - // Initialize missiles - for (int i = 0; i < MAX_MISSILES; i++) - { - missile[i].origin = (Vector2){ 0, 0 }; - missile[i].speed = (Vector2){ 0, 0 }; - missile[i].position = (Vector2){ 0, 0 }; - - missile[i].active = false; - } - - // Initialize interceptors - for (int i = 0; i < MAX_INTERCEPTORS; i++) - { - interceptor[i].origin = (Vector2){ 0, 0 }; - interceptor[i].speed = (Vector2){ 0, 0 }; - interceptor[i].position = (Vector2){ 0, 0 }; - - interceptor[i].active = false; - } - - // Initialize explosions - for (int i = 0; i < MAX_EXPLOSIONS; i++) - { - explosion[i].position = (Vector2){ 0, 0 }; - explosion[i].frame = 0; - explosion[i].active = false; - } - - // Initialize buildings and launchers - int sparcing = screenWidth/(LAUNCHERS_AMOUNT + BUILDINGS_AMOUNT + 1); - - // Buildings and launchers placing - launcher[0].position = (Vector2){ 1*sparcing, screenHeight - LAUNCHER_SIZE/2 }; - building[0].position = (Vector2){ 2*sparcing, screenHeight - BUILDING_SIZE/2 }; - building[1].position = (Vector2){ 3*sparcing, screenHeight - BUILDING_SIZE/2 }; - building[2].position = (Vector2){ 4*sparcing, screenHeight - BUILDING_SIZE/2 }; - launcher[1].position = (Vector2){ 5*sparcing, screenHeight - LAUNCHER_SIZE/2 }; - building[3].position = (Vector2){ 6*sparcing, screenHeight - BUILDING_SIZE/2 }; - building[4].position = (Vector2){ 7*sparcing, screenHeight - BUILDING_SIZE/2 }; - building[5].position = (Vector2){ 8*sparcing, screenHeight - BUILDING_SIZE/2 }; - launcher[2].position = (Vector2){ 9*sparcing, screenHeight - LAUNCHER_SIZE/2 }; - - // Buildings and launchers activation - for (int i = 0; i < LAUNCHERS_AMOUNT; i++) launcher[i].active = true; - for (int i = 0; i < BUILDINGS_AMOUNT; i++) building[i].active = true; - - // Initialize game variables - score = 0; -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - framesCounter++; - - static - float distance; - - // Interceptors update - for (int i = 0; i < MAX_INTERCEPTORS; i++) - { - if (interceptor[i].active) - { - // Update position - interceptor[i].position.x += interceptor[i].speed.x; - interceptor[i].position.y += interceptor[i].speed.y; - - // Distance to objective - distance = sqrt( pow(interceptor[i].position.x - interceptor[i].objective.x, 2) + - pow(interceptor[i].position.y - interceptor[i].objective.y, 2)); - - if (distance < INTERCEPTOR_SPEED) - { - // Interceptor dissapears - interceptor[i].active = false; - - // Explosion - explosion[explosionIndex].position = interceptor[i].position; - explosion[explosionIndex].active = true; - explosion[explosionIndex].frame = 0; - explosionIndex++; - if (explosionIndex == MAX_EXPLOSIONS) explosionIndex = 0; - - break; - } - } - } - - // Missiles update - for (int i = 0; i < MAX_MISSILES; i++) - { - if (missile[i].active) - { - // Update position - missile[i].position.x += missile[i].speed.x; - missile[i].position.y += missile[i].speed.y; - - // Collision and missile out of bounds - if (missile[i].position.y > screenHeight) missile[i].active = false; - else - { - // CHeck collision with launchers - for (int j = 0; j < LAUNCHERS_AMOUNT; j++) - { - if (launcher[j].active) - { - if (CheckCollisionPointRec(missile[i].position, (Rectangle){ launcher[j].position.x - LAUNCHER_SIZE/2, launcher[j].position.y - LAUNCHER_SIZE/2, - LAUNCHER_SIZE, LAUNCHER_SIZE })) - { - // Missile dissapears - missile[i].active = false; - - // Explosion and destroy building - launcher[j].active = false; - - explosion[explosionIndex].position = missile[i].position; - explosion[explosionIndex].active = true; - explosion[explosionIndex].frame = 0; - explosionIndex++; - if (explosionIndex == MAX_EXPLOSIONS) explosionIndex = 0; - - break; - } - } - } - - // CHeck collision with buildings - for (int j = 0; j < BUILDINGS_AMOUNT; j++) - { - if (building[j].active) - { - if (CheckCollisionPointRec(missile[i].position, (Rectangle){ building[j].position.x - BUILDING_SIZE/2, building[j].position.y - BUILDING_SIZE/2, - BUILDING_SIZE, BUILDING_SIZE })) - { - // Missile dissapears - missile[i].active = false; - - // Explosion and destroy building - building[j].active = false; - - explosion[explosionIndex].position = missile[i].position; - explosion[explosionIndex].active = true; - explosion[explosionIndex].frame = 0; - explosionIndex++; - if (explosionIndex == MAX_EXPLOSIONS) explosionIndex = 0; - - break; - } - } - } - - // CHeck collision with explosions - for (int j = 0; j < MAX_EXPLOSIONS; j++) - { - if (explosion[j].active) - { - if (CheckCollisionPointCircle(missile[i].position, explosion[j].position, EXPLOSION_RADIUS*explosion[j].radiusMultiplier)) - { - // Missile dissapears and we earn 100 points - missile[i].active = false; - score += 100; - - explosion[explosionIndex].position = missile[i].position; - explosion[explosionIndex].active = true; - explosion[explosionIndex].frame = 0; - explosionIndex++; - if (explosionIndex == MAX_EXPLOSIONS) explosionIndex = 0; - - break; - } - } - } - } - } - } - - // Explosions update - for (int i = 0; i < MAX_EXPLOSIONS; i++) - { - if (explosion[i].active) - { - explosion[i].frame++; - - if (explosion[i].frame <= EXPLOSION_INCREASE_TIME) explosion[i].radiusMultiplier = explosion[i].frame/(float)EXPLOSION_INCREASE_TIME; - else if (explosion[i].frame <= EXPLOSION_TOTAL_TIME) explosion[i].radiusMultiplier = 1 - (explosion[i].frame - (float)EXPLOSION_INCREASE_TIME)/(float)EXPLOSION_TOTAL_TIME; - else - { - explosion[i].frame = 0; - explosion[i].active = false; - } - } - } - - // Fire logic - UpdateOutgoingFire(); - UpdateIncomingFire(); - - // Game over logic - int checker = 0; - - for (int i = 0; i < LAUNCHERS_AMOUNT; i++) - { - if (!launcher[i].active) checker++; - if (checker == LAUNCHERS_AMOUNT) gameOver = true; - } - - checker = 0; - for (int i = 0; i < BUILDINGS_AMOUNT; i++) - { - if (!building[i].active) checker++; - if (checker == BUILDINGS_AMOUNT) gameOver = true; - } - } - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - // Draw missiles - for (int i = 0; i < MAX_MISSILES; i++) - { - if (missile[i].active) - { - DrawLine(missile[i].origin.x, missile[i].origin.y, missile[i].position.x, missile[i].position.y, RED); - - if (framesCounter % 16 < 8) DrawCircle(missile[i].position.x, missile[i].position.y, 3, YELLOW); - } - } - - // Draw interceptors - for (int i = 0; i < MAX_INTERCEPTORS; i++) - { - if (interceptor[i].active) - { - DrawLine(interceptor[i].origin.x, interceptor[i].origin.y, interceptor[i].position.x, interceptor[i].position.y, GREEN); - - if (framesCounter % 16 < 8) DrawCircle(interceptor[i].position.x, interceptor[i].position.y, 3, BLUE); - } - } - - // Draw explosions - for (int i = 0; i < MAX_EXPLOSIONS; i++) - { - if (explosion[i].active) DrawCircle(explosion[i].position.x, explosion[i].position.y, EXPLOSION_RADIUS*explosion[i].radiusMultiplier, EXPLOSION_COLOR); - } - - // Draw buildings and launchers - for (int i = 0; i < LAUNCHERS_AMOUNT; i++) - { - if (launcher[i].active) DrawRectangle(launcher[i].position.x - LAUNCHER_SIZE/2, launcher[i].position.y - LAUNCHER_SIZE/2, LAUNCHER_SIZE, LAUNCHER_SIZE, GRAY); - } - - for (int i = 0; i < BUILDINGS_AMOUNT; i++) - { - if (building[i].active) DrawRectangle(building[i].position.x - BUILDING_SIZE/2, building[i].position.y - BUILDING_SIZE/2, BUILDING_SIZE, BUILDING_SIZE, LIGHTGRAY); - } - - // Draw score - DrawText(TextFormat("SCORE %4i", score), 20, 20, 40, LIGHTGRAY); - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); - - EndDrawing(); -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} - -//-------------------------------------------------------------------------------------- -// Additional module functions -//-------------------------------------------------------------------------------------- -static void UpdateOutgoingFire() -{ - static int interceptorNumber = 0; - int launcherShooting = 0; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) launcherShooting = 1; - if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) launcherShooting = 2; - if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) launcherShooting = 3; - - if (launcherShooting > 0 && launcher[launcherShooting - 1].active) - { - float module; - float sideX; - float sideY; - - // Activate the interceptor - interceptor[interceptorNumber].active = true; - - // Assign start position - interceptor[interceptorNumber].origin = launcher[launcherShooting - 1].position; - interceptor[interceptorNumber].position = interceptor[interceptorNumber].origin; - interceptor[interceptorNumber].objective = GetMousePosition(); - - // Calculate speed - module = sqrt( pow(interceptor[interceptorNumber].objective.x - interceptor[interceptorNumber].origin.x, 2) + - pow(interceptor[interceptorNumber].objective.y - interceptor[interceptorNumber].origin.y, 2)); - - sideX = (interceptor[interceptorNumber].objective.x - interceptor[interceptorNumber].origin.x)*INTERCEPTOR_SPEED/module; - sideY = (interceptor[interceptorNumber].objective.y - interceptor[interceptorNumber].origin.y)*INTERCEPTOR_SPEED/module; - - interceptor[interceptorNumber].speed = (Vector2){ sideX, sideY }; - - // Update - interceptorNumber++; - if (interceptorNumber == MAX_INTERCEPTORS) interceptorNumber = 0; - } -} - -static void UpdateIncomingFire() -{ - static int missileIndex = 0; - - // Launch missile - if (framesCounter%MISSILE_LAUNCH_FRAMES == 0) - { - float module; - float sideX; - float sideY; - - // Activate the missile - missile[missileIndex].active = true; - - // Assign start position - missile[missileIndex].origin = (Vector2){ GetRandomValue(20, screenWidth - 20), -10 }; - missile[missileIndex].position = missile[missileIndex].origin; - missile[missileIndex].objective = (Vector2){ GetRandomValue(20, screenWidth - 20), screenHeight + 10 }; - - // Calculate speed - module = sqrt( pow(missile[missileIndex].objective.x - missile[missileIndex].origin.x, 2) + - pow(missile[missileIndex].objective.y - missile[missileIndex].origin.y, 2)); - - sideX = (missile[missileIndex].objective.x - missile[missileIndex].origin.x)*MISSILE_SPEED/module; - sideY = (missile[missileIndex].objective.y - missile[missileIndex].origin.y)*MISSILE_SPEED/module; - - missile[missileIndex].speed = (Vector2){ sideX, sideY }; - - // Update - missileIndex++; - if (missileIndex == MAX_MISSILES) missileIndex = 0; - } -} diff --git a/games/pang.c b/games/pang.c deleted file mode 100644 index 20c4093e9..000000000 --- a/games/pang.c +++ /dev/null @@ -1,624 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: pang -* -* Sample game developed by Ian Eito and Albert Martos and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Some Defines -//---------------------------------------------------------------------------------- -#define PLAYER_BASE_SIZE 20.0f -#define PLAYER_SPEED 5.0f -#define PLAYER_MAX_SHOOTS 1 - -#define MAX_BIG_BALLS 2 -#define BALLS_SPEED 2.0f - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef struct Player { - Vector2 position; - Vector2 speed; - Vector3 collider; - float rotation; -} Player; - -typedef struct Shoot { - Vector2 position; - Vector2 speed; - float radius; - float rotation; - int lifeSpawn; - bool active; -} Shoot; - -typedef struct Ball { - Vector2 position; - Vector2 speed; - float radius; - int points; - bool active; -} Ball; - -typedef struct Points { - Vector2 position; - int value; - float alpha; -} Points; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static const int screenWidth = 800; -static const int screenHeight = 450; - -static int framesCounter = 0; -static bool gameOver = false; -static bool pause = false; -static int score = 0; - -static Player player = { 0 }; -static Shoot shoot[PLAYER_MAX_SHOOTS] = { 0 }; -static Ball bigBalls[MAX_BIG_BALLS] = { 0 }; -static Ball mediumBalls[MAX_BIG_BALLS*2] = { 0 }; -static Ball smallBalls[MAX_BIG_BALLS*4] = { 0 }; -static Points points[5] = { 0 }; - -// NOTE: Defined triangle is isosceles with common angles of 70 degrees. -static float shipHeight = 0.0f; -static float gravity = 0.0f; - -static int countmediumBallss = 0; -static int countsmallBallss = 0; -static int meteorsDestroyed = 0; -static Vector2 linePosition = { 0 }; - -static bool victory = false; -static bool lose = false; -static bool awake = false; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: pang"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Initialize game variables -static void InitGame(void) -{ - int posx, posy; - int velx = 0; - int vely = 0; - - framesCounter = 0; - gameOver = false; - pause = false; - score = 0; - - victory = false; - lose = false; - awake = true; - gravity = 0.25f; - - linePosition = (Vector2){ 0.0f , 0.0f }; - shipHeight = (PLAYER_BASE_SIZE/2)/tanf(20*DEG2RAD); - - // Initialization player - player.position = (Vector2){ screenWidth/2, screenHeight }; - player.speed = (Vector2){ PLAYER_SPEED, PLAYER_SPEED }; - player.rotation = 0; - player.collider = (Vector3){ player.position.x, player.position.y - shipHeight/2.0f, 12.0f }; - - meteorsDestroyed = 0; - - // Initialize shoots - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - shoot[i].position = (Vector2){ 0, 0 }; - shoot[i].speed = (Vector2){ 0, 0 }; - shoot[i].radius = 2; - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - } - - // Initialize big meteors - for (int i = 0; i < MAX_BIG_BALLS; i++) - { - bigBalls[i].radius = 40.0f; - posx = GetRandomValue(0 + bigBalls[i].radius, screenWidth - bigBalls[i].radius); - posy = GetRandomValue(0 + bigBalls[i].radius, screenHeight/2); - - bigBalls[i].position = (Vector2){ posx, posy }; - - while ((velx == 0) || (vely == 0)) - { - velx = GetRandomValue(-BALLS_SPEED, BALLS_SPEED); - vely = GetRandomValue(-BALLS_SPEED, BALLS_SPEED); - } - - bigBalls[i].speed = (Vector2){ velx, vely }; - bigBalls[i].points = 200; - bigBalls[i].active = true; - } - - // Initialize medium meteors - for (int i = 0; i < MAX_BIG_BALLS*2; i++) - { - mediumBalls[i].position = (Vector2){-100, -100}; - mediumBalls[i].speed = (Vector2){0,0}; - mediumBalls[i].radius = 20.0f; - mediumBalls[i].points = 100; - mediumBalls[i].active = false; - } - - // Initialize small meteors - for (int i = 0; i < MAX_BIG_BALLS*4; i++) - { - smallBalls[i].position = (Vector2){ -100, -100 }; - smallBalls[i].speed = (Vector2){ 0, 0 }; - smallBalls[i].radius = 10.0f; - smallBalls[i].points = 50; - smallBalls[i].active = false; - } - - // Initialize animated points - for (int i = 0; i < 5; i++) - { - points[i].position = (Vector2){ 0, 0 }; - points[i].value = 0; - points[i].alpha = 0.0f; - } - - countmediumBallss = 0; - countsmallBallss = 0; -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver && !victory) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - // Player logic - if (IsKeyDown(KEY_LEFT)) player.position.x -= player.speed.x; - if (IsKeyDown(KEY_RIGHT)) player.position.x += player.speed.x; - - // Player vs wall collision logic - if (player.position.x + PLAYER_BASE_SIZE/2 > screenWidth) player.position.x = screenWidth - PLAYER_BASE_SIZE/2; - else if (player.position.x - PLAYER_BASE_SIZE/2 < 0) player.position.x = 0 + PLAYER_BASE_SIZE/2; - - // Player shot logic - if (IsKeyPressed(KEY_SPACE)) - { - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - if (!shoot[i].active) - { - shoot[i].position = (Vector2){ player.position.x, player.position.y - shipHeight }; - shoot[i].speed.y = PLAYER_SPEED; - shoot[i].active = true; - - linePosition = (Vector2){ player.position.x, player.position.y}; - - break; - } - } - } - - // Shoot life timer - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - if (shoot[i].active) shoot[i].lifeSpawn++; - } - - // Shot logic - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - if (shoot[i].active) - { - shoot[i].position.y -= shoot[i].speed.y; - - // Shot vs walls collision logic - if ((shoot[i].position.x > screenWidth + shoot[i].radius) || (shoot[i].position.x < 0 - shoot[i].radius) || - (shoot[i].position.y > screenHeight + shoot[i].radius) || (shoot[i].position.y < 0 - shoot[i].radius)) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - } - - // Player shot life spawn - if (shoot[i].lifeSpawn >= 120) - { - shoot[i].position = (Vector2){ 0.0f, 0.0f }; - shoot[i].speed = (Vector2){ 0.0f, 0.0f }; - shoot[i].lifeSpawn = 0; - shoot[i].active = false; - } - } - } - - // Player vs meteors collision logic - player.collider = (Vector3){player.position.x, player.position.y - shipHeight/2, 12}; - - for (int i = 0; i < MAX_BIG_BALLS; i++) - { - if (CheckCollisionCircles((Vector2){ player.collider.x, player.collider.y }, player.collider.z, bigBalls[i].position, bigBalls[i].radius) && bigBalls[i].active) - { - gameOver = true; - } - } - - for (int i = 0; i < MAX_BIG_BALLS*2; i++) - { - if (CheckCollisionCircles((Vector2){ player.collider.x, player.collider.y }, player.collider.z, mediumBalls[i].position, mediumBalls[i].radius) && mediumBalls[i].active) - { - gameOver = true; - } - } - - for (int i = 0; i < MAX_BIG_BALLS*4; i++) - { - if (CheckCollisionCircles((Vector2){ player.collider.x, player.collider.y }, player.collider.z, smallBalls[i].position, smallBalls[i].radius) && smallBalls[i].active) - { - gameOver = true; - } - } - - // Meteors logic (big) - for (int i = 0; i < MAX_BIG_BALLS; i++) - { - if (bigBalls[i].active) - { - // Meteor movement logic - bigBalls[i].position.x += bigBalls[i].speed.x; - bigBalls[i].position.y += bigBalls[i].speed.y; - - // Meteor vs wall collision logic - if (((bigBalls[i].position.x + bigBalls[i].radius) >= screenWidth) || ((bigBalls[i].position.x - bigBalls[i].radius) <= 0)) bigBalls[i].speed.x *= -1; - if ((bigBalls[i].position.y - bigBalls[i].radius) <= 0) bigBalls[i].speed.y *= -1.5; - - if ((bigBalls[i].position.y + bigBalls[i].radius) >= screenHeight) - { - bigBalls[i].speed.y *= -1; - bigBalls[i].position.y = screenHeight - bigBalls[i].radius; - } - - bigBalls[i].speed.y += gravity; - } - } - - // Meteors logic (medium) - for (int i = 0; i < MAX_BIG_BALLS*2; i++) - { - if (mediumBalls[i].active) - { - // Meteor movement logic - mediumBalls[i].position.x += mediumBalls[i].speed.x; - mediumBalls[i].position.y += mediumBalls[i].speed.y; - - // Meteor vs wall collision logic - if (mediumBalls[i].position.x + mediumBalls[i].radius >= screenWidth || mediumBalls[i].position.x - mediumBalls[i].radius <= 0) mediumBalls[i].speed.x *= -1; - if (mediumBalls[i].position.y - mediumBalls[i].radius <= 0) mediumBalls[i].speed.y *= -1; - if (mediumBalls[i].position.y + mediumBalls[i].radius >= screenHeight) - { - mediumBalls[i].speed.y *= -1; - mediumBalls[i].position.y = screenHeight - mediumBalls[i].radius; - } - - mediumBalls[i].speed.y += gravity + 0.12f; - } - } - - // Meteors logic (small) - for (int i = 0; i < MAX_BIG_BALLS*4; i++) - { - if (smallBalls[i].active) - { - // Meteor movement logic - smallBalls[i].position.x += smallBalls[i].speed.x; - smallBalls[i].position.y += smallBalls[i].speed.y; - - // Meteor vs wall collision logic - if (smallBalls[i].position.x + smallBalls[i].radius >= screenWidth || smallBalls[i].position.x - smallBalls[i].radius <= 0) smallBalls[i].speed.x *= -1; - if (smallBalls[i].position.y - smallBalls[i].radius <= 0) smallBalls[i].speed.y *= -1; - if (smallBalls[i].position.y + smallBalls[i].radius >= screenHeight) - { - smallBalls[i].speed.y *= -1; - smallBalls[i].position.y = screenHeight - smallBalls[i].radius; - } - - smallBalls[i].speed.y += gravity + 0.25f; - } - } - - // Player-shot vs meteors logic - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - if ((shoot[i].active)) - { - for (int a = 0; a < MAX_BIG_BALLS; a++) - { - if (bigBalls[a].active && (bigBalls[a].position.x - bigBalls[a].radius <= linePosition.x && bigBalls[a].position.x + bigBalls[a].radius >= linePosition.x) - && (bigBalls[a].position.y + bigBalls[a].radius >= shoot[i].position.y)) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - bigBalls[a].active = false; - meteorsDestroyed++; - score += bigBalls[a].points; - - for (int z = 0; z < 5; z++) - { - if (points[z].alpha == 0.0f) - { - points[z].position = bigBalls[a].position; - points[z].value = bigBalls[a].points; - points[z].alpha = 1.0f; - z = 5; - } - } - - for (int j = 0; j < 2; j ++) - { - if ((countmediumBallss%2) == 0) - { - mediumBalls[countmediumBallss].position = (Vector2){bigBalls[a].position.x, bigBalls[a].position.y}; - mediumBalls[countmediumBallss].speed = (Vector2){ -1*BALLS_SPEED, BALLS_SPEED }; - } - else - { - mediumBalls[countmediumBallss].position = (Vector2){bigBalls[a].position.x, bigBalls[a].position.y}; - mediumBalls[countmediumBallss].speed = (Vector2){ BALLS_SPEED, BALLS_SPEED }; - } - - mediumBalls[countmediumBallss].active = true; - countmediumBallss ++; - } - - a = MAX_BIG_BALLS; - } - } - } - - if ((shoot[i].active)) - { - for (int b = 0; b < MAX_BIG_BALLS*2; b++) - { - if (mediumBalls[b].active && (mediumBalls[b].position.x - mediumBalls[b].radius <= linePosition.x && mediumBalls[b].position.x + mediumBalls[b].radius >= linePosition.x) - && (mediumBalls[b].position.y + mediumBalls[b].radius >= shoot[i].position.y)) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - mediumBalls[b].active = false; - meteorsDestroyed++; - score += mediumBalls[b].points; - - for (int z = 0; z < 5; z++) - { - if (points[z].alpha == 0.0f) - { - points[z].position = mediumBalls[b].position; - points[z].value = mediumBalls[b].points; - points[z].alpha = 1.0f; - z = 5; - } - } - - for (int j = 0; j < 2; j ++) - { - if (countsmallBallss%2 == 0) - { - smallBalls[countsmallBallss].position = (Vector2){mediumBalls[b].position.x, mediumBalls[b].position.y}; - smallBalls[countsmallBallss].speed = (Vector2){ BALLS_SPEED*-1, BALLS_SPEED*-1}; - } - else - { - smallBalls[countsmallBallss].position = (Vector2){mediumBalls[b].position.x, mediumBalls[b].position.y}; - smallBalls[countsmallBallss].speed = (Vector2){ BALLS_SPEED, BALLS_SPEED*-1}; - } - - smallBalls[countsmallBallss].active = true; - countsmallBallss ++; - } - - b = MAX_BIG_BALLS*2; - } - } - } - - if ((shoot[i].active)) - { - for (int c = 0; c < MAX_BIG_BALLS*4; c++) - { - if (smallBalls[c].active && (smallBalls[c].position.x - smallBalls[c].radius <= linePosition.x && smallBalls[c].position.x + smallBalls[c].radius >= linePosition.x) - && (smallBalls[c].position.y + smallBalls[c].radius >= shoot[i].position.y)) - { - shoot[i].active = false; - shoot[i].lifeSpawn = 0; - smallBalls[c].active = false; - meteorsDestroyed++; - score += smallBalls[c].points; - - for (int z = 0; z < 5; z++) - { - if (points[z].alpha == 0.0f) - { - points[z].position = smallBalls[c].position; - points[z].value = smallBalls[c].points; - points[z].alpha = 1.0f; - z = 5; - } - } - - c = MAX_BIG_BALLS*4; - } - } - } - } - - if (meteorsDestroyed == (MAX_BIG_BALLS + MAX_BIG_BALLS*2 + MAX_BIG_BALLS*4)) victory = true; - } - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } - - // Points move-up and fade logic - for (int z = 0; z < 5; z++) - { - if (points[z].alpha > 0.0f) - { - points[z].position.y -= 2; - points[z].alpha -= 0.02f; - } - - if (points[z].alpha < 0.0f) points[z].alpha = 0.0f; - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - // Draw player - Vector2 v1 = { player.position.x + sinf(player.rotation*DEG2RAD)*(shipHeight), player.position.y - cosf(player.rotation*DEG2RAD)*(shipHeight) }; - Vector2 v2 = { player.position.x - cosf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2), player.position.y - sinf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2) }; - Vector2 v3 = { player.position.x + cosf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2), player.position.y + sinf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2) }; - DrawTriangle(v1, v2, v3, MAROON); - - // Draw meteors (big) - for (int i = 0;i < MAX_BIG_BALLS; i++) - { - if (bigBalls[i].active) DrawCircleV(bigBalls[i].position, bigBalls[i].radius, DARKGRAY); - else DrawCircleV(bigBalls[i].position, bigBalls[i].radius, Fade(LIGHTGRAY, 0.3f)); - } - - // Draw meteors (medium) - for (int i = 0;i < MAX_BIG_BALLS*2; i++) - { - if (mediumBalls[i].active) DrawCircleV(mediumBalls[i].position, mediumBalls[i].radius, GRAY); - else DrawCircleV(mediumBalls[i].position, mediumBalls[i].radius, Fade(LIGHTGRAY, 0.3f)); - } - - // Draw meteors (small) - for (int i = 0;i < MAX_BIG_BALLS*4; i++) - { - if (smallBalls[i].active) DrawCircleV(smallBalls[i].position, smallBalls[i].radius, GRAY); - else DrawCircleV(smallBalls[i].position, smallBalls[i].radius, Fade(LIGHTGRAY, 0.3f)); - } - - // Draw shoot - for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) - { - if (shoot[i].active) DrawLine(linePosition.x, linePosition.y, shoot[i].position.x, shoot[i].position.y, RED); - } - - // Draw score points - for (int z = 0; z < 5; z++) - { - if (points[z].alpha > 0.0f) - { - DrawText(TextFormat("+%02i", points[z].value), points[z].position.x, points[z].position.y, 20, Fade(BLUE, points[z].alpha)); - } - } - - // Draw score (UI) - DrawText(TextFormat("SCORE: %i", score), 10, 10, 20, LIGHTGRAY); - - if (victory) - { - DrawText("YOU WIN!", screenWidth/2 - MeasureText("YOU WIN!", 60)/2, 100, 60, LIGHTGRAY); - DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, LIGHTGRAY); - } - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, LIGHTGRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, LIGHTGRAY); - - EndDrawing(); -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} diff --git a/games/repair/LICENSE.txt b/games/repair/LICENSE.txt deleted file mode 100644 index d8fb27384..000000000 --- a/games/repair/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ - -This game sources are licensed under an unmodified zlib/libpng license, -which is an OSI-certified, BSD-like license: - -Copyright (c) 2020 Ramon Santamaria (@raysan5) - -This software is provided "as-is", without any express or implied warranty. In no event -will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial -applications, and to alter it and redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not claim that you - wrote the original software. If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be misrepresented - as being the original software. - - 3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/games/repair/Makefile b/games/repair/Makefile deleted file mode 100644 index 63cb45c3a..000000000 --- a/games/repair/Makefile +++ /dev/null @@ -1,406 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= repair -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= C:\GitHub\raylib - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - # -Wl,--subsystem,windows hides the console window - ifeq ($(BUILD_MODE), RELEASE) - LDFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -PROJECT_SOURCE_FILES ?= \ - repair.c \ - screens/screen_logo.c \ - screens/screen_title.c \ - screens/screen_gameplay.c \ - screens/screen_ending.c - -# Define all object files from source files -OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) - -# For Android platform we call a custom Makefile.Android -ifeq ($(PLATFORM),PLATFORM_ANDROID) - MAKEFILE_PARAMS = -f Makefile.Android - export PROJECT_NAME - export PROJECT_SOURCE_FILES -else - MAKEFILE_PARAMS = $(PROJECT_NAME) -endif - -# Default target entry -# NOTE: We call this Makefile target or Makefile.Android target -all: - $(MAKE) $(MAKEFILE_PARAMS) - -# Project target defined by PROJECT_NAME -$(PROJECT_NAME): $(OBJS) - $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) - -# Compile source files -# NOTE: This pattern will compile every module defined on $(OBJS) -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/repair/repair.c b/games/repair/repair.c deleted file mode 100644 index 437f94f65..000000000 --- a/games/repair/repair.c +++ /dev/null @@ -1,413 +0,0 @@ -/******************************************************************************************* -* -* RE_PAIR [GLOBAL GAME JAM 2020] -* -* Let's find your perfect match! -* Ready for dating? Do you need some face tweaks? Choose wisely! -* -* This game has been created using raylib 3.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2020 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include "screens/screens.h" // NOTE: Defines global variable: currentScreen - -#if defined(PLATFORM_WEB) - #include -#endif - -GameScreen currentScreen = 0; -Font font = { 0 }; -Music music = { 0 }; -Sound fxCoin = { 0 }; -Texture2D background = { 0 }; -Texture2D texNPatch = { 0 }; -NPatchInfo npInfo = { 0 }; - -Texture2D texHead, texHair, texNose, texMouth, texEyes, texComp; - -Character playerBase = { 0 }; -Character datingBase = { 0 }; - -Character player = { 0 }; -Character dating = { 0 }; - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- -const int screenWidth = 1280; -const int screenHeight = 720; - -// Required variables to manage screen transitions (fade-in, fade-out) -static float transAlpha = 0.0f; -static bool onTransition = false; -static bool transFadeOut = false; -static int transFromScreen = -1; -static int transToScreen = -1; - -// NOTE: Some global variables that require to be visible for all screens, -// are defined in screens.h (i.e. currentScreen) - -//---------------------------------------------------------------------------------- -// Local Functions Declaration -//---------------------------------------------------------------------------------- -static void ChangeToScreen(int screen); // No transition effect - -static void TransitionToScreen(int screen); -static void UpdateTransition(void); -static void DrawTransition(void); - -static void UpdateDrawFrame(void); // Update and Draw one frame - -//---------------------------------------------------------------------------------- -// Main entry point -//---------------------------------------------------------------------------------- -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "RE-PAIR [GGJ2020]"); - - // Global data loading (assets that must be available in all screens, i.e. fonts) - InitAudioDevice(); - - font = LoadFont("resources/font.png"); - SetTextureFilter(font.texture, FILTER_BILINEAR); - - music = LoadMusicStream("resources/elevator_romance.ogg"); - fxCoin = LoadSound("resources/coin.wav"); - - background = LoadTexture("resources/background.png"); - - texNPatch = LoadTexture("resources/npatch.png"); - npInfo.sourceRec = (Rectangle){ 0, 0, 80, texNPatch.height }, - npInfo.left = 24; - npInfo.top = 24; - npInfo.right = 24; - npInfo.bottom = 24; - - // Load required textures - texHead = LoadTexture("resources/head_models.png"); - texHair = LoadTexture("resources/hair_models.png"); - texNose = LoadTexture("resources/nose_models.png"); - texMouth = LoadTexture("resources/mouth_models.png"); - texEyes = LoadTexture("resources/eyes_models.png"); - //texComp = LoadTexture("resources/comp_models.png"); - - SetMusicVolume(music, 0.5f); - //PlayMusicStream(music); - - // Setup and Init first screen - currentScreen = LOGO; - InitLogoScreen(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - UpdateDrawFrame(); - } -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload current screen data before closing - switch (currentScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Unload all global loaded data (i.e. fonts) here! - UnloadFont(font); - UnloadMusicStream(music); - UnloadSound(fxCoin); - UnloadTexture(background); - UnloadTexture(texNPatch); - - UnloadTexture(texHead); - UnloadTexture(texHair); - UnloadTexture(texNose); - UnloadTexture(texMouth); - UnloadTexture(texEyes); - //UnloadTexture(texComp); - - CloseAudioDevice(); // Close audio context - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//---------------------------------------------------------------------------------- -// Public Functions Definition -//---------------------------------------------------------------------------------- - -Character GenerateCharacter(void) -{ - Character character = { 0 }; - - // Generate player character! - character.head = GetRandomValue(0, texHead.width/BASE_HEAD_WIDTH - 1); - character.colHead = headColors[GetRandomValue(0, 5)]; - character.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH - 1); - character.colHair = hairColors[GetRandomValue(0, 9)]; - character.eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH - 1); - character.nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH - 1); - character.mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH - 1); - - // NOTE: No character customization at this point - - return character; -} - -void CustomizeCharacter(Character *character) -{ - if (GetRandomValue(0, 1)) character->hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH - 1); - if (GetRandomValue(0, 1)) character->colHair = hairColors[GetRandomValue(0, 9)]; - if (GetRandomValue(0, 1)) character->eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH - 1); - if (GetRandomValue(0, 1)) character->nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH - 1); - if (GetRandomValue(0, 1)) character->mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH - 1); -} - -void DrawCharacter(Character character, Vector2 position) -{ - DrawTextureRec(texHair, (Rectangle){ BASE_HAIR_WIDTH*character.hair, 240, BASE_HAIR_WIDTH, texHair.height - 240 }, (Vector2){ position.x + (250 - BASE_HAIR_WIDTH)/2, position.y + 240 }, GetColor(character.colHair)); - DrawTextureRec(texHead, (Rectangle){ BASE_HEAD_WIDTH*character.head, 0, BASE_HEAD_WIDTH, texHead.height }, (Vector2){ position.x + (250 - BASE_HEAD_WIDTH)/2, position.y + 60 }, GetColor(character.colHead)); - DrawTextureRec(texHair, (Rectangle){ BASE_HAIR_WIDTH*character.hair, 0, BASE_HAIR_WIDTH, 240 }, (Vector2){ position.x + (250 - BASE_HAIR_WIDTH)/2, position.y }, GetColor(character.colHair)); - DrawTextureRec(texEyes, (Rectangle){ BASE_EYES_WIDTH*character.eyes, 0, BASE_EYES_WIDTH, texEyes.height }, (Vector2){ position.x + (250 - BASE_EYES_WIDTH)/2, position.y + 190 }, WHITE); - DrawTextureRec(texNose, (Rectangle){ BASE_NOSE_WIDTH*character.nose, 0, BASE_NOSE_WIDTH, texNose.height }, (Vector2){ position.x + (250 - BASE_NOSE_WIDTH)/2, position.y + 275 }, GetColor(character.colHead)); - DrawTextureRec(texMouth, (Rectangle){ BASE_MOUTH_WIDTH*character.mouth, 0, BASE_MOUTH_WIDTH, texMouth.height }, (Vector2){ position.x + (250 - BASE_MOUTH_WIDTH)/2, position.y + 370 }, GetColor(character.colHead)); -} - -// Gui Button -bool GuiButton(Rectangle bounds, const char *text, int forcedState) -{ - static const int textColor[4] = { 0xeff6ffff, 0x78e782ff, 0xb04d5fff, 0xd6d6d6ff }; - - int state = (forcedState >= 0)? forcedState : 0; // NORMAL - bool pressed = false; - Vector2 textSize = MeasureTextEx(font, text, font.baseSize, 1); - - // Update control - //-------------------------------------------------------------------- - if ((state < 3) && (forcedState < 0)) - { - Vector2 mousePoint = GetMousePosition(); - - // Check button state - if (CheckCollisionPointRec(mousePoint, bounds)) - { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = 2; // PRESSED - else state = 1; // FOCUSED - - if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON) || IsGestureDetected(GESTURE_TAP)) - { - pressed = true; - PlaySound(fxCoin); - } - } - } - - npInfo.sourceRec.x = 80*state; - - //-------------------------------------------------------------------- - - // Draw control - //-------------------------------------------------------------------- - //DrawRectangleRec(bounds, GREEN); - //DrawRectangleLinesEx(bounds, 4, DARKGREEN); - DrawTextureNPatch(texNPatch, npInfo, bounds, (Vector2){ 0.0f, 0.0f }, 0.0f, WHITE); - DrawTextEx(font, text, (Vector2){ bounds.x + bounds.width/2 - textSize.x/2, bounds.y + bounds.height/2 - textSize.y/2 + 4 }, font.baseSize, 1, GetColor(textColor[state])); - //------------------------------------------------------------------ - - return pressed; -} - -//---------------------------------------------------------------------------------- -// Module specific Functions Definition -//---------------------------------------------------------------------------------- - -// Change to next screen, no transition -static void ChangeToScreen(int screen) -{ - // Unload current screen - switch (currentScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Init next screen - switch (screen) - { - case LOGO: InitLogoScreen(); break; - case TITLE: InitTitleScreen(); break; - case GAMEPLAY: InitGameplayScreen(); break; - case ENDING: InitEndingScreen(); break; - default: break; - } - - currentScreen = screen; -} - -// Define transition to next screen -static void TransitionToScreen(int screen) -{ - onTransition = true; - transFadeOut = false; - transFromScreen = currentScreen; - transToScreen = screen; - transAlpha = 0.0f; -} - -// Update transition effect -static void UpdateTransition(void) -{ - if (!transFadeOut) - { - transAlpha += 0.05f; - - // NOTE: Due to float internal representation, condition jumps on 1.0f instead of 1.05f - // For that reason we compare against 1.01f, to avoid last frame loading stop - if (transAlpha > 1.01f) - { - transAlpha = 1.0f; - - // Unload current screen - switch (transFromScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Load next screen - switch (transToScreen) - { - case LOGO: InitLogoScreen(); break; - case TITLE: InitTitleScreen(); break; - case GAMEPLAY: InitGameplayScreen(); break; - case ENDING: InitEndingScreen(); break; - default: break; - } - - currentScreen = transToScreen; - - // Activate fade out effect to next loaded screen - transFadeOut = true; - } - } - else // Transition fade out logic - { - transAlpha -= 0.02f; - - if (transAlpha < -0.01f) - { - transAlpha = 0.0f; - transFadeOut = false; - onTransition = false; - transFromScreen = -1; - transToScreen = -1; - } - } -} - -// Draw transition effect (full-screen rectangle) -static void DrawTransition(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha)); -} - -// Update and draw game frame -static void UpdateDrawFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - UpdateMusicStream(music); // NOTE: Music keeps playing between screens - - if (!onTransition) - { - switch(currentScreen) - { - case LOGO: - { - UpdateLogoScreen(); - - if (FinishLogoScreen()) - { - TransitionToScreen(TITLE); - PlayMusicStream(music); - } - - } break; - case TITLE: - { - UpdateTitleScreen(); - - if (FinishTitleScreen() == 1) TransitionToScreen(GAMEPLAY); - //else if (FinishTitleScreen() == 2) TransitionToScreen(GAMEPLAY); - - } break; - case GAMEPLAY: - { - UpdateGameplayScreen(); - - if (FinishGameplayScreen() == 1) TransitionToScreen(ENDING); - //else if (FinishGameplayScreen() == 2) TransitionToScreen(TITLE); - - } break; - case ENDING: - { - UpdateEndingScreen(); - - if (FinishEndingScreen() == 1) TransitionToScreen(TITLE); - - } break; - default: break; - } - } - else UpdateTransition(); // Update transition (fade-in, fade-out) - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch(currentScreen) - { - case LOGO: DrawLogoScreen(); break; - case TITLE: DrawTitleScreen(); break; - case GAMEPLAY: DrawGameplayScreen(); break; - case ENDING: DrawEndingScreen(); break; - default: break; - } - - // Draw full screen rectangle in front of everything - if (onTransition) DrawTransition(); - - //DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- -} diff --git a/games/repair/resources/background.png b/games/repair/resources/background.png deleted file mode 100644 index ecd8969fe..000000000 Binary files a/games/repair/resources/background.png and /dev/null differ diff --git a/games/repair/resources/coin.wav b/games/repair/resources/coin.wav deleted file mode 100644 index 6684ffc6a..000000000 Binary files a/games/repair/resources/coin.wav and /dev/null differ diff --git a/games/repair/resources/elevator_romance.ogg b/games/repair/resources/elevator_romance.ogg deleted file mode 100644 index 0bcb12480..000000000 Binary files a/games/repair/resources/elevator_romance.ogg and /dev/null differ diff --git a/games/repair/resources/eyes_models.png b/games/repair/resources/eyes_models.png deleted file mode 100644 index cd0eb603e..000000000 Binary files a/games/repair/resources/eyes_models.png and /dev/null differ diff --git a/games/repair/resources/font.png b/games/repair/resources/font.png deleted file mode 100644 index dab375017..000000000 Binary files a/games/repair/resources/font.png and /dev/null differ diff --git a/games/repair/resources/hair_models.png b/games/repair/resources/hair_models.png deleted file mode 100644 index a7c86ad0b..000000000 Binary files a/games/repair/resources/hair_models.png and /dev/null differ diff --git a/games/repair/resources/head_models.png b/games/repair/resources/head_models.png deleted file mode 100644 index 6990db1b0..000000000 Binary files a/games/repair/resources/head_models.png and /dev/null differ diff --git a/games/repair/resources/match.png b/games/repair/resources/match.png deleted file mode 100644 index c1637fda9..000000000 Binary files a/games/repair/resources/match.png and /dev/null differ diff --git a/games/repair/resources/mouth_models.png b/games/repair/resources/mouth_models.png deleted file mode 100644 index 88a165a03..000000000 Binary files a/games/repair/resources/mouth_models.png and /dev/null differ diff --git a/games/repair/resources/nose_models.png b/games/repair/resources/nose_models.png deleted file mode 100644 index 7f4782d38..000000000 Binary files a/games/repair/resources/nose_models.png and /dev/null differ diff --git a/games/repair/resources/npatch.png b/games/repair/resources/npatch.png deleted file mode 100644 index 824083ab3..000000000 Binary files a/games/repair/resources/npatch.png and /dev/null differ diff --git a/games/repair/resources/qmark.png b/games/repair/resources/qmark.png deleted file mode 100644 index 6d5e7869e..000000000 Binary files a/games/repair/resources/qmark.png and /dev/null differ diff --git a/games/repair/resources/raylib_logo.png b/games/repair/resources/raylib_logo.png deleted file mode 100644 index 99ba54374..000000000 Binary files a/games/repair/resources/raylib_logo.png and /dev/null differ diff --git a/games/repair/resources/title.png b/games/repair/resources/title.png deleted file mode 100644 index 0d9b725a0..000000000 Binary files a/games/repair/resources/title.png and /dev/null differ diff --git a/games/repair/screens/screen_ending.c b/games/repair/screens/screen_ending.c deleted file mode 100644 index 95ff41b40..000000000 --- a/games/repair/screens/screen_ending.c +++ /dev/null @@ -1,246 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Ending Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2020 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -typedef struct { - int hair; - int colHair; - int eyes; - int nose; - int mouth; - //int glasses; - //int piercing; -} CharLikes; - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Ending screen global variables -static int framesCounter = 0; -static int finishScreen = 0; - -static Texture2D texQmark = { 0 }; -static Texture2D texMatch = { 0 }; - -static int state = 0; -static int matchValue = 0; - -static CharLikes playerLikes = { 0 }; -static CharLikes playerBaseLikes = { 0 }; - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Ending Screen Initialization logic -void InitEndingScreen(void) -{ - framesCounter = 0; - finishScreen = 0; - state = 0; - - CustomizeCharacter(&dating); - - texQmark = LoadTexture("resources/qmark.png"); - texMatch = LoadTexture("resources/match.png"); -} - -// Ending Screen Update logic -void UpdateEndingScreen(void) -{ - if (state == 0) - { - framesCounter++; - - if (framesCounter > 200) - { - state = 1; - - // Check like percentatge for player base (playerBaseLikes) - if (playerBase.hair == dating.hair) playerBaseLikes.hair = GetRandomValue(70, 100); - else if (playerBase.hair == datingBase.hair) playerBaseLikes.hair = GetRandomValue(0, 30); - else playerBaseLikes.hair = GetRandomValue(0, 100); - - if (playerBase.colHair == dating.colHair) playerBaseLikes.colHair = GetRandomValue(70, 100); - else if (playerBase.colHair == datingBase.colHair) playerBaseLikes.colHair = GetRandomValue(0, 30); - else playerBaseLikes.colHair = GetRandomValue(0, 100); - - if (playerBase.eyes == dating.eyes) playerBaseLikes.eyes = GetRandomValue(70, 100); - else if (playerBase.eyes == datingBase.eyes) playerBaseLikes.eyes = GetRandomValue(0, 30); - else playerBaseLikes.eyes = GetRandomValue(0, 100); - - if (playerBase.nose == dating.nose) playerBaseLikes.nose = GetRandomValue(70, 100); - else if (playerBase.nose == datingBase.nose) playerBaseLikes.nose = GetRandomValue(0, 30); - else playerBaseLikes.nose = GetRandomValue(0, 100); - - if (playerBase.mouth == dating.mouth) playerBaseLikes.mouth = GetRandomValue(70, 100); - else if (playerBase.mouth == datingBase.mouth) playerBaseLikes.mouth = GetRandomValue(0, 30); - else playerBaseLikes.mouth = GetRandomValue(0, 100); - - - // Check like percentatge for player (playerLikes) - if (player.hair == dating.hair) playerLikes.hair = GetRandomValue(70, 100); - else if (player.hair == datingBase.hair) playerLikes.hair = GetRandomValue(0, 30); - else playerLikes.hair = GetRandomValue(0, 100); - - if (player.colHair == dating.colHair) playerLikes.colHair = GetRandomValue(70, 100); - else if (player.colHair == datingBase.colHair) playerLikes.colHair = GetRandomValue(0, 30); - else playerLikes.colHair = GetRandomValue(0, 100); - - if (player.eyes == dating.eyes) playerLikes.eyes = GetRandomValue(70, 100); - else if (player.eyes == datingBase.eyes) playerLikes.eyes = GetRandomValue(0, 30); - else playerLikes.eyes = GetRandomValue(0, 100); - - if (player.nose == dating.nose) playerLikes.nose = GetRandomValue(70, 100); - else if (player.nose == datingBase.nose) playerLikes.nose = GetRandomValue(0, 30); - else playerLikes.nose = GetRandomValue(0, 100); - - if (player.mouth == dating.mouth) playerLikes.mouth = GetRandomValue(70, 100); - else if (player.mouth == datingBase.mouth) playerLikes.mouth = GetRandomValue(0, 30); - else playerLikes.mouth = GetRandomValue(0, 100); - - // NOTE: Max possible points to get 5*100 = 500 - // If getting > 250 player likes! :D - matchValue = playerLikes.hair + playerLikes.colHair + playerLikes.eyes + playerLikes.nose + playerLikes.mouth; - } - } - else if (state == 1) - { - // Levels animation? - } - - // Press enter or tap to return to TITLE screen - if (IsKeyPressed(KEY_ENTER)) - { - finishScreen = 1; - PlaySound(fxCoin); - } -} - -// Ending Screen Draw logic -void DrawEndingScreen(void) -{ - // Draw background - DrawTexture(background, 0, 0, GetColor(0xf6aa60ff)); - - DrawCharacter(player, (Vector2){ 180, 40 }); - - DrawCharacter(dating, (Vector2){ 820, 40 }); - - if (state == 0) - { - if ((framesCounter/15)%2 == 1) DrawTexture(texQmark, GetScreenWidth()/2 - texQmark.width/2, 180, WHITE); - } - else if (state == 1) - { - DrawTextEx(font, TextFormat("MATCH: %i%%", (int)(((float)matchValue/500.0f)*100.0f)), (Vector2){ 420, 40 }, font.baseSize*2, 1, SKYBLUE); - - DrawTextureRec(texMatch, (Rectangle){ 0, (matchValue > 250)? 0 : texMatch.height/2, texMatch.width, texMatch.height/2 }, (Vector2){ GetScreenWidth()/2 - texMatch.width/2, 240 }, WHITE); - - int barsPositionX = 80; - - //DrawRectangle(0, 530, GetScreenWidth(), GetScreenHeight() - 530, Fade(GRAY, 0.6f)); - //DrawRectangleLines(0, 530, GetScreenWidth(), GetScreenHeight() - 530, Fade(DARKGRAY, 0.8f)); - - // Draw like values: player base - DrawTextEx(font, "HAIR:", (Vector2){ barsPositionX, 550 }, font.baseSize/2, 1, WHITE); - DrawRectangle(barsPositionX + 80, 550 + 6, 400, font.baseSize/4, GRAY); - DrawRectangle(barsPositionX + 80, 550 + 6, playerBaseLikes.hair*4, font.baseSize/4, RED); - - DrawTextEx(font, "TINT:", (Vector2){ barsPositionX, 580 }, font.baseSize/2, 1, WHITE); - DrawRectangle(barsPositionX + 80, 580 + 6, 400, font.baseSize/4, GRAY); - DrawRectangle(barsPositionX + 80, 580 + 6, playerBaseLikes.colHair*4, font.baseSize/4, RED); - - DrawTextEx(font, "EYES:", (Vector2){ barsPositionX, 610 }, font.baseSize/2, 1, WHITE); - DrawRectangle(barsPositionX + 80, 610 + 6, 400, font.baseSize/4, GRAY); - DrawRectangle(barsPositionX + 80, 610 + 6, playerBaseLikes.eyes*4, font.baseSize/4, RED); - - DrawTextEx(font, "NOSE:", (Vector2){ barsPositionX, 640 }, font.baseSize/2, 1, WHITE); - DrawRectangle(barsPositionX + 80, 640 + 6, 400, font.baseSize/4, GRAY); - DrawRectangle(barsPositionX + 80, 640 + 6, playerBaseLikes.nose*4, font.baseSize/4, RED); - - DrawTextEx(font, "LIPS:", (Vector2){ barsPositionX, 670 }, font.baseSize/2, 1, WHITE); - DrawRectangle(barsPositionX + 80, 670 + 6, 400, font.baseSize/4, GRAY); - DrawRectangle(barsPositionX + 80, 670 + 6, playerBaseLikes.mouth*4, font.baseSize/4, RED); - - // Draw like values: player - if (player.hair != playerBase.hair) - { - DrawTextEx(font, "after re-touch:", (Vector2){ barsPositionX + 80 + 400 + 20, 550 }, font.baseSize/2, 1, WHITE); - DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 550 + 6, 400, font.baseSize/4, GRAY); - DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 550 + 6, playerLikes.hair*4, font.baseSize/4, RED); - } - - if (player.colHair != playerBase.colHair) - { - DrawTextEx(font, "after re-touch:", (Vector2){ barsPositionX + 80 + 400 + 20, 580 }, font.baseSize/2, 1, WHITE); - DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 580 + 6, 400, font.baseSize/4, GRAY); - DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 580 + 6, playerLikes.colHair*4, font.baseSize/4, RED); - } - - if (player.eyes != playerBase.eyes) - { - DrawTextEx(font, "after re-touch:", (Vector2){ barsPositionX + 80 + 400 + 20, 610 }, font.baseSize/2, 1, WHITE); - DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 610 + 6, 400, font.baseSize/4, GRAY); - DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 610 + 6, playerLikes.eyes*4, font.baseSize/4, RED); - } - - if (player.nose != playerBase.nose) - { - DrawTextEx(font, "after re-touch:", (Vector2){ barsPositionX + 80 + 400 + 20, 640 }, font.baseSize/2, 1, WHITE); - DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 640 + 6, 400, font.baseSize/4, GRAY); - DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 640 + 6, playerLikes.nose*4, font.baseSize/4, RED); - } - - if (player.mouth != playerBase.mouth) - { - DrawTextEx(font, "after re-touch:", (Vector2){ barsPositionX + 80 + 400 + 20, 670 }, font.baseSize/2, 1, WHITE); - DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 670 + 6, 400, font.baseSize/4, GRAY); - DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 670 + 6, playerLikes.mouth*4, font.baseSize/4, RED); - } - - // Draw left button: date! - if (GuiButton((Rectangle){ GetScreenWidth() - 280, 60, 260, 80 }, "AGAIN!", -1)) - { - finishScreen = 1; - } - } -} - -// Ending Screen Unload logic -void UnloadEndingScreen(void) -{ - UnloadTexture(texQmark); - UnloadTexture(texMatch); -} - -// Ending Screen should finish? -int FinishEndingScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/repair/screens/screen_gameplay.c b/games/repair/screens/screen_gameplay.c deleted file mode 100644 index 9d1c44738..000000000 --- a/games/repair/screens/screen_gameplay.c +++ /dev/null @@ -1,169 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2020 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -static bool doHairCut = false; -static bool doHairTint = false; -static bool doEyeLiner = false; -static bool doLipStick = false; -static bool doNose = false; -static bool doGlasses = false; - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -const unsigned int headColors[6] = { 0xffe29bff, 0xfed5a8ff, 0xad8962ff, 0xfff1b8ff, 0xffd6c4ff, 0xd49c8dff }; -const unsigned int hairColors[10] = { 0xf5bf60ff, 0xaa754aff, 0x974e14ff, 0xf36347ff, 0x87f347ff, 0xfc48d0ff, 0x3b435dff, 0x5f5e60ff, 0xe7e7e7ff, 0xfb386bff }; - -// Gameplay screen global variables -static int framesCounter = 0; -static int finishScreen = 0; - -static RenderTexture target = { 0 }; - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitGameplayScreen(void) -{ - // Initialize GAMEPLAY screen variables - framesCounter = 0; - finishScreen = 0; - - target = LoadRenderTexture(720, 720); - SetTextureFilter(target.texture, FILTER_BILINEAR); - - // Generate player character! - //player = GenerateCharacter(); - playerBase = player; - - // Generate dating character! - dating = GenerateCharacter(); - datingBase = dating; - - // TODO: Generate dating character likes - // For the different types of properties we assign random like values: 0% (total-dislike) -> 100% (total-like) - - // The total match point will be the (like accumulated amount)/(num properties) - // Some of the elements add points or remove points - - // At the end we can show the like percentadge of every element - - doHairCut = false; - doHairTint = false; - doEyeLiner = false; - doLipStick = false; - doNose = false; - doGlasses = false; -} - -// Gameplay Screen Update logic -void UpdateGameplayScreen(void) -{ - if (IsKeyPressed(KEY_SPACE)) - { - player = GenerateCharacter(); - playerBase = player; - } - - if (IsKeyPressed(KEY_ENTER)) finishScreen = 1; -} - -// Gameplay Screen Draw logic -void DrawGameplayScreen(void) -{ - // Draw background - DrawTexture(background, 0, 0, GetColor(0xf6aa60ff)); - - // Draw left menu buttons - GuiButton((Rectangle){ 20, 40, 300, 60 }, "RE-TOUCH:", 2); - - if (GuiButton((Rectangle){ 20, 40 + 90, 300, 80 }, "HAIR TINT", doHairTint? 3 : -1)) - { - doHairTint = true; - player.colHair = hairColors[GetRandomValue(0, 9)]; - } - if (GuiButton((Rectangle){ 20, 40 + 180, 300, 80 }, "HAIR", doHairCut? 3 : -1)) - { - doHairCut = true; - player.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH); - - } - if (GuiButton((Rectangle){ 20, 40 + 270, 300, 80 }, "EYES", doEyeLiner? 3 : -1)) - { - doEyeLiner = true; - player.eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH - 1); - } - if (GuiButton((Rectangle){ 20, 40 + 360, 300, 80 }, "NOSE", doNose? 3 : -1)) - { - doNose = true; - player.nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH - 1); - } - if (GuiButton((Rectangle){ 20, 40 + 450, 300, 80 }, "LIPS", doLipStick? 3 : -1)) - { - doLipStick = true; - player.mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH - 1); - } - if (GuiButton((Rectangle){ 20, 40 + 540, 300, 80 }, "GLASSES", 3)) - { - doGlasses = true; - } - - // Draw player - DrawCharacter(player, (Vector2){ GetScreenWidth()/2 - 125, 80 }); - - // Draw dating view - GuiButton((Rectangle){ 970, 40, 260, 60 }, "DATING:", 2); - GuiButton((Rectangle){ 970, 40 + 70, 260, 260 }, " ", 0); - - BeginTextureMode(target); - DrawCharacter(dating, (Vector2){ (720 - 250)/2, (720 - 500)/2 }); - EndTextureMode(); - - DrawTexturePro(target.texture, (Rectangle){ 0.0f, 0.0f, (float)target.texture.width, (float)-target.texture.height }, (Rectangle){ 970, 40 + 70, 260, 260 }, (Vector2){ 0, 0 }, 0.0f, WHITE); - - // Draw left button: date! - if (GuiButton((Rectangle){ 970, 580, 260, 90 }, "GO DATE!", -1)) - { - finishScreen = 1; - } -} - -// Gameplay Screen Unload logic -void UnloadGameplayScreen(void) -{ - // Unload required textures -} - -// Gameplay Screen should finish? -int FinishGameplayScreen(void) -{ - return finishScreen; -} diff --git a/games/repair/screens/screen_logo.c b/games/repair/screens/screen_logo.c deleted file mode 100644 index d9548450a..000000000 --- a/games/repair/screens/screen_logo.c +++ /dev/null @@ -1,211 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Logo Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2020 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#define LOGO_RECS_SIDE 16 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Logo screen global variables -static int framesCounter = 0; -static int finishScreen = 0; - -static int logoPositionX = 0; -static int logoPositionY = 0; - -static int lettersCount = 0; - -static int topSideRecWidth = 0; -static int leftSideRecHeight = 0; - -static int bottomSideRecWidth = 0; -static int rightSideRecHeight = 0; - -static char raylib[8] = { 0 }; // raylib text array, max 8 letters -static int state = 0; // Tracking animation states (State Machine) -static float alpha = 1.0f; // Useful for fading - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Logo Screen Initialization logic -void InitLogoScreen(void) -{ - // Initialize LOGO screen variables here! - finishScreen = 0; - framesCounter = 0; - lettersCount = 0; - - logoPositionX = GetScreenWidth()/2 - 128; - logoPositionY = GetScreenHeight()/2 - 128; - - topSideRecWidth = LOGO_RECS_SIDE; - leftSideRecHeight = LOGO_RECS_SIDE; - bottomSideRecWidth = LOGO_RECS_SIDE; - rightSideRecHeight = LOGO_RECS_SIDE; - - for (int i = 0; i < 8; i++) raylib[i] = '\0'; - - state = 0; - alpha = 1.0f; -} - -// Logo Screen Update logic -void UpdateLogoScreen(void) -{ - // Update LOGO screen variables here! - if (state == 0) // State 0: Small box blinking - { - framesCounter++; - - if (framesCounter == 80) - { - state = 1; - framesCounter = 0; // Reset counter... will be used later... - } - } - else if (state == 1) // State 1: Top and left bars growing - { - topSideRecWidth += 8; - leftSideRecHeight += 8; - - if (topSideRecWidth == 256) state = 2; - } - else if (state == 2) // State 2: Bottom and right bars growing - { - bottomSideRecWidth += 8; - rightSideRecHeight += 8; - - if (bottomSideRecWidth == 256) state = 3; - } - else if (state == 3) // State 3: Letters appearing (one by one) - { - framesCounter++; - - if (framesCounter/10) // Every 12 frames, one more letter! - { - lettersCount++; - framesCounter = 0; - } - - switch (lettersCount) - { - case 1: raylib[0] = 'r'; break; - case 2: raylib[1] = 'a'; break; - case 3: raylib[2] = 'y'; break; - case 4: raylib[3] = 'l'; break; - case 5: raylib[4] = 'i'; break; - case 6: raylib[5] = 'b'; break; - default: break; - } - - // When all letters have appeared... - if (lettersCount >= 10) - { - state = 4; - framesCounter = 0; - } - } - else if (state == 4) - { - framesCounter++; - - if (framesCounter > 100) - { - alpha -= 0.02f; - - if (alpha <= 0.0f) - { - alpha = 0.0f; - finishScreen = 1; - } - } - } -} - -// Logo Screen Draw logic -void DrawLogoScreen(void) -{ - if (state == 0) - { - if ((framesCounter/10)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK); - } - else if (state == 1) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - } - else if (state == 2) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK); - } - else if (state == 3) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - } - else if (state == 4) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - - if (framesCounter > 20) DrawText("powered by", logoPositionX, logoPositionY - 27, 20, Fade(DARKGRAY, alpha)); - } -} - -// Logo Screen Unload logic -void UnloadLogoScreen(void) -{ - // Unload LOGO screen variables here! -} - -// Logo Screen should finish? -int FinishLogoScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/repair/screens/screen_title.c b/games/repair/screens/screen_title.c deleted file mode 100644 index 1d424ae20..000000000 --- a/games/repair/screens/screen_title.c +++ /dev/null @@ -1,130 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Title Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2020 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Title screen global variables -static int framesCounter = 0; -static int finishScreen = 0; - -static Texture2D texTitle = { 0 }; -static Texture2D texLogo = { 0 }; - -static int titlePositionY = 0; -static int titleCounter = 0; - -//---------------------------------------------------------------------------------- -// Title Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Title Screen Initialization logic -void InitTitleScreen(void) -{ - framesCounter = 0; - finishScreen = 0; - - texTitle = LoadTexture("resources/title.png"); - texLogo = LoadTexture("resources/raylib_logo.png"); - - player = GenerateCharacter(); - - titlePositionY = -200; -} - -// Title Screen Update logic -void UpdateTitleScreen(void) -{ - framesCounter++; - - if (framesCounter > 5) - { - int partToChange = GetRandomValue(0, 4); - - if (partToChange == 0) - { - player.head = GetRandomValue(0, texHead.width/BASE_HEAD_WIDTH - 1); - player.colHead = headColors[GetRandomValue(0, 5)]; - } - else if (partToChange == 1) player.eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH - 1); - else if (partToChange == 2) player.nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH - 1); - else if (partToChange == 3) player.mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH - 1); - else if (partToChange == 4) - { - player.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH - 1); - player.colHair = hairColors[GetRandomValue(0, 9)]; - } - - framesCounter = 0; - } - - titlePositionY += 3; - if (titlePositionY > 40) titlePositionY = 40; - - titleCounter++; - - if (IsKeyPressed(KEY_ENTER)) finishScreen = 1; -} - -// Title Screen Draw logic -void DrawTitleScreen(void) -{ - DrawTexture(background, 0, 0, GetColor(0xf6aa60ff)); - - // Draw face, parts keep changing ranomly - DrawCharacter(player, (Vector2){ GetScreenWidth()/2 - 125, 80 }); - - // Draw face rectangles - //DrawRectangleRec((Rectangle){ GetScreenWidth()/2 - BASE_EYES_WIDTH/2, 270, BASE_EYES_WIDTH, texEyes.height }, Fade(GREEN, 0.3f)); - //DrawRectangleRec((Rectangle){ GetScreenWidth()/2 - BASE_NOSE_WIDTH/2, 355, BASE_NOSE_WIDTH, texNose.height }, Fade(SKYBLUE, 0.3f)); - //DrawRectangleRec((Rectangle){ GetScreenWidth()/2 - BASE_MOUTH_WIDTH/2, 450, BASE_MOUTH_WIDTH, texMouth.height }, Fade(RED, 0.3f)); - - DrawTexture(texTitle, GetScreenWidth()/2 - texTitle.width/2, titlePositionY, WHITE); - - if (titleCounter > 180) - { - if (GuiButton((Rectangle){ GetScreenWidth()/2 - 440/2, 580, 440, 80 }, "START DATE!", -1)) finishScreen = 1; // GAMEPLAY - } - - DrawText("powered by", 20, GetScreenHeight() - texLogo.height - 35, 10, BLACK); - DrawTexture(texLogo, 20, GetScreenHeight() - texLogo.height - 20, WHITE); -} - -// Title Screen Unload logic -void UnloadTitleScreen(void) -{ - UnloadTexture(texTitle); - UnloadTexture(texLogo); -} - -// Title Screen should finish? -int FinishTitleScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/repair/screens/screens.h b/games/repair/screens/screens.h deleted file mode 100644 index a9756bb88..000000000 --- a/games/repair/screens/screens.h +++ /dev/null @@ -1,125 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Screens Functions Declarations (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2020 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef SCREENS_H -#define SCREENS_H - -#define BASE_HEAD_WIDTH 400 -#define BASE_HAIR_WIDTH 500 -#define BASE_NOSE_WIDTH 80 -#define BASE_MOUTH_WIDTH 170 -#define BASE_EYES_WIDTH 240 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum GameScreen { LOGO = 0, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen; - -typedef struct { - int head; - int colHead; - int eyes; // Config - int nose; // Config - int mouth; // Config - int hair; // Config - int colHair; // Config - int glasses; // Config - //int piercing; - //int freckles; -} Character; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -extern const unsigned int headColors[6]; -extern const unsigned int hairColors[10]; - -extern GameScreen currentScreen; -extern Font font; -extern Music music; -extern Sound fxCoin; -extern Texture2D background; -extern Texture2D texNPatch; -extern NPatchInfo npInfo; -extern Texture2D texHead, texHair, texNose, texMouth, texEyes, texComp; -extern Texture2D texMakeup; - -extern Character player; -extern Character playerBase; -extern Character dating; -extern Character datingBase; - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -// Gui Button -bool GuiButton(Rectangle rec, const char *text, int forcedState); - -Character GenerateCharacter(void); -void CustomizeCharacter(Character *character); -void DrawCharacter(Character character, Vector2 position); - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLogoScreen(void); -void UpdateLogoScreen(void); -void DrawLogoScreen(void); -void UnloadLogoScreen(void); -int FinishLogoScreen(void); - -//---------------------------------------------------------------------------------- -// Title Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitTitleScreen(void); -void UpdateTitleScreen(void); -void DrawTitleScreen(void); -void UnloadTitleScreen(void); -int FinishTitleScreen(void); - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitGameplayScreen(void); -void UpdateGameplayScreen(void); -void DrawGameplayScreen(void); -void UnloadGameplayScreen(void); -int FinishGameplayScreen(void); - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitEndingScreen(void); -void UpdateEndingScreen(void); -void DrawEndingScreen(void); -void UnloadEndingScreen(void); -int FinishEndingScreen(void); - -#ifdef __cplusplus -} -#endif - -#endif // SCREENS_H \ No newline at end of file diff --git a/games/skully_escape/CMakeLists.txt b/games/skully_escape/CMakeLists.txt deleted file mode 100644 index 51047ca14..000000000 --- a/games/skully_escape/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(skully_escape) - -# Grab the screens -file(GLOB screen_sources "screens/*.c") - -# Executable & linking -add_executable(${PROJECT_NAME} skully_escape.c player.c monster.c ${screen_sources}) -if (NOT TARGET raylib) - find_package(raylib 2.0 REQUIRED) -endif() -target_link_libraries(${PROJECT_NAME} raylib) - -# Resources -# Copy all of the resource files to the destination -file(COPY "resources/" DESTINATION "resources/") diff --git a/games/skully_escape/LICENSE.txt b/games/skully_escape/LICENSE.txt deleted file mode 100644 index 510604da4..000000000 --- a/games/skully_escape/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ - -This game sources are licensed under an unmodified zlib/libpng license, -which is an OSI-certified, BSD-like license: - -Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) - -This software is provided "as-is", without any express or implied warranty. In no event -will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial -applications, and to alter it and redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not claim that you - wrote the original software. If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be misrepresented - as being the original software. - - 3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/games/skully_escape/Makefile b/games/skully_escape/Makefile deleted file mode 100644 index fa45e2a4c..000000000 --- a/games/skully_escape/Makefile +++ /dev/null @@ -1,415 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= skully_escape -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= C:\GitHub\raylib - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - # -Wl,--subsystem,windows hides the console window - ifeq ($(BUILD_MODE), RELEASE) - LDFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -PROJECT_SOURCE_FILES ?= \ - skully_escape.c \ - player.c \ - monster.c \ - screens/screen_logo.c \ - screens/screen_logo_raylib.c \ - screens/screen_title.c \ - screens/screen_attic.c \ - screens/screen_aisle01.c \ - screens/screen_aisle02.c \ - screens/screen_armory.c \ - screens/screen_livingroom.c \ - screens/screen_kitchen.c \ - screens/screen_bathroom.c \ - screens/screen_ending.c - -# Define all object files from source files -OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) - -# For Android platform we call a custom Makefile.Android -ifeq ($(PLATFORM),PLATFORM_ANDROID) - MAKEFILE_PARAMS = -f Makefile.Android - export PROJECT_NAME - export PROJECT_SOURCE_FILES -else - MAKEFILE_PARAMS = $(PROJECT_NAME) -endif - -# Default target entry -# NOTE: We call this Makefile target or Makefile.Android target -all: - $(MAKE) $(MAKEFILE_PARAMS) - -# Project target defined by PROJECT_NAME -$(PROJECT_NAME): $(OBJS) - $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) - -# Compile source files -# NOTE: This pattern will compile every module defined on $(OBJS) -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/skully_escape/Makefile.Android b/games/skully_escape/Makefile.Android deleted file mode 100644 index 29d437b1b..000000000 --- a/games/skully_escape/Makefile.Android +++ /dev/null @@ -1,300 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Android project (APK building) -# -# Copyright (c) 2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -# Define required raylib variables -PLATFORM ?= PLATFORM_ANDROID -RAYLIB_PATH ?= ..\.. - -# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version -ANDROID_ARCH ?= ARM -ANDROID_API_VERSION = 21 -ifeq ($(ANDROID_ARCH),ARM) - ANDROID_ARCH_NAME = armeabi-v7a -endif -ifeq ($(ANDROID_ARCH),ARM64) - ANDROID_ARCH_NAME = arm64-v8a -endif - -# Required path variables -# NOTE: JAVA_HOME must be set to JDK -JAVA_HOME ?= C:/JavaJDK -ANDROID_HOME = C:/android-sdk -ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION) -ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1 -ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools - -# Android project configuration variables -PROJECT_NAME ?= raylib_game -PROJECT_LIBRARY_NAME ?= main -PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME) -PROJECT_RESOURCES_PATH ?= resources -PROJECT_SOURCE_FILES ?= raylib_game.c - -# Some source files are placed in directories, when compiling to some -# output directory other than source, that directory must pre-exist. -# Here we get a list of required folders that need to be created on -# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors. -PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES))) - -# Android app configuration variables -APP_LABEL_NAME ?= rGame -APP_COMPANY_NAME ?= raylib -APP_PRODUCT_NAME ?= rgame -APP_VERSION_CODE ?= 1 -APP_VERSION_NAME ?= 1.0 -APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png -APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png -APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png -APP_SCREEN_ORIENTATION ?= landscape -APP_KEYSTORE_PASS ?= raylib - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Library path for libraylib.a/libraylib.so -RAYLIB_LIB_PATH = $(RAYLIB_PATH)\src - -# Shared libs must be added to APK if required -# NOTE: Generated NativeLoader.java automatically load those libraries -ifeq ($(RAYLIB_LIBTYPE),SHARED) - PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so -endif - -# Compiler and archiver -# NOTE: GCC is being deprecated in Android NDK r16 -ifeq ($(ANDROID_ARCH),ARM) - CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang - AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar -endif -ifeq ($(ANDROID_ARCH),ARM64) - CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang - AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar -endif - -# Compiler flags for arquitecture -ifeq ($(ANDROID_ARCH),ARM) - CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -endif -ifeq ($(ANDROID_ARCH),ARM64) - CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769 -endif -# Compilation functions attributes options -CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC -# Compiler options for the linker -CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes -# Preprocessor macro definitions -CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) - -# Paths containing required header files -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue - -# Linker options -LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a -LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -# Force linking of library module to define symbol -LDFLAGS += -u ANativeActivity_onCreate -# Library paths containing required libs -LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME) -L$(ANDROID_TOOLCHAIN)\sysroot\usr\lib - -# Define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl - -# Generate target objects list from PROJECT_SOURCE_FILES -OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES)) - -# Android APK building process... some steps required... -# NOTE: typing 'make' will invoke the default target entry called 'all', -all: create_temp_project_dirs \ - copy_project_required_libs \ - copy_project_resources \ - generate_loader_script \ - generate_android_manifest \ - generate_apk_keystore \ - config_project_package \ - compile_project_code \ - compile_project_class \ - compile_project_class_dex \ - create_project_apk_package \ - sign_project_apk_package \ - zipalign_project_apk_package - -# Create required temp directories for APK building -create_temp_project_dirs: - if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj - if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src - if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) - if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib - if not exist $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) mkdir $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) - if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin - if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res - if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi - if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values - if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets - if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens - $(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir))) - -define create_dir - if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1) -endef - -# Copy required shared libs for integration into APK -# NOTE: If using shared libs they are loaded by generated NativeLoader.java -copy_project_required_libs: -ifeq ($(RAYLIB_LIBTYPE),SHARED) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so -endif -ifeq ($(RAYLIB_LIBTYPE),STATIC) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a -endif - -# Copy project required resources: strings.xml, icon.png, assets -# NOTE: Required strings.xml is generated and game resources are copied to assets folder -# TODO: Review xcopy usage, it can not be found in some systems! -copy_project_resources: - copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y - copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y - copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y - @echo ^ > $(PROJECT_BUILD_PATH)/res/values/strings.xml - @echo ^^$(APP_LABEL_NAME)^^ >> $(PROJECT_BUILD_PATH)/res/values/strings.xml - if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F - -# Generate NativeLoader.java to load required shared libraries -# NOTE: Probably not the bet way to generate this file... but it works. -generate_loader_script: - @echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -ifeq ($(RAYLIB_LIBTYPE),SHARED) - @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -endif - @echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Generate AndroidManifest.xml with all the required options -# NOTE: Probably not the bet way to generate this file... but it works. -generate_android_manifest: - @echo ^ > $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - -# Generate storekey for APK signing: $(PROJECT_NAME).keystore -# NOTE: Configure here your Distinguished Names (-dname) if required! -generate_apk_keystore: - if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA - -# Config project package and resource using AndroidManifest.xml and res/values/strings.xml -# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java -config_project_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar - -# Compile native_app_glue code as static library: obj/libnative_app_glue.a -compile_native_app_glue: - $(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS) - $(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o - -# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so -compile_project_code: $(OBJS) - $(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) - -# Compile all .c files required into object (.o) files -# NOTE: Those files will be linked into a shared library -$(PROJECT_BUILD_PATH)/obj/%.o:%.c - $(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot - -# Compile project .java code into .class (Java bytecode) -compile_project_class: - $(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Compile .class files into Dalvik executable bytecode (.dex) -# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT) -compile_project_class_dex: - $(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj - -# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk -# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so -# NOTE: Use -A resources to define additional directory in which to find raw asset files -create_project_apk_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin - cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS) - -# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk -sign_project_apk_package: - $(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key - -# Create zip-aligned APK package: $(PROJECT_NAME).apk -zipalign_project_apk_package: - $(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk - -# Install $(PROJECT_NAME).apk to default emulator/device -# NOTE: Use -e (emulator) or -d (device) parameters if required -install: - $(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk - -# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64) -check_device_abi: - $(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi - -# Monitorize output log coming from device, only raylib tag -logcat: - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -# Install and monitorize $(PROJECT_NAME).apk to default emulator/device -deploy: - $(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W - -# Clean everything -clean: - del $(PROJECT_BUILD_PATH)\* /f /s /q - rmdir $(PROJECT_BUILD_PATH) /s /q - @echo Cleaning done diff --git a/games/skully_escape/monster.c b/games/skully_escape/monster.c deleted file mode 100644 index 469cd9ca6..000000000 --- a/games/skully_escape/monster.c +++ /dev/null @@ -1,54 +0,0 @@ -/*********************************************************************************** -* -* KING GAME JAM - GRAY TEAM -* -* -* -* -* This game has been created using raylib (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -************************************************************************************/ - -#include "raylib.h" -#include "monster.h" - -void UpdateMonster(Monster *monster) -{ - if (!monster->active) - { - if (CheckCollisionPointRec(GetMousePosition(), monster->bounds)) monster->selected = true; - else monster->selected = false; - } - else if (monster->spooky) - { - monster->framesCounter++; - monster->currentSeq = 0; - - if (monster->framesCounter > 7) - { - monster->currentFrame++; - monster->framesCounter = 0; - - if (monster->currentFrame > monster->numFrames - 1) monster->currentFrame = 1; - } - } - - monster->frameRec.x = monster->currentFrame*monster->texture.width/monster->numFrames; - monster->frameRec.y = monster->currentSeq*monster->texture.height; -} - -void DrawMonster(Monster monster, int scroll) -{ - Vector2 scrollPos = { monster.position.x - scroll, monster.position.y }; - - if (monster.selected) DrawTextureRec(monster.texture, monster.frameRec, scrollPos, RED); - else DrawTextureRec(monster.texture, monster.frameRec, scrollPos, WHITE); -} - -void UnloadMonster(Monster monster) -{ - UnloadTexture(monster.texture); -} \ No newline at end of file diff --git a/games/skully_escape/monster.h b/games/skully_escape/monster.h deleted file mode 100644 index 2ef4eb6a4..000000000 --- a/games/skully_escape/monster.h +++ /dev/null @@ -1,73 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Screens Functions Declarations (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef MONSTER_H -#define MONSTER_H - -#define MONSTER_ANIM_FRAMES 7 -#define MONSTER_ANIM_SEQ 2 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//--------------------------------------------------------------------------------- -typedef struct Monster { - Vector2 position; - Texture2D texture; - Rectangle bounds; - Rectangle frameRec; - Color color; - int framesCounter; - int currentFrame; - int currentSeq; - int numFrames; - bool active; - bool selected; - bool spooky; -} Monster; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- - - - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -//---------------------------------------------------------------------------------- -// Monster Functions Declaration -//---------------------------------------------------------------------------------- - -void UpdateMonster(Monster *monster); -void DrawMonster(Monster monster, int scroll); -void UnloadMonster(Monster monster); - - -#ifdef __cplusplus -} -#endif - -#endif // SCREENS_H \ No newline at end of file diff --git a/games/skully_escape/player.c b/games/skully_escape/player.c deleted file mode 100644 index 552326e18..000000000 --- a/games/skully_escape/player.c +++ /dev/null @@ -1,281 +0,0 @@ -/*********************************************************************************** -* -* KING GAME JAM - GRAY TEAM -* -* -* -* -* This game has been created using raylib (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -************************************************************************************/ - -#include "raylib.h" -#include "player.h" - -#define PLAYER_ANIM_FRAMES 4 -#define PLAYER_ANIM_SEQ 6 - -//---------------------------------------------------------------------------------- -// Module Variables Definition -//---------------------------------------------------------------------------------- - -// Player mouse moving variables -static bool movingAnim; -static int moveDirection; -static int nextMovePoint; - -// Mouse pointer variables -static Vector2 pointerPosition; -static bool pointerAnim; -static float pointerAlpha; - -static int framesCounter; -static bool outControl = false; - -static int animTimer = 0; - -static Texture2D texLife; - -static void DrawLifes(void); - -// player initialitaction definition -void InitPlayer(void) -{ - // NOTE: Some player variables are only initialized once - player.texture = LoadTexture("resources/textures/skully.png"); - player.position = (Vector2){ 350, 400 }; - player.numLifes = 4; - - ResetPlayer(); - - framesCounter = 0; - - texLife = LoadTexture("resources/textures/skully_icon.png"); -} - -// player update definition -void UpdatePlayer(void) -{ - if (!outControl) - { - if ((IsKeyDown(KEY_LEFT)) || (IsKeyDown(KEY_RIGHT))) - { - moveDirection = -1; - movingAnim = false; - } - - if ((IsKeyDown(KEY_RIGHT)) || (moveDirection == 0)) - { - player.currentSeq = WALK_RIGHT; - framesCounter++; - - if (framesCounter > 15) - { - player.currentFrame++; - framesCounter = 0; - - if (player.currentFrame > PLAYER_ANIM_FRAMES - 1) player.currentFrame = 0; - } - - player.position.x += 4; - } - else if ((IsKeyDown(KEY_LEFT)) || (moveDirection == 1)) - { - player.currentSeq = WALK_LEFT; - framesCounter++; - - if (framesCounter > 15) - { - player.currentFrame++; - framesCounter = 0; - - if (player.currentFrame > PLAYER_ANIM_FRAMES - 1) player.currentFrame = 0; - } - - player.position.x -= 4; - } - else player.currentFrame = 0; - } - else - { - framesCounter++; - animTimer++; - - if (framesCounter > 10) - { - player.currentFrame++; - framesCounter = 0; - - if (player.currentFrame > PLAYER_ANIM_FRAMES - 1) player.currentFrame = 0; - - // We can adjust animation playing time depending on sequence - switch (player.currentSeq) - { - case SCARE_RIGHT: - { - if (animTimer > 180) - { - animTimer = 0; - outControl = false; - player.currentSeq = WALK_LEFT; - } - } break; - case SCARE_LEFT: - { - if (animTimer > 240) - { - animTimer = 0; - outControl = false; - player.currentSeq = WALK_RIGHT; - } - } break; - case SEARCH: - case FIND_KEY: - { - if (animTimer > 240) - { - animTimer = 0; - outControl = false; - player.currentSeq = WALK_RIGHT; - } - } break; - } - } - } - - if (player.position.x < 30) player.position.x = 30; - else if (player.position.x > (GetScreenWidth() - 200)) player.position.x = GetScreenWidth() - 200; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - pointerPosition = GetMousePosition(); - pointerAnim = true; - pointerAlpha = 1.0f; - - nextMovePoint = (int)pointerPosition.x; - movingAnim = true; - } - - if (movingAnim) - { - if (nextMovePoint > (player.position.x + (player.frameRec.width/2) + 5)) moveDirection = 0; // Move Left - else if (nextMovePoint < (player.position.x + (player.frameRec.width/2) - 5)) moveDirection = 1; // Move Right - else - { - moveDirection = -1; - movingAnim = 0; - } - } - - player.frameRec.x = player.currentFrame*player.texture.width/PLAYER_ANIM_FRAMES; - player.frameRec.y = (player.currentSeq - 1)*player.texture.height/PLAYER_ANIM_SEQ; - - // Update player bounds - player.bounds = (Rectangle){ player.position.x + 50, player.position.y - 60, 100, 300 }; - - // Mouse pointer alpha animation - if (pointerAnim) - { - pointerAlpha -= 0.1f; - - if (pointerAlpha <= 0.0f) - { - pointerAlpha = 0.0f; - pointerAnim = false; - } - } -} -// -void DrawPlayer(void) -{ - DrawTextureRec(player.texture, player.frameRec, player.position, WHITE); - - // Draw mouse pointer on click - if (pointerAnim) DrawCircleV(pointerPosition, 20, Fade(RED, pointerAlpha)); - - DrawLifes(); -} - -void UnloadPlayer(void) -{ - UnloadTexture(player.texture); - UnloadTexture(texLife); -} - -void ResetPlayer(void) -{ - // Reset player variables - player.frameRec = (Rectangle){ 0, 0, player.texture.width/PLAYER_ANIM_FRAMES, player.texture.height/PLAYER_ANIM_SEQ }; - player.currentFrame = 0; - player.currentSeq = WALK_RIGHT; - - player.key = false; - player.dead = false; - - // Reset player position - if (player.position.x < 400) player.position.x = GetScreenWidth() - 350; - if (player.position.x > (GetScreenWidth() - 400)) player.position.x = 350; - - // Reset moving variables - movingAnim = false; - moveDirection = -1; - nextMovePoint = 0; - framesCounter = 0; - outControl = false; - animTimer = 0; - - // Reset pointer - pointerAlpha = 0.0f; - pointerAnim = false; -} - -void ScarePlayer(void) -{ - player.currentFrame = 0; - - if (moveDirection == 0) player.currentSeq = SCARE_RIGHT; - else if (moveDirection == 1) player.currentSeq = SCARE_LEFT; - else player.currentSeq = SCARE_RIGHT; - - player.numLifes--; - - if (player.numLifes <= 0) player.dead = true; - - outControl = true; -} - -void SearchKeyPlayer(void) -{ - moveDirection = -1; - movingAnim = 0; - - player.currentFrame = 0; - player.currentSeq = SEARCH; - - outControl = true; -} - -void FindKeyPlayer(void) -{ - player.currentFrame = 0; - player.currentSeq = FIND_KEY; - player.key = true; - - outControl = true; -} - -static void DrawLifes(void) -{ - if (player.numLifes != 0) - { - Vector2 position = { 20, GetScreenHeight() - texLife.height - 20 }; - - for(int i = 0; i < player.numLifes; i++) - { - DrawTexture(texLife, position.x + i*texLife.width, position.y, Fade(RAYWHITE, 0.7f)); - } - } -} \ No newline at end of file diff --git a/games/skully_escape/player.h b/games/skully_escape/player.h deleted file mode 100644 index 7d59bdde8..000000000 --- a/games/skully_escape/player.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef PLAYER_H -#define PLAYER_H - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum { NONE, WALK_RIGHT, WALK_LEFT, SCARE_RIGHT, SCARE_LEFT, SEARCH, FIND_KEY } PlayerSequence; - -typedef struct Player { - Vector2 position; - Rectangle bounds; - Texture2D texture; - Color color; - - // Animation variables - Rectangle frameRec; - int currentFrame; - int currentSeq; - - bool key; - int numLifes; - bool dead; -} Player; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -Player player; - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitPlayer(void); -void UpdatePlayer(void); -void DrawPlayer(void); -void UnloadPlayer(void); -void ResetPlayer(void); - -void ScarePlayer(void); -void SearchKeyPlayer(void); -void FindKeyPlayer(void); - -#ifdef __cplusplus -} -#endif - -#endif // SCREENS_H \ No newline at end of file diff --git a/games/skully_escape/resources/audio/come_play_with_me.ogg b/games/skully_escape/resources/audio/come_play_with_me.ogg deleted file mode 100644 index 425498b81..000000000 Binary files a/games/skully_escape/resources/audio/come_play_with_me.ogg and /dev/null differ diff --git a/games/skully_escape/resources/audio/door.ogg b/games/skully_escape/resources/audio/door.ogg deleted file mode 100644 index a1d1cd1b3..000000000 Binary files a/games/skully_escape/resources/audio/door.ogg and /dev/null differ diff --git a/games/skully_escape/resources/audio/scream.ogg b/games/skully_escape/resources/audio/scream.ogg deleted file mode 100644 index 415240279..000000000 Binary files a/games/skully_escape/resources/audio/scream.ogg and /dev/null differ diff --git a/games/skully_escape/resources/textures/alagard.png b/games/skully_escape/resources/textures/alagard.png deleted file mode 100644 index c5cc54dc8..000000000 Binary files a/games/skully_escape/resources/textures/alagard.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/background_aisle01.png b/games/skully_escape/resources/textures/background_aisle01.png deleted file mode 100644 index 32fe5b699..000000000 Binary files a/games/skully_escape/resources/textures/background_aisle01.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/background_aisle02.png b/games/skully_escape/resources/textures/background_aisle02.png deleted file mode 100644 index fced627f3..000000000 Binary files a/games/skully_escape/resources/textures/background_aisle02.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/background_armory.png b/games/skully_escape/resources/textures/background_armory.png deleted file mode 100644 index 1a93807f9..000000000 Binary files a/games/skully_escape/resources/textures/background_armory.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/background_attic.png b/games/skully_escape/resources/textures/background_attic.png deleted file mode 100644 index 446e09a77..000000000 Binary files a/games/skully_escape/resources/textures/background_attic.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/background_bathroom.png b/games/skully_escape/resources/textures/background_bathroom.png deleted file mode 100644 index 55061d1f1..000000000 Binary files a/games/skully_escape/resources/textures/background_bathroom.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/background_kitchen.png b/games/skully_escape/resources/textures/background_kitchen.png deleted file mode 100644 index 5c74c74e1..000000000 Binary files a/games/skully_escape/resources/textures/background_kitchen.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/background_livingroom.png b/games/skully_escape/resources/textures/background_livingroom.png deleted file mode 100644 index f91a11f95..000000000 Binary files a/games/skully_escape/resources/textures/background_livingroom.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/doors.png b/games/skully_escape/resources/textures/doors.png deleted file mode 100644 index ff33169d9..000000000 Binary files a/games/skully_escape/resources/textures/doors.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_arc.png b/games/skully_escape/resources/textures/monster_arc.png deleted file mode 100644 index ae3e346d9..000000000 Binary files a/games/skully_escape/resources/textures/monster_arc.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_blazon01.png b/games/skully_escape/resources/textures/monster_blazon01.png deleted file mode 100644 index 2d2a409cb..000000000 Binary files a/games/skully_escape/resources/textures/monster_blazon01.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_blazon02.png b/games/skully_escape/resources/textures/monster_blazon02.png deleted file mode 100644 index 8cea93618..000000000 Binary files a/games/skully_escape/resources/textures/monster_blazon02.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_blazon03.png b/games/skully_escape/resources/textures/monster_blazon03.png deleted file mode 100644 index cc4665a1b..000000000 Binary files a/games/skully_escape/resources/textures/monster_blazon03.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_candle.png b/games/skully_escape/resources/textures/monster_candle.png deleted file mode 100644 index 9feef00d9..000000000 Binary files a/games/skully_escape/resources/textures/monster_candle.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_chair_left.png b/games/skully_escape/resources/textures/monster_chair_left.png deleted file mode 100644 index a47740324..000000000 Binary files a/games/skully_escape/resources/textures/monster_chair_left.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_chair_right.png b/games/skully_escape/resources/textures/monster_chair_right.png deleted file mode 100644 index 8d3007a3c..000000000 Binary files a/games/skully_escape/resources/textures/monster_chair_right.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_closet.png b/games/skully_escape/resources/textures/monster_closet.png deleted file mode 100644 index 7c0c8f27f..000000000 Binary files a/games/skully_escape/resources/textures/monster_closet.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_lamp_left.png b/games/skully_escape/resources/textures/monster_lamp_left.png deleted file mode 100644 index d95dd2486..000000000 Binary files a/games/skully_escape/resources/textures/monster_lamp_left.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_lamp_right.png b/games/skully_escape/resources/textures/monster_lamp_right.png deleted file mode 100644 index 81bbc6d6a..000000000 Binary files a/games/skully_escape/resources/textures/monster_lamp_right.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_mirror.png b/games/skully_escape/resources/textures/monster_mirror.png deleted file mode 100644 index 2e9943091..000000000 Binary files a/games/skully_escape/resources/textures/monster_mirror.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_phone.png b/games/skully_escape/resources/textures/monster_phone.png deleted file mode 100644 index a4862ef76..000000000 Binary files a/games/skully_escape/resources/textures/monster_phone.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_picture.png b/games/skully_escape/resources/textures/monster_picture.png deleted file mode 100644 index f4f9d84be..000000000 Binary files a/games/skully_escape/resources/textures/monster_picture.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/monster_window.png b/games/skully_escape/resources/textures/monster_window.png deleted file mode 100644 index 4a20a5c64..000000000 Binary files a/games/skully_escape/resources/textures/monster_window.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/skully.png b/games/skully_escape/resources/textures/skully.png deleted file mode 100644 index 5fec59397..000000000 Binary files a/games/skully_escape/resources/textures/skully.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/skully_icon.png b/games/skully_escape/resources/textures/skully_icon.png deleted file mode 100644 index 91a0bc2aa..000000000 Binary files a/games/skully_escape/resources/textures/skully_icon.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/skully_logo.png b/games/skully_escape/resources/textures/skully_logo.png deleted file mode 100644 index 93e8bfe2b..000000000 Binary files a/games/skully_escape/resources/textures/skully_logo.png and /dev/null differ diff --git a/games/skully_escape/resources/textures/title.png b/games/skully_escape/resources/textures/title.png deleted file mode 100644 index 20e08c887..000000000 Binary files a/games/skully_escape/resources/textures/title.png and /dev/null differ diff --git a/games/skully_escape/screens/screen_aisle01.c b/games/skully_escape/screens/screen_aisle01.c deleted file mode 100644 index 78bb20c48..000000000 --- a/games/skully_escape/screens/screen_aisle01.c +++ /dev/null @@ -1,409 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" -#include "../player.h" -#include "../monster.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D background; - -// Declare doors -static Door doorRight; -static Door doorCenter; -static Door doorLeft; - -// Decalre monsters -static Monster lamp; -static Monster picture; - -static bool monsterHover = false; -static int monsterCheck = -1; // Identify checking monster - -static const char message[256] = "WHO IS THERE???\nANYBODY IN THE ROOM???"; -static int msgPosX = 100; - -static int msgState = 0; // 0-writting, 1-wait, 2-choose -static int lettersCounter = 0; -static char msgBuffer[256] = { '\0' }; -static int msgCounter = 0; - -static bool searching = false; - -static int scroll = 0; - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitAisle01Screen(void) -{ - ResetPlayer(); - - // Reset Screen variables - monsterHover = false; - monsterCheck = -1; - msgState = 0; - msgCounter = 0; - lettersCounter = 0; - for (int i = 0; i < 256; i++) msgBuffer[i] = '\0'; - - framesCounter = 0; - finishScreen = 0; - - background = LoadTexture("resources/textures/background_aisle01.png"); - - scroll = player.position.x - 200; - - // Initialize doors - doorLeft.position = (Vector2) { -30, 135 }; - doorLeft.facing = 0; - doorLeft.locked = true; - doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2}; - doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2}; - doorLeft.selected = false; - - doorCenter.position = (Vector2) { 1115, 104 }; - doorCenter.facing = 1; - doorCenter.locked = true; - doorCenter.frameRec =(Rectangle) {((doors.width/3)*doorCenter.facing), doors.height/2, doors.width/3, doors.height/2}; - doorCenter.bound = (Rectangle) { doorCenter.position.x, doorCenter.position.y, doors.width/3, doors.height/2}; - doorCenter.selected = false; - - doorRight.position = (Vector2) { 1710, 140 }; - doorRight.facing = 2; - doorRight.locked = true; - doorRight.frameRec =(Rectangle) {((doors.width/3)*doorRight.facing), doors.height/2, doors.width/3, doors.height/2}; - doorRight.bound = (Rectangle) { doorRight.position.x, doorRight.position.y, doors.width/3, doors.height/2}; - - // Monster init: lamp - lamp.position = (Vector2){ 187, 256 }; - lamp.texture = LoadTexture("resources/textures/monster_lamp_left.png"); - lamp.currentFrame = 0; - lamp.framesCounter = 0; - lamp.numFrames = 4; - lamp.bounds = (Rectangle){ lamp.position.x + 20, lamp.position.y, 90, 380 }; - lamp.frameRec = (Rectangle) { 0, 0, lamp.texture.width/lamp.numFrames, lamp.texture.height }; - lamp.selected = false; - lamp.active = false; - lamp.spooky = true; - - // Monster init: arc - picture.position = (Vector2){ 637, 178 }; - picture.texture = LoadTexture("resources/textures/monster_picture.png"); - picture.currentFrame = 0; - picture.framesCounter = 0; - picture.numFrames = 4; - picture.bounds = (Rectangle){ picture.position.x + 44, picture.position.y, 174, 256 }; - picture.frameRec = (Rectangle) { 0, 0, picture.texture.width/picture.numFrames, picture.texture.height }; - picture.selected = false; - picture.active = false; - picture.spooky = false; -} - -// Gameplay Screen Update logic -void UpdateAisle01Screen(void) -{ - // Update doors bounds - doorLeft.bound.x = doorLeft.position.x - scroll; - doorCenter.bound.x = doorCenter.position.x - scroll; - doorRight.bound.x = doorRight.position.x - scroll; - - if (player.key) - { - // Door: left - if ((CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || - (CheckCollisionRecs(player.bounds, doorLeft.bound))) doorLeft.selected = true; - else doorLeft.selected = false; - - if ((doorLeft.selected) && (CheckCollisionRecs(player.bounds, doorLeft.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorLeft.locked) - { - doorLeft.frameRec.y = 0; - doorLeft.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 1; - } - } - - // Door: center - if ((CheckCollisionPointRec(GetMousePosition(), doorCenter.bound)) || - (CheckCollisionRecs(player.bounds, doorCenter.bound))) doorCenter.selected = true; - else doorCenter.selected = false; - - if ((doorCenter.selected) && (CheckCollisionRecs(player.bounds, doorCenter.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorCenter.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorCenter.locked) - { - doorCenter.frameRec.y = 0; - doorCenter.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 2; - } - } - - // Door: right - if ((CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || - (CheckCollisionRecs(player.bounds, doorRight.bound))) doorRight.selected = true; - else doorRight.selected = false; - - if ((doorRight.selected) && (CheckCollisionRecs(player.bounds, doorRight.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorRight.locked) - { - doorRight.frameRec.y = 0; - doorRight.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 3; - } - } - } - - if (msgState > 2) - { - UpdatePlayer(); - - // Monsters logic - UpdateMonster(&lamp); - UpdateMonster(&picture); - } - - // Update monster bounds - lamp.bounds.x = lamp.position.x + 20 - scroll; - picture.bounds.x = picture.position.x + 44 - scroll; - - // Check player hover monsters to interact - if (((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) || - ((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.active)) monsterHover = true; - else monsterHover = false; - - // Monters logic: lamp - if ((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) - { - lamp.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), lamp.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 1; - } - } - else lamp.selected = false; - - // Monters logic: picture - if ((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.active) - { - picture.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), picture.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 2; - } - } - else picture.selected = false; - - if (searching) - { - framesCounter++; - - if (framesCounter > 180) - { - if (monsterCheck == 1) - { - if (lamp.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - lamp.active = true; - lamp.selected = false; - } - else if (monsterCheck == 2) - { - if (picture.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - picture.active = true; - picture.selected = false; - } - - searching = false; - framesCounter = 0; - } - } - - // Text animation - framesCounter++; - - if ((framesCounter%2) == 0) lettersCounter++; - - if (msgState == 0) - { - if (lettersCounter <= (int)strlen(message)) strncpy(msgBuffer, message, lettersCounter); - else - { - for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = '\0'; - - lettersCounter = 0; - msgState = 1; - } - - if (IsKeyPressed(KEY_ENTER)) msgState = 1; - } - else if (msgState == 1) - { - msgCounter++; - - if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) - { - msgState = 2; - msgCounter = 0; - } - } - else if (msgState == 2) - { - msgCounter++; - - if (msgCounter > 180) msgState = 3; - } - else msgCounter++; - - if (player.position.x > 200) - { - scroll = player.position.x - 200; - - if (scroll > 620) scroll = 620; - } -} - -// Gameplay Screen Draw logic -void DrawAisle01Screen(void) -{ - DrawTexture(background, -scroll, 0, WHITE); - - // Draw monsters - DrawMonster(lamp, scroll); - DrawMonster(picture, scroll); - - // Draw door - Vector2 doorScrollPos = { doorCenter.position.x - scroll, doorCenter.position.y }; - if (doorCenter.selected) DrawTextureRec(doors, doorCenter.frameRec, doorScrollPos, GREEN); - else DrawTextureRec(doors, doorCenter.frameRec, doorScrollPos, WHITE); - - doorScrollPos = (Vector2){ doorLeft.position.x - scroll, doorLeft.position.y }; - if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, GREEN); - else DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, WHITE); - - doorScrollPos = (Vector2){ doorRight.position.x - scroll, doorRight.position.y }; - if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorScrollPos, GREEN); - else DrawTextureRec(doors, doorRight.frameRec, doorScrollPos, WHITE); - - // Draw messsages - if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f)); - else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f)); - - if (msgState == 0) - { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - } - else if (msgState == 1) - { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - - if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); - } - else if (msgState == 2) - { - if ((msgCounter/30)%2) - { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); - - DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(picture.bounds, Fade(RED, 0.6f)); - } - } - else - { - if ((monsterHover) && ((msgCounter/30)%2)) - { - DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f)); - DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK); - } - } - - DrawPlayer(); // NOTE: Also draws mouse pointer! -} - -// Gameplay Screen Unload logic -void UnloadAisle01Screen(void) -{ - // TODO: Unload GAMEPLAY screen variables here! - UnloadTexture(background); - - UnloadMonster(lamp); - UnloadMonster(picture); -} - -// Gameplay Screen should finish? -int FinishAisle01Screen(void) -{ - return finishScreen; -} diff --git a/games/skully_escape/screens/screen_aisle02.c b/games/skully_escape/screens/screen_aisle02.c deleted file mode 100644 index 9dc02d377..000000000 --- a/games/skully_escape/screens/screen_aisle02.c +++ /dev/null @@ -1,444 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" -#include "../player.h" -#include "../monster.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D background; - -// Declare doors -static Door doorLeft; - -// Decalre monsters -static Monster lamp; -static Monster chair; -static Monster picture; -static Monster arc; - -static bool monsterHover = false; -static int monsterCheck = -1; // Identify checking monster - -static const char message[256] = "HAS LEGS BUT CAN NOT WALK...\nSEARCH FOR IT TO OPEN THE DOOR!"; -static int msgPosX = 100; - -static int msgState = 0; // 0-writting, 1-wait, 2-choose -static int lettersCounter = 0; -static char msgBuffer[256] = { '\0' }; -static int msgCounter = 0; - -static bool searching = false; - -static int scroll = 0; - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitAisle02Screen(void) -{ - ResetPlayer(); - - // Reset Screen variables - monsterHover = false; - monsterCheck = -1; - msgState = 0; - msgCounter = 0; - lettersCounter = 0; - for (int i = 0; i < 256; i++) msgBuffer[i] = '\0'; - - framesCounter = 0; - finishScreen = 0; - - background = LoadTexture("resources/textures/background_aisle02.png"); - - scroll = player.position.x - 200; - - // Initialize doors - doorLeft.position = (Vector2) { -10, 136 }; - doorLeft.facing = 0; - doorLeft.locked = true; - doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2}; - doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2}; - doorLeft.selected = false; - - // Monster init: lamp - lamp.position = (Vector2){ 1520, 300 }; - lamp.texture = LoadTexture("resources/textures/monster_lamp_right.png"); - lamp.currentFrame = 0; - lamp.framesCounter = 0; - lamp.numFrames = 4; - lamp.bounds = (Rectangle){ lamp.position.x + 200, lamp.position.y, 90, 380 }; - lamp.frameRec = (Rectangle) { 0, 0, lamp.texture.width/lamp.numFrames, lamp.texture.height }; - lamp.selected = false; - lamp.active = false; - lamp.spooky = true; - - // Monster init: chair - chair.position = (Vector2){ 1400, 404 }; - chair.texture = LoadTexture("resources/textures/monster_chair_right.png"); - chair.currentFrame = 0; - chair.framesCounter = 0; - chair.numFrames = 4; - chair.bounds = (Rectangle){ chair.position.x + 50, chair.position.y + 30, 120, 190 }; - chair.frameRec = (Rectangle) { 0, 0, chair.texture.width/chair.numFrames, chair.texture.height }; - chair.selected = false; - chair.active = false; - chair.spooky = false; - - // Monster init: picture - picture.position = (Vector2){ 837, 162 }; - picture.texture = LoadTexture("resources/textures/monster_picture.png"); - picture.currentFrame = 0; - picture.framesCounter = 0; - picture.numFrames = 4; - picture.bounds = (Rectangle){ picture.position.x + 44, picture.position.y, 174, 264 }; - picture.frameRec = (Rectangle) { 0, 0, picture.texture.width/picture.numFrames, picture.texture.height }; - picture.selected = false; - picture.active = false; - picture.spooky = true; - - // Monster init: arc - arc.position = (Vector2){ 388, 423 }; - arc.texture = LoadTexture("resources/textures/monster_arc.png"); - arc.currentFrame = 0; - arc.framesCounter = 0; - arc.numFrames = 4; - arc.bounds = (Rectangle){ arc.position.x + 44, arc.position.y + 70, 220, 120 }; - arc.frameRec = (Rectangle) { 0, 0, arc.texture.width/arc.numFrames, arc.texture.height }; - arc.selected = false; - arc.active = false; - arc.spooky = true; -} - -// Gameplay Screen Update logic -void UpdateAisle02Screen(void) -{ - // Update doors bounds - doorLeft.bound.x = doorLeft.position.x - scroll; - - if (player.key) - { - // Door: left - if ((CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || - (CheckCollisionRecs(player.bounds, doorLeft.bound))) doorLeft.selected = true; - else doorLeft.selected = false; - - if ((doorLeft.selected) && (CheckCollisionRecs(player.bounds, doorLeft.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorLeft.locked) - { - doorLeft.frameRec.y = 0; - doorLeft.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 1; - } - } - } - - if (msgState > 2) - { - UpdatePlayer(); - - // Monsters logic - UpdateMonster(&lamp); - UpdateMonster(&chair); - UpdateMonster(&picture); - UpdateMonster(&arc); - } - - // Update monster bounds - lamp.bounds.x = lamp.position.x + 200 - scroll; - chair.bounds.x = chair.position.x + 50 - scroll; - picture.bounds.x = picture.position.x + 44 - scroll; - arc.bounds.x = arc.position.x + 44 - scroll; - - // Check player hover monsters to interact - if (((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) || - ((CheckCollisionRecs(player.bounds, chair.bounds)) && !chair.active) || - ((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.active) || - ((CheckCollisionRecs(player.bounds, arc.bounds)) && !arc.active)) monsterHover = true; - else monsterHover = false; - - - // Monters logic: lamp - if ((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) - { - lamp.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), lamp.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 1; - } - } - else lamp.selected = false; - - // Monters logic: chair - if ((CheckCollisionRecs(player.bounds, chair.bounds)) && !chair.active) - { - chair.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), chair.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 2; - } - } - else chair.selected = false; - - // Monters logic: picture - if ((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.active) - { - picture.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), picture.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 3; - } - } - else picture.selected = false; - - // Monters logic: arc - if ((CheckCollisionRecs(player.bounds, arc.bounds)) && !arc.active) - { - arc.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), arc.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 4; - } - } - else arc.selected = false; - - if (searching) - { - framesCounter++; - - if (framesCounter > 180) - { - if (monsterCheck == 1) - { - if (lamp.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - lamp.active = true; - lamp.selected = false; - } - else if (monsterCheck == 2) - { - if (chair.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - chair.active = true; - chair.selected = false; - } - else if (monsterCheck == 3) - { - if (picture.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - picture.active = true; - picture.selected = false; - } - else if (monsterCheck == 4) - { - if (arc.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - arc.active = true; - arc.selected = false; - } - - searching = false; - framesCounter = 0; - } - } - - // Text animation - framesCounter++; - - if ((framesCounter%2) == 0) lettersCounter++; - - if (msgState == 0) - { - if (lettersCounter <= (int)strlen(message)) strncpy(msgBuffer, message, lettersCounter); - else - { - for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = '\0'; - - lettersCounter = 0; - msgState = 1; - } - - if (IsKeyPressed(KEY_ENTER)) msgState = 1; - } - else if (msgState == 1) - { - msgCounter++; - - if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) - { - msgState = 2; - msgCounter = 0; - } - } - else if (msgState == 2) - { - msgCounter++; - - if (msgCounter > 180) msgState = 3; - } - else msgCounter++; - - if (player.position.x > 200) - { - scroll = player.position.x - 200; - - if (scroll > 620) scroll = 620; - } -} - -// Gameplay Screen Draw logic -void DrawAisle02Screen(void) -{ - DrawTexture(background, -scroll, 0, WHITE); - - // Draw monsters - DrawMonster(lamp, scroll); - DrawMonster(arc, scroll); - DrawMonster(picture, scroll); - DrawMonster(chair, scroll); - - // Draw door - Vector2 doorScrollPos = { doorLeft.position.x - scroll, doorLeft.position.y }; - - if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, GREEN); - else DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, WHITE); - - // Draw messsages - if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f)); - else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f)); - - if (msgState == 0) - { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - } - else if (msgState == 1) - { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - - if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); - } - else if (msgState == 2) - { - if ((msgCounter/30)%2) - { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); - - DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(arc.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(chair.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(picture.bounds, Fade(RED, 0.6f)); - } - } - else - { - if ((monsterHover) && ((msgCounter/30)%2)) - { - DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f)); - DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK); - } - } - - DrawPlayer(); // NOTE: Also draws mouse pointer! -} - -// Gameplay Screen Unload logic -void UnloadAisle02Screen(void) -{ - // TODO: Unload GAMEPLAY screen variables here! - UnloadTexture(background); - - UnloadMonster(lamp); - UnloadMonster(chair); - UnloadMonster(picture); - UnloadMonster(arc); -} - -// Gameplay Screen should finish? -int FinishAisle02Screen(void) -{ - return finishScreen; -} diff --git a/games/skully_escape/screens/screen_armory.c b/games/skully_escape/screens/screen_armory.c deleted file mode 100644 index e05ca4e7f..000000000 --- a/games/skully_escape/screens/screen_armory.c +++ /dev/null @@ -1,404 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" -#include "../player.h" -#include "../monster.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D background; - -// Declare doors -static Door doorLeft; -static Door doorRight; - -// Decalre monsters -static Monster blazon01; -static Monster blazon02; -static Monster blazon03; - -static bool monsterHover = false; -static int monsterCheck = -1; // Identify checking monster - -static const char message[256] = "NO MORE TIPS...\nFOLLOW YOUR INSTINCT!"; -static int msgPosX = 100; - -static int msgState = 0; // 0-writting, 1-wait, 2-choose -static int lettersCounter = 0; -static char msgBuffer[256] = { '\0' }; -static int msgCounter = 0; - -static bool searching = false; - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitArmoryScreen(void) -{ - ResetPlayer(); - - // Reset Screen variables - monsterHover = false; - monsterCheck = -1; - msgState = 0; - msgCounter = 0; - lettersCounter = 0; - for (int i = 0; i < 256; i++) msgBuffer[i] = '\0'; - - framesCounter = 0; - finishScreen = 0; - - background = LoadTexture("resources/textures/background_armory.png"); - - // Initialize doors - doorLeft.position = (Vector2) { -50, 145 }; - doorLeft.facing = 0; - doorLeft.locked = true; - doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2}; - doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2}; - doorLeft.selected = false; - - doorRight.position = (Vector2) { 1074, 140 }; - doorRight.facing = 2; - doorRight.locked = true; - doorRight.frameRec =(Rectangle) {((doors.width/3)*doorRight.facing), doors.height/2, doors.width/3, doors.height/2}; - doorRight.bound = (Rectangle) { doorRight.position.x, doorRight.position.y, doors.width/3, doors.height/2}; - doorRight.selected = false; - - // Monster init: blazon01 - blazon01.position = (Vector2){ 300, 260 }; - blazon01.texture = LoadTexture("resources/textures/monster_blazon01.png"); - blazon01.currentFrame = 0; - blazon01.framesCounter = 0; - blazon01.numFrames = 4; - blazon01.bounds = (Rectangle){ blazon01.position.x, blazon01.position.y + 20, 160, 230 }; - blazon01.frameRec = (Rectangle) { 0, 0, blazon01.texture.width/blazon01.numFrames, blazon01.texture.height }; - blazon01.selected = false; - blazon01.active = false; - blazon01.spooky = true; - - // Monster init: blazon02 - blazon02.position = (Vector2){ 550, 260 }; - blazon02.texture = LoadTexture("resources/textures/monster_blazon02.png"); - blazon02.currentFrame = 0; - blazon02.framesCounter = 0; - blazon02.numFrames = 4; - blazon02.bounds = (Rectangle){ blazon02.position.x, blazon02.position.y + 20, 160, 230 }; - blazon02.frameRec = (Rectangle) { 0, 0, blazon02.texture.width/blazon02.numFrames, blazon02.texture.height }; - blazon02.selected = false; - blazon02.active = false; - blazon02.spooky = true; - - // Monster init: blazon03 - blazon03.position = (Vector2){ 800, 260 }; - blazon03.texture = LoadTexture("resources/textures/monster_blazon03.png"); - blazon03.currentFrame = 0; - blazon03.framesCounter = 0; - blazon03.numFrames = 4; - blazon03.bounds = (Rectangle){ blazon03.position.x, blazon03.position.y + 20, 160, 230 }; - blazon03.frameRec = (Rectangle) { 0, 0, blazon03.texture.width/blazon03.numFrames, blazon03.texture.height }; - blazon03.selected = false; - blazon03.active = false; - blazon03.spooky = false; -} - -// Gameplay Screen Update logic -void UpdateArmoryScreen(void) -{ - if (player.key) - { - // Door: left - if ((CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || - (CheckCollisionRecs(player.bounds, doorLeft.bound))) doorLeft.selected = true; - else doorLeft.selected = false; - - if ((doorLeft.selected) && (CheckCollisionRecs(player.bounds, doorLeft.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorLeft.locked) - { - doorLeft.frameRec.y = 0; - doorLeft.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 1; - } - } - - // Door: right - if ((CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || - (CheckCollisionRecs(player.bounds, doorRight.bound))) doorRight.selected = true; - else doorRight.selected = false; - - if ((doorRight.selected) && (CheckCollisionRecs(player.bounds, doorRight.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorRight.locked) - { - doorRight.frameRec.y = 0; - doorRight.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 2; - } - } - } - - if (msgState > 2) - { - UpdatePlayer(); - - // Monsters logic - UpdateMonster(&blazon01); - UpdateMonster(&blazon02); - UpdateMonster(&blazon03); - } - - // Check player hover monsters to interact - if (((CheckCollisionRecs(player.bounds, blazon01.bounds)) && !blazon01.active) || - ((CheckCollisionRecs(player.bounds, blazon02.bounds)) && !blazon02.active) || - ((CheckCollisionRecs(player.bounds, blazon03.bounds)) && !blazon03.active)) monsterHover = true; - else monsterHover = false; - - // Monters logic: blazon01 - if ((CheckCollisionRecs(player.bounds, blazon01.bounds)) && !blazon01.active) - { - blazon01.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), blazon01.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 1; - } - } - else blazon01.selected = false; - - // Monters logic: blazon02 - if ((CheckCollisionRecs(player.bounds, blazon02.bounds)) && !blazon02.active) - { - blazon02.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), blazon02.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 2; - } - } - else blazon02.selected = false; - - // Monters logic: blazon03 - if ((CheckCollisionRecs(player.bounds, blazon03.bounds)) && !blazon03.active) - { - blazon03.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), blazon03.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 3; - } - } - else blazon03.selected = false; - - if (searching) - { - framesCounter++; - - if (framesCounter > 180) - { - if (monsterCheck == 1) - { - if (blazon01.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - blazon01.active = true; - blazon01.selected = false; - } - else if (monsterCheck == 2) - { - if (blazon02.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - blazon02.active = true; - blazon02.selected = false; - } - else if (monsterCheck == 3) - { - if (blazon03.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - blazon03.active = true; - blazon03.selected = false; - } - - searching = false; - framesCounter = 0; - } - } - - // Text animation - framesCounter++; - - if ((framesCounter%2) == 0) lettersCounter++; - - if (msgState == 0) - { - if (lettersCounter <= (int)strlen(message)) strncpy(msgBuffer, message, lettersCounter); - else - { - for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = '\0'; - - lettersCounter = 0; - msgState = 1; - } - - if (IsKeyPressed(KEY_ENTER)) msgState = 1; - } - else if (msgState == 1) - { - msgCounter++; - - if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) - { - msgState = 2; - msgCounter = 0; - } - } - else if (msgState == 2) - { - msgCounter++; - - if (msgCounter > 180) msgState = 3; - } - else msgCounter++; -} - -// Gameplay Screen Draw logic -void DrawArmoryScreen(void) -{ - DrawTexture(background, 0, 0, WHITE); - - // Draw monsters - DrawMonster(blazon01, 0); - DrawMonster(blazon02, 0); - DrawMonster(blazon03, 0); - - // Draw door - if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, GREEN); - else DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, WHITE); - - if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorRight.position, GREEN); - else DrawTextureRec(doors, doorRight.frameRec, doorRight.position, WHITE); - - // Draw messsages - if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f)); - else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f)); - - if (msgState == 0) - { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - } - else if (msgState == 1) - { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - - if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); - } - else if (msgState == 2) - { - if ((msgCounter/30)%2) - { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); - - DrawRectangleRec(blazon01.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(blazon02.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(blazon03.bounds, Fade(RED, 0.6f)); - } - } - else - { - if ((monsterHover) && ((msgCounter/30)%2)) - { - DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f)); - DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK); - } - } - - DrawPlayer(); // NOTE: Also draws mouse pointer! -} - -// Gameplay Screen Unload logic -void UnloadArmoryScreen(void) -{ - // TODO: Unload GAMEPLAY screen variables here! - UnloadTexture(background); - - UnloadMonster(blazon01); - UnloadMonster(blazon02); - UnloadMonster(blazon03); -} - -// Gameplay Screen should finish? -int FinishArmoryScreen(void) -{ - return finishScreen; -} diff --git a/games/skully_escape/screens/screen_attic.c b/games/skully_escape/screens/screen_attic.c deleted file mode 100644 index 87bffaa22..000000000 --- a/games/skully_escape/screens/screen_attic.c +++ /dev/null @@ -1,332 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" -#include "../player.h" -#include "../monster.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D background; - -// Declare doors -static Door doorRight; - -// Decalre monsters -static Monster lamp; -static Monster arc; - -static bool monsterHover; -static int monsterCheck; // Identify checking monster - -static const char message[256] = "YOUR PARENTS ARE GONE! TIME TO ESCAPE!\nTHE DOOR IS LOCKED... TURN ON THE LIGHTS! ;)"; -static int msgPosX = 100; - -static int msgState = 0; // 0-writting, 1-wait, 2-choose -static int lettersCounter = 0; -static char msgBuffer[256] = { '\0' }; -static int msgCounter = 0; - -static bool searching = false; - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitAtticScreen(void) -{ - ResetPlayer(); - - // Reset Screen variables - monsterHover = false; - monsterCheck = -1; - msgState = 0; - msgCounter = 0; - lettersCounter = 0; - for (int i = 0; i < 256; i++) msgBuffer[i] = '\0'; - - framesCounter = 0; - finishScreen = 0; - - background = LoadTexture("resources/textures/background_attic.png"); - - // Initialize doors - doorRight.position = (Vector2) { 1074, 140 }; - doorRight.facing = 2; - doorRight.locked = true; - doorRight.frameRec =(Rectangle) {((doors.width/3)*doorRight.facing), doors.height/2, doors.width/3, doors.height/2}; - doorRight.bound = (Rectangle) { doorRight.position.x, doorRight.position.y, doors.width/3, doors.height/2}; - doorRight.selected = false; - - // Monster init: lamp - lamp.position = (Vector2){ 50, 316 }; - lamp.texture = LoadTexture("resources/textures/monster_lamp_left.png"); - lamp.currentFrame = 0; - lamp.framesCounter = 0; - lamp.numFrames = 4; - lamp.bounds = (Rectangle){ lamp.position.x + 20, lamp.position.y, 90, 380 }; - lamp.frameRec = (Rectangle) { 0, 0, lamp.texture.width/lamp.numFrames, lamp.texture.height }; - lamp.selected = false; - lamp.active = false; - lamp.spooky = false; - - // Monster init: arc - arc.position = (Vector2){ 760, 430 }; - arc.texture = LoadTexture("resources/textures/monster_arc.png"); - arc.currentFrame = 0; - arc.framesCounter = 0; - arc.numFrames = 4; - arc.bounds = (Rectangle){ arc.position.x + 44, arc.position.y + 70, 220, 120 }; - arc.frameRec = (Rectangle) { 0, 0, arc.texture.width/arc.numFrames, arc.texture.height }; - arc.selected = false; - arc.active = false; - arc.spooky = true; -} - -// Gameplay Screen Update logic -void UpdateAtticScreen(void) -{ - if (player.key) - { - // Door: right - if ((CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || - (CheckCollisionRecs(player.bounds, doorRight.bound))) doorRight.selected = true; - else doorRight.selected = false; - - if ((doorRight.selected) && (CheckCollisionRecs(player.bounds, doorRight.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorRight.locked) - { - doorRight.frameRec.y = 0; - doorRight.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 1; - } - } - } - - if (msgState > 2) - { - UpdatePlayer(); - - // Monsters logic - UpdateMonster(&lamp); - UpdateMonster(&arc); - } - - // Check player hover monsters to interact - if (((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) || - ((CheckCollisionRecs(player.bounds, arc.bounds)) && !arc.active)) monsterHover = true; - else monsterHover = false; - - // Monters logic: lamp - if ((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) - { - lamp.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), lamp.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 1; - } - } - else lamp.selected = false; - - // Monters logic: arc - if ((CheckCollisionRecs(player.bounds, arc.bounds)) && !arc.active) - { - arc.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), arc.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 2; - } - } - else arc.selected = false; - - if (searching) - { - framesCounter++; - - if (framesCounter > 180) - { - if (monsterCheck == 1) - { - if (lamp.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - lamp.active = true; - lamp.selected = false; - } - else if (monsterCheck == 2) - { - if (arc.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - arc.active = true; - arc.selected = false; - } - - searching = false; - framesCounter = 0; - } - } - - // Text animation - framesCounter++; - - if ((framesCounter%2) == 0) lettersCounter++; - - if (msgState == 0) - { - if (lettersCounter <= (int)strlen(message)) strncpy(msgBuffer, message, lettersCounter); - else - { - for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = '\0'; - - lettersCounter = 0; - msgState = 1; - } - - if (IsKeyPressed(KEY_ENTER)) msgState = 1; - } - else if (msgState == 1) - { - msgCounter++; - - if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) - { - msgState = 2; - msgCounter = 0; - } - } - else if (msgState == 2) - { - msgCounter++; - - if (msgCounter > 180) msgState = 3; - } - else msgCounter++; - - if (IsKeyPressed('M')) - { - finishScreen = 1; - } -} - -// Gameplay Screen Draw logic -void DrawAtticScreen(void) -{ - DrawTexture(background, 0, 0, WHITE); - - // Draw monsters - DrawMonster(lamp, 0); - DrawMonster(arc, 0); - - // Draw door - if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorRight.position, GREEN); - else DrawTextureRec(doors, doorRight.frameRec, doorRight.position, WHITE); - - // Draw messsages - if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f)); - else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f)); - - if (msgState == 0) - { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - } - else if (msgState == 1) - { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - - if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); - } - else if (msgState == 2) - { - if ((msgCounter/30)%2) - { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); - - DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(arc.bounds, Fade(RED, 0.6f)); - } - } - else - { - if ((monsterHover) && ((msgCounter/30)%2)) - { - DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f)); - DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK); - } - } - - DrawPlayer(); // NOTE: Also draws mouse pointer! -} - -// Gameplay Screen Unload logic -void UnloadAtticScreen(void) -{ - // TODO: Unload GAMEPLAY screen variables here! - UnloadTexture(background); - - UnloadMonster(lamp); - UnloadMonster(arc); -} - -// Gameplay Screen should finish? -int FinishAtticScreen(void) -{ - return finishScreen; -} diff --git a/games/skully_escape/screens/screen_bathroom.c b/games/skully_escape/screens/screen_bathroom.c deleted file mode 100644 index 1f228803d..000000000 --- a/games/skully_escape/screens/screen_bathroom.c +++ /dev/null @@ -1,383 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" -#include "../player.h" -#include "../monster.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D background; - -// Declare doors -static Door doorRight; - -// Decalre monst -static Monster lamp; -static Monster chair; -static Monster mirror; - -static bool monsterHover = false; -static int monsterCheck = -1; // Identify checking monster - -static const char message[256] = "TRICK OR TREAT! WHO IS THE MOST BEAUTIFUL\nSKELETON IN THE WORLD?"; -static int msgPosX = 100; - -static int msgState = 0; // 0-writting, 1-wait, 2-choose -static int lettersCounter = 0; -static char msgBuffer[256] = { '\0' }; -static int msgCounter = 0; - -static bool searching = false; - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitBathroomScreen(void) -{ - ResetPlayer(); - - // Reset Screen variables - monsterHover = false; - monsterCheck = -1; - msgState = 0; - msgCounter = 0; - lettersCounter = 0; - for (int i = 0; i < 256; i++) msgBuffer[i] = '\0'; - - framesCounter = 0; - finishScreen = 0; - - background = LoadTexture("resources/textures/background_bathroom.png"); - - // Reset Screen variables - monsterHover = false; - monsterCheck = -1; - msgState = 0; - msgCounter = 0; - lettersCounter = 0; - for (int i = 0; i < 256; i++) msgBuffer[i] = '\0'; - - // Initialize doors - doorRight.position = (Vector2) { 1070, 135 }; - doorRight.facing = 2; - doorRight.locked = true; - doorRight.frameRec =(Rectangle) {((doors.width/3)*doorRight.facing), doors.height/2, doors.width/3, doors.height/2}; - doorRight.bound = (Rectangle) { doorRight.position.x, doorRight.position.y, doors.width/3, doors.height/2}; - doorRight.selected = false; - - // Monster init: lamp - lamp.position = (Vector2){ 35, 334 }; - lamp.texture = LoadTexture("resources/textures/monster_lamp_left.png"); - lamp.currentFrame = 0; - lamp.framesCounter = 0; - lamp.numFrames = 4; - lamp.bounds = (Rectangle){ lamp.position.x + 20, lamp.position.y + 0, 90, 380}; - lamp.frameRec = (Rectangle) { 0, 0, lamp.texture.width/lamp.numFrames, lamp.texture.height }; - lamp.selected = false; - lamp.active = false; - lamp.spooky = true; - - // Monster init: mirror - mirror.position = (Vector2){ 300, 200 }; - mirror.texture = LoadTexture("resources/textures/monster_mirror.png"); - mirror.currentFrame = 0; - mirror.framesCounter = 0; - mirror.numFrames = 4; - mirror.bounds = (Rectangle){ mirror.position.x + 40, mirror.position.y + 20, 190, 200 }; - mirror.frameRec = (Rectangle) { 0, 0, mirror.texture.width/mirror.numFrames, mirror.texture.height }; - mirror.selected = false; - mirror.active = false; - mirror.spooky = false; - - // Monster init: chair - chair.position = (Vector2){ 760, 430 }; - chair.texture = LoadTexture("resources/textures/monster_chair_right.png"); - chair.currentFrame = 0; - chair.framesCounter = 0; - chair.numFrames = 4; - chair.bounds = (Rectangle){ chair.position.x + 30, chair.position.y + 30, 120, 190 }; - chair.frameRec = (Rectangle) { 0, 0, chair.texture.width/chair.numFrames, chair.texture.height }; - chair.selected = false; - chair.active = false; - chair.spooky = true; -} - -// Gameplay Screen Update logic -void UpdateBathroomScreen(void) -{ - if (player.key) - { - // Door: right - if ((CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || - (CheckCollisionRecs(player.bounds, doorRight.bound))) doorRight.selected = true; - else doorRight.selected = false; - - if ((doorRight.selected) && (CheckCollisionRecs(player.bounds, doorRight.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorRight.locked) - { - doorRight.frameRec.y = 0; - doorRight.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 1; - } - } - } - - if (msgState > 2) - { - UpdatePlayer(); - - // Monsters logic - UpdateMonster(&lamp); - UpdateMonster(&mirror); - UpdateMonster(&chair); - } - - // Check player hover monsters to interact - if (((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) || - ((CheckCollisionRecs(player.bounds, mirror.bounds)) && !mirror.active) || - ((CheckCollisionRecs(player.bounds, chair.bounds)) && !chair.active)) monsterHover = true; - else monsterHover = false; - - - // Monters logic: lamp - if ((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) - { - lamp.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), lamp.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 1; - } - } - else lamp.selected = false; - - // Monters logic: mirror - if ((CheckCollisionRecs(player.bounds, mirror.bounds)) && !mirror.active) - { - mirror.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), mirror.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 2; - } - } - else mirror.selected = false; - - // Monters logic: chair - if ((CheckCollisionRecs(player.bounds, chair.bounds)) && !chair.active) - { - chair.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), chair.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 3; - } - } - else chair.selected = false; - - if (searching) - { - framesCounter++; - - if (framesCounter > 180) - { - if (monsterCheck == 1) - { - if (lamp.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - lamp.active = true; - lamp.selected = false; - } - else if (monsterCheck == 2) - { - if (mirror.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - mirror.active = true; - mirror.selected = false; - } - else if (monsterCheck == 3) - { - if (chair.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - chair.active = true; - chair.selected = false; - } - - searching = false; - framesCounter = 0; - } - } - - // Text animation - framesCounter++; - - if ((framesCounter%2) == 0) lettersCounter++; - - if (msgState == 0) - { - if (lettersCounter <= (int)strlen(message)) strncpy(msgBuffer, message, lettersCounter); - else - { - for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = '\0'; - - lettersCounter = 0; - msgState = 1; - } - - if (IsKeyPressed(KEY_ENTER)) msgState = 1; - } - else if (msgState == 1) - { - msgCounter++; - - if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) - { - msgState = 2; - msgCounter = 0; - } - } - else if (msgState == 2) - { - msgCounter++; - - if (msgCounter > 180) msgState = 3; - } - else msgCounter++; -} - -// Gameplay Screen Draw logic -void DrawBathroomScreen(void) -{ - DrawTexture(background, 0, 0, WHITE); - - // Draw monsters - DrawMonster(lamp, 0); - DrawMonster(mirror, 0); - DrawMonster(chair, 0); - - // Draw door - if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorRight.position, GREEN); - else DrawTextureRec(doors, doorRight.frameRec, doorRight.position, WHITE); - - // Draw messsages - if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f)); - else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f)); - - if (msgState == 0) - { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - } - else if (msgState == 1) - { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - - if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); - } - else if (msgState == 2) - { - if ((msgCounter/30)%2) - { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); - - DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(mirror.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(chair.bounds, Fade(RED, 0.6f)); - } - } - else - { - if ((monsterHover) && ((msgCounter/30)%2)) - { - DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f)); - DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK); - } - } - - DrawPlayer(); // NOTE: Also draws mouse pointer! -} - -// Gameplay Screen Unload logic -void UnloadBathroomScreen(void) -{ - // TODO: Unload GAMEPLAY screen variables here! - UnloadTexture(background); - - UnloadMonster(lamp); - UnloadMonster(chair); - UnloadMonster(mirror); -} - -// Gameplay Screen should finish? -int FinishBathroomScreen(void) -{ - return finishScreen; -} diff --git a/games/skully_escape/screens/screen_ending.c b/games/skully_escape/screens/screen_ending.c deleted file mode 100644 index deffbb82c..000000000 --- a/games/skully_escape/screens/screen_ending.c +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Ending Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Ending screen global variables -static int framesCounter; -static int finishScreen; - -static float alpha = 0.0f; - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Ending Screen Initialization logic -void InitEndingScreen(void) -{ - // TODO: Initialize ENDING screen variables here! - framesCounter = 0; - finishScreen = 0; - alpha = 0.0f; -} - -// Ending Screen Update logic -void UpdateEndingScreen(void) -{ - // TODO: Update ENDING screen variables here! - framesCounter++; - - alpha += 0.005f; - - if (alpha >= 1.0f) alpha = 1.0f; - - // Press enter to change to ATTIC screen - if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) - { - finishScreen = 1; - } -} - -// Ending Screen Draw logic -void DrawEndingScreen(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKGRAY); - - DrawTextEx(font, "CONGRATULATIONS!", (Vector2){ 50, 160 }, font.baseSize*3, 2, Fade(WHITE, alpha)); - DrawTextEx(font, "SKULLY ESCAPED!", (Vector2){ 100, 300 }, font.baseSize*3, 2, Fade(WHITE, alpha)); - - if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawText("PRESS ENTER or CLICK", 380, 545, 40, BLACK); -} - -// Ending Screen Unload logic -void UnloadEndingScreen(void) -{ - // TODO: Unload ENDING screen variables here! -} - -// Ending Screen should finish? -int FinishEndingScreen(void) -{ - return finishScreen; -} diff --git a/games/skully_escape/screens/screen_kitchen.c b/games/skully_escape/screens/screen_kitchen.c deleted file mode 100644 index 01ce326ab..000000000 --- a/games/skully_escape/screens/screen_kitchen.c +++ /dev/null @@ -1,403 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" -#include "../player.h" -#include "../monster.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D background; - -// Declare doors -static Door doorLeft; -static Door doorRight; - -// Decalre monsters -static Monster closet; -static Monster chair; -static Monster window; - -static bool monsterHover = false; -static int monsterCheck = -1; // Identify checking monster - -static const char message[256] = "QUITE BORING AROUND...\nANY BETTER ENTERTAINING?"; -static int msgPosX = 100; - -static int msgState = 0; // 0-writting, 1-wait, 2-choose -static int lettersCounter = 0; -static char msgBuffer[256] = { '\0' }; -static int msgCounter = 0; - -static bool searching = false; - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitKitchenScreen(void) -{ - ResetPlayer(); - - // Reset Screen variables - monsterHover = false; - monsterCheck = -1; - msgState = 0; - msgCounter = 0; - lettersCounter = 0; - for (int i = 0; i < 256; i++) msgBuffer[i] = '\0'; - - framesCounter = 0; - finishScreen = 0; - - background = LoadTexture("resources/textures/background_kitchen.png"); - - // Initialize doors - doorLeft.position = (Vector2) { -45, 136 }; - doorLeft.facing = 0; - doorLeft.locked = true; - doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2}; - doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2}; - doorLeft.selected = false; - - doorRight.position = (Vector2) { 1090, 148 }; - doorRight.facing = 2; - doorRight.locked = true; - doorRight.frameRec =(Rectangle) {((doors.width/3)*doorRight.facing), doors.height/2, doors.width/3, doors.height/2}; - doorRight.bound = (Rectangle) { doorRight.position.x, doorRight.position.y, doors.width/3, doors.height/2}; - doorRight.selected = false; - - // Monster init: lamp - closet.position = (Vector2){ 280, 260 }; - closet.texture = LoadTexture("resources/textures/monster_closet.png"); - closet.currentFrame = 0; - closet.framesCounter = 0; - closet.numFrames = 4; - closet.bounds = (Rectangle){ closet.position.x + 100, closet.position.y+25, 272,348 }; - closet.frameRec = (Rectangle) { 0, 0, closet.texture.width/closet.numFrames, closet.texture.height }; - closet.selected = false; - closet.active = false; - closet.spooky = true; - - // Monster init: chair - chair.position = (Vector2){ 230, 410 }; - chair.texture = LoadTexture("resources/textures/monster_chair_left.png"); - chair.currentFrame = 0; - chair.framesCounter = 0; - chair.numFrames = 4; - chair.bounds = (Rectangle){ chair.position.x + 30, chair.position.y + 60, 100, 160 }; - chair.frameRec = (Rectangle) { 0, 0, chair.texture.width/chair.numFrames, chair.texture.height }; - chair.selected = false; - chair.active = false; - chair.spooky = true; - - // Monster init: window - window.position = (Vector2){ 715, 88 }; - window.texture = LoadTexture("resources/textures/monster_window.png"); - window.currentFrame = 0; - window.framesCounter = 0; - window.numFrames = 4; - window.bounds = (Rectangle){ window.position.x + 100, window.position.y + 10, 200, 370 }; - window.frameRec = (Rectangle) { 0, 0, window.texture.width/window.numFrames, window.texture.height }; - window.selected = false; - window.active = false; - window.spooky = false; -} - -// Gameplay Screen Update logic -void UpdateKitchenScreen(void) -{ - if (player.key) - { - // Door: left - if ((CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || - (CheckCollisionRecs(player.bounds, doorLeft.bound))) doorLeft.selected = true; - else doorLeft.selected = false; - - if ((doorLeft.selected) && (CheckCollisionRecs(player.bounds, doorLeft.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorLeft.locked) - { - doorLeft.frameRec.y = 0; - doorLeft.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 1; - } - } - - // Door: right - if ((CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || - (CheckCollisionRecs(player.bounds, doorRight.bound))) doorRight.selected = true; - else doorRight.selected = false; - - if ((doorRight.selected) && (CheckCollisionRecs(player.bounds, doorRight.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorRight.locked) - { - doorRight.frameRec.y = 0; - doorRight.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 2; - } - } - } - - if (msgState > 2) - { - UpdatePlayer(); - - // Monsters logic - UpdateMonster(&closet); - UpdateMonster(&chair); - UpdateMonster(&window); - } - - // Check player hover monsters to interact - if (((CheckCollisionRecs(player.bounds, closet.bounds)) && !closet.active) || - ((CheckCollisionRecs(player.bounds, window.bounds)) && !window.active)) monsterHover = true; - else monsterHover = false; - - // Monters logic: closet - if ((CheckCollisionRecs(player.bounds, closet.bounds)) && !closet.active) - { - closet.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), closet.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 1; - } - } - else closet.selected = false; - - // Monters logic: chair - if ((CheckCollisionRecs(player.bounds, chair.bounds)) && !chair.active) - { - chair.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), chair.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 2; - } - } - else chair.selected = false; - - // Monters logic: window - if ((CheckCollisionRecs(player.bounds, window.bounds)) && !window.active) - { - window.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), window.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 3; - } - } - else window.selected = false; - - if (searching) - { - framesCounter++; - - if (framesCounter > 180) - { - if (monsterCheck == 1) - { - if (closet.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - closet.active = true; - closet.selected = false; - } - else if (monsterCheck == 2) - { - if (chair.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - chair.active = true; - chair.selected = false; - } - else if (monsterCheck == 3) - { - if (window.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - window.active = true; - window.selected = false; - } - - searching = false; - framesCounter = 0; - } - } - - // Text animation - framesCounter++; - - if ((framesCounter%2) == 0) lettersCounter++; - - if (msgState == 0) - { - if (lettersCounter <= (int)strlen(message)) strncpy(msgBuffer, message, lettersCounter); - else - { - for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = '\0'; - - lettersCounter = 0; - msgState = 1; - } - - if (IsKeyPressed(KEY_ENTER)) msgState = 1; - } - else if (msgState == 1) - { - msgCounter++; - - if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) - { - msgState = 2; - msgCounter = 0; - } - } - else if (msgState == 2) - { - msgCounter++; - - if (msgCounter > 180) msgState = 3; - } - else msgCounter++; -} - -// Gameplay Screen Draw logic -void DrawKitchenScreen(void) -{ - DrawTexture(background, 0, 0, WHITE); - - // Draw monsters - DrawMonster(closet, 0); - DrawMonster(chair, 0); - DrawMonster(window, 0); - - // Draw door - if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorRight.position, GREEN); - else DrawTextureRec(doors, doorRight.frameRec, doorRight.position, WHITE); - - if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, GREEN); - else DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, WHITE); - - // Draw messsages - if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f)); - else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f)); - - if (msgState == 0) - { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - } - else if (msgState == 1) - { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - - if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); - } - else if (msgState == 2) - { - if ((msgCounter/30)%2) - { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); - - DrawRectangleRec(closet.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(window.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(chair.bounds, Fade(RED, 0.6f)); - } - } - else - { - if ((monsterHover) && ((msgCounter/30)%2)) - { - DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f)); - DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK); - } - } - - DrawPlayer(); // NOTE: Also draws mouse pointer! -} - -// Gameplay Screen Unload logic -void UnloadKitchenScreen(void) -{ - // TODO: Unload GAMEPLAY screen variables here! - UnloadTexture(background); - - UnloadMonster(closet); - UnloadMonster(chair); - UnloadMonster(window); -} - -// Gameplay Screen should finish? -int FinishKitchenScreen(void) -{ - return finishScreen; -} diff --git a/games/skully_escape/screens/screen_livingroom.c b/games/skully_escape/screens/screen_livingroom.c deleted file mode 100644 index fa465bfa2..000000000 --- a/games/skully_escape/screens/screen_livingroom.c +++ /dev/null @@ -1,403 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" -#include "../player.h" -#include "../monster.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D background; - -// Declare doors -static Door doorCenter; -static Door doorLeft; - -// Decalre monsters -static Monster candle; -static Monster picture; -static Monster phone; - -static bool monsterHover = false; -static int monsterCheck = -1; // Identify checking monster - -static const char message[256] = "WHEN WIND BLOWS, IT KNOWS THE DIRECTION\nLET IT GUIDE YOU!"; -static int msgPosX = 100; - -static int msgState = 0; // 0-writting, 1-wait, 2-choose -static int lettersCounter = 0; -static char msgBuffer[256] = { '\0' }; -static int msgCounter = 0; - -static bool searching = false; - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitLivingroomScreen(void) -{ - ResetPlayer(); - - // Reset Screen variables - monsterHover = false; - monsterCheck = -1; - msgState = 0; - msgCounter = 0; - lettersCounter = 0; - for (int i = 0; i < 256; i++) msgBuffer[i] = '\0'; - - framesCounter = 0; - finishScreen = 0; - - background = LoadTexture("resources/textures/background_livingroom.png"); - - // Initialize doors - doorLeft.position = (Vector2) { -45, 140}; - doorLeft.facing = 0; - doorLeft.locked = true; - doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2}; - doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2}; - doorLeft.selected = false; - - doorCenter.position = (Vector2) { 830, 108 }; - doorCenter.facing = 1; - doorCenter.locked = true; - doorCenter.frameRec =(Rectangle) {((doors.width/3)*doorCenter.facing), doors.height/2, doors.width/3, doors.height/2}; - doorCenter.bound = (Rectangle) { doorCenter.position.x, doorCenter.position.y, doors.width/3, doors.height/2}; - doorCenter.selected = false; - - // Monster init: lamp - candle.position = (Vector2){ 154, 256 }; - candle.texture = LoadTexture("resources/textures/monster_candle.png"); - candle.currentFrame = 0; - candle.framesCounter = 0; - candle.numFrames = 4; - candle.bounds = (Rectangle){ candle.position.x + 90, candle.position.y + 30, 185, 340 }; - candle.frameRec = (Rectangle) { 0, 0, candle.texture.width/candle.numFrames, candle.texture.height }; - candle.selected = false; - candle.active = false; - candle.spooky = false; - - // Monster init: arc - picture.position = (Vector2){ 504, 164 }; - picture.texture = LoadTexture("resources/textures/monster_picture.png"); - picture.currentFrame = 0; - picture.framesCounter = 0; - picture.numFrames = 4; - picture.bounds = (Rectangle){ picture.position.x + 44, picture.position.y, 174, 264 }; - picture.frameRec = (Rectangle) { 0, 0, picture.texture.width/picture.numFrames, picture.texture.height }; - picture.selected = false; - picture.active = false; - picture.spooky = true; - - // Monster init: phone - phone.position = (Vector2){ 1054, 404 }; - phone.texture = LoadTexture("resources/textures/monster_phone.png"); - phone.currentFrame = 0; - phone.framesCounter = 0; - phone.numFrames = 4; - phone.bounds = (Rectangle){ phone.position.x + 64, phone.position.y +120, 100, 160 }; - phone.frameRec = (Rectangle) { 0, 0, phone.texture.width/phone.numFrames, phone.texture.height }; - phone.selected = false; - phone.active = false; - phone.spooky = true; -} - -// Gameplay Screen Update logic -void UpdateLivingroomScreen(void) -{ - if (player.key) - { - // Door: left - if ((CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || - (CheckCollisionRecs(player.bounds, doorLeft.bound))) doorLeft.selected = true; - else doorLeft.selected = false; - - if ((doorLeft.selected) && (CheckCollisionRecs(player.bounds, doorLeft.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorLeft.locked) - { - doorLeft.frameRec.y = 0; - doorLeft.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 1; - } - } - - // Door: center - if ((CheckCollisionPointRec(GetMousePosition(), doorCenter.bound)) || - (CheckCollisionRecs(player.bounds, doorCenter.bound))) doorCenter.selected = true; - else doorCenter.selected = false; - - if ((doorCenter.selected) && (CheckCollisionRecs(player.bounds, doorCenter.bound))) - { - if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorCenter.bound)) || (IsKeyPressed(KEY_SPACE))) - { - if (doorCenter.locked) - { - doorCenter.frameRec.y = 0; - doorCenter.locked = false; - PlaySound(sndDoor); - } - else finishScreen = 2; - } - } - } - - if (msgState > 2) - { - UpdatePlayer(); - - // Monsters logic - UpdateMonster(&candle); - UpdateMonster(&picture); - UpdateMonster(&phone); - } - - // Check player hover monsters to interact - if (((CheckCollisionRecs(player.bounds, candle.bounds)) && !candle.active) || - ((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.active) || - ((CheckCollisionRecs(player.bounds, phone.bounds)) && !phone.active)) monsterHover = true; - else monsterHover = false; - - // Monters logic: candle - if ((CheckCollisionRecs(player.bounds, candle.bounds)) && !candle.active) - { - candle.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), candle.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 1; - } - } - else candle.selected = false; - - // Monters logic: picture - if ((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.active) - { - picture.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), picture.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 2; - } - } - else picture.selected = false; - - // Monters logic: phone - if ((CheckCollisionRecs(player.bounds, phone.bounds)) && !phone.active) - { - phone.selected = true; - - if ((IsKeyPressed(KEY_SPACE)) || - ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), phone.bounds)))) - { - SearchKeyPlayer(); - searching = true; - framesCounter = 0; - - monsterCheck = 3; - } - } - else phone.selected = false; - - if (searching) - { - framesCounter++; - - if (framesCounter > 180) - { - if (monsterCheck == 1) - { - if (candle.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - candle.active = true; - candle.selected = false; - } - else if (monsterCheck == 2) - { - if (picture.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - picture.active = true; - picture.selected = false; - } - else if (monsterCheck == 3) - { - if (phone.spooky) - { - ScarePlayer(); - PlaySound(sndScream); - } - else FindKeyPlayer(); - - phone.active = true; - phone.selected = false; - } - - searching = false; - framesCounter = 0; - } - } - - // Text animation - framesCounter++; - - if ((framesCounter%2) == 0) lettersCounter++; - - if (msgState == 0) - { - if (lettersCounter <= (int)strlen(message)) strncpy(msgBuffer, message, lettersCounter); - else - { - for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = '\0'; - - lettersCounter = 0; - msgState = 1; - } - - if (IsKeyPressed(KEY_ENTER)) msgState = 1; - } - else if (msgState == 1) - { - msgCounter++; - - if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) - { - msgState = 2; - msgCounter = 0; - } - } - else if (msgState == 2) - { - msgCounter++; - - if (msgCounter > 180) msgState = 3; - } - else msgCounter++; -} - -// Gameplay Screen Draw logic -void DrawLivingroomScreen(void) -{ - DrawTexture(background, 0, 0, WHITE); - - // Draw monsters - DrawMonster(picture, 0); - DrawMonster(candle, 0); - DrawMonster(phone, 0); - - // Draw door - if (doorCenter.selected) DrawTextureRec(doors, doorCenter.frameRec, doorCenter.position, GREEN); - else DrawTextureRec(doors, doorCenter.frameRec, doorCenter.position, WHITE); - if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, GREEN); - else DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, WHITE); - - // Draw messsages - if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f)); - else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f)); - - if (msgState == 0) - { - DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - } - else if (msgState == 1) - { - DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE); - - if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); - } - else if (msgState == 2) - { - if ((msgCounter/30)%2) - { - DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE); - - DrawRectangleRec(candle.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(phone.bounds, Fade(RED, 0.6f)); - DrawRectangleRec(picture.bounds, Fade(RED, 0.6f)); - } - } - else - { - if ((monsterHover) && ((msgCounter/30)%2)) - { - DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f)); - DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK); - } - } - - DrawPlayer(); // NOTE: Also draws mouse pointer! -} - -// Gameplay Screen Unload logic -void UnloadLivingroomScreen(void) -{ - // TODO: Unload GAMEPLAY screen variables here! - UnloadTexture(background); - - UnloadMonster(candle); - UnloadMonster(picture); - UnloadMonster(phone); -} - -// Gameplay Screen should finish? -int FinishLivingroomScreen(void) -{ - return finishScreen; -} diff --git a/games/skully_escape/screens/screen_logo.c b/games/skully_escape/screens/screen_logo.c deleted file mode 100644 index 3e5e311d3..000000000 --- a/games/skully_escape/screens/screen_logo.c +++ /dev/null @@ -1,108 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Logo Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Logo screen global variables -static int framesCounter = 0; -static int finishScreen; - -static Texture2D logo; -static float logoAlpha = 0; - -static int state = 0; - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Logo Screen Initialization logic -void InitLogoScreen(void) -{ - // Initialize LOGO screen variables here! - finishScreen = 0; - - logo = LoadTexture("resources/textures/skully_logo.png"); -} - -// Logo Screen Update logic -void UpdateLogoScreen(void) -{ - // Update LOGO screen variables here! - if (state == 0) - { - logoAlpha += 0.04f; - - if (logoAlpha >= 1.0f) state = 1; - } - else if (state == 1) - { - framesCounter++; - - if (framesCounter > 180) state = 2; - } - else if (state == 2) - { - logoAlpha -= 0.04f; - - if (logoAlpha <= 0.0f) - { - framesCounter = 0; - state = 3; - } - } - else if (state == 3) - { - finishScreen = 1; - } -} - -// Logo Screen Draw logic -void DrawLogoScreen(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), RAYWHITE); - - DrawTexture(logo, GetScreenWidth()/2 - logo.width/2, 130, Fade(WHITE, logoAlpha)); - - DrawText("GRAY TEAM", 340, 450, 100, Fade(DARKGRAY, logoAlpha)); -} - -// Logo Screen Unload logic -void UnloadLogoScreen(void) -{ - // Unload LOGO screen variables here! - UnloadTexture(logo); -} - -// Logo Screen should finish? -int FinishLogoScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/skully_escape/screens/screen_logo_raylib.c b/games/skully_escape/screens/screen_logo_raylib.c deleted file mode 100644 index 1eb6cca40..000000000 --- a/games/skully_escape/screens/screen_logo_raylib.c +++ /dev/null @@ -1,201 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Logo Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#define LOGO_RECS_SIDE 16 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Logo screen global variables -static int framesCounter = 0; -static int finishScreen; - -static int logoPositionX; -static int logoPositionY; - -static int lettersCount = 0; - -static int topSideRecWidth = LOGO_RECS_SIDE; -static int leftSideRecHeight = LOGO_RECS_SIDE; - -static int bottomSideRecWidth = LOGO_RECS_SIDE; -static int rightSideRecHeight = LOGO_RECS_SIDE; - -static char raylib[8]; // raylib text array, max 8 letters -static int state = 0; // Tracking animation states (State Machine) -static float alpha = 1.0f; // Useful for fading - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Logo Screen Initialization logic -void rlInitLogoScreen(void) -{ - // TODO: Initialize LOGO screen variables here! - finishScreen = 0; - - logoPositionX = GetScreenWidth()/2 - 128; - logoPositionY = GetScreenHeight()/2 - 128; - - for (int i = 0; i < 8; i++) raylib[i] = '\0'; -} - -// Logo Screen Update logic -void rlUpdateLogoScreen(void) -{ - // Update LOGO screen variables here! - if (state == 0) // State 0: Small box blinking - { - framesCounter++; - - if (framesCounter == 80) - { - state = 1; - framesCounter = 0; // Reset counter... will be used later... - } - } - else if (state == 1) // State 1: Top and left bars growing - { - topSideRecWidth += 8; - leftSideRecHeight += 8; - - if (topSideRecWidth == 256) state = 2; - } - else if (state == 2) // State 2: Bottom and right bars growing - { - bottomSideRecWidth += 8; - rightSideRecHeight += 8; - - if (bottomSideRecWidth == 256) state = 3; - } - else if (state == 3) // State 3: Letters appearing (one by one) - { - framesCounter++; - - if (framesCounter/10) // Every 12 frames, one more letter! - { - lettersCount++; - framesCounter = 0; - } - - switch (lettersCount) - { - case 1: raylib[0] = 'r'; break; - case 2: raylib[1] = 'a'; break; - case 3: raylib[2] = 'y'; break; - case 4: raylib[3] = 'l'; break; - case 5: raylib[4] = 'i'; break; - case 6: raylib[5] = 'b'; break; - default: break; - } - - // When all letters have appeared... - if (lettersCount >= 10) - { - state = 4; - framesCounter = 0; - } - } - else if (state == 4) - { - framesCounter++; - - if (framesCounter > 100) - { - alpha -= 0.02f; - - if (alpha <= 0.0f) - { - alpha = 0.0f; - finishScreen = 1; - } - } - } -} - -// Logo Screen Draw logic -void rlDrawLogoScreen(void) -{ - if (state == 0) - { - if ((framesCounter/10)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK); - } - else if (state == 1) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - } - else if (state == 2) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK); - } - else if (state == 3) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - } - else if (state == 4) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - - if (framesCounter > 20) DrawText("powered by", logoPositionX, logoPositionY - 27, 20, Fade(DARKGRAY, alpha)); - } -} - -// Logo Screen Unload logic -void rlUnloadLogoScreen(void) -{ - // TODO: Unload LOGO screen variables here! -} - -// Logo Screen should finish? -int rlFinishLogoScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/skully_escape/screens/screen_title.c b/games/skully_escape/screens/screen_title.c deleted file mode 100644 index ad231dcdb..000000000 --- a/games/skully_escape/screens/screen_title.c +++ /dev/null @@ -1,92 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Title Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Title screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D title; -static float titleAlpha = 0.0f; - -//---------------------------------------------------------------------------------- -// Title Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Title Screen Initialization logic -void InitTitleScreen(void) -{ - // Initialize TITLE screen variables here! - framesCounter = 0; - finishScreen = 0; - - title = LoadTexture("resources/textures/title.png"); -} - -// Title Screen Update logic -void UpdateTitleScreen(void) -{ - // Update TITLE screen variables here! - framesCounter++; - - titleAlpha += 0.005f; - - if (titleAlpha >= 1.0f) titleAlpha = 1.0f; - - // Press enter to change to ATTIC screen - if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) - { - finishScreen = 1; - } -} - -// Title Screen Draw logic -void DrawTitleScreen(void) -{ - //DrawText("TITLE SCREEN", 100, 100, 140, Fade(BLACK, titleAlpha)); - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKGRAY); - DrawTexture(title, GetScreenWidth()/2 - title.width/2, 20, Fade(WHITE, titleAlpha)); - - if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawText("PRESS ENTER to START", 380, 545, 40, BLACK); -} - -// Title Screen Unload logic -void UnloadTitleScreen(void) -{ - // Unload TITLE screen variables here! - UnloadTexture(title); -} - -// Title Screen should finish? -int FinishTitleScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/skully_escape/screens/screens.h b/games/skully_escape/screens/screens.h deleted file mode 100644 index eed0138cc..000000000 --- a/games/skully_escape/screens/screens.h +++ /dev/null @@ -1,164 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Screens Functions Declarations (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef SCREENS_H -#define SCREENS_H - -#define PLAYER_ANIM_FRAMES 7 -#define PLAYER_ANIM_SEQ 2 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum GameScreen { LOGO = 0, LOGO_RL, TITLE, ATTIC, AISLE01, AISLE02, BATHROOM, LIVINGROOM, KITCHEN, ARMORY, ENDING } GameScreen; - -typedef struct Door { - Vector2 position; - int facing; - bool locked; - bool selected; - Rectangle frameRec; - Rectangle bound; -} Door; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -GameScreen currentScreen; -Font font; - -Texture2D doors; -Sound sndDoor; -Sound sndScream; - - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLogoScreen(void); -void UpdateLogoScreen(void); -void DrawLogoScreen(void); -void UnloadLogoScreen(void); -int FinishLogoScreen(void); - -//---------------------------------------------------------------------------------- -// raylib Logo Screen Functions Declaration -//---------------------------------------------------------------------------------- -void rlInitLogoScreen(void); -void rlUpdateLogoScreen(void); -void rlDrawLogoScreen(void); -void rlUnloadLogoScreen(void); -int rlFinishLogoScreen(void); - -//---------------------------------------------------------------------------------- -// Title Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitTitleScreen(void); -void UpdateTitleScreen(void); -void DrawTitleScreen(void); -void UnloadTitleScreen(void); -int FinishTitleScreen(void); - -//---------------------------------------------------------------------------------- -// Attic Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitAtticScreen(void); -void UpdateAtticScreen(void); -void DrawAtticScreen(void); -void UnloadAtticScreen(void); -int FinishAtticScreen(void); - -//---------------------------------------------------------------------------------- -// Aisle01 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitAisle01Screen(void); -void UpdateAisle01Screen(void); -void DrawAisle01Screen(void); -void UnloadAisle01Screen(void); -int FinishAisle01Screen(void); - -//---------------------------------------------------------------------------------- -// Aisle02 Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitAisle02Screen(void); -void UpdateAisle02Screen(void); -void DrawAisle02Screen(void); -void UnloadAisle02Screen(void); -int FinishAisle02Screen(void); - -//---------------------------------------------------------------------------------- -// Bathroom Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitBathroomScreen(void); -void UpdateBathroomScreen(void); -void DrawBathroomScreen(void); -void UnloadBathroomScreen(void); -int FinishBathroomScreen(void); - -//---------------------------------------------------------------------------------- -// Livingroom Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLivingroomScreen(void); -void UpdateLivingroomScreen(void); -void DrawLivingroomScreen(void); -void UnloadLivingroomScreen(void); -int FinishLivingroomScreen(void); - -//---------------------------------------------------------------------------------- -// Kitchen Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitKitchenScreen(void); -void UpdateKitchenScreen(void); -void DrawKitchenScreen(void); -void UnloadKitchenScreen(void); -int FinishKitchenScreen(void); - -//---------------------------------------------------------------------------------- -// Armory Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitArmoryScreen(void); -void UpdateArmoryScreen(void); -void DrawArmoryScreen(void); -void UnloadArmoryScreen(void); -int FinishArmoryScreen(void); - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitEndingScreen(void); -void UpdateEndingScreen(void); -void DrawEndingScreen(void); -void UnloadEndingScreen(void); -int FinishEndingScreen(void); - -#ifdef __cplusplus -} -#endif - -#endif // SCREENS_H \ No newline at end of file diff --git a/games/skully_escape/skully_escape.c b/games/skully_escape/skully_escape.c deleted file mode 100644 index 1bb598ea3..000000000 --- a/games/skully_escape/skully_escape.c +++ /dev/null @@ -1,408 +0,0 @@ -/******************************************************************************************* -* -* SKULLY ESCAPE [KING GAME JAM 2015] -* -* A scary graphic adventure in an old mansion -* -* This game has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include "screens/screens.h" // NOTE: Defines global variable: currentScreen - -#include "player.h" - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- -const int screenWidth = 1280; -const int screenHeight = 720; - -// Required variables to manage screen transitions (fade-in, fade-out) -float transAlpha = 0; -bool onTransition = false; -bool transFadeOut = false; -int transFromScreen = -1; -int transToScreen = -1; - -static int framesCounter = 0; - -Music music; - -//---------------------------------------------------------------------------------- -// Local Functions Declaration -//---------------------------------------------------------------------------------- -void TransitionToScreen(int screen); -void ChangeToScreen(int screen); // No transition effect -void UpdateTransition(void); -void DrawTransition(void); - -void UpdateDrawFrame(void); // Update and Draw one frame - -//---------------------------------------------------------------------------------- -// Main entry point -//---------------------------------------------------------------------------------- -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "SKULLY ESCAPE [KING GAMEJAM 2015]"); - - // Global data loading (assets that must be available in all screens, i.e. fonts) - InitAudioDevice(); - - music = LoadMusicStream("resources/audio/come_play_with_me.ogg"); - PlayMusicStream(music); - - font = LoadFont("resources/textures/alagard.png"); - doors = LoadTexture("resources/textures/doors.png"); - sndDoor = LoadSound("resources/audio/door.ogg"); - sndScream = LoadSound("resources/audio/scream.ogg"); - - InitPlayer(); - - // Setup and Init first screen - currentScreen = LOGO; - InitLogoScreen(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - UpdateDrawFrame(); - } -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload all global loaded data (i.e. fonts) here! - UnloadPlayer(); - UnloadFont(font); - UnloadTexture(doors); - UnloadSound(sndDoor); - UnloadSound(sndScream); - - UnloadMusicStream(music); - - CloseAudioDevice(); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -void TransitionToScreen(int screen) -{ - onTransition = true; - transFromScreen = currentScreen; - transToScreen = screen; -} - -void ChangeToScreen(int screen) -{ - switch (currentScreen) - { - case LOGO: UnloadLogoScreen(); break; - case LOGO_RL: rlUnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case ATTIC: UnloadAtticScreen(); break; - case AISLE01: UnloadAisle01Screen();break; - case AISLE02: UnloadAisle02Screen();break; - case ARMORY: UnloadArmoryScreen();break; - case LIVINGROOM: UnloadLivingroomScreen();break; - case KITCHEN: UnloadKitchenScreen(); break; - case BATHROOM: UnloadBathroomScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - switch (screen) - { - case LOGO: InitLogoScreen(); break; - case LOGO_RL: rlInitLogoScreen(); break; - case TITLE: InitTitleScreen(); break; - case ATTIC: InitAtticScreen(); break; - case AISLE01: InitAisle01Screen();break; - case AISLE02: InitAisle02Screen();break; - case ARMORY: InitArmoryScreen();break; - case LIVINGROOM: InitLivingroomScreen();break; - case KITCHEN: InitKitchenScreen(); break; - case BATHROOM: InitBathroomScreen(); break; - case ENDING: InitEndingScreen(); break; - default: break; - } - - currentScreen = screen; -} - -void UpdateTransition(void) -{ - if (!transFadeOut) - { - transAlpha += 0.05f; - - if (transAlpha >= 1.0) - { - transAlpha = 1.0; - - switch (transFromScreen) - { - case LOGO: UnloadLogoScreen(); break; - case LOGO_RL: rlUnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case ATTIC: UnloadAtticScreen(); break; - case AISLE01: UnloadAisle01Screen();break; - case AISLE02: UnloadAisle02Screen();break; - case ARMORY: UnloadArmoryScreen();break; - case LIVINGROOM: UnloadLivingroomScreen();break; - case KITCHEN: UnloadKitchenScreen(); break; - case BATHROOM: UnloadBathroomScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - switch (transToScreen) - { - case LOGO: - { - InitLogoScreen(); - currentScreen = LOGO; - } break; - case LOGO_RL: - { - rlInitLogoScreen(); - currentScreen = LOGO_RL; - } break; - case TITLE: - { - InitTitleScreen(); - currentScreen = TITLE; - } break; - case ATTIC: - { - InitAtticScreen(); - currentScreen = ATTIC; - } break; - case AISLE01: - { - InitAisle01Screen(); - currentScreen = AISLE01; - } break; - case AISLE02: - { - InitAisle02Screen(); - currentScreen = AISLE02; - } break; - case BATHROOM: - { - InitBathroomScreen(); - currentScreen = BATHROOM; - } break; - case LIVINGROOM: - { - InitLivingroomScreen(); - currentScreen = LIVINGROOM; - } break; - case KITCHEN: - { - InitKitchenScreen(); - currentScreen = KITCHEN; - } break; - case ARMORY: - { - InitArmoryScreen(); - currentScreen = ARMORY; - } break; - case ENDING: - { - InitEndingScreen(); - currentScreen = ENDING; - } break; - default: break; - } - - transFadeOut = true; - } - } - else // Transition fade out logic - { - transAlpha -= 0.05f; - - if (transAlpha <= 0) - { - transAlpha = 0; - transFadeOut = false; - onTransition = false; - transFromScreen = -1; - transToScreen = -1; - } - } -} - -void DrawTransition(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha)); -} - -// Update and draw game frame -void UpdateDrawFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - if (!onTransition) - { - if (player.dead) - { - framesCounter++; - - if (framesCounter > 80) - { - framesCounter = 0; - player.dead = false; - player.numLifes = 4; - - TransitionToScreen(TITLE); - } - } - - switch(currentScreen) - { - case LOGO: - { - UpdateLogoScreen(); - - if (FinishLogoScreen()) ChangeToScreen(LOGO_RL); - - } break; - case LOGO_RL: - { - rlUpdateLogoScreen(); - - if (rlFinishLogoScreen()) TransitionToScreen(TITLE); - - } break; - case TITLE: - { - UpdateTitleScreen(); - - if (FinishTitleScreen() == 1) TransitionToScreen(ATTIC); - - } break; - case ATTIC: - { - UpdateAtticScreen(); - - if (FinishAtticScreen() == 1) TransitionToScreen(AISLE01); - - } break; - case AISLE01: - { - UpdateAisle01Screen(); - - if (FinishAisle01Screen() == 1) TransitionToScreen(BATHROOM); - else if(FinishAisle01Screen() == 2) TransitionToScreen(KITCHEN); - else if(FinishAisle01Screen() == 3) TransitionToScreen(LIVINGROOM); - - } break; - case BATHROOM: - { - UpdateBathroomScreen(); - - if (FinishBathroomScreen() == 1) TransitionToScreen(AISLE01); - - } break; - case LIVINGROOM: - { - UpdateLivingroomScreen(); - - if (FinishLivingroomScreen() == 1) TransitionToScreen(AISLE01); - else if(FinishLivingroomScreen() == 2)TransitionToScreen(AISLE02); - - } break; - case AISLE02: - { - UpdateAisle02Screen(); - - if (FinishAisle02Screen() == 1) TransitionToScreen(KITCHEN); - - } break; - case KITCHEN: - { - UpdateKitchenScreen(); - - if (FinishKitchenScreen() == 1) TransitionToScreen(ARMORY); - else if(FinishKitchenScreen() == 2)TransitionToScreen(AISLE02); - - } break; - case ARMORY: - { - UpdateArmoryScreen(); - - if(FinishArmoryScreen() == 1) TransitionToScreen(ENDING); - else if(FinishArmoryScreen() == 2) TransitionToScreen(KITCHEN); - - } break; - case ENDING: - { - UpdateEndingScreen(); - - if (FinishEndingScreen()) TransitionToScreen(TITLE); - - } break; - default: break; - } - } - else - { - // Update transition (fade-in, fade-out) - UpdateTransition(); - } - - UpdateMusicStream(music); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch(currentScreen) - { - case LOGO: DrawLogoScreen(); break; - case LOGO_RL: rlDrawLogoScreen(); break; - case TITLE: DrawTitleScreen(); break; - case ATTIC: DrawAtticScreen(); break; - case AISLE01: DrawAisle01Screen();break; - case AISLE02: DrawAisle02Screen();break; - case BATHROOM: DrawBathroomScreen();break; - case LIVINGROOM: DrawLivingroomScreen();break; - case KITCHEN: DrawKitchenScreen();break; - case ARMORY: DrawArmoryScreen();break; - case ENDING: DrawEndingScreen(); break; - default: break; - } - - if (onTransition) DrawTransition(); - - //DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- -} - diff --git a/games/snake.c b/games/snake.c deleted file mode 100644 index 475227543..000000000 --- a/games/snake.c +++ /dev/null @@ -1,286 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: snake -* -* Sample game developed by Ian Eito, Albert Martos and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Some Defines -//---------------------------------------------------------------------------------- -#define SNAKE_LENGTH 256 -#define SQUARE_SIZE 31 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef struct Snake { - Vector2 position; - Vector2 size; - Vector2 speed; - Color color; -} Snake; - -typedef struct Food { - Vector2 position; - Vector2 size; - bool active; - Color color; -} Food; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static const int screenWidth = 800; -static const int screenHeight = 450; - -static int framesCounter = 0; -static bool gameOver = false; -static bool pause = false; - -static Food fruit = { 0 }; -static Snake snake[SNAKE_LENGTH] = { 0 }; -static Vector2 snakePosition[SNAKE_LENGTH] = { 0 }; -static bool allowMove = false; -static Vector2 offset = { 0 }; -static int counterTail = 0; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: snake"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Initialize game variables -void InitGame(void) -{ - framesCounter = 0; - gameOver = false; - pause = false; - - counterTail = 1; - allowMove = false; - - offset.x = screenWidth%SQUARE_SIZE; - offset.y = screenHeight%SQUARE_SIZE; - - for (int i = 0; i < SNAKE_LENGTH; i++) - { - snake[i].position = (Vector2){ offset.x/2, offset.y/2 }; - snake[i].size = (Vector2){ SQUARE_SIZE, SQUARE_SIZE }; - snake[i].speed = (Vector2){ SQUARE_SIZE, 0 }; - - if (i == 0) snake[i].color = DARKBLUE; - else snake[i].color = BLUE; - } - - for (int i = 0; i < SNAKE_LENGTH; i++) - { - snakePosition[i] = (Vector2){ 0.0f, 0.0f }; - } - - fruit.size = (Vector2){ SQUARE_SIZE, SQUARE_SIZE }; - fruit.color = SKYBLUE; - fruit.active = false; -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - // Player control - if (IsKeyPressed(KEY_RIGHT) && (snake[0].speed.x == 0) && allowMove) - { - snake[0].speed = (Vector2){ SQUARE_SIZE, 0 }; - allowMove = false; - } - if (IsKeyPressed(KEY_LEFT) && (snake[0].speed.x == 0) && allowMove) - { - snake[0].speed = (Vector2){ -SQUARE_SIZE, 0 }; - allowMove = false; - } - if (IsKeyPressed(KEY_UP) && (snake[0].speed.y == 0) && allowMove) - { - snake[0].speed = (Vector2){ 0, -SQUARE_SIZE }; - allowMove = false; - } - if (IsKeyPressed(KEY_DOWN) && (snake[0].speed.y == 0) && allowMove) - { - snake[0].speed = (Vector2){ 0, SQUARE_SIZE }; - allowMove = false; - } - - // Snake movement - for (int i = 0; i < counterTail; i++) snakePosition[i] = snake[i].position; - - if ((framesCounter%5) == 0) - { - for (int i = 0; i < counterTail; i++) - { - if (i == 0) - { - snake[0].position.x += snake[0].speed.x; - snake[0].position.y += snake[0].speed.y; - allowMove = true; - } - else snake[i].position = snakePosition[i-1]; - } - } - - // Wall behaviour - if (((snake[0].position.x) > (screenWidth - offset.x)) || - ((snake[0].position.y) > (screenHeight - offset.y)) || - (snake[0].position.x < 0) || (snake[0].position.y < 0)) - { - gameOver = true; - } - - // Collision with yourself - for (int i = 1; i < counterTail; i++) - { - if ((snake[0].position.x == snake[i].position.x) && (snake[0].position.y == snake[i].position.y)) gameOver = true; - } - - // Fruit position calculation - if (!fruit.active) - { - fruit.active = true; - fruit.position = (Vector2){ GetRandomValue(0, (screenWidth/SQUARE_SIZE) - 1)*SQUARE_SIZE + offset.x/2, GetRandomValue(0, (screenHeight/SQUARE_SIZE) - 1)*SQUARE_SIZE + offset.y/2 }; - - for (int i = 0; i < counterTail; i++) - { - while ((fruit.position.x == snake[i].position.x) && (fruit.position.y == snake[i].position.y)) - { - fruit.position = (Vector2){ GetRandomValue(0, (screenWidth/SQUARE_SIZE) - 1)*SQUARE_SIZE + offset.x/2, GetRandomValue(0, (screenHeight/SQUARE_SIZE) - 1)*SQUARE_SIZE + offset.y/2 }; - i = 0; - } - } - } - - // Collision - if ((snake[0].position.x < (fruit.position.x + fruit.size.x) && (snake[0].position.x + snake[0].size.x) > fruit.position.x) && - (snake[0].position.y < (fruit.position.y + fruit.size.y) && (snake[0].position.y + snake[0].size.y) > fruit.position.y)) - { - snake[counterTail].position = snakePosition[counterTail - 1]; - counterTail += 1; - fruit.active = false; - } - - framesCounter++; - } - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - // Draw grid lines - for (int i = 0; i < screenWidth/SQUARE_SIZE + 1; i++) - { - DrawLineV((Vector2){SQUARE_SIZE*i + offset.x/2, offset.y/2}, (Vector2){SQUARE_SIZE*i + offset.x/2, screenHeight - offset.y/2}, LIGHTGRAY); - } - - for (int i = 0; i < screenHeight/SQUARE_SIZE + 1; i++) - { - DrawLineV((Vector2){offset.x/2, SQUARE_SIZE*i + offset.y/2}, (Vector2){screenWidth - offset.x/2, SQUARE_SIZE*i + offset.y/2}, LIGHTGRAY); - } - - // Draw snake - for (int i = 0; i < counterTail; i++) DrawRectangleV(snake[i].position, snake[i].size, snake[i].color); - - // Draw fruit to pick - DrawRectangleV(fruit.position, fruit.size, fruit.color); - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); - - EndDrawing(); -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} diff --git a/games/space_invaders.c b/games/space_invaders.c deleted file mode 100644 index 7d5007782..000000000 --- a/games/space_invaders.c +++ /dev/null @@ -1,398 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: space invaders -* -* Sample game developed by Ian Eito, Albert Martos and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Some Defines -//---------------------------------------------------------------------------------- -#define NUM_SHOOTS 50 -#define NUM_MAX_ENEMIES 50 -#define FIRST_WAVE 10 -#define SECOND_WAVE 20 -#define THIRD_WAVE 50 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum { FIRST = 0, SECOND, THIRD } EnemyWave; - -typedef struct Player{ - Rectangle rec; - Vector2 speed; - Color color; -} Player; - -typedef struct Enemy{ - Rectangle rec; - Vector2 speed; - bool active; - Color color; -} Enemy; - -typedef struct Shoot{ - Rectangle rec; - Vector2 speed; - bool active; - Color color; -} Shoot; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static const int screenWidth = 800; -static const int screenHeight = 450; - -static bool gameOver = false; -static bool pause = false; -static int score = 0; -static bool victory = false; - -static Player player = { 0 }; -static Enemy enemy[NUM_MAX_ENEMIES] = { 0 }; -static Shoot shoot[NUM_SHOOTS] = { 0 }; -static EnemyWave wave = { 0 }; - -static int shootRate = 0; -static float alpha = 0.0f; - -static int activeEnemies = 0; -static int enemiesKill = 0; -static bool smooth = false; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: space invaders"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Initialize game variables -void InitGame(void) -{ - // Initialize game variables - shootRate = 0; - pause = false; - gameOver = false; - victory = false; - smooth = false; - wave = FIRST; - activeEnemies = FIRST_WAVE; - enemiesKill = 0; - score = 0; - alpha = 0; - - // Initialize player - player.rec.x = 20; - player.rec.y = 50; - player.rec.width = 20; - player.rec.height = 20; - player.speed.x = 5; - player.speed.y = 5; - player.color = BLACK; - - // Initialize enemies - for (int i = 0; i < NUM_MAX_ENEMIES; i++) - { - enemy[i].rec.width = 10; - enemy[i].rec.height = 10; - enemy[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000); - enemy[i].rec.y = GetRandomValue(0, screenHeight - enemy[i].rec.height); - enemy[i].speed.x = 5; - enemy[i].speed.y = 5; - enemy[i].active = true; - enemy[i].color = GRAY; - } - - // Initialize shoots - for (int i = 0; i < NUM_SHOOTS; i++) - { - shoot[i].rec.x = player.rec.x; - shoot[i].rec.y = player.rec.y + player.rec.height/4; - shoot[i].rec.width = 10; - shoot[i].rec.height = 5; - shoot[i].speed.x = 7; - shoot[i].speed.y = 0; - shoot[i].active = false; - shoot[i].color = MAROON; - } -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - switch (wave) - { - case FIRST: - { - if (!smooth) - { - alpha += 0.02f; - - if (alpha >= 1.0f) smooth = true; - } - - if (smooth) alpha -= 0.02f; - - if (enemiesKill == activeEnemies) - { - enemiesKill = 0; - - for (int i = 0; i < activeEnemies; i++) - { - if (!enemy[i].active) enemy[i].active = true; - } - - activeEnemies = SECOND_WAVE; - wave = SECOND; - smooth = false; - alpha = 0.0f; - } - } break; - case SECOND: - { - if (!smooth) - { - alpha += 0.02f; - - if (alpha >= 1.0f) smooth = true; - } - - if (smooth) alpha -= 0.02f; - - if (enemiesKill == activeEnemies) - { - enemiesKill = 0; - - for (int i = 0; i < activeEnemies; i++) - { - if (!enemy[i].active) enemy[i].active = true; - } - - activeEnemies = THIRD_WAVE; - wave = THIRD; - smooth = false; - alpha = 0.0f; - } - } break; - case THIRD: - { - if (!smooth) - { - alpha += 0.02f; - - if (alpha >= 1.0f) smooth = true; - } - - if (smooth) alpha -= 0.02f; - - if (enemiesKill == activeEnemies) victory = true; - - } break; - default: break; - } - - // Player movement - if (IsKeyDown(KEY_RIGHT)) player.rec.x += player.speed.x; - if (IsKeyDown(KEY_LEFT)) player.rec.x -= player.speed.x; - if (IsKeyDown(KEY_UP)) player.rec.y -= player.speed.y; - if (IsKeyDown(KEY_DOWN)) player.rec.y += player.speed.y; - - // Player collision with enemy - for (int i = 0; i < activeEnemies; i++) - { - if (CheckCollisionRecs(player.rec, enemy[i].rec)) gameOver = true; - } - - // Enemy behaviour - for (int i = 0; i < activeEnemies; i++) - { - if (enemy[i].active) - { - enemy[i].rec.x -= enemy[i].speed.x; - - if (enemy[i].rec.x < 0) - { - enemy[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000); - enemy[i].rec.y = GetRandomValue(0, screenHeight - enemy[i].rec.height); - } - } - } - - // Wall behaviour - if (player.rec.x <= 0) player.rec.x = 0; - if (player.rec.x + player.rec.width >= screenWidth) player.rec.x = screenWidth - player.rec.width; - if (player.rec.y <= 0) player.rec.y = 0; - if (player.rec.y + player.rec.height >= screenHeight) player.rec.y = screenHeight - player.rec.height; - - // Shoot initialization - if (IsKeyDown(KEY_SPACE)) - { - shootRate += 5; - - for (int i = 0; i < NUM_SHOOTS; i++) - { - if (!shoot[i].active && shootRate%20 == 0) - { - shoot[i].rec.x = player.rec.x; - shoot[i].rec.y = player.rec.y + player.rec.height/4; - shoot[i].active = true; - break; - } - } - } - - // Shoot logic - for (int i = 0; i < NUM_SHOOTS; i++) - { - if (shoot[i].active) - { - // Movement - shoot[i].rec.x += shoot[i].speed.x; - - // Collision with enemy - for (int j = 0; j < activeEnemies; j++) - { - if (enemy[j].active) - { - if (CheckCollisionRecs(shoot[i].rec, enemy[j].rec)) - { - shoot[i].active = false; - enemy[j].rec.x = GetRandomValue(screenWidth, screenWidth + 1000); - enemy[j].rec.y = GetRandomValue(0, screenHeight - enemy[j].rec.height); - shootRate = 0; - enemiesKill++; - score += 100; - } - - if (shoot[i].rec.x + shoot[i].rec.width >= screenWidth) - { - shoot[i].active = false; - shootRate = 0; - } - } - } - } - } - } - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - DrawRectangleRec(player.rec, player.color); - - if (wave == FIRST) DrawText("FIRST WAVE", screenWidth/2 - MeasureText("FIRST WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha)); - else if (wave == SECOND) DrawText("SECOND WAVE", screenWidth/2 - MeasureText("SECOND WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha)); - else if (wave == THIRD) DrawText("THIRD WAVE", screenWidth/2 - MeasureText("THIRD WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha)); - - for (int i = 0; i < activeEnemies; i++) - { - if (enemy[i].active) DrawRectangleRec(enemy[i].rec, enemy[i].color); - } - - for (int i = 0; i < NUM_SHOOTS; i++) - { - if (shoot[i].active) DrawRectangleRec(shoot[i].rec, shoot[i].color); - } - - DrawText(TextFormat("%04i", score), 20, 20, 40, GRAY); - - if (victory) DrawText("YOU WIN", screenWidth/2 - MeasureText("YOU WIN", 40)/2, screenHeight/2 - 40, 40, BLACK); - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); - - EndDrawing(); -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} diff --git a/games/tetris.c b/games/tetris.c deleted file mode 100644 index 2b309184b..000000000 --- a/games/tetris.c +++ /dev/null @@ -1,791 +0,0 @@ -/******************************************************************************************* -* -* raylib - sample game: tetris -* -* Sample game Marc Palau and Ramon Santamaria -* -* This game has been created using raylib v1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include -#include -#include -#include - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Some Defines -//---------------------------------------------------------------------------------- -#define SQUARE_SIZE 20 - -#define GRID_HORIZONTAL_SIZE 12 -#define GRID_VERTICAL_SIZE 20 - -#define LATERAL_SPEED 10 -#define TURNING_SPEED 12 -#define FAST_FALL_AWAIT_COUNTER 30 - -#define FADING_TIME 33 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum GridSquare { EMPTY, MOVING, FULL, BLOCK, FADING } GridSquare; - -//------------------------------------------------------------------------------------ -// Global Variables Declaration -//------------------------------------------------------------------------------------ -static const int screenWidth = 800; -static const int screenHeight = 450; - -static bool gameOver = false; -static bool pause = false; - -// Matrices -static GridSquare grid [GRID_HORIZONTAL_SIZE][GRID_VERTICAL_SIZE]; -static GridSquare piece [4][4]; -static GridSquare incomingPiece [4][4]; - -// Theese variables keep track of the active piece position -static int piecePositionX = 0; -static int piecePositionY = 0; - -// Game parameters -static Color fadingColor; -//static int fallingSpeed; // In frames - -static bool beginPlay = true; // This var is only true at the begining of the game, used for the first matrix creations -static bool pieceActive = false; -static bool detection = false; -static bool lineToDelete = false; - -// Statistics -static int level = 1; -static int lines = 0; - -// Counters -static int gravityMovementCounter = 0; -static int lateralMovementCounter = 0; -static int turnMovementCounter = 0; -static int fastFallMovementCounter = 0; - -static int fadeLineCounter = 0; - -// Based on level -static int gravitySpeed = 30; - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void InitGame(void); // Initialize game -static void UpdateGame(void); // Update game (one frame) -static void DrawGame(void); // Draw game (one frame) -static void UnloadGame(void); // Unload game -static void UpdateDrawFrame(void); // Update and Draw (one frame) - -// Additional module functions -static bool Createpiece(); -static void GetRandompiece(); -static void ResolveFallingMovement(); -static bool ResolveLateralMovement(); -static bool ResolveTurnMovement(); -static void CheckDetection(); -static void CheckCompletion(); -static void DeleteCompleteLines(); - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "sample game: tetris"); - - InitGame(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update and Draw - //---------------------------------------------------------------------------------- - UpdateDrawFrame(); - //---------------------------------------------------------------------------------- - } -#endif - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadGame(); // Unload loaded data (textures, sounds, models...) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//-------------------------------------------------------------------------------------- -// Game Module Functions Definition -//-------------------------------------------------------------------------------------- - -// Initialize game variables -void InitGame(void) -{ - // Initialize game statistics - level = 1; - lines = 0; - - fadingColor = GRAY; - - piecePositionX = 0; - piecePositionY = 0; - - pause = false; - - beginPlay = true; - pieceActive = false; - detection = false; - lineToDelete = false; - - // Counters - gravityMovementCounter = 0; - lateralMovementCounter = 0; - turnMovementCounter = 0; - fastFallMovementCounter = 0; - - fadeLineCounter = 0; - gravitySpeed = 30; - - // Initialize grid matrices - for (int i = 0; i < GRID_HORIZONTAL_SIZE; i++) - { - for (int j = 0; j < GRID_VERTICAL_SIZE; j++) - { - if ((j == GRID_VERTICAL_SIZE - 1) || (i == 0) || (i == GRID_HORIZONTAL_SIZE - 1)) grid[i][j] = BLOCK; - else grid[i][j] = EMPTY; - } - } - - // Initialize incoming piece matrices - for (int i = 0; i < 4; i++) - { - for (int j = 0; j< 4; j++) - { - incomingPiece[i][j] = EMPTY; - } - } -} - -// Update game (one frame) -void UpdateGame(void) -{ - if (!gameOver) - { - if (IsKeyPressed('P')) pause = !pause; - - if (!pause) - { - if (!lineToDelete) - { - if (!pieceActive) - { - // Get another piece - pieceActive = Createpiece(); - - // We leave a little time before starting the fast falling down - fastFallMovementCounter = 0; - } - else // Piece falling - { - // Counters update - fastFallMovementCounter++; - gravityMovementCounter++; - lateralMovementCounter++; - turnMovementCounter++; - - // We make sure to move if we've pressed the key this frame - if (IsKeyPressed(KEY_LEFT) || IsKeyPressed(KEY_RIGHT)) lateralMovementCounter = LATERAL_SPEED; - if (IsKeyPressed(KEY_UP)) turnMovementCounter = TURNING_SPEED; - - // Fall down - if (IsKeyDown(KEY_DOWN) && (fastFallMovementCounter >= FAST_FALL_AWAIT_COUNTER)) - { - // We make sure the piece is going to fall this frame - gravityMovementCounter += gravitySpeed; - } - - if (gravityMovementCounter >= gravitySpeed) - { - // Basic falling movement - CheckDetection(&detection); - - // Check if the piece has collided with another piece or with the boundings - ResolveFallingMovement(&detection, &pieceActive); - - // Check if we fullfilled a line and if so, erase the line and pull down the the lines above - CheckCompletion(&lineToDelete); - - gravityMovementCounter = 0; - } - - // Move laterally at player's will - if (lateralMovementCounter >= LATERAL_SPEED) - { - // Update the lateral movement and if success, reset the lateral counter - if (!ResolveLateralMovement()) lateralMovementCounter = 0; - } - - // Turn the piece at player's will - if (turnMovementCounter >= TURNING_SPEED) - { - // Update the turning movement and reset the turning counter - if (ResolveTurnMovement()) turnMovementCounter = 0; - } - } - - // Game over logic - for (int j = 0; j < 2; j++) - { - for (int i = 1; i < GRID_HORIZONTAL_SIZE - 1; i++) - { - if (grid[i][j] == FULL) - { - gameOver = true; - } - } - } - } - else - { - // Animation when deleting lines - fadeLineCounter++; - - if (fadeLineCounter%8 < 4) fadingColor = MAROON; - else fadingColor = GRAY; - - if (fadeLineCounter >= FADING_TIME) - { - DeleteCompleteLines(); - fadeLineCounter = 0; - lineToDelete = false; - - lines++; - } - } - } - } - else - { - if (IsKeyPressed(KEY_ENTER)) - { - InitGame(); - gameOver = false; - } - } -} - -// Draw game (one frame) -void DrawGame(void) -{ - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!gameOver) - { - // Draw gameplay area - Vector2 offset; - offset.x = screenWidth/2 - (GRID_HORIZONTAL_SIZE*SQUARE_SIZE/2) - 50; - offset.y = screenHeight/2 - ((GRID_VERTICAL_SIZE - 1)*SQUARE_SIZE/2) + SQUARE_SIZE*2; - - offset.y -= 50; // NOTE: Harcoded position! - - int controller = offset.x; - - for (int j = 0; j < GRID_VERTICAL_SIZE; j++) - { - for (int i = 0; i < GRID_HORIZONTAL_SIZE; i++) - { - // Draw each square of the grid - if (grid[i][j] == EMPTY) - { - DrawLine(offset.x, offset.y, offset.x + SQUARE_SIZE, offset.y, LIGHTGRAY ); - DrawLine(offset.x, offset.y, offset.x, offset.y + SQUARE_SIZE, LIGHTGRAY ); - DrawLine(offset.x + SQUARE_SIZE, offset.y, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, LIGHTGRAY ); - DrawLine(offset.x, offset.y + SQUARE_SIZE, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, LIGHTGRAY ); - offset.x += SQUARE_SIZE; - } - else if (grid[i][j] == FULL) - { - DrawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, GRAY); - offset.x += SQUARE_SIZE; - } - else if (grid[i][j] == MOVING) - { - DrawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, DARKGRAY); - offset.x += SQUARE_SIZE; - } - else if (grid[i][j] == BLOCK) - { - DrawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, LIGHTGRAY); - offset.x += SQUARE_SIZE; - } - else if (grid[i][j] == FADING) - { - DrawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, fadingColor); - offset.x += SQUARE_SIZE; - } - } - - offset.x = controller; - offset.y += SQUARE_SIZE; - } - - // Draw incoming piece (hardcoded) - offset.x = 500; - offset.y = 45; - - int controler = offset.x; - - for (int j = 0; j < 4; j++) - { - for (int i = 0; i < 4; i++) - { - if (incomingPiece[i][j] == EMPTY) - { - DrawLine(offset.x, offset.y, offset.x + SQUARE_SIZE, offset.y, LIGHTGRAY ); - DrawLine(offset.x, offset.y, offset.x, offset.y + SQUARE_SIZE, LIGHTGRAY ); - DrawLine(offset.x + SQUARE_SIZE, offset.y, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, LIGHTGRAY ); - DrawLine(offset.x, offset.y + SQUARE_SIZE, offset.x + SQUARE_SIZE, offset.y + SQUARE_SIZE, LIGHTGRAY ); - offset.x += SQUARE_SIZE; - } - else if (incomingPiece[i][j] == MOVING) - { - DrawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, GRAY); - offset.x += SQUARE_SIZE; - } - } - - offset.x = controler; - offset.y += SQUARE_SIZE; - } - - DrawText("INCOMING:", offset.x, offset.y - 100, 10, GRAY); - DrawText(TextFormat("LINES: %04i", lines), offset.x, offset.y + 20, 10, GRAY); - - if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); - } - else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); - - EndDrawing(); -} - -// Unload game variables -void UnloadGame(void) -{ - // TODO: Unload all dynamic loaded data (textures, sounds, models...) -} - -// Update and Draw (one frame) -void UpdateDrawFrame(void) -{ - UpdateGame(); - DrawGame(); -} - -//-------------------------------------------------------------------------------------- -// Additional module functions -//-------------------------------------------------------------------------------------- -static bool Createpiece() -{ - piecePositionX = (int)((GRID_HORIZONTAL_SIZE - 4)/2); - piecePositionY = 0; - - // If the game is starting and you are going to create the first piece, we create an extra one - if (beginPlay) - { - GetRandompiece(); - beginPlay = false; - } - - // We assign the incoming piece to the actual piece - for (int i = 0; i < 4; i++) - { - for (int j = 0; j< 4; j++) - { - piece[i][j] = incomingPiece[i][j]; - } - } - - // We assign a random piece to the incoming one - GetRandompiece(); - - // Assign the piece to the grid - for (int i = piecePositionX; i < piecePositionX + 4; i++) - { - for (int j = 0; j < 4; j++) - { - if (piece[i - (int)piecePositionX][j] == MOVING) grid[i][j] = MOVING; - } - } - - return true; -} - -static void GetRandompiece() -{ - int random = GetRandomValue(0, 6); - - for (int i = 0; i < 4; i++) - { - for (int j = 0; j < 4; j++) - { - incomingPiece[i][j] = EMPTY; - } - } - - switch (random) - { - case 0: { incomingPiece[1][1] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[1][2] = MOVING; incomingPiece[2][2] = MOVING; } break; //Cube - case 1: { incomingPiece[1][0] = MOVING; incomingPiece[1][1] = MOVING; incomingPiece[1][2] = MOVING; incomingPiece[2][2] = MOVING; } break; //L - case 2: { incomingPiece[1][2] = MOVING; incomingPiece[2][0] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[2][2] = MOVING; } break; //L inversa - case 3: { incomingPiece[0][1] = MOVING; incomingPiece[1][1] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[3][1] = MOVING; } break; //Recta - case 4: { incomingPiece[1][0] = MOVING; incomingPiece[1][1] = MOVING; incomingPiece[1][2] = MOVING; incomingPiece[2][1] = MOVING; } break; //Creu tallada - case 5: { incomingPiece[1][1] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[2][2] = MOVING; incomingPiece[3][2] = MOVING; } break; //S - case 6: { incomingPiece[1][2] = MOVING; incomingPiece[2][2] = MOVING; incomingPiece[2][1] = MOVING; incomingPiece[3][1] = MOVING; } break; //S inversa - } -} - -static void ResolveFallingMovement(bool *detection, bool *pieceActive) -{ - // If we finished moving this piece, we stop it - if (*detection) - { - for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) - { - for (int i = 1; i < GRID_HORIZONTAL_SIZE - 1; i++) - { - if (grid[i][j] == MOVING) - { - grid[i][j] = FULL; - *detection = false; - *pieceActive = false; - } - } - } - } - else // We move down the piece - { - for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) - { - for (int i = 1; i < GRID_HORIZONTAL_SIZE - 1; i++) - { - if (grid[i][j] == MOVING) - { - grid[i][j+1] = MOVING; - grid[i][j] = EMPTY; - } - } - } - - piecePositionY++; - } -} - -static bool ResolveLateralMovement() -{ - bool collision = false; - - // Piece movement - if (IsKeyDown(KEY_LEFT)) // Move left - { - // Check if is possible to move to left - for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) - { - for (int i = 1; i < GRID_HORIZONTAL_SIZE - 1; i++) - { - if (grid[i][j] == MOVING) - { - // Check if we are touching the left wall or we have a full square at the left - if ((i-1 == 0) || (grid[i-1][j] == FULL)) collision = true; - } - } - } - - // If able, move left - if (!collision) - { - for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) - { - for (int i = 1; i < GRID_HORIZONTAL_SIZE - 1; i++) // We check the matrix from left to right - { - // Move everything to the left - if (grid[i][j] == MOVING) - { - grid[i-1][j] = MOVING; - grid[i][j] = EMPTY; - } - } - } - - piecePositionX--; - } - } - else if (IsKeyDown(KEY_RIGHT)) // Move right - { - // Check if is possible to move to right - for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) - { - for (int i = 1; i < GRID_HORIZONTAL_SIZE - 1; i++) - { - if (grid[i][j] == MOVING) - { - // Check if we are touching the right wall or we have a full square at the right - if ((i+1 == GRID_HORIZONTAL_SIZE - 1) || (grid[i+1][j] == FULL)) - { - collision = true; - - } - } - } - } - - // If able move right - if (!collision) - { - for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) - { - for (int i = GRID_HORIZONTAL_SIZE - 1; i >= 1; i--) // We check the matrix from right to left - { - // Move everything to the right - if (grid[i][j] == MOVING) - { - grid[i+1][j] = MOVING; - grid[i][j] = EMPTY; - } - } - } - - piecePositionX++; - } - } - - return collision; -} - -static bool ResolveTurnMovement() -{ - // Input for turning the piece - if (IsKeyDown(KEY_UP)) - { - int aux = 0; - bool checker = false; - - // Check all turning possibilities - if ((grid[piecePositionX + 3][piecePositionY] == MOVING) && - (grid[piecePositionX][piecePositionY] != EMPTY) && - (grid[piecePositionX][piecePositionY] != MOVING)) checker = true; - - if ((grid[piecePositionX + 3][piecePositionY + 3] == MOVING) && - (grid[piecePositionX + 3][piecePositionY] != EMPTY) && - (grid[piecePositionX + 3][piecePositionY] != MOVING)) checker = true; - - if ((grid[piecePositionX][piecePositionY + 3] == MOVING) && - (grid[piecePositionX + 3][piecePositionY + 3] != EMPTY) && - (grid[piecePositionX + 3][piecePositionY + 3] != MOVING)) checker = true; - - if ((grid[piecePositionX][piecePositionY] == MOVING) && - (grid[piecePositionX][piecePositionY + 3] != EMPTY) && - (grid[piecePositionX][piecePositionY + 3] != MOVING)) checker = true; - - if ((grid[piecePositionX + 1][piecePositionY] == MOVING) && - (grid[piecePositionX][piecePositionY + 2] != EMPTY) && - (grid[piecePositionX][piecePositionY + 2] != MOVING)) checker = true; - - if ((grid[piecePositionX + 3][piecePositionY + 1] == MOVING) && - (grid[piecePositionX + 1][piecePositionY] != EMPTY) && - (grid[piecePositionX + 1][piecePositionY] != MOVING)) checker = true; - - if ((grid[piecePositionX + 2][piecePositionY + 3] == MOVING) && - (grid[piecePositionX + 3][piecePositionY + 1] != EMPTY) && - (grid[piecePositionX + 3][piecePositionY + 1] != MOVING)) checker = true; - - if ((grid[piecePositionX][piecePositionY + 2] == MOVING) && - (grid[piecePositionX + 2][piecePositionY + 3] != EMPTY) && - (grid[piecePositionX + 2][piecePositionY + 3] != MOVING)) checker = true; - - if ((grid[piecePositionX + 2][piecePositionY] == MOVING) && - (grid[piecePositionX][piecePositionY + 1] != EMPTY) && - (grid[piecePositionX][piecePositionY + 1] != MOVING)) checker = true; - - if ((grid[piecePositionX + 3][piecePositionY + 2] == MOVING) && - (grid[piecePositionX + 2][piecePositionY] != EMPTY) && - (grid[piecePositionX + 2][piecePositionY] != MOVING)) checker = true; - - if ((grid[piecePositionX + 1][piecePositionY + 3] == MOVING) && - (grid[piecePositionX + 3][piecePositionY + 2] != EMPTY) && - (grid[piecePositionX + 3][piecePositionY + 2] != MOVING)) checker = true; - - if ((grid[piecePositionX][piecePositionY + 1] == MOVING) && - (grid[piecePositionX + 1][piecePositionY + 3] != EMPTY) && - (grid[piecePositionX + 1][piecePositionY + 3] != MOVING)) checker = true; - - if ((grid[piecePositionX + 1][piecePositionY + 1] == MOVING) && - (grid[piecePositionX + 1][piecePositionY + 2] != EMPTY) && - (grid[piecePositionX + 1][piecePositionY + 2] != MOVING)) checker = true; - - if ((grid[piecePositionX + 2][piecePositionY + 1] == MOVING) && - (grid[piecePositionX + 1][piecePositionY + 1] != EMPTY) && - (grid[piecePositionX + 1][piecePositionY + 1] != MOVING)) checker = true; - - if ((grid[piecePositionX + 2][piecePositionY + 2] == MOVING) && - (grid[piecePositionX + 2][piecePositionY + 1] != EMPTY) && - (grid[piecePositionX + 2][piecePositionY + 1] != MOVING)) checker = true; - - if ((grid[piecePositionX + 1][piecePositionY + 2] == MOVING) && - (grid[piecePositionX + 2][piecePositionY + 2] != EMPTY) && - (grid[piecePositionX + 2][piecePositionY + 2] != MOVING)) checker = true; - - if (!checker) - { - aux = piece[0][0]; - piece[0][0] = piece[3][0]; - piece[3][0] = piece[3][3]; - piece[3][3] = piece[0][3]; - piece[0][3] = aux; - - aux = piece[1][0]; - piece[1][0] = piece[3][1]; - piece[3][1] = piece[2][3]; - piece[2][3] = piece[0][2]; - piece[0][2] = aux; - - aux = piece[2][0]; - piece[2][0] = piece[3][2]; - piece[3][2] = piece[1][3]; - piece[1][3] = piece[0][1]; - piece[0][1] = aux; - - aux = piece[1][1]; - piece[1][1] = piece[2][1]; - piece[2][1] = piece[2][2]; - piece[2][2] = piece[1][2]; - piece[1][2] = aux; - } - - for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) - { - for (int i = 1; i < GRID_HORIZONTAL_SIZE - 1; i++) - { - if (grid[i][j] == MOVING) - { - grid[i][j] = EMPTY; - } - } - } - - for (int i = piecePositionX; i < piecePositionX + 4; i++) - { - for (int j = piecePositionY; j < piecePositionY + 4; j++) - { - if (piece[i - piecePositionX][j - piecePositionY] == MOVING) - { - grid[i][j] = MOVING; - } - } - } - - return true; - } - - return false; -} - -static void CheckDetection(bool *detection) -{ - for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) - { - for (int i = 1; i < GRID_HORIZONTAL_SIZE - 1; i++) - { - if ((grid[i][j] == MOVING) && ((grid[i][j+1] == FULL) || (grid[i][j+1] == BLOCK))) *detection = true; - } - } -} - -static void CheckCompletion(bool *lineToDelete) -{ - int calculator = 0; - - for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) - { - calculator = 0; - for (int i = 1; i < GRID_HORIZONTAL_SIZE - 1; i++) - { - // Count each square of the line - if (grid[i][j] == FULL) - { - calculator++; - } - - // Check if we completed the whole line - if (calculator == GRID_HORIZONTAL_SIZE - 2) - { - *lineToDelete = true; - calculator = 0; - // points++; - - // Mark the completed line - for (int z = 1; z < GRID_HORIZONTAL_SIZE - 1; z++) - { - grid[z][j] = FADING; - } - } - } - } -} - -static void DeleteCompleteLines() -{ - // Erase the completed line - for (int j = GRID_VERTICAL_SIZE - 2; j >= 0; j--) - { - while (grid[1][j] == FADING) - { - for (int i = 1; i < GRID_HORIZONTAL_SIZE - 1; i++) - { - grid[i][j] = EMPTY; - } - - for (int j2 = j-1; j2 >= 0; j2--) - { - for (int i2 = 1; i2 < GRID_HORIZONTAL_SIZE - 1; i2++) - { - if (grid[i2][j2] == FULL) - { - grid[i2][j2+1] = FULL; - grid[i2][j2] = EMPTY; - } - else if (grid[i2][j2] == FADING) - { - grid[i2][j2+1] = FADING; - grid[i2][j2] = EMPTY; - } - } - } - } - } -} diff --git a/games/transmission/Makefile b/games/transmission/Makefile deleted file mode 100644 index d84993fdf..000000000 --- a/games/transmission/Makefile +++ /dev/null @@ -1,407 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= transmission -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= C:\GitHub\raylib - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - # -Wl,--subsystem,windows hides the console window - ifeq ($(BUILD_MODE), RELEASE) - LDFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -PROJECT_SOURCE_FILES ?= \ - transmission.c \ - screens/screen_logo.c \ - screens/screen_title.c \ - screens/screen_mission.c \ - screens/screen_gameplay.c \ - screens/screen_ending.c - -# Define all object files from source files -OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) - -# For Android platform we call a custom Makefile.Android -ifeq ($(PLATFORM),PLATFORM_ANDROID) - MAKEFILE_PARAMS = -f Makefile.Android - export PROJECT_NAME - export PROJECT_SOURCE_FILES -else - MAKEFILE_PARAMS = $(PROJECT_NAME) -endif - -# Default target entry -# NOTE: We call this Makefile target or Makefile.Android target -all: - $(MAKE) $(MAKEFILE_PARAMS) - -# Project target defined by PROJECT_NAME -$(PROJECT_NAME): $(OBJS) - $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) - -# Compile source files -# NOTE: This pattern will compile every module defined on $(OBJS) -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/transmission/Makefile.Android b/games/transmission/Makefile.Android deleted file mode 100644 index 29d437b1b..000000000 --- a/games/transmission/Makefile.Android +++ /dev/null @@ -1,300 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Android project (APK building) -# -# Copyright (c) 2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -# Define required raylib variables -PLATFORM ?= PLATFORM_ANDROID -RAYLIB_PATH ?= ..\.. - -# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version -ANDROID_ARCH ?= ARM -ANDROID_API_VERSION = 21 -ifeq ($(ANDROID_ARCH),ARM) - ANDROID_ARCH_NAME = armeabi-v7a -endif -ifeq ($(ANDROID_ARCH),ARM64) - ANDROID_ARCH_NAME = arm64-v8a -endif - -# Required path variables -# NOTE: JAVA_HOME must be set to JDK -JAVA_HOME ?= C:/JavaJDK -ANDROID_HOME = C:/android-sdk -ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION) -ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1 -ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools - -# Android project configuration variables -PROJECT_NAME ?= raylib_game -PROJECT_LIBRARY_NAME ?= main -PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME) -PROJECT_RESOURCES_PATH ?= resources -PROJECT_SOURCE_FILES ?= raylib_game.c - -# Some source files are placed in directories, when compiling to some -# output directory other than source, that directory must pre-exist. -# Here we get a list of required folders that need to be created on -# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors. -PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES))) - -# Android app configuration variables -APP_LABEL_NAME ?= rGame -APP_COMPANY_NAME ?= raylib -APP_PRODUCT_NAME ?= rgame -APP_VERSION_CODE ?= 1 -APP_VERSION_NAME ?= 1.0 -APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png -APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png -APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png -APP_SCREEN_ORIENTATION ?= landscape -APP_KEYSTORE_PASS ?= raylib - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Library path for libraylib.a/libraylib.so -RAYLIB_LIB_PATH = $(RAYLIB_PATH)\src - -# Shared libs must be added to APK if required -# NOTE: Generated NativeLoader.java automatically load those libraries -ifeq ($(RAYLIB_LIBTYPE),SHARED) - PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so -endif - -# Compiler and archiver -# NOTE: GCC is being deprecated in Android NDK r16 -ifeq ($(ANDROID_ARCH),ARM) - CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang - AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar -endif -ifeq ($(ANDROID_ARCH),ARM64) - CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang - AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar -endif - -# Compiler flags for arquitecture -ifeq ($(ANDROID_ARCH),ARM) - CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -endif -ifeq ($(ANDROID_ARCH),ARM64) - CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769 -endif -# Compilation functions attributes options -CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC -# Compiler options for the linker -CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes -# Preprocessor macro definitions -CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) - -# Paths containing required header files -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue - -# Linker options -LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a -LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -# Force linking of library module to define symbol -LDFLAGS += -u ANativeActivity_onCreate -# Library paths containing required libs -LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME) -L$(ANDROID_TOOLCHAIN)\sysroot\usr\lib - -# Define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl - -# Generate target objects list from PROJECT_SOURCE_FILES -OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES)) - -# Android APK building process... some steps required... -# NOTE: typing 'make' will invoke the default target entry called 'all', -all: create_temp_project_dirs \ - copy_project_required_libs \ - copy_project_resources \ - generate_loader_script \ - generate_android_manifest \ - generate_apk_keystore \ - config_project_package \ - compile_project_code \ - compile_project_class \ - compile_project_class_dex \ - create_project_apk_package \ - sign_project_apk_package \ - zipalign_project_apk_package - -# Create required temp directories for APK building -create_temp_project_dirs: - if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj - if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src - if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) - if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib - if not exist $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) mkdir $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) - if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin - if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res - if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi - if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values - if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets - if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens - $(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir))) - -define create_dir - if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1) -endef - -# Copy required shared libs for integration into APK -# NOTE: If using shared libs they are loaded by generated NativeLoader.java -copy_project_required_libs: -ifeq ($(RAYLIB_LIBTYPE),SHARED) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so -endif -ifeq ($(RAYLIB_LIBTYPE),STATIC) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a -endif - -# Copy project required resources: strings.xml, icon.png, assets -# NOTE: Required strings.xml is generated and game resources are copied to assets folder -# TODO: Review xcopy usage, it can not be found in some systems! -copy_project_resources: - copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y - copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y - copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y - @echo ^ > $(PROJECT_BUILD_PATH)/res/values/strings.xml - @echo ^^$(APP_LABEL_NAME)^^ >> $(PROJECT_BUILD_PATH)/res/values/strings.xml - if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F - -# Generate NativeLoader.java to load required shared libraries -# NOTE: Probably not the bet way to generate this file... but it works. -generate_loader_script: - @echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -ifeq ($(RAYLIB_LIBTYPE),SHARED) - @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -endif - @echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Generate AndroidManifest.xml with all the required options -# NOTE: Probably not the bet way to generate this file... but it works. -generate_android_manifest: - @echo ^ > $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - -# Generate storekey for APK signing: $(PROJECT_NAME).keystore -# NOTE: Configure here your Distinguished Names (-dname) if required! -generate_apk_keystore: - if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA - -# Config project package and resource using AndroidManifest.xml and res/values/strings.xml -# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java -config_project_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar - -# Compile native_app_glue code as static library: obj/libnative_app_glue.a -compile_native_app_glue: - $(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS) - $(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o - -# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so -compile_project_code: $(OBJS) - $(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) - -# Compile all .c files required into object (.o) files -# NOTE: Those files will be linked into a shared library -$(PROJECT_BUILD_PATH)/obj/%.o:%.c - $(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot - -# Compile project .java code into .class (Java bytecode) -compile_project_class: - $(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Compile .class files into Dalvik executable bytecode (.dex) -# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT) -compile_project_class_dex: - $(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj - -# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk -# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so -# NOTE: Use -A resources to define additional directory in which to find raw asset files -create_project_apk_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin - cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS) - -# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk -sign_project_apk_package: - $(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key - -# Create zip-aligned APK package: $(PROJECT_NAME).apk -zipalign_project_apk_package: - $(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk - -# Install $(PROJECT_NAME).apk to default emulator/device -# NOTE: Use -e (emulator) or -d (device) parameters if required -install: - $(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk - -# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64) -check_device_abi: - $(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi - -# Monitorize output log coming from device, only raylib tag -logcat: - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -# Install and monitorize $(PROJECT_NAME).apk to default emulator/device -deploy: - $(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W - -# Clean everything -clean: - del $(PROJECT_BUILD_PATH)\* /f /s /q - rmdir $(PROJECT_BUILD_PATH) /s /q - @echo Cleaning done diff --git a/games/transmission/resources/audio/fx_batman.ogg b/games/transmission/resources/audio/fx_batman.ogg deleted file mode 100644 index d3e25ae29..000000000 Binary files a/games/transmission/resources/audio/fx_batman.ogg and /dev/null differ diff --git a/games/transmission/resources/audio/fx_button.ogg b/games/transmission/resources/audio/fx_button.ogg deleted file mode 100644 index 8d0747cad..000000000 Binary files a/games/transmission/resources/audio/fx_button.ogg and /dev/null differ diff --git a/games/transmission/resources/audio/fx_grab.ogg b/games/transmission/resources/audio/fx_grab.ogg deleted file mode 100644 index b78e13157..000000000 Binary files a/games/transmission/resources/audio/fx_grab.ogg and /dev/null differ diff --git a/games/transmission/resources/audio/fx_leave.ogg b/games/transmission/resources/audio/fx_leave.ogg deleted file mode 100644 index 24abdbeef..000000000 Binary files a/games/transmission/resources/audio/fx_leave.ogg and /dev/null differ diff --git a/games/transmission/resources/audio/fx_message.ogg b/games/transmission/resources/audio/fx_message.ogg deleted file mode 100644 index 60de66552..000000000 Binary files a/games/transmission/resources/audio/fx_message.ogg and /dev/null differ diff --git a/games/transmission/resources/audio/fx_newspaper.ogg b/games/transmission/resources/audio/fx_newspaper.ogg deleted file mode 100644 index bcc548418..000000000 Binary files a/games/transmission/resources/audio/fx_newspaper.ogg and /dev/null differ diff --git a/games/transmission/resources/audio/fx_place.ogg b/games/transmission/resources/audio/fx_place.ogg deleted file mode 100644 index a300a9683..000000000 Binary files a/games/transmission/resources/audio/fx_place.ogg and /dev/null differ diff --git a/games/transmission/resources/audio/fx_typing.ogg b/games/transmission/resources/audio/fx_typing.ogg deleted file mode 100644 index 89a09dafc..000000000 Binary files a/games/transmission/resources/audio/fx_typing.ogg and /dev/null differ diff --git a/games/transmission/resources/audio/music_mission.ogg b/games/transmission/resources/audio/music_mission.ogg deleted file mode 100644 index 2de719bbc..000000000 Binary files a/games/transmission/resources/audio/music_mission.ogg and /dev/null differ diff --git a/games/transmission/resources/audio/music_title.ogg b/games/transmission/resources/audio/music_title.ogg deleted file mode 100644 index d75b1ddc8..000000000 Binary files a/games/transmission/resources/audio/music_title.ogg and /dev/null differ diff --git a/games/transmission/resources/audio/s_p_y.xm b/games/transmission/resources/audio/s_p_y.xm deleted file mode 100644 index ebbdbf93d..000000000 Binary files a/games/transmission/resources/audio/s_p_y.xm and /dev/null differ diff --git a/games/transmission/resources/audio/spy_versus_spy.xm b/games/transmission/resources/audio/spy_versus_spy.xm deleted file mode 100644 index 11602adc4..000000000 Binary files a/games/transmission/resources/audio/spy_versus_spy.xm and /dev/null differ diff --git a/games/transmission/resources/fonts/Lora-Bold.ttf b/games/transmission/resources/fonts/Lora-Bold.ttf deleted file mode 100644 index e48c4262e..000000000 Binary files a/games/transmission/resources/fonts/Lora-Bold.ttf and /dev/null differ diff --git a/games/transmission/resources/fonts/mom_typewritter.ttf b/games/transmission/resources/fonts/mom_typewritter.ttf deleted file mode 100644 index 13f5dc7dd..000000000 Binary files a/games/transmission/resources/fonts/mom_typewritter.ttf and /dev/null differ diff --git a/games/transmission/resources/fonts/traveling_typewriter.ttf b/games/transmission/resources/fonts/traveling_typewriter.ttf deleted file mode 100644 index 5d9d7c9ba..000000000 Binary files a/games/transmission/resources/fonts/traveling_typewriter.ttf and /dev/null differ diff --git a/games/transmission/resources/missions.txt b/games/transmission/resources/missions.txt deleted file mode 100644 index 635696081..000000000 --- a/games/transmission/resources/missions.txt +++ /dev/null @@ -1,65 +0,0 @@ -# Total missions -# NOTE: Missions follow the order of this file -t 4 -# ----------------------------------------------------------------- -# Briefing of the mission -b Se ha visto al Presidente en actitud cariñosa con una persona que no es la Primera Dama. Una situación comprometida que definirá el curso de la historia... Especialmente en campaña electoral y siendo del partido conservador... ¡El pueblo debe saber! -# -# Mission keyword -k oviparo -# -# Message to be coded -# NOTE: Sensible words must be noted using @ -m El @presidente es visto en un @hotel acompañado de su @amante. -# -# Solution to mission -# NOTE: Provide the correct solution nums, according to above words -# WARNING: Always provide 8 values, use -1 for not used ones -# Coding Words: POLLO = 0, CONEJO, HUEVO, NIDO, AIRE, ARMARIO, AGUJERO, PLATANO, PASTEL, MERCADO, RATON, MELON -s 0 3 2 -1 -1 -1 -1 -1 -# ----------------------------------------------------------------- -# Briefing of the mission -b Se ha visto un ovni sobrevolando la ciudad, al parecer se prevee un ataque alienígena inminente que definirá el curso de la historia... ¡El pueblo debe saber! -# -# Mission keyword -k roedor -# -# Message to be coded -# NOTE: Sensible words must be noted using @ -m Un @ovni ha sido detectado en el @cielo del @pais . Preparaos para el ataque de un @alien. -# -# NOTE: Provide the correct solution nums, according to above words -# WARNING: Always provide 8 values, use -1 for not used ones -# Coding Words: POLLO = 0, CONEJO, HUEVO, NIDO, AIRE, ARMARIO, AGUJERO, PLATANO, PASTEL, MERCADO, RATON, MELON -s 1 6 5 10 -1 -1 -1 -1 -# ----------------------------------------------------------------- -# Briefing of the mission -b Se ha filtrado una inminente subida del precio de un producto básico para todo el mundo: el ajo. Le evolución de su precio de mercado definirá el curso de la historia... ¡El pueblo debe saber! -# -# Mission keyword -k comida -# -# Message to be coded -# NOTE: Sensible words must be noted using @ -m Sube el @precio del @ajo. ¡Un @desastre inminente! -# -# NOTE: Provide the correct solution nums, according to above words -# WARNING: Always provide 8 values, use -1 for not used ones -# Coding Words: POLLO = 0, CONEJO, HUEVO, NIDO, AIRE, ARMARIO, AGUJERO, PLATANO, PASTEL, MERCADO, RATON, MELON -s 9 7 2 -1 -1 -1 -1 -1 -# ----------------------------------------------------------------- -# Briefing of the mission -b Se ha visto a un famoso presentador de TV deshaciéndose del cuerpo de un rival de otra cadena. Una pérdida que definirá el curso de la historia... Especialmente cuando su programa podría no continuar... ¡El pueblo debe saber! -# -# Mission keyword -k postre -# -# Message to be coded -# NOTE: Sensible words must be noted using @ -m Un @presentador se deshace del @cuerpo de su rival. ¡Peligra el @programa del Prime Time! -# -# NOTE: Provide the correct solution nums, according to above words -# WARNING: Always provide 8 values, use -1 for not used ones -# Coding Words: POLLO = 0, CONEJO, HUEVO, NIDO, AIRE, ARMARIO, AGUJERO, PLATANO, PASTEL, MERCADO, RATON, MELON -s 7 11 8 -1 -1 -1 -1 -1 -# ----------------------------------------------------------------- \ No newline at end of file diff --git a/games/transmission/resources/textures/cw_logo.png b/games/transmission/resources/textures/cw_logo.png deleted file mode 100644 index bc4011d84..000000000 Binary files a/games/transmission/resources/textures/cw_logo.png and /dev/null differ diff --git a/games/transmission/resources/textures/ending_background.png b/games/transmission/resources/textures/ending_background.png deleted file mode 100644 index 208886588..000000000 Binary files a/games/transmission/resources/textures/ending_background.png and /dev/null differ diff --git a/games/transmission/resources/textures/ending_newspaper.png b/games/transmission/resources/textures/ending_newspaper.png deleted file mode 100644 index f44e646d4..000000000 Binary files a/games/transmission/resources/textures/ending_newspaper.png and /dev/null differ diff --git a/games/transmission/resources/textures/message_background.png b/games/transmission/resources/textures/message_background.png deleted file mode 100644 index fb544796e..000000000 Binary files a/games/transmission/resources/textures/message_background.png and /dev/null differ diff --git a/games/transmission/resources/textures/message_vignette.png b/games/transmission/resources/textures/message_vignette.png deleted file mode 100644 index 6ef64b6bc..000000000 Binary files a/games/transmission/resources/textures/message_vignette.png and /dev/null differ diff --git a/games/transmission/resources/textures/mission_background.png b/games/transmission/resources/textures/mission_background.png deleted file mode 100644 index da5f3f67a..000000000 Binary files a/games/transmission/resources/textures/mission_background.png and /dev/null differ diff --git a/games/transmission/resources/textures/mission_backline.png b/games/transmission/resources/textures/mission_backline.png deleted file mode 100644 index 6123a9845..000000000 Binary files a/games/transmission/resources/textures/mission_backline.png and /dev/null differ diff --git a/games/transmission/resources/textures/mission_words.png b/games/transmission/resources/textures/mission_words.png deleted file mode 100644 index 4e4e9d936..000000000 Binary files a/games/transmission/resources/textures/mission_words.png and /dev/null differ diff --git a/games/transmission/resources/textures/title_background.png b/games/transmission/resources/textures/title_background.png deleted file mode 100644 index e45bbec80..000000000 Binary files a/games/transmission/resources/textures/title_background.png and /dev/null differ diff --git a/games/transmission/resources/textures/title_ribbon.png b/games/transmission/resources/textures/title_ribbon.png deleted file mode 100644 index f75438dd6..000000000 Binary files a/games/transmission/resources/textures/title_ribbon.png and /dev/null differ diff --git a/games/transmission/resources/textures/words_base.png b/games/transmission/resources/textures/words_base.png deleted file mode 100644 index e79e9815e..000000000 Binary files a/games/transmission/resources/textures/words_base.png and /dev/null differ diff --git a/games/transmission/screens/screen_ending.c b/games/transmission/screens/screen_ending.c deleted file mode 100644 index 22c2298be..000000000 --- a/games/transmission/screens/screen_ending.c +++ /dev/null @@ -1,250 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Ending Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include -#include - -#define MAX_TITLE_CHAR 256 -#define MAX_SUBTITLE_CHAR 256 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- -static char *codingWords[MAX_CODING_WORDS] = { - "pollo\0", - "conejo\0", - "huevo\0", - "nido\0", - "aire\0", - "armario\0", - "agujero\0", - "platano\0", - "pastel\0", - "mercado\0", - "raton\0", - "melon\0", -}; - -// Ending screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D texBackground; -static Texture2D texNewspaper; -static Texture2D texVignette; - -static Sound fxNews; - -static float rotation = 0.1f; -static float scale = 0.05f; -static int state = 0; - -static Mission *missions = NULL; - -static char headline[MAX_TITLE_CHAR] = "\0"; - -Font fontNews; - -// String (const char *) replacement function -static char *StringReplace(char *orig, char *rep, char *with); - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Ending Screen Initialization logic -void InitEndingScreen(void) -{ - framesCounter = 0; - finishScreen = 0; - - rotation = 0.1f; - scale = 0.05f; - state = 0; - - texBackground = LoadTexture("resources/textures/ending_background.png"); - texVignette = LoadTexture("resources/textures/message_vignette.png"); - fxNews = LoadSound("resources/audio/fx_batman.ogg"); - - missions = LoadMissions("resources/missions.txt"); - int wordsCount = missions[currentMission].wordsCount; - - strcpy(headline, missions[currentMission].msg); // Base headline - int len = strlen(headline); - - // Remove @ from headline - // TODO: Also remove additional spaces - for (int i = 0; i < len; i++) - { - if (headline[i] == '@') headline[i] = ' '; - } - - for (int i = 0; i < wordsCount; i++) - { - if (messageWords[i].id != missions[currentMission].sols[i]) - { - // WARNING: It fails if the last sentence word has a '.' after space - char *title = StringReplace(headline, messageWords[i].text, codingWords[messageWords[i].id]); - - if (title != NULL) - { - strcpy(headline, title); // Base headline updated - free(title); - } - } - } - - TraceLog(LOG_WARNING, "Titular: %s", headline); - - // Generate newspaper with title and subtitle - Image imNewspaper = LoadImage("resources/textures/ending_newspaper.png"); - fontNews = LoadFontEx("resources/fonts/Lora-Bold.ttf", 32, 0, 250); - ImageDrawTextEx(&imNewspaper, (Vector2){ 50, 220 }, fontNews, headline, fontNews.baseSize, 0, DARKGRAY); - - texNewspaper = LoadTextureFromImage(imNewspaper); - //UnloadFont(fontNews); - UnloadImage(imNewspaper); -} - -// Ending Screen Update logic -void UpdateEndingScreen(void) -{ - framesCounter++; - - if (framesCounter == 10) PlaySound(fxNews); - - if (state == 0) - { - rotation += 18.0f; - scale += 0.0096f; - - if (scale >= 1.0f) - { - scale = 1.0f; - state = 1; - } - } - - if ((state == 1) && (IsKeyPressed(KEY_ENTER) || IsButtonPressed())) - { - currentMission++; - - if (currentMission >= totalMissions) finishScreen = 2; - else finishScreen = 1; - } -} - -// Ending Screen Draw logic -void DrawEndingScreen(void) -{ - DrawTexture(texBackground, 0, 0, WHITE); - - DrawTexturePro(texNewspaper, (Rectangle){ 0, 0, texNewspaper.width, texNewspaper.height }, - (Rectangle){ GetScreenWidth()/2, GetScreenHeight()/2, texNewspaper.width*scale, texNewspaper.height*scale }, - (Vector2){ (float)texNewspaper.width*scale/2, (float)texNewspaper.height*scale/2 }, rotation, WHITE); - - DrawTextureEx(texVignette, (Vector2){ 0, 0 }, 0.0f, 2.0f, WHITE); - - // Draw debug information - DrawTextEx(fontNews, headline, (Vector2){ 10, 10 }, fontNews.baseSize, 0, RAYWHITE); - - for (int i = 0; i < missions[currentMission].wordsCount; i++) - { - DrawText(codingWords[messageWords[i].id], 10, 60 + 30*i, 20, (messageWords[i].id == missions[currentMission].sols[i]) ? GREEN : RED); - } - - if (state == 1) DrawButton("continuar"); -} - -// Ending Screen Unload logic -void UnloadEndingScreen(void) -{ - UnloadTexture(texBackground); - UnloadTexture(texNewspaper); - UnloadTexture(texVignette); - - UnloadSound(fxNews); - free(missions); -} - -// Ending Screen should finish? -int FinishEndingScreen(void) -{ - return finishScreen; -} - -// String (const char *) replacement function -// NOTE: Internally allocated memory must be freed by the user (if return != NULL) -// https://stackoverflow.com/questions/779875/what-is-the-function-to-replace-string-in-c -static char *StringReplace(char *orig, char *rep, char *with) -{ - char *result; // the return string - char *ins; // the next insert point - char *tmp; // varies - int len_rep; // length of rep (the string to remove) - int len_with; // length of with (the string to replace rep with) - int len_front; // distance between rep and end of last rep - int count; // number of replacements - - // Sanity checks and initialization - if (!orig || !rep) return NULL; - - len_rep = strlen(rep); - if (len_rep == 0) return NULL; // Empty rep causes infinite loop during count - - if (!with) with = ""; // Replace with nothing if not provided - len_with = strlen(with); - - // Count the number of replacements needed - ins = orig; - for (count = 0; (tmp = strstr(ins, rep)); ++count) - { - ins = tmp + len_rep; - } - - tmp = result = malloc(strlen(orig) + (len_with - len_rep)*count + 1); - - if (!result) return NULL; // Memory could not be allocated - - // First time through the loop, all the variable are set correctly from here on, - // tmp points to the end of the result string - // ins points to the next occurrence of rep in orig - // orig points to the remainder of orig after "end of rep" - while (count--) - { - ins = strstr(orig, rep); - len_front = ins - orig; - tmp = strncpy(tmp, orig, len_front) + len_front; - tmp = strcpy(tmp, with) + len_with; - orig += len_front + len_rep; // move to next "end of rep" - } - - strcpy(tmp, orig); - - return result; -} diff --git a/games/transmission/screens/screen_gameplay.c b/games/transmission/screens/screen_gameplay.c deleted file mode 100644 index 0541c863e..000000000 --- a/games/transmission/screens/screen_gameplay.c +++ /dev/null @@ -1,412 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include -#include -#include - -//#define MAX_CODING_WORDS 12 -//#define MAX_MISSION_WORDS 8 -#define MAX_LINE_CHAR 30 - -/* -// NOTE: Coding words are generic and the same words -// are used for all missions, -typedef enum CodingWords { - POLLO = 0, - CONEJO, - HUEVO, - NIDO, - AIRE, - ARMARIO, - AGUJERO, - COSA, - WORD, -} CodingWords; -*/ - -static char *codingWords[MAX_CODING_WORDS] = { - "pollo\0", - "conejo\0", - "huevo\0", - "nido\0", - "aire\0", - "armario\0", - "agujero\0", - "platano\0", - "pastel\0", - "mercado\0", - "raton\0", - "melon\0" -}; - -// Words to be coded or coding words -/*typedef struct Word { - int id; - Rectangle rec; - Rectangle iniRec; - bool hover; - bool picked; - char text[32]; // text -} Word;*/ - -/* -// Mission information -typedef struct Mission { - int id; - char brief[512]; // Mission briefing - char key[32]; // Mission keyword - char msg[256]; // Message to be coded - int wordsCount; // Number of words to coded - int sols[8]; // Solution code, depends on wordsCount -} Mission; -*/ -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D texBackground; -static Font fontMessage; -static Texture2D texWordsAtlas; -static Texture2D texVignette; - -static Sound fxGrab; -static Sound fxPlace; -static Sound fxLeave; - -static Music musSpy; - -static Word words[MAX_CODING_WORDS] = { 0 }; - -// Hay que hacerlo global, para poder consultar el resultado desde la endingscreen -//static Word messageWords[MAX_MISSION_WORDS] = { 0 }; - -static Mission *missions = NULL; - -static bool canSend = false; - -Vector2 msgOffset = { 430, 300 }; - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitGameplayScreen(void) -{ - framesCounter = 0; - finishScreen = 0; - - fontMessage = LoadFontEx("resources/fonts/traveling_typewriter.ttf", 30, 0, 250); - - texBackground = LoadTexture("resources/textures/message_background.png"); - texVignette = LoadTexture("resources/textures/message_vignette.png"); - - fxGrab = LoadSound("resources/audio/fx_grab.ogg"); - fxPlace = LoadSound("resources/audio/fx_place.ogg"); - fxLeave = LoadSound("resources/audio/fx_leave.ogg"); - - musSpy = LoadMusicStream("resources/audio/s_p_y.xm"); - PlayMusicStream(musSpy); - -#if defined(PLATFORM_WEB) - #define WORD_ATLAS_FROM_FILE -#endif -#if defined(WORD_ATLAS_FROM_FILE) - texWordsAtlas = LoadTexture("resources/textures/mission_words.png"); -#else - // Generate coding words atlas directly from text - Image imWordsBase = LoadImage("resources/textures/words_base.png"); - Image imWords = GenImageColor(imWordsBase.width, imWordsBase.height*MAX_CODING_WORDS, WHITE); - - for (int i = 0; i < MAX_CODING_WORDS; i++) - { - ImageDraw(&imWords, imWordsBase, - (Rectangle){ 0, 0, imWordsBase.width, imWordsBase.height }, - (Rectangle){ 0, imWordsBase.height*i, imWordsBase.width, imWordsBase.height }, WHITE); - - ImageDrawTextEx(&imWords,(Vector2){ imWordsBase.width/2 - MeasureTextEx(fontMessage, codingWords[i], - fontMessage.baseSize, 0).x/2, imWordsBase.height*i }, fontMessage, codingWords[i], - fontMessage.baseSize, 0, BLACK); - } - - texWordsAtlas = LoadTextureFromImage(imWords); - - UnloadImage(imWordsBase); - UnloadImage(imWords); -#endif - - // Initialize missions - // WARNING: Some problem with imWords image generation (memory leak?) could cause - // that loading missions before/after generation breaks game, on web is the other way round... :( - missions = LoadMissions("resources/missions.txt"); - TraceLog(LOG_WARNING, "Words count %i", missions[currentMission].wordsCount); - - // Initialize coding words - for (int i = 0; i < MAX_CODING_WORDS; i++) - { - words[i].id = -1; // Not placed anywhere - - words[i].rec.x = 110 + 940*(i/(MAX_CODING_WORDS/2)); - words[i].rec.y = 200 + 60*(i%(MAX_CODING_WORDS/2)); - words[i].rec.width = 140; // texWordsAtlas.width/MAX_MISSIONS - words[i].rec.height = 35; // texWordsAtlas.height/MAX_MISSION_WORDS - words[i].iniRec = words[i].rec; - words[i].hover = false; // Mouse hover detected - words[i].picked = false; // Mouse picked - - //words[i].text = ''; //codingWords[i]; // Fill text if required... - } - - // Analize missions[currentMission].msg string for words! - int msgLen = strlen(missions[currentMission].msg); - - // Add '/' each MAX_LINE_CHAR chars - int currentLine = 1; - int i = currentLine * MAX_LINE_CHAR; - - while (i < msgLen - 1) - { - if (missions[currentMission].msg[i] == ' ') - { - missions[currentMission].msg[i] = '/'; - currentLine++; - i = currentLine*MAX_LINE_CHAR; - } - else i++; - } - - int currentWord = 0; - int offsetX = 0; - int offsetY = 0; - bool foundWord = false; - int wordInitPosX = 0; - int wordInitPosY = 0; - - for (int i = 0; i < msgLen; i++) - { - char c = missions[currentMission].msg[i]; - if (foundWord && (c == ' ' || c == '.')) - { - foundWord = false; - - messageWords[currentWord - 1].rec.width = (int)MeasureTextEx(fontMessage, TextSubtext(missions[currentMission].msg, wordInitPosX, (i - wordInitPosX)), 30, 0).x; - messageWords[currentWord - 1].rec.height = fontMessage.baseSize; - - strncpy(messageWords[currentWord - 1].text, TextSubtext(missions[currentMission].msg, wordInitPosX, (i - wordInitPosX)), i - wordInitPosX); - } - - if (c == '@') // One word to change - { - foundWord = true; - missions[currentMission].msg[i] = ' '; - - offsetX = (int)MeasureTextEx(fontMessage, TextSubtext(missions[currentMission].msg, wordInitPosY, (i + 1) - wordInitPosY), 30, 0).x; - - messageWords[currentWord].rec.x = offsetX; - messageWords[currentWord].rec.y = offsetY; - - wordInitPosX = i + 1; - - currentWord++; - } - else if (c == '/') - { - missions[currentMission].msg[i] = '\n'; - wordInitPosY = i; - offsetY += (fontMessage.baseSize + fontMessage.baseSize/2); // raylib internal increment on line break... - } - } - - for (int i = 0; i < missions[currentMission].wordsCount; i++) - { - messageWords[i].id = -1; // Not required for message words, id is the array position - - // Recalculate words rectangles considering text offset on screen - messageWords[i].rec.x += msgOffset.x; - messageWords[i].rec.y += msgOffset.y; - - // Recalculate words rectangle considering new width height - messageWords[i].rec.x -= (texWordsAtlas.width - messageWords[i].rec.width)/2; - messageWords[i].rec.y -= ((texWordsAtlas.height / MAX_CODING_WORDS) - messageWords[i].rec.height)/2; - - //Recalculate width height - messageWords[i].rec.width = texWordsAtlas.width; - messageWords[i].rec.height = texWordsAtlas.height / MAX_CODING_WORDS; - - messageWords[i].hover = false; // Mouse hover detected - messageWords[i].picked = false; // Mouse picked - } -} - -// Gameplay Screen Update logic -void UpdateGameplayScreen(void) -{ - UpdateMusicStream(musSpy); - - for (int i = 0; i < MAX_CODING_WORDS; i++) - { - if (CheckCollisionPointRec(GetMousePosition(), words[i].rec)) - { - words[i].hover = true; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - words[i].picked = true; - PlaySound(fxGrab); - } - } - else words[i].hover = false; - - - if (words[i].picked) - { - for (int j = 0; j < missions[currentMission].wordsCount; j++) - { - if (CheckCollisionPointRec(GetMousePosition(), messageWords[j].rec)) messageWords[j].hover = true; - else messageWords[j].hover = false; - } - - if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) - { - words[i].picked = false; - - for (int j = 0; j < missions[currentMission].wordsCount; j++) - { - messageWords[j].hover = false; - - if (CheckCollisionPointRec(GetMousePosition(), messageWords[j].rec)) - { - PlaySound(fxPlace); - - words[i].rec.x = messageWords[j].rec.x; - words[i].rec.y = messageWords[j].rec.y; - - if (messageWords[j].id != -1) - { - int id = messageWords[j].id; - words[id].rec = words[id].iniRec; - } - - messageWords[j].id = i; - for (int k = 0; k < missions[currentMission].wordsCount; k++) - { - if (j != k && messageWords[j].id == messageWords[k].id) - { - messageWords[k].id = -1; - break; - } - } - break; - } - else - { - PlaySound(fxLeave); - - words[i].rec = words[i].iniRec; - if (i == messageWords[j].id) messageWords[j].id = -1; - } - } - } - } - - // Move word picked with mouse - if (words[i].picked) - { - words[i].rec.x = GetMouseX() - words[i].rec.width/2; - words[i].rec.y = GetMouseY() - words[i].rec.height/2; - } - } - - canSend = true; - for (int j = 0; j < missions[currentMission].wordsCount; j++) - { - if (messageWords[j].id == -1) - { - canSend = false; - break; - } - } - - if (canSend && (IsKeyPressed(KEY_ENTER) || IsButtonPressed())) - { - finishScreen = true; - } -} - -// Gameplay Screen Draw logic -void DrawGameplayScreen(void) -{ - DrawTexture(texBackground, 0, 0, WHITE); - - DrawTextEx(fontMessage, missions[currentMission].msg, msgOffset, fontMessage.baseSize, 0, BLACK); - - for (int i = 0; i < missions[currentMission].wordsCount; i++) - { - Rectangle recLines = messageWords[i].rec; - DrawRectangleLines(recLines.x, recLines.y, recLines.width, recLines.height, Fade(RED, 0.35f)); - if (messageWords[i].hover) DrawRectangleRec(messageWords[i].rec, Fade(RED, 0.30f)); - DrawText(FormatText("%i", messageWords[i].id), i*25, 0, 30, RED); - } - for (int i = 0; i < MAX_CODING_WORDS; i++) - { - if (words[i].picked) DrawTextureRec(texWordsAtlas, (Rectangle){ 0, i*35, 140, 35 }, (Vector2){ words[i].rec.x, words[i].rec.y }, MAROON); - else if (words[i].hover) DrawTextureRec(texWordsAtlas, (Rectangle){ 0, i*35, 140, 35 }, (Vector2){ words[i].rec.x, words[i].rec.y }, RED); - else DrawTextureRec(texWordsAtlas, (Rectangle){ 0, i*35, 140, 35 }, (Vector2){ words[i].rec.x, words[i].rec.y }, WHITE); - } - - DrawTexturePro(texVignette, (Rectangle){0,0,texVignette.width, texVignette.height}, (Rectangle){0,0,GetScreenWidth(), GetScreenHeight()}, (Vector2){0,0}, 0, WHITE); - - if (canSend) DrawButton("enviar"); -} - -// Gameplay Screen Unload logic -void UnloadGameplayScreen(void) -{ - UnloadTexture(texBackground); - UnloadTexture(texVignette); - UnloadTexture(texWordsAtlas); - - UnloadSound(fxGrab); - UnloadSound(fxLeave); - UnloadSound(fxPlace); - - UnloadMusicStream(musSpy); - - free(missions); -} - -// Gameplay Screen should finish? -int FinishGameplayScreen(void) -{ - return finishScreen; -} diff --git a/games/transmission/screens/screen_logo.c b/games/transmission/screens/screen_logo.c deleted file mode 100644 index 80c998097..000000000 --- a/games/transmission/screens/screen_logo.c +++ /dev/null @@ -1,242 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Logo Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#define LOGO_RECS_SIDE 16 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Logo screen global variables -static int framesCounter = 0; -static int finishScreen = 0; - -static int logoPositionX = 0; -static int logoPositionY = 0; - -static int lettersCount = 0; - -static int topSideRecWidth = 0; -static int leftSideRecHeight = 0; - -static int bottomSideRecWidth = 0; -static int rightSideRecHeight = 0; - -static char raylib[8] = { 0 }; // raylib text array, max 8 letters -static int state = 0; // Tracking animation states (State Machine) -static float alpha = 1.0f; // Useful for fading - -static Texture2D texLogoCW = { 0 }; // Cinamon Works texture - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Logo Screen Initialization logic -void InitLogoScreen(void) -{ - // Initialize LOGO screen variables here! - finishScreen = 0; - framesCounter = 0; - lettersCount = 0; - - logoPositionX = GetScreenWidth()/2 - 128; - logoPositionY = GetScreenHeight()/2 - 128; - - topSideRecWidth = LOGO_RECS_SIDE; - leftSideRecHeight = LOGO_RECS_SIDE; - bottomSideRecWidth = LOGO_RECS_SIDE; - rightSideRecHeight = LOGO_RECS_SIDE; - - for (int i = 0; i < 8; i++) raylib[i] = '\0'; - - state = 0; - alpha = 1.0f; - - texLogoCW = LoadTexture("resources/textures/cw_logo.png"); -} - -// Logo Screen Update logic -void UpdateLogoScreen(void) -{ - // Update LOGO screen variables here! - if (state == 0) // State 0: Small box blinking - { - framesCounter++; - - if (framesCounter == 80) - { - state = 1; - framesCounter = 0; // Reset counter... will be used later... - } - } - else if (state == 1) // State 1: Top and left bars growing - { - topSideRecWidth += 8; - leftSideRecHeight += 8; - - if (topSideRecWidth == 256) state = 2; - } - else if (state == 2) // State 2: Bottom and right bars growing - { - bottomSideRecWidth += 8; - rightSideRecHeight += 8; - - if (bottomSideRecWidth == 256) state = 3; - } - else if (state == 3) // State 3: Letters appearing (one by one) - { - framesCounter++; - - if (framesCounter/10) // Every 12 frames, one more letter! - { - lettersCount++; - framesCounter = 0; - } - - switch (lettersCount) - { - case 1: raylib[0] = 'r'; break; - case 2: raylib[1] = 'a'; break; - case 3: raylib[2] = 'y'; break; - case 4: raylib[3] = 'l'; break; - case 5: raylib[4] = 'i'; break; - case 6: raylib[5] = 'b'; break; - default: break; - } - - // When all letters have appeared... - if (lettersCount >= 10) - { - state = 4; - framesCounter = 0; - } - } - else if (state == 4) - { - framesCounter++; - - if (framesCounter > 100) - { - alpha -= 0.02f; - - if (alpha <= 0.0f) - { - alpha = 0.0f; - framesCounter = 0; - state = 5; - } - } - } - else if (state == 5) - { - alpha += 0.02f; - if (alpha >= 1.0f) alpha = 1.0f; - - framesCounter++; - if (framesCounter > 200) - { - framesCounter = 0; - state = 6; - } - } - else if (state == 6) - { - alpha -= 0.02f; - if (alpha >= 1.0f) alpha = 1.0f; - - framesCounter++; - if (framesCounter > 100) - { - framesCounter = 0; - finishScreen = 1; - } - } -} - -// Logo Screen Draw logic -void DrawLogoScreen(void) -{ - if (state == 0) - { - if ((framesCounter/10)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK); - } - else if (state == 1) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - } - else if (state == 2) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK); - } - else if (state == 3) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - } - else if (state == 4) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - - if (framesCounter > 20) DrawText("powered by", logoPositionX, logoPositionY - 27, 20, Fade(DARKGRAY, alpha)); - } - else if ((state == 5) || (state == 6)) DrawTexture(texLogoCW, GetScreenWidth()/2 - texLogoCW.width/2, GetScreenHeight()/2 - texLogoCW.height/2, Fade(WHITE, alpha)); -} - -// Logo Screen Unload logic -void UnloadLogoScreen(void) -{ - // Unload LOGO screen variables here! - UnloadTexture(texLogoCW); -} - -// Logo Screen should finish? -int FinishLogoScreen(void) -{ - return finishScreen; -} diff --git a/games/transmission/screens/screen_mission.c b/games/transmission/screens/screen_mission.c deleted file mode 100644 index 77777c73e..000000000 --- a/games/transmission/screens/screen_mission.c +++ /dev/null @@ -1,291 +0,0 @@ -/********************************************************************************************** -* -* raylib - transmission mission -* -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include -#include - -#define MISSION_MAX_LENGTH 256 -#define KEYWORD_MAX_LENGTH 32 -#define MAX_LINE_CHAR 75 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Mission screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D texBackground; - -static Texture2D texBackline; //mission_backline -static Rectangle sourceRecBackLine; -static Rectangle destRecBackLine; -static float fadeBackLine; - -static Vector2 numberPosition; -static Color numberColor; - -//static char textMission[MISSION_MAX_LENGTH]; -static Vector2 missionPosition; -static int missionSize; -static Color missionColor; -static int missionLenght; -static bool missionMaxLength; -static int missionSpeed; - -//static char textKeyword[KEYWORD_MAX_LENGTH]; -static Vector2 keywordPosition; -static Color keywordColor; - -static int showMissionWaitFrames; -static int showNumberWaitFrames; -static int showKeywordWaitFrames; - -static bool startWritting; -static bool writeMission; -static bool writeNumber; -static bool writeKeyword; -static bool writeEnd; - -static bool writtingMission; - -static int blinkFrames; -static bool blinkKeyWord = true; - -static bool showButton = false; - -static Mission *missions = NULL; - -static Sound fxTransmit; -static Music musMission; - -//---------------------------------------------------------------------------------- -// Mission Screen Functions Definition -//---------------------------------------------------------------------------------- -static void WriteMissionText(); - - -// Mission Screen Initialization logic -void InitMissionScreen(void) -{ - framesCounter = 0; - finishScreen = 0; - - fadeButton = 0.80f; - - texBackground = LoadTexture("resources/textures/mission_background.png"); - - texBackline = LoadTexture("resources/textures/mission_backline.png"); - sourceRecBackLine = (Rectangle){0,0,GetScreenWidth(), texBackline.height}; - destRecBackLine = (Rectangle){0,0,sourceRecBackLine.width, sourceRecBackLine.height}; - fadeBackLine = 0; - - fxTransmit = LoadSound("resources/audio/fx_message.ogg"); - musMission = LoadMusicStream("resources/audio/music_mission.ogg"); - - PlayMusicStream(musMission); - - // Initialize missions - missions = LoadMissions("resources/missions.txt"); - - missionMaxLength = strlen(missions[currentMission].brief); - - // Insert line breaks every MAX_LINE_CHAR - int currentLine = 1; - int i = currentLine * MAX_LINE_CHAR; - - while (i < missionMaxLength) - { - if (missions[currentMission].brief[i] == ' ') - { - missions[currentMission].brief[i] = '\n'; - currentLine++; - i = currentLine*MAX_LINE_CHAR; - } - else i++; - } - - missionSize = 30; - missionLenght = 0; - missionSpeed = 1; - - numberColor = RAYWHITE; - missionColor = LIGHTGRAY; - keywordColor = (Color){198, 49, 60, 255}; //RED - - numberPosition = (Vector2){150, 185}; - missionPosition = (Vector2){numberPosition.x, numberPosition.y + 60}; - keywordPosition = (Vector2){missionPosition.x, missionPosition.y + MeasureTextEx(fontMission, missions[currentMission].brief, missionSize, 0).y + 60}; - - startWritting = false; - writeNumber = false; - writeMission = false; - writeKeyword = false; - writeEnd = false; - - writtingMission = false; - - showNumberWaitFrames = 30; - showMissionWaitFrames = 60; - showKeywordWaitFrames = 60; - - blinkKeyWord = true; - blinkFrames = 15; - - PlaySound(fxTransmit); -} - -// Mission Screen Update logic -void UpdateMissionScreen(void) -{ - UpdateMusicStream(musMission); - - if (!writeEnd) WriteMissionText(); - else - { - framesCounter++; - - if ((framesCounter%blinkFrames) == 0) - { - framesCounter = 0; - blinkKeyWord = !blinkKeyWord; - } - } - - if (showButton) - { - if (IsKeyPressed(KEY_ENTER) || IsButtonPressed()) - { - if (!writeEnd) - { - writeEnd = true; - writeKeyword = true; - writeNumber = true; - missionLenght = missionMaxLength; - } - else - { - finishScreen = true; - showButton = false; - } - } - } -} - -// Mission Screen Draw logic -void DrawMissionScreen(void) -{ - // Draw MISSION screen here! - DrawTexture(texBackground, 0,0, WHITE); - DrawTexturePro(texBackline, sourceRecBackLine, destRecBackLine, (Vector2){0,0},0, Fade(WHITE, fadeBackLine)); - - if (writeNumber) DrawTextEx(fontMission, FormatText("Filtración #%02i ", currentMission + 1), numberPosition, missionSize + 10, 0, numberColor); - DrawTextEx(fontMission, TextSubtext(missions[currentMission].brief, 0, missionLenght), missionPosition, missionSize, 0, missionColor); - if (writeKeyword && blinkKeyWord) DrawTextEx(fontMission, FormatText("Keyword: %s", missions[currentMission].key), keywordPosition, missionSize + 10, 0, keywordColor); - - if (showButton) - { - if (!writeEnd) DrawButton("saltar"); - else DrawButton("codificar"); - } -} - -// Mission Screen Unload logic -void UnloadMissionScreen(void) -{ - // Unload MISSION screen variables here! - UnloadTexture(texBackground); - UnloadTexture(texBackline); - UnloadSound(fxTransmit); - UnloadMusicStream(musMission); - free(missions); -} - -// Mission Screen should finish? -int FinishMissionScreen(void) -{ - return finishScreen; -} - -static void WriteMissionText() -{ - if (!startWritting) - { - framesCounter++; - if (framesCounter % 60 == 0) - { - framesCounter = 0; - startWritting = true; - } - } - else if (!writeNumber) - { - framesCounter++; - fadeBackLine += 0.020f; - if (framesCounter % showNumberWaitFrames == 0) - { - framesCounter = 0; - writeNumber = true; - showButton = true; - } - } - else if (!writeMission) - { - framesCounter ++; - if (framesCounter % showMissionWaitFrames == 0) - { - framesCounter = 0; - writeMission = true; - writtingMission = true; - } - } - else if (writeMission && writtingMission) - { - framesCounter++; - if (framesCounter % missionSpeed == 0) - { - framesCounter = 0; - missionLenght++; - - if (missionLenght == missionMaxLength) - { - writtingMission = false; - } - } - } - else if (!writeKeyword) - { - framesCounter++; - if (framesCounter % showKeywordWaitFrames == 0) - { - framesCounter = 0; - writeKeyword = true; - writeEnd = true; - } - } -} diff --git a/games/transmission/screens/screen_title.c b/games/transmission/screens/screen_title.c deleted file mode 100644 index e9023b089..000000000 --- a/games/transmission/screens/screen_title.c +++ /dev/null @@ -1,168 +0,0 @@ -/********************************************************************************************** -* -* raylib - transmission mission -* -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Title screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D texBackground; -static Font fontTitle; -static Sound fxTyping; - -static float titleSize; -static Vector2 transmissionPosition; -static Vector2 missionPositon; - -static const char textTitle[20] = "transmissionmission"; - -static Color titleColor; -static int speedText; - -static int transmissionLenght; -static int missionLenght; -static int transmissionMaxLenght; -static int missionMaxLenght; - -static bool writeTransmission; -static bool writeMission; -static bool writeEnd; - -//---------------------------------------------------------------------------------- -// Title Screen Functions Definition -//---------------------------------------------------------------------------------- -static void MissionScreen(); - -// Title Screen Initialization logic -void InitTitleScreen(void) -{ - // TODO: Initialize TITLE screen variables here! - framesCounter = 0; - finishScreen = 0; - - texBackground = LoadTexture("resources/textures/title_background.png"); - fxTyping = LoadSound("resources/audio/fx_typing.ogg"); - fontTitle = LoadFontEx("resources/fonts/mom_typewritter.ttf", 96, 0, 0); - - titleSize = 44; - transmissionPosition = (Vector2){519, 221}; - missionPositon = (Vector2){580, 261}; - - titleColor = BLACK; - speedText = 15; - - missionLenght = 0; - transmissionLenght = 0; - - missionMaxLenght = 7; - transmissionMaxLenght = 12; - - writeTransmission = true; - writeMission = false; - writeEnd = false; - - currentMission = 0; -} - -// Title Screen Update logic -void UpdateTitleScreen(void) -{ - if (!writeEnd) - { - framesCounter ++; - - if (framesCounter%speedText == 0) - { - framesCounter = 0; - if (writeTransmission) - { - transmissionLenght++; - if (transmissionLenght == transmissionMaxLenght) - { - writeTransmission = false; - writeMission = true; - } - } - else if (writeMission) - { - missionLenght++; - if (missionLenght == missionMaxLenght) - { - writeMission = false; - writeEnd = true; - } - } - - PlaySound(fxTyping); - } - } - - if(IsButtonPressed()) - { - MissionScreen(); - } - else if (IsKeyPressed(KEY_ENTER)) MissionScreen(); -} - -// Title Screen Draw logic -void DrawTitleScreen(void) -{ - DrawTexture(texBackground, 0,0, WHITE); - DrawTextEx(fontTitle, TextSubtext(textTitle, 0, transmissionLenght), transmissionPosition, titleSize, 0, titleColor); - DrawTextEx(fontTitle, TextSubtext(textTitle, 12, missionLenght), missionPositon, titleSize, 0, titleColor); - - DrawButton("start"); -} - -// Title Screen Unload logic -void UnloadTitleScreen(void) -{ - UnloadTexture(texBackground); - UnloadSound(fxTyping); - UnloadFont(fontTitle); -} - -// Title Screen should finish? -int FinishTitleScreen(void) -{ - return finishScreen; -} - -static void MissionScreen() -{ - transmissionLenght = transmissionMaxLenght; - missionLenght = missionMaxLenght; - writeEnd = true; - //finishScreen = 1; // OPTIONS - finishScreen = true; // GAMEPLAY - //PlaySound(fxCoin); -} \ No newline at end of file diff --git a/games/transmission/screens/screens.h b/games/transmission/screens/screens.h deleted file mode 100644 index 49698f0d9..000000000 --- a/games/transmission/screens/screens.h +++ /dev/null @@ -1,143 +0,0 @@ -/********************************************************************************************** -* -* raylib - transmission mission -* -* Screens Functions Declarations (Init, Update, Draw, Unload) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef SCREENS_H -#define SCREENS_H - -#define MAX_CODING_WORDS 12 -#define MAX_MISSION_WORDS 8 - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum GameScreen { LOGO = 0, TITLE, MISSION, GAMEPLAY, ENDING } GameScreen; - -// Words to be coded or coding words -typedef struct Word { - int id; - Rectangle rec; - Rectangle iniRec; - bool hover; - bool picked; - char text[32]; // text -} Word; - -// Mission information -typedef struct Mission { - int id; - char brief[512]; // Mission briefing - char key[32]; // Mission keyword - char msg[256]; // Message to be coded - int wordsCount; // Number of words to coded - int sols[10]; // Solution code, depends on wordsCount -} Mission; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -GameScreen currentScreen; - -Music music; -Sound fxButton; - -//Mission *missions; - -// UI BUTTON -Rectangle recButton; -float fadeButton; -Color colorButton; -Texture2D texButton; -Vector2 textPositionButton; -int fontSizeButton; -Color textColorButton; - -int currentMission; -int totalMissions; - -Font fontMission; - -Word messageWords[MAX_MISSION_WORDS]; - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -//---------------------------------------------------------------------------------- -// Transmission Functions Declaration -//---------------------------------------------------------------------------------- -bool IsButtonPressed(); -void DrawButton(const char *text); -Mission *LoadMissions(const char *fileName); - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLogoScreen(void); -void UpdateLogoScreen(void); -void DrawLogoScreen(void); -void UnloadLogoScreen(void); -int FinishLogoScreen(void); - -//---------------------------------------------------------------------------------- -// Title Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitTitleScreen(void); -void UpdateTitleScreen(void); -void DrawTitleScreen(void); -void UnloadTitleScreen(void); -int FinishTitleScreen(void); - -//---------------------------------------------------------------------------------- -// Mission Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitMissionScreen(void); -void UpdateMissionScreen(void); -void DrawMissionScreen(void); -void UnloadMissionScreen(void); -int FinishMissionScreen(void); - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitGameplayScreen(void); -void UpdateGameplayScreen(void); -void DrawGameplayScreen(void); -void UnloadGameplayScreen(void); -int FinishGameplayScreen(void); - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitEndingScreen(void); -void UpdateEndingScreen(void); -void DrawEndingScreen(void); -void UnloadEndingScreen(void); -int FinishEndingScreen(void); - -#ifdef __cplusplus -} -#endif - -#endif // SCREENS_H \ No newline at end of file diff --git a/games/transmission/transmission.c b/games/transmission/transmission.c deleted file mode 100644 index 79097b069..000000000 --- a/games/transmission/transmission.c +++ /dev/null @@ -1,452 +0,0 @@ -/******************************************************************************************* -* -* TRANSMISSION MISSION [GLOBAL GAME JAM 2018] -* -* Code the different filtration messages to be send to newspaper -* to avoid being understood in case of interception. -* -* This game has been created using raylib 1.8 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2018 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include "screens/screens.h" // NOTE: Defines global variable: currentScreen - -#include -#include - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- -const int screenWidth = 1280; -const int screenHeight = 720; - -// Required variables to manage screen transitions (fade-in, fade-out) -static float transAlpha = 0.0f; -static bool onTransition = false; -static bool transFadeOut = false; -static int transFromScreen = -1; -static int transToScreen = -1; - -// NOTE: Some global variables that require to be visible for all screens, -// are defined in screens.h (i.e. currentScreen) - -//---------------------------------------------------------------------------------- -// Local Functions Declaration -//---------------------------------------------------------------------------------- -static void ChangeToScreen(int screen); // No transition effect - -static void TransitionToScreen(int screen); -static void UpdateTransition(void); -static void DrawTransition(void); - -static void UpdateDrawFrame(void); // Update and Draw one frame - -//---------------------------------------------------------------------------------- -// Main entry point -//---------------------------------------------------------------------------------- -int main(void) -{ - // Initialization (Note windowTitle is unused on Android) - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "transmission mission [GGJ18]"); - - // Global data loading (assets that must be available in all screens, i.e. fonts) - InitAudioDevice(); - - music = LoadMusicStream("resources/audio/music_title.ogg"); - fxButton = LoadSound("resources/audio/fx_newspaper.ogg"); - - SetMusicVolume(music, 1.0f); - PlayMusicStream(music); - - fontMission = LoadFontEx("resources/fonts/traveling_typewriter.ttf", 64, 0, 250); - texButton = LoadTexture("resources/textures/title_ribbon.png"); - - // UI BUTTON - recButton.width = texButton.width; - recButton.height = texButton.height; - recButton.x = screenWidth - recButton.width; - recButton.y = screenHeight - recButton.height - 50; - fadeButton = 0.8f; - colorButton = RED; - textPositionButton = (Vector2){recButton.x + recButton.width/2, recButton.y + recButton.height/2}; - fontSizeButton = 30; - textColorButton = WHITE; - - currentMission = 0; - totalMissions = 4; - - // Setup and Init first screen - currentScreen = LOGO; - InitLogoScreen(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - UpdateDrawFrame(); - } -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload current screen data before closing - switch (currentScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case MISSION: UnloadMissionScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Unload all global loaded data (i.e. fonts) here! - UnloadMusicStream(music); - UnloadSound(fxButton); - - UnloadFont(fontMission); - UnloadTexture(texButton); - - CloseAudioDevice(); // Close audio context - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//---------------------------------------------------------------------------------- -// Module specific Functions Definition -//---------------------------------------------------------------------------------- - -// Change to next screen, no transition -static void ChangeToScreen(int screen) -{ - // Unload current screen - switch (currentScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case MISSION: UnloadMissionScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Init next screen - switch (screen) - { - case LOGO: InitLogoScreen(); break; - case TITLE: InitTitleScreen(); break; - case MISSION: InitMissionScreen(); break; - case GAMEPLAY: InitGameplayScreen(); break; - case ENDING: InitEndingScreen(); break; - default: break; - } - - currentScreen = screen; -} - -// Define transition to next screen -static void TransitionToScreen(int screen) -{ - onTransition = true; - transFadeOut = false; - transFromScreen = currentScreen; - transToScreen = screen; - transAlpha = 0.0f; -} - -// Update transition effect -static void UpdateTransition(void) -{ - if (!transFadeOut) - { - transAlpha += 0.02f; - - // NOTE: Due to float internal representation, condition jumps on 1.0f instead of 1.05f - // For that reason we compare against 1.01f, to avoid last frame loading stop - if (transAlpha > 1.01f) - { - transAlpha = 1.0f; - - // Unload current screen - switch (transFromScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case MISSION: UnloadMissionScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Load next screen - switch (transToScreen) - { - case LOGO: InitLogoScreen(); break; - case TITLE: InitTitleScreen(); break; - case MISSION: InitMissionScreen(); break; - case GAMEPLAY: InitGameplayScreen(); break; - case ENDING: InitEndingScreen(); break; - default: break; - } - - currentScreen = transToScreen; - - // Activate fade out effect to next loaded screen - transFadeOut = true; - } - } - else // Transition fade out logic - { - transAlpha -= 0.02f; - - if (transAlpha < -0.01f) - { - transAlpha = 0.0f; - transFadeOut = false; - onTransition = false; - transFromScreen = -1; - transToScreen = -1; - } - } -} - -// Draw transition effect (full-screen rectangle) -static void DrawTransition(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha)); -} - -// Update and draw game frame -static void UpdateDrawFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - UpdateMusicStream(music); // NOTE: Music keeps playing between screens - - if (!onTransition) - { - switch(currentScreen) - { - case LOGO: - { - UpdateLogoScreen(); - - if (FinishLogoScreen()) TransitionToScreen(TITLE); - - } break; - case TITLE: - { - UpdateTitleScreen(); - - if (FinishTitleScreen()) - { - StopMusicStream(music); - TransitionToScreen(MISSION); - } - - } break; - case MISSION: - { - UpdateMissionScreen(); - - if (FinishMissionScreen()) - { - StopMusicStream(music); - TransitionToScreen(GAMEPLAY); - } - - } break; - case GAMEPLAY: - { - UpdateGameplayScreen(); - - if (FinishGameplayScreen() == 1) TransitionToScreen(ENDING); - //else if (FinishGameplayScreen() == 2) TransitionToScreen(TITLE); - - } break; - case ENDING: - { - UpdateEndingScreen(); - - if (FinishEndingScreen() == 1) // Continue to next mission - { - TransitionToScreen(MISSION); - } - else if (FinishEndingScreen() == 2) // Replay current mission - { - PlayMusicStream(music); - TransitionToScreen(TITLE); - } - - } break; - default: break; - } - } - else UpdateTransition(); // Update transition (fade-in, fade-out) - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch(currentScreen) - { - case LOGO: DrawLogoScreen(); break; - case TITLE: DrawTitleScreen(); break; - case MISSION: DrawMissionScreen(); break; - case GAMEPLAY: DrawGameplayScreen(); break; - case ENDING: DrawEndingScreen(); break; - default: break; - } - - // Draw full screen rectangle in front of everything - if (onTransition) DrawTransition(); - - //DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- -} - -// Load missions from text file -Mission *LoadMissions(const char *fileName) -{ - Mission *missions = NULL; - char buffer[512]; - - int missionsCount = 0; - - FILE *misFile = fopen(fileName, "rt"); - - if (misFile == NULL) printf("[%s] Missions file could not be opened\n", fileName); - else - { - // First pass to get total missions count - while (!feof(misFile)) - { - fgets(buffer, 512, misFile); - - switch (buffer[0]) - { - case 't': sscanf(buffer, "t %i", &missionsCount); break; - default: break; - } - } - - if (missionsCount > 0) missions = (Mission *)malloc(missionsCount*sizeof(Mission)); - else return NULL; - - rewind(misFile); // Return to the beginning of the file, to read again - - int missionNum = 0; - - while (!feof(misFile)) - { - fgets(buffer, 512, misFile); - - if (missionNum < missionsCount) - { - switch (buffer[0]) - { - case 'b': - { - // New mission brief starts! - missions[missionNum].id = missionNum; - sscanf(buffer, "b %[^\n]s", missions[missionNum].brief); - } break; - case 'k': sscanf(buffer, "k %[^\n]s", missions[missionNum].key); break; - case 'm': - { - // NOTE: Message is loaded as is, needs to be processed! - sscanf(buffer, "m %[^\n]s", missions[missionNum].msg); - } break; - case 's': - { - sscanf(buffer, "s %i %i %i %i %i %i %i %i", - &missions[missionNum].sols[0], - &missions[missionNum].sols[1], - &missions[missionNum].sols[2], - &missions[missionNum].sols[3], - &missions[missionNum].sols[4], - &missions[missionNum].sols[5], - &missions[missionNum].sols[6], - &missions[missionNum].sols[7]); - - missions[missionNum].wordsCount = 0; - - for (int i = 0; i < 8; i++) - { - if (missions[missionNum].sols[i] > -1) - { - missions[missionNum].wordsCount++; - } - } - - TraceLog(LOG_WARNING, "Mission %i - Words count %i", missionNum, missions[missionNum].wordsCount); - - missionNum++; - } break; - default: break; - } - } - } - - if (missionsCount != missionNum) TraceLog(LOG_WARNING, "Missions count and loaded missions don't match!"); - } - - fclose(misFile); - - if (missions != NULL) - { - TraceLog(LOG_INFO, "Missions loaded: %i", missionsCount); - TraceLog(LOG_INFO, "Missions loaded successfully!"); - } - - return missions; -} - -bool IsButtonPressed() -{ - if (CheckCollisionPointRec(GetMousePosition(), recButton)) - { - fadeButton = 1.0f; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsGestureDetected(GESTURE_TAP)) - { - PlaySound(fxButton); - return true; - } - } - else fadeButton = 0.80f; - - return false; -} - -void DrawButton(const char *text) -{ - //DrawRectangleRec(recButton, Fade(colorButton, fadeButton)); - DrawTexturePro(texButton, (Rectangle){0,0,texButton.width, texButton.height}, recButton, (Vector2){0,0},0, Fade(WHITE, fadeButton)); - Vector2 measure = MeasureTextEx(fontMission, text, fontSizeButton, 0); - Vector2 textPos = {textPositionButton.x - measure.x/2 + 10, textPositionButton.y - measure.y/2 - 10}; - DrawTextEx(fontMission, text, textPos , fontSizeButton, 0, textColorButton); -} diff --git a/games/wave_collector/CMakeLists.txt b/games/wave_collector/CMakeLists.txt deleted file mode 100644 index a87dbeda8..000000000 --- a/games/wave_collector/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(wave_collector) - -# Grab the screens -file(GLOB screen_sources "screens/*.c") - -# Executable & linking -add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c ${screen_sources}) -if (NOT TARGET raylib) - find_package(raylib 2.0 REQUIRED) -endif() -target_link_libraries(${PROJECT_NAME} raylib) - -# Resources -# Copy all of the resource files to the destination -file(COPY "resources/" DESTINATION "resources/") diff --git a/games/wave_collector/LICENSE.txt b/games/wave_collector/LICENSE.txt deleted file mode 100644 index 510604da4..000000000 --- a/games/wave_collector/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ - -This game sources are licensed under an unmodified zlib/libpng license, -which is an OSI-certified, BSD-like license: - -Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) - -This software is provided "as-is", without any express or implied warranty. In no event -will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial -applications, and to alter it and redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not claim that you - wrote the original software. If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be misrepresented - as being the original software. - - 3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/games/wave_collector/Makefile b/games/wave_collector/Makefile deleted file mode 100644 index 092d37d97..000000000 --- a/games/wave_collector/Makefile +++ /dev/null @@ -1,406 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= wave_collector -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= C:\GitHub\raylib - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - # -Wl,--subsystem,windows hides the console window - ifeq ($(BUILD_MODE), RELEASE) - LDFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -PROJECT_SOURCE_FILES ?= \ - wave_collector.c \ - screens/screen_logo.c \ - screens/screen_title.c \ - screens/screen_gameplay.c \ - screens/screen_ending.c - -# Define all object files from source files -OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES)) - -# For Android platform we call a custom Makefile.Android -ifeq ($(PLATFORM),PLATFORM_ANDROID) - MAKEFILE_PARAMS = -f Makefile.Android - export PROJECT_NAME - export PROJECT_SOURCE_FILES -else - MAKEFILE_PARAMS = $(PROJECT_NAME) -endif - -# Default target entry -# NOTE: We call this Makefile target or Makefile.Android target -all: - $(MAKE) $(MAKEFILE_PARAMS) - -# Project target defined by PROJECT_NAME -$(PROJECT_NAME): $(OBJS) - $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) - -# Compile source files -# NOTE: This pattern will compile every module defined on $(OBJS) -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/wave_collector/Makefile.Android b/games/wave_collector/Makefile.Android deleted file mode 100644 index 29d437b1b..000000000 --- a/games/wave_collector/Makefile.Android +++ /dev/null @@ -1,300 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Android project (APK building) -# -# Copyright (c) 2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -# Define required raylib variables -PLATFORM ?= PLATFORM_ANDROID -RAYLIB_PATH ?= ..\.. - -# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version -ANDROID_ARCH ?= ARM -ANDROID_API_VERSION = 21 -ifeq ($(ANDROID_ARCH),ARM) - ANDROID_ARCH_NAME = armeabi-v7a -endif -ifeq ($(ANDROID_ARCH),ARM64) - ANDROID_ARCH_NAME = arm64-v8a -endif - -# Required path variables -# NOTE: JAVA_HOME must be set to JDK -JAVA_HOME ?= C:/JavaJDK -ANDROID_HOME = C:/android-sdk -ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION) -ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1 -ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools - -# Android project configuration variables -PROJECT_NAME ?= raylib_game -PROJECT_LIBRARY_NAME ?= main -PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME) -PROJECT_RESOURCES_PATH ?= resources -PROJECT_SOURCE_FILES ?= raylib_game.c - -# Some source files are placed in directories, when compiling to some -# output directory other than source, that directory must pre-exist. -# Here we get a list of required folders that need to be created on -# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors. -PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES))) - -# Android app configuration variables -APP_LABEL_NAME ?= rGame -APP_COMPANY_NAME ?= raylib -APP_PRODUCT_NAME ?= rgame -APP_VERSION_CODE ?= 1 -APP_VERSION_NAME ?= 1.0 -APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png -APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png -APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png -APP_SCREEN_ORIENTATION ?= landscape -APP_KEYSTORE_PASS ?= raylib - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Library path for libraylib.a/libraylib.so -RAYLIB_LIB_PATH = $(RAYLIB_PATH)\src - -# Shared libs must be added to APK if required -# NOTE: Generated NativeLoader.java automatically load those libraries -ifeq ($(RAYLIB_LIBTYPE),SHARED) - PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so -endif - -# Compiler and archiver -# NOTE: GCC is being deprecated in Android NDK r16 -ifeq ($(ANDROID_ARCH),ARM) - CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang - AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar -endif -ifeq ($(ANDROID_ARCH),ARM64) - CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang - AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar -endif - -# Compiler flags for arquitecture -ifeq ($(ANDROID_ARCH),ARM) - CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -endif -ifeq ($(ANDROID_ARCH),ARM64) - CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769 -endif -# Compilation functions attributes options -CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC -# Compiler options for the linker -CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes -# Preprocessor macro definitions -CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) - -# Paths containing required header files -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue - -# Linker options -LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a -LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -# Force linking of library module to define symbol -LDFLAGS += -u ANativeActivity_onCreate -# Library paths containing required libs -LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME) -L$(ANDROID_TOOLCHAIN)\sysroot\usr\lib - -# Define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl - -# Generate target objects list from PROJECT_SOURCE_FILES -OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES)) - -# Android APK building process... some steps required... -# NOTE: typing 'make' will invoke the default target entry called 'all', -all: create_temp_project_dirs \ - copy_project_required_libs \ - copy_project_resources \ - generate_loader_script \ - generate_android_manifest \ - generate_apk_keystore \ - config_project_package \ - compile_project_code \ - compile_project_class \ - compile_project_class_dex \ - create_project_apk_package \ - sign_project_apk_package \ - zipalign_project_apk_package - -# Create required temp directories for APK building -create_temp_project_dirs: - if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj - if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src - if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) - if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) - if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib - if not exist $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) mkdir $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) - if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin - if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res - if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi - if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi - if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values - if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets - if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) - if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens - $(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir))) - -define create_dir - if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1) -endef - -# Copy required shared libs for integration into APK -# NOTE: If using shared libs they are loaded by generated NativeLoader.java -copy_project_required_libs: -ifeq ($(RAYLIB_LIBTYPE),SHARED) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so -endif -ifeq ($(RAYLIB_LIBTYPE),STATIC) - copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a -endif - -# Copy project required resources: strings.xml, icon.png, assets -# NOTE: Required strings.xml is generated and game resources are copied to assets folder -# TODO: Review xcopy usage, it can not be found in some systems! -copy_project_resources: - copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y - copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y - copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y - @echo ^ > $(PROJECT_BUILD_PATH)/res/values/strings.xml - @echo ^^$(APP_LABEL_NAME)^^ >> $(PROJECT_BUILD_PATH)/res/values/strings.xml - if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F - -# Generate NativeLoader.java to load required shared libraries -# NOTE: Probably not the bet way to generate this file... but it works. -generate_loader_script: - @echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -ifeq ($(RAYLIB_LIBTYPE),SHARED) - @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -endif - @echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - @echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Generate AndroidManifest.xml with all the required options -# NOTE: Probably not the bet way to generate this file... but it works. -generate_android_manifest: - @echo ^ > $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - @echo ^ >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml - -# Generate storekey for APK signing: $(PROJECT_NAME).keystore -# NOTE: Configure here your Distinguished Names (-dname) if required! -generate_apk_keystore: - if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA - -# Config project package and resource using AndroidManifest.xml and res/values/strings.xml -# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java -config_project_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar - -# Compile native_app_glue code as static library: obj/libnative_app_glue.a -compile_native_app_glue: - $(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS) - $(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o - -# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so -compile_project_code: $(OBJS) - $(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) - -# Compile all .c files required into object (.o) files -# NOTE: Those files will be linked into a shared library -$(PROJECT_BUILD_PATH)/obj/%.o:%.c - $(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot - -# Compile project .java code into .class (Java bytecode) -compile_project_class: - $(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java - -# Compile .class files into Dalvik executable bytecode (.dex) -# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT) -compile_project_class_dex: - $(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj - -# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk -# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so -# NOTE: Use -A resources to define additional directory in which to find raw asset files -create_project_apk_package: - $(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin - cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS) - -# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk -sign_project_apk_package: - $(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key - -# Create zip-aligned APK package: $(PROJECT_NAME).apk -zipalign_project_apk_package: - $(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk - -# Install $(PROJECT_NAME).apk to default emulator/device -# NOTE: Use -e (emulator) or -d (device) parameters if required -install: - $(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk - -# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64) -check_device_abi: - $(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi - -# Monitorize output log coming from device, only raylib tag -logcat: - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -# Install and monitorize $(PROJECT_NAME).apk to default emulator/device -deploy: - $(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk - $(ANDROID_PLATFORM_TOOLS)/adb logcat -c - $(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S - -#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W - -# Clean everything -clean: - del $(PROJECT_BUILD_PATH)\* /f /s /q - rmdir $(PROJECT_BUILD_PATH) /s /q - @echo Cleaning done diff --git a/games/wave_collector/resources/audio/pause.wav b/games/wave_collector/resources/audio/pause.wav deleted file mode 100644 index f35301eea..000000000 Binary files a/games/wave_collector/resources/audio/pause.wav and /dev/null differ diff --git a/games/wave_collector/resources/audio/sample_off.wav b/games/wave_collector/resources/audio/sample_off.wav deleted file mode 100644 index d2203e721..000000000 Binary files a/games/wave_collector/resources/audio/sample_off.wav and /dev/null differ diff --git a/games/wave_collector/resources/audio/sample_on.wav b/games/wave_collector/resources/audio/sample_on.wav deleted file mode 100644 index 38b7ca58d..000000000 Binary files a/games/wave_collector/resources/audio/sample_on.wav and /dev/null differ diff --git a/games/wave_collector/resources/audio/start.wav b/games/wave_collector/resources/audio/start.wav deleted file mode 100644 index 66ce7ac16..000000000 Binary files a/games/wave_collector/resources/audio/start.wav and /dev/null differ diff --git a/games/wave_collector/resources/audio/wave.ogg b/games/wave_collector/resources/audio/wave.ogg deleted file mode 100644 index a5b0dea4f..000000000 Binary files a/games/wave_collector/resources/audio/wave.ogg and /dev/null differ diff --git a/games/wave_collector/resources/font.fnt b/games/wave_collector/resources/font.fnt deleted file mode 100644 index 607e5a4d3..000000000 --- a/games/wave_collector/resources/font.fnt +++ /dev/null @@ -1,100 +0,0 @@ -info face=font size=57 bold=0 italic=0 charset= unicode= stretchH=100 smooth=1 aa=1 padding=2,2,2,2 spacing=0,0 outline=0 -common lineHeight=68 base=55 scaleW=512 scaleH=1024 pages=1 packed=0 -page id=0 file="font.png" -chars count=95 -char id=32 x=2 y=57 width=0 height=0 xoffset=0 yoffset=55 xadvance=29 page=0 chnl=15 -char id=33 x=4 y=5 width=16 height=61 xoffset=2 yoffset=4 xadvance=16 page=0 chnl=15 -char id=34 x=22 y=10 width=25 height=27 xoffset=0 yoffset=8 xadvance=23 page=0 chnl=15 -char id=35 x=49 y=26 width=41 height=27 xoffset=-3 yoffset=24 xadvance=34 page=0 chnl=15 -char id=36 x=92 y=26 width=41 height=27 xoffset=-3 yoffset=24 xadvance=34 page=0 chnl=15 -char id=37 x=135 y=13 width=34 height=49 xoffset=-1 yoffset=12 xadvance=30 page=0 chnl=15 -char id=38 x=171 y=16 width=51 height=46 xoffset=-1 yoffset=14 xadvance=47 page=0 chnl=15 -char id=39 x=224 y=10 width=16 height=27 xoffset=0 yoffset=9 xadvance=13 page=0 chnl=15 -char id=40 x=242 y=8 width=18 height=60 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15 -char id=41 x=262 y=8 width=18 height=60 xoffset=-1 yoffset=6 xadvance=15 page=0 chnl=15 -char id=42 x=282 y=11 width=29 height=32 xoffset=-1 yoffset=10 xadvance=25 page=0 chnl=15 -char id=43 x=313 y=25 width=29 height=29 xoffset=-2 yoffset=24 xadvance=24 page=0 chnl=15 -char id=44 x=344 y=45 width=16 height=29 xoffset=0 yoffset=44 xadvance=13 page=0 chnl=15 -char id=45 x=362 y=33 width=29 height=15 xoffset=1 yoffset=31 xadvance=28 page=0 chnl=15 -char id=46 x=393 y=45 width=16 height=17 xoffset=-1 yoffset=44 xadvance=13 page=0 chnl=15 -char id=47 x=411 y=6 width=37 height=61 xoffset=-3 yoffset=4 xadvance=30 page=0 chnl=15 -char id=48 x=450 y=14 width=43 height=49 xoffset=-1 yoffset=12 xadvance=39 page=0 chnl=15 -char id=49 x=2 y=91 width=22 height=49 xoffset=-1 yoffset=12 xadvance=19 page=0 chnl=15 -char id=50 x=26 y=91 width=42 height=49 xoffset=-1 yoffset=12 xadvance=39 page=0 chnl=15 -char id=51 x=70 y=91 width=41 height=48 xoffset=-2 yoffset=12 xadvance=35 page=0 chnl=15 -char id=52 x=113 y=91 width=40 height=48 xoffset=-2 yoffset=12 xadvance=35 page=0 chnl=15 -char id=53 x=155 y=91 width=35 height=49 xoffset=-1 yoffset=12 xadvance=31 page=0 chnl=15 -char id=54 x=192 y=91 width=48 height=48 xoffset=-2 yoffset=13 xadvance=43 page=0 chnl=15 -char id=55 x=242 y=91 width=38 height=49 xoffset=-2 yoffset=12 xadvance=33 page=0 chnl=15 -char id=56 x=282 y=91 width=49 height=49 xoffset=-2 yoffset=12 xadvance=43 page=0 chnl=15 -char id=57 x=333 y=91 width=46 height=49 xoffset=-2 yoffset=12 xadvance=41 page=0 chnl=15 -char id=58 x=381 y=102 width=16 height=37 xoffset=0 yoffset=24 xadvance=14 page=0 chnl=15 -char id=59 x=399 y=102 width=16 height=48 xoffset=0 yoffset=24 xadvance=15 page=0 chnl=15 -char id=60 x=417 y=98 width=41 height=42 xoffset=-2 yoffset=19 xadvance=37 page=0 chnl=15 -char id=61 x=460 y=104 width=29 height=30 xoffset=0 yoffset=25 xadvance=27 page=0 chnl=15 -char id=62 x=2 y=173 width=42 height=42 xoffset=-1 yoffset=19 xadvance=36 page=0 chnl=15 -char id=63 x=46 y=155 width=39 height=61 xoffset=0 yoffset=0 xadvance=35 page=0 chnl=15 -char id=64 x=87 y=167 width=58 height=53 xoffset=-1 yoffset=12 xadvance=54 page=0 chnl=15 -char id=65 x=147 y=169 width=47 height=47 xoffset=-2 yoffset=14 xadvance=41 page=0 chnl=15 -char id=66 x=196 y=169 width=47 height=46 xoffset=0 yoffset=14 xadvance=42 page=0 chnl=15 -char id=67 x=245 y=169 width=41 height=47 xoffset=-1 yoffset=14 xadvance=37 page=0 chnl=15 -char id=68 x=288 y=169 width=43 height=47 xoffset=0 yoffset=14 xadvance=39 page=0 chnl=15 -char id=69 x=333 y=169 width=43 height=46 xoffset=-2 yoffset=14 xadvance=39 page=0 chnl=15 -char id=70 x=378 y=169 width=40 height=46 xoffset=-2 yoffset=14 xadvance=35 page=0 chnl=15 -char id=71 x=420 y=169 width=41 height=46 xoffset=-2 yoffset=14 xadvance=37 page=0 chnl=15 -char id=72 x=463 y=167 width=43 height=48 xoffset=1 yoffset=12 xadvance=43 page=0 chnl=15 -char id=73 x=2 y=237 width=16 height=48 xoffset=1 yoffset=12 xadvance=15 page=0 chnl=15 -char id=74 x=20 y=239 width=25 height=46 xoffset=-2 yoffset=14 xadvance=21 page=0 chnl=15 -char id=75 x=47 y=238 width=45 height=49 xoffset=1 yoffset=14 xadvance=41 page=0 chnl=15 -char id=76 x=94 y=237 width=31 height=48 xoffset=1 yoffset=13 xadvance=28 page=0 chnl=15 -char id=77 x=127 y=239 width=51 height=46 xoffset=0 yoffset=14 xadvance=49 page=0 chnl=15 -char id=78 x=180 y=239 width=40 height=46 xoffset=0 yoffset=14 xadvance=39 page=0 chnl=15 -char id=79 x=222 y=239 width=51 height=46 xoffset=-2 yoffset=14 xadvance=45 page=0 chnl=15 -char id=80 x=275 y=239 width=44 height=46 xoffset=0 yoffset=14 xadvance=40 page=0 chnl=15 -char id=81 x=321 y=239 width=51 height=46 xoffset=-2 yoffset=14 xadvance=45 page=0 chnl=15 -char id=82 x=374 y=239 width=45 height=48 xoffset=0 yoffset=15 xadvance=41 page=0 chnl=15 -char id=83 x=421 y=238 width=34 height=48 xoffset=-2 yoffset=13 xadvance=28 page=0 chnl=15 -char id=84 x=457 y=239 width=41 height=47 xoffset=-2 yoffset=14 xadvance=36 page=0 chnl=15 -char id=85 x=2 y=306 width=46 height=46 xoffset=0 yoffset=15 xadvance=43 page=0 chnl=15 -char id=86 x=50 y=305 width=44 height=48 xoffset=-2 yoffset=13 xadvance=38 page=0 chnl=15 -char id=87 x=96 y=305 width=55 height=47 xoffset=-2 yoffset=13 xadvance=49 page=0 chnl=15 -char id=88 x=153 y=306 width=43 height=46 xoffset=-2 yoffset=14 xadvance=38 page=0 chnl=15 -char id=89 x=198 y=305 width=38 height=47 xoffset=-2 yoffset=13 xadvance=31 page=0 chnl=15 -char id=90 x=238 y=306 width=40 height=47 xoffset=-2 yoffset=14 xadvance=35 page=0 chnl=15 -char id=91 x=280 y=295 width=26 height=66 xoffset=1 yoffset=4 xadvance=24 page=0 chnl=15 -char id=92 x=308 y=293 width=37 height=61 xoffset=-4 yoffset=2 xadvance=29 page=0 chnl=15 -char id=93 x=347 y=295 width=26 height=66 xoffset=-2 yoffset=4 xadvance=22 page=0 chnl=15 -char id=94 x=375 y=294 width=28 height=17 xoffset=-1 yoffset=3 xadvance=24 page=0 chnl=15 -char id=95 x=405 y=346 width=49 height=15 xoffset=-1 yoffset=55 xadvance=45 page=0 chnl=15 -char id=96 x=456 y=295 width=20 height=17 xoffset=1 yoffset=3 xadvance=18 page=0 chnl=15 -char id=97 x=2 y=387 width=38 height=39 xoffset=-2 yoffset=22 xadvance=35 page=0 chnl=15 -char id=98 x=42 y=375 width=41 height=52 xoffset=1 yoffset=9 xadvance=38 page=0 chnl=15 -char id=99 x=85 y=387 width=38 height=39 xoffset=-2 yoffset=22 xadvance=34 page=0 chnl=15 -char id=100 x=125 y=375 width=41 height=52 xoffset=-2 yoffset=9 xadvance=38 page=0 chnl=15 -char id=101 x=168 y=387 width=38 height=39 xoffset=1 yoffset=22 xadvance=34 page=0 chnl=15 -char id=102 x=208 y=375 width=27 height=52 xoffset=1 yoffset=9 xadvance=23 page=0 chnl=15 -char id=103 x=237 y=387 width=41 height=52 xoffset=-2 yoffset=21 xadvance=38 page=0 chnl=15 -char id=104 x=280 y=375 width=37 height=51 xoffset=1 yoffset=9 xadvance=34 page=0 chnl=15 -char id=105 x=319 y=380 width=15 height=47 xoffset=2 yoffset=14 xadvance=16 page=0 chnl=15 -char id=106 x=336 y=378 width=25 height=60 xoffset=-6 yoffset=12 xadvance=18 page=0 chnl=15 -char id=107 x=363 y=375 width=40 height=51 xoffset=2 yoffset=9 xadvance=38 page=0 chnl=15 -char id=108 x=405 y=379 width=15 height=48 xoffset=1 yoffset=13 xadvance=16 page=0 chnl=15 -char id=109 x=422 y=387 width=47 height=39 xoffset=0 yoffset=22 xadvance=46 page=0 chnl=15 -char id=110 x=2 y=465 width=37 height=39 xoffset=0 yoffset=22 xadvance=34 page=0 chnl=15 -char id=111 x=41 y=465 width=41 height=40 xoffset=-1 yoffset=21 xadvance=37 page=0 chnl=15 -char id=112 x=84 y=465 width=41 height=52 xoffset=1 yoffset=22 xadvance=37 page=0 chnl=15 -char id=113 x=127 y=465 width=41 height=51 xoffset=-2 yoffset=22 xadvance=38 page=0 chnl=15 -char id=114 x=170 y=465 width=34 height=39 xoffset=1 yoffset=22 xadvance=30 page=0 chnl=15 -char id=115 x=206 y=462 width=37 height=42 xoffset=-2 yoffset=19 xadvance=31 page=0 chnl=15 -char id=116 x=245 y=453 width=36 height=52 xoffset=0 yoffset=9 xadvance=31 page=0 chnl=15 -char id=117 x=283 y=465 width=37 height=39 xoffset=0 yoffset=22 xadvance=35 page=0 chnl=15 -char id=118 x=322 y=463 width=35 height=41 xoffset=-2 yoffset=19 xadvance=28 page=0 chnl=15 -char id=119 x=359 y=463 width=51 height=41 xoffset=-2 yoffset=19 xadvance=44 page=0 chnl=15 -char id=120 x=412 y=465 width=35 height=40 xoffset=-2 yoffset=21 xadvance=29 page=0 chnl=15 -char id=121 x=449 y=465 width=37 height=52 xoffset=0 yoffset=22 xadvance=35 page=0 chnl=15 -char id=122 x=2 y=543 width=38 height=40 xoffset=-3 yoffset=21 xadvance=31 page=0 chnl=15 -char id=123 x=42 y=527 width=24 height=61 xoffset=-3 yoffset=5 xadvance=18 page=0 chnl=15 -char id=124 x=68 y=522 width=16 height=66 xoffset=1 yoffset=1 xadvance=15 page=0 chnl=15 -char id=125 x=86 y=527 width=24 height=61 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=15 -char id=126 x=112 y=526 width=32 height=16 xoffset=0 yoffset=4 xadvance=29 page=0 chnl=15 -char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=4 xadvance=29 page=0 chnl=15 \ No newline at end of file diff --git a/games/wave_collector/resources/font.png b/games/wave_collector/resources/font.png deleted file mode 100644 index 15287ccb3..000000000 Binary files a/games/wave_collector/resources/font.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/background.png b/games/wave_collector/resources/textures/background.png deleted file mode 100644 index b4f767f75..000000000 Binary files a/games/wave_collector/resources/textures/background.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/background_gameplay.png b/games/wave_collector/resources/textures/background_gameplay.png deleted file mode 100644 index 9be7d17de..000000000 Binary files a/games/wave_collector/resources/textures/background_gameplay.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/background_title.png b/games/wave_collector/resources/textures/background_title.png deleted file mode 100644 index 19546d863..000000000 Binary files a/games/wave_collector/resources/textures/background_title.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/icon_synchro.png b/games/wave_collector/resources/textures/icon_synchro.png deleted file mode 100644 index 841f826b7..000000000 Binary files a/games/wave_collector/resources/textures/icon_synchro.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/icon_warp.png b/games/wave_collector/resources/textures/icon_warp.png deleted file mode 100644 index e91f43d4a..000000000 Binary files a/games/wave_collector/resources/textures/icon_warp.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/logo_raylib.png b/games/wave_collector/resources/textures/logo_raylib.png deleted file mode 100644 index 99ba54374..000000000 Binary files a/games/wave_collector/resources/textures/logo_raylib.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/lose.png b/games/wave_collector/resources/textures/lose.png deleted file mode 100644 index ba69a4c28..000000000 Binary files a/games/wave_collector/resources/textures/lose.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/player.png b/games/wave_collector/resources/textures/player.png deleted file mode 100644 index 86b843b29..000000000 Binary files a/games/wave_collector/resources/textures/player.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/sample_big.png b/games/wave_collector/resources/textures/sample_big.png deleted file mode 100644 index 6fb20b638..000000000 Binary files a/games/wave_collector/resources/textures/sample_big.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/sample_mid.png b/games/wave_collector/resources/textures/sample_mid.png deleted file mode 100644 index 20ec58686..000000000 Binary files a/games/wave_collector/resources/textures/sample_mid.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/sample_small.png b/games/wave_collector/resources/textures/sample_small.png deleted file mode 100644 index 5fa7d01ba..000000000 Binary files a/games/wave_collector/resources/textures/sample_small.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/title.png b/games/wave_collector/resources/textures/title.png deleted file mode 100644 index 383dfdc3d..000000000 Binary files a/games/wave_collector/resources/textures/title.png and /dev/null differ diff --git a/games/wave_collector/resources/textures/win.png b/games/wave_collector/resources/textures/win.png deleted file mode 100644 index 7d539f66b..000000000 Binary files a/games/wave_collector/resources/textures/win.png and /dev/null differ diff --git a/games/wave_collector/screens/screen_ending.c b/games/wave_collector/screens/screen_ending.c deleted file mode 100644 index 7dc21965a..000000000 --- a/games/wave_collector/screens/screen_ending.c +++ /dev/null @@ -1,111 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Ending Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Ending screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D texBackground; -static Texture2D texWin; -static Texture2D texLose; -static Texture2D texLogo; - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Ending Screen Initialization logic -void InitEndingScreen(void) -{ - // TODO: Initialize ENDING screen variables here! - framesCounter = 0; - finishScreen = 0; - - texBackground = LoadTexture("resources/textures/background.png"); - texWin = LoadTexture("resources/textures/win.png"); - texLose = LoadTexture("resources/textures/lose.png"); - texLogo = LoadTexture("resources/textures/logo_raylib.png"); -} - -// Ending Screen Update logic -void UpdateEndingScreen(void) -{ - // TODO: Update ENDING screen variables here! - framesCounter++; - - // Press enter to return to TITLE screen - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - finishScreen = 1; - } -} - -// Ending Screen Draw logic -void DrawEndingScreen(void) -{ - DrawTexture(texBackground, 0, 0, WHITE); - - if (endingStatus == 1) // Win - { - DrawTexture(texWin, GetScreenWidth()/2 - texWin.width/2, 90, WHITE); - DrawTextEx(font, "congrats, you got the wave!", (Vector2){ 200, 335 }, font.baseSize, 0, WHITE); - } - else if (endingStatus == 2) // Lose - { - DrawTexture(texLose, GetScreenWidth()/2 - texWin.width/2, 90, WHITE); - DrawTextEx(font, "it seems you lose the wave...", (Vector2){ 205, 335 }, font.baseSize, 0, WHITE); - } - - DrawRectangle(0, GetScreenHeight() - 70, 560, 40, Fade(RAYWHITE, 0.8f)); - DrawText("(c) Developed by Ramon Santamaria (@raysan5)", 36, GetScreenHeight() - 60, 20, DARKBLUE); - - DrawText("powered by", GetScreenWidth() - 162, GetScreenHeight() - 190, 20, DARKGRAY); - DrawTexture(texLogo, GetScreenWidth() - 128 - 34, GetScreenHeight() - 128 - 36, WHITE); - - if ((framesCounter > 80) && ((framesCounter/40)%2)) DrawTextEx(font, "mouse click to return", (Vector2){ 300, 464 }, font.baseSize, 0, SKYBLUE); -} - -// Ending Screen Unload logic -void UnloadEndingScreen(void) -{ - // TODO: Unload ENDING screen variables here! - UnloadTexture(texBackground); - UnloadTexture(texWin); - UnloadTexture(texLose); - UnloadTexture(texLogo); -} - -// Ending Screen should finish? -int FinishEndingScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/wave_collector/screens/screen_gameplay.c b/games/wave_collector/screens/screen_gameplay.c deleted file mode 100644 index 1835c2229..000000000 --- a/games/wave_collector/screens/screen_gameplay.c +++ /dev/null @@ -1,496 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#include - -#include // Required for: malloc(), free() -#include // Required for: sqrtf(), asinf() - -#define MAX_SAMPLES_SPEED 7 // Max speed for samples movement -#define MIN_SAMPLES_SPEED 3 // Min speed for samples movement -#define SAMPLES_SPACING 100 // Separation between samples in pixels -#define SAMPLES_MULTIPLIER 700 // Defines sample data scaling value (it would be adjusted to MAX_GAME_HEIGHT) -#define MAX_GAME_HEIGHT 400 // Defines max possible amplitude between samples (game area) - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef struct Player { - Vector2 position; - Vector2 speed; - int width; - int height; - Color color; -} Player; - -typedef struct Sample { - Vector2 position; - float value; // Raw audio sample value (normalized) - int radius; - bool active; // Define if sample is active (can be collected) - bool collected; // Define if sample has been collected - bool renderable; // Define if sample should be rendered - Color color; -} Sample; - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Gameplay screen global variables -static int framesCounter; -static int finishScreen; -static bool pause; - -// Player variables -static Player player; -static Rectangle playerArea; // Define player movement area (and sample collection limits) - -static float warpCounter; // Time warp counter -static float synchro; // Calculates collected samples relation [0..1] - -static int combo; -static int maxCombo; - -static Rectangle waveRec; - -// Samples variables -static Sample *samples; // Game samples -static int totalSamples; // Total game samples (proportional to waveData num samples) -static int collectedSamples; // Samples collected by player -static int currentSample; // Last sample to go through player collect area -static float samplesSpeed; // All samples move at the same speed -static float waveTime; // Total sample time in ms - -// Resources variables -static Texture2D texBackground; -static Texture2D texPlayer; -static Texture2D texSampleSmall; -static Texture2D texSampleMid; -static Texture2D texSampleBig; - -static RenderTexture2D waveTarget; - -static Sound fxSampleOn; // Collected sample sound -static Sound fxSampleOff; // Miss sample sound -static Sound fxPause; // Pause sound -// Debug variables - -//------------------------------------------------------------------------------------ -// Module Functions Declaration (local) -//------------------------------------------------------------------------------------ -static void DrawSamplesMap(Sample *samples, int sampleCount, int playedSamples, Rectangle bounds, Color color); - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Gameplay Screen Initialization logic -void InitGameplayScreen(void) -{ - framesCounter = 0; - finishScreen = 0; - pause = false; - endingStatus = 0; - - // Textures loading - texBackground = LoadTexture("resources/textures/background_gameplay.png"); - texPlayer = LoadTexture("resources/textures/player.png"); - texSampleSmall = LoadTexture("resources/textures/sample_small.png"); - texSampleMid = LoadTexture("resources/textures/sample_mid.png"); - texSampleBig = LoadTexture("resources/textures/sample_big.png"); - - waveRec = (Rectangle){ 32, 32, 1280 - 64, 105 }; - waveTarget = LoadRenderTexture(waveRec.width, waveRec.height); - - // Sound loading - fxSampleOn = LoadSound("resources/audio/sample_on.wav"); - fxSampleOff = LoadSound("resources/audio/sample_off.wav"); - fxPause = LoadSound("resources/audio/pause.wav"); - - SetSoundVolume(fxSampleOn, 0.6f); - SetSoundVolume(fxPause, 0.5f); - - // Initialize player data - playerArea = (Rectangle){ 200, 160, 80, 400 }; - - player.width = 20; - player.height = 60; - player.speed = (Vector2){ 15, 15 }; - player.color = GOLD; - player.position = (Vector2){ playerArea.x + playerArea.width/2 - texPlayer.width/2, - playerArea.y + playerArea.height/2 - texPlayer.height/2 }; - - warpCounter = 395; - synchro = 0.2f; - - combo = 0; - maxCombo = 0; - - // Initialize wave and samples data - Wave wave = LoadWave("resources/audio/wave.ogg"); - float *waveData = GetWaveData(wave); // TODO: Be careful with channels! - - // We calculate the required parameters to adjust audio time to gameplay time - // that way samples collected correspond to audio playing - // Synchonization is not perfect due to possible rounding issues (float to int) - waveTime = wave.sampleCount/wave.sampleRate; // Total sample time in seconds - float requiredSamples = (MAX_SAMPLES_SPEED*waveTime*60 - 1000)/SAMPLES_SPACING; - int samplesDivision = (int)(wave.sampleCount/requiredSamples); - - totalSamples = wave.sampleCount/samplesDivision; - - // We don't need wave any more (already got waveData) - UnloadWave(wave); - - collectedSamples = 0; - - // Init samples - samples = (Sample *)malloc(totalSamples*sizeof(Sample)); - - // Normalize wave data (min vs max values) to scale properly - float minSampleValue = 0.0f; - float maxSampleValue = 0.0f; - - for (int i = 0; i < totalSamples; i++) - { - if (waveData[i*samplesDivision] < minSampleValue) minSampleValue = waveData[i*samplesDivision]; - if (waveData[i*samplesDivision] > maxSampleValue) maxSampleValue = waveData[i*samplesDivision]; - } - - float sampleScaleFactor = 1.0f/(maxSampleValue - minSampleValue); // 400 pixels maximum size - - // Initialize samples - for (int i = 0; i < totalSamples; i++) - { - samples[i].value = waveData[i*samplesDivision]*sampleScaleFactor; // Normalized value [-1.0..1.0] - samples[i].position.x = player.position.x + 1000 + i*SAMPLES_SPACING; - - samples[i].position.y = GetScreenHeight()/2 + samples[i].value*SAMPLES_MULTIPLIER; - - if (samples[i].position.y > GetScreenHeight()/2 + MAX_GAME_HEIGHT/2) samples[i].position.y = GetScreenHeight()/2 - MAX_GAME_HEIGHT/2; - else if (samples[i].position.y < GetScreenHeight()/2 - MAX_GAME_HEIGHT/2) samples[i].position.y = GetScreenHeight()/2 + MAX_GAME_HEIGHT/2; - - samples[i].radius = 6; - samples[i].active = true; - samples[i].collected = false; - samples[i].color = RED; - samples[i].renderable = false; - } - - samplesSpeed = MAX_SAMPLES_SPEED; - currentSample = 0; - - //FILE *samplesFile = fopen("resources/samples.data", "wb"); - //fwrite(samples, totalSamples*sizeof(Sample), 1, samplesFile); - //fclose(samplesFile); - - // We already saved the samples we needed for the game, we can free waveData - free(waveData); - - // Load and start playing music - // NOTE: Music is loaded in main code base - StopMusicStream(music); - PlayMusicStream(music); -} - -// Gameplay Screen Update logic -void UpdateGameplayScreen(void) -{ - if (IsKeyPressed('P')) - { - PlaySound(fxPause); - pause = !pause; - - if (pause) PauseMusicStream(music); - else ResumeMusicStream(music); - } - - if (!pause) - { - framesCounter++; // Time starts counting to awake enemies - - // Player movement logic (mouse) - player.position.y = GetMousePosition().y; - - // Player movement logic (keyboard) - if (IsKeyDown(KEY_W)) player.position.y -= player.speed.y; - else if (IsKeyDown(KEY_S)) player.position.y += player.speed.y; - - // Player movement logic (gamepad) - /* - if (IsGamepadAvailable(GAMEPAD_PLAYER1)) - { - Vector2 movement = { 0.0f }; - - movement.x = GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_LEFT_X); - movement.y = GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_LEFT_Y); - - player.position.x += movement.x*0.1f; // Scale gamepad movement value - player.position.y += movement.y*0.1f; // Scale gamepad movement value - } - */ - - // Player logic: check player area limits - if (player.position.x < playerArea.x) player.position.x = playerArea.x; - else if ((player.position.x + player.width) > (playerArea.x + playerArea.width)) player.position.x = playerArea.x + playerArea.width - player.width; - - if (player.position.y < playerArea.y) player.position.y = playerArea.y; - else if ((player.position.y + player.height) > (playerArea.y + playerArea.height)) player.position.y = playerArea.y + playerArea.height - player.height; - - // Samples logic - for (int i = 0; i < totalSamples; i++) - { - // Samples movement logic - samples[i].position.x -= samplesSpeed; - - if (((samples[i].position.x + samples[i].radius) > -SAMPLES_SPACING) && - ((samples[i].position.x - samples[i].radius) < GetScreenWidth())) samples[i].renderable = true; - else samples[i].renderable = false; - - // Samples catch logic - if (!samples[i].collected && CheckCollisionCircleRec(samples[i].position, samples[i].radius, (Rectangle){ (int)player.position.x, (int)player.position.y, player.width, player.height })) - { - samples[i].collected = true; - collectedSamples++; - synchro += 0.02; - - combo++; - if (combo > maxCombo) maxCombo = combo; - - if (synchro >= 1.0f) synchro = 1.0f; - - // Set sound pitch depending on sample position (base pitch: 1.0f) - // NOTE: waveData[i*WAVE_SAMPLES_DIV] is scaled to [0.3..1.7] - SetSoundPitch(fxSampleOn, samples[i].value*1.4f + 0.7f); - - PlaySound(fxSampleOn); - } - - if ((samples[i].position.x - samples[i].radius) < player.position.x) - { - currentSample = i; // Register last sample going out range - - if (samples[i].active) - { - samples[i].active = false; - - if (!samples[i].collected) - { - synchro -= 0.05f; - PlaySound(fxSampleOff); - combo = 0; - } - } - } - } - - if (IsKeyDown(KEY_SPACE) && (warpCounter > 0)) - { - warpCounter--; - if (warpCounter < 0) warpCounter = 0; - - samplesSpeed -= 0.1f; - if (samplesSpeed <= MIN_SAMPLES_SPEED) samplesSpeed = MIN_SAMPLES_SPEED; - - SetMusicPitch(music, samplesSpeed/MAX_SAMPLES_SPEED); - } - else - { - warpCounter++; - if (warpCounter > 395) warpCounter = 395; - - samplesSpeed += 0.1f; - if (samplesSpeed >= MAX_SAMPLES_SPEED) samplesSpeed = MAX_SAMPLES_SPEED; - - SetMusicPitch(music, samplesSpeed/MAX_SAMPLES_SPEED); - } - - // Check ending conditions - if (currentSample >= totalSamples - 1) - { - endingStatus = 1; // Win - finishScreen = 1; - } - - if (synchro <= 0.0f) - { - synchro = 0.0f; - endingStatus = 2; // Loose - finishScreen = 1; - } - } -} - -// Gameplay Screen Draw logic -void DrawGameplayScreen(void) -{ - // Draw background - DrawTexture(texBackground, 0, 0, WHITE); - - // Screen elements drawing - //DrawRectangleLines(playerArea.x, playerArea.y, playerArea.width, playerArea.height, BLUE); - DrawRectangle(0, GetScreenHeight()/2 - 1, GetScreenWidth(), 2, Fade(BLUE, 0.3f)); - //DrawRectangleLines(0, GetScreenHeight()/2 - MAX_GAME_HEIGHT/2, GetScreenWidth(), MAX_GAME_HEIGHT, GRAY); - - // Draw samples - for (int i = 0; i < totalSamples - 1; i++) - { - if (samples[i].renderable) - { - Color col = samples[i].color; - - if (i < (currentSample + 1)) col = Fade(DARKGRAY, 0.5f); - else col = WHITE; - - if (!samples[i].collected) - { - //DrawCircleV(samples[i].position, samples[i].radius, col); - - if (combo > 30) DrawTexture(texSampleSmall, samples[i].position.x - texSampleSmall.width/2, samples[i].position.y - texSampleSmall.height/2, col); - else if (combo > 15) DrawTexture(texSampleMid, samples[i].position.x - texSampleMid.width/2, samples[i].position.y - texSampleMid.height/2, col); - else DrawTexture(texSampleBig, samples[i].position.x - texSampleBig.width/2, samples[i].position.y - texSampleBig.height/2, col); - } - - if (i < (currentSample + 1)) col = Fade(GRAY, 0.3f); - else col = Fade(RED, 0.5f); - - // Draw line between samples - DrawLineEx(samples[i].position, samples[i + 1].position, 3.0f, col); - } - } - - // Draw player - //DrawRectangle((int)player.position.x, (int)player.position.y, player.width, player.height, player.color); - DrawTexture(texPlayer, player.position.x - 32, player.position.y - 24, WHITE); - - // Draw pause message - if (pause) DrawTextEx(font, "WAVE PAUSED", (Vector2){ 235, 400 }, font.baseSize*2, 0, WHITE); - - // Draw number of samples - //DrawText(FormatText("%05i", collectedSamples), 900, 200, 40, GRAY); - //DrawText(FormatText("%05i", totalSamples), 900, 250, 40, GRAY); - DrawTextEx(font, FormatText("%05i / %05i", collectedSamples, totalSamples), (Vector2){810, 170}, font.baseSize, -2, SKYBLUE); - - // Draw combo - DrawTextEx(font, FormatText("Combo: %02i [max: %02i]", combo, maxCombo), (Vector2){200, 170}, font.baseSize/2, -2, SKYBLUE); - - // Draw synchonicity level - DrawRectangle(99, 622, 395, 32, Fade(RAYWHITE, 0.8f)); - - if (synchro <= 0.3f) DrawRectangle(99, 622, synchro*395, 32, Fade(RED, 0.8f)); - else if (synchro <= 0.8f) DrawRectangle(99, 622, synchro*395, 32, Fade(ORANGE,0.8f)); - else if (synchro < 1.0f) DrawRectangle(99, 622, synchro*395, 32, Fade(LIME,0.8f)); - else DrawRectangle(99, 622, synchro*395, 32, Fade(GREEN, 0.9f)); - - DrawRectangleLines(99, 622, 395, 32, MAROON); - - if (synchro == 1.0f) DrawTextEx(font, FormatText("%02i%%", (int)(synchro*100)), (Vector2){99 + 390, 600}, font.baseSize, -2, GREEN); - else DrawTextEx(font, FormatText("%02i%%", (int)(synchro*100)), (Vector2){99 + 390, 600}, font.baseSize, -2, SKYBLUE); - - // Draw time warp coool-down bar - DrawRectangle(754, 622, 395, 32, Fade(RAYWHITE, 0.8f)); - DrawRectangle(754, 622, warpCounter, 32, Fade(SKYBLUE, 0.8f)); - DrawRectangleLines(754, 622, 395, 32, DARKGRAY); - //DrawText(FormatText("%02i%%", (int)(synchro*100)), 754 + 410, 628, 20, DARKGRAY); - DrawTextEx(font, FormatText("%02i%%", (int)((float)warpCounter/395.0f*100.0f)), (Vector2){754 + 390, 600}, font.baseSize, -2, SKYBLUE); - - // Draw wave - if (waveTarget.texture.id <= 0) // Render target could not be loaded (OpenGL 1.1) - { - // Draw wave directly on screen - DrawSamplesMap(samples, totalSamples, currentSample, waveRec, MAROON); - DrawRectangle(waveRec.x + (int)currentSample*1215/totalSamples, waveRec.y, 2, 99, DARKGRAY); - } - else - { - // Draw wave using render target - BeginTextureMode(waveTarget); - ClearBackground(BLANK); - DrawSamplesMap(samples, totalSamples, currentSample, (Rectangle){ 0, 0, waveTarget.texture.width, waveTarget.texture.height }, MAROON); - EndTextureMode(); - - // TODO: Apply antialiasing shader - - DrawTextureEx(waveTarget.texture, (Vector2){ waveRec.x, waveRec.y }, 0.0f, 1.0f, WHITE); - DrawRectangle(waveRec.x + (int)currentSample*1215/totalSamples, waveRec.y, 2, 99, DARKGRAY); - } -} - -// Gameplay Screen Unload logic -void UnloadGameplayScreen(void) -{ - StopMusicStream(music); - - // Unload textures - UnloadTexture(texBackground); - UnloadTexture(texPlayer); - UnloadTexture(texSampleSmall); - UnloadTexture(texSampleMid); - UnloadTexture(texSampleBig); - - UnloadRenderTexture(waveTarget); - - // Unload sounds - UnloadSound(fxSampleOn); - UnloadSound(fxSampleOff); - UnloadSound(fxPause); - - free(samples); // Unload game samples -} - -// Gameplay Screen should finish? -int FinishGameplayScreen(void) -{ - return finishScreen; -} - -//------------------------------------------------------------------------------------ -// Module Functions Definitions (local) -//------------------------------------------------------------------------------------ - -// Draw samples in wave form (including already played samples in a different color!) -// NOTE: For proper visualization, MSAA x4 is recommended, alternatively -// it should be rendered to a bigger texture and then scaled down with -// bilinear/trilinear texture filtering -static void DrawSamplesMap(Sample *samples, int sampleCount, int playedSamples, Rectangle bounds, Color color) -{ - // NOTE: We just pick a sample to draw every increment - float sampleIncrementX = (float)bounds.width/sampleCount; - - Color col = color; - - for (int i = 0; i < sampleCount - 1; i++) - { - if (i < playedSamples) col = GRAY; - else col = color; - - DrawLineV((Vector2){ (float)bounds.x + (float)i*sampleIncrementX, (float)(bounds.y + bounds.height/2) + samples[i].value*bounds.height }, - (Vector2){ (float)bounds.x + (float)(i + 1)*sampleIncrementX, (float)(bounds.y + bounds.height/2) + + samples[i + 1].value*bounds.height }, col); - } -} \ No newline at end of file diff --git a/games/wave_collector/screens/screen_logo.c b/games/wave_collector/screens/screen_logo.c deleted file mode 100644 index 5f18a3210..000000000 --- a/games/wave_collector/screens/screen_logo.c +++ /dev/null @@ -1,181 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Logo Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -#define LOGO_RECS_SIDE 16 - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Logo screen global variables -static int framesCounter; -static int finishScreen; - -static int logoPositionX; -static int logoPositionY; - -static int lettersCount; - -static int topSideRecWidth; -static int leftSideRecHeight; - -static int bottomSideRecWidth; -static int rightSideRecHeight; - -static int state; // Tracking animation states (State Machine) -static float alpha = 1.0f; // Useful for fading - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Logo Screen Initialization logic -void InitLogoScreen(void) -{ - // Initialize LOGO screen variables here! - finishScreen = 0; - framesCounter = 0; - lettersCount = 0; - - logoPositionX = GetScreenWidth()/2 - 128; - logoPositionY = GetScreenHeight()/2 - 128; - - topSideRecWidth = LOGO_RECS_SIDE; - leftSideRecHeight = LOGO_RECS_SIDE; - bottomSideRecWidth = LOGO_RECS_SIDE; - rightSideRecHeight = LOGO_RECS_SIDE; - - state = 0; - alpha = 1.0f; -} - -// Logo Screen Update logic -void UpdateLogoScreen(void) -{ - // Update LOGO screen variables here! - if (state == 0) // State 0: Small box blinking - { - framesCounter++; - - if (framesCounter == 80) - { - state = 1; - framesCounter = 0; // Reset counter... will be used later... - - PlayMusicStream(music); // Start playing music... ;) - } - } - else if (state == 1) // State 1: Top and left bars growing - { - topSideRecWidth += 8; - leftSideRecHeight += 8; - - if (topSideRecWidth == 256) state = 2; - } - else if (state == 2) // State 2: Bottom and right bars growing - { - bottomSideRecWidth += 8; - rightSideRecHeight += 8; - - if (bottomSideRecWidth == 256) state = 3; - } - else if (state == 3) // State 3: Letters appearing (one by one) - { - framesCounter++; - - if (lettersCount < 10) - { - if (framesCounter/15) // Every 12 frames, one more letter! - { - lettersCount++; - framesCounter = 0; - } - } - else // When all letters have appeared, just fade out everything - { - if (framesCounter > 200) - { - alpha -= 0.02f; - - if (alpha <= 0.0f) - { - alpha = 0.0f; - finishScreen = 1; - } - } - } - } -} - -// Logo Screen Draw logic -void DrawLogoScreen(void) -{ - if (state == 0) - { - if ((framesCounter/10)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK); - } - else if (state == 1) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - } - else if (state == 2) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK); - } - else if (state == 3) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(SubText("raylib", 0, lettersCount), GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha)); - - if (framesCounter > 20) DrawText("powered by", logoPositionX, logoPositionY - 27, 20, Fade(DARKGRAY, alpha)); - } -} - -// Logo Screen Unload logic -void UnloadLogoScreen(void) -{ - // Unload LOGO screen variables here! -} - -// Logo Screen should finish? -int FinishLogoScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/wave_collector/screens/screen_title.c b/games/wave_collector/screens/screen_title.c deleted file mode 100644 index 5c414f4f3..000000000 --- a/games/wave_collector/screens/screen_title.c +++ /dev/null @@ -1,112 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Title Screen Functions Definitions (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#include "raylib.h" -#include "screens.h" - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- - -// Title screen global variables -static int framesCounter; -static int finishScreen; - -static Texture2D texBackground; -static Texture2D texTitle; -static Texture2D texLogo; - -static float titleAlpha = 0.0f; - -static Sound fxStart; - -//---------------------------------------------------------------------------------- -// Title Screen Functions Definition -//---------------------------------------------------------------------------------- - -// Title Screen Initialization logic -void InitTitleScreen(void) -{ - // Initialize TITLE screen variables here! - framesCounter = 0; - finishScreen = 0; - - texBackground = LoadTexture("resources/textures/background_title.png"); - texTitle = LoadTexture("resources/textures/title.png"); - texLogo = LoadTexture("resources/textures/logo_raylib.png"); - - fxStart = LoadSound("resources/audio/start.wav"); -} - -// Title Screen Update logic -void UpdateTitleScreen(void) -{ - // Update TITLE screen variables here! - framesCounter++; - - titleAlpha += 0.005f; - - if (titleAlpha >= 1.0f) titleAlpha = 1.0f; - - // Press enter to change to ATTIC screen - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - PlaySound(fxStart); - StopMusicStream(music); - finishScreen = 1; - } -} - -// Title Screen Draw logic -void DrawTitleScreen(void) -{ - DrawTexture(texBackground, 0, 0, WHITE); - DrawTexture(texTitle, GetScreenWidth()/2 - texTitle.width/2, -25, Fade(WHITE, titleAlpha)); - - DrawRectangle(0, GetScreenHeight() - 70, 560, 40, Fade(RAYWHITE, 0.8f)); - DrawText("(c) Developed by Ramon Santamaria (@raysan5)", 36, GetScreenHeight() - 60, 20, DARKBLUE); - - DrawText("powered by", GetScreenWidth() - 162, GetScreenHeight() - 190, 20, DARKGRAY); - DrawTexture(texLogo, GetScreenWidth() - 128 - 34, GetScreenHeight() - 128 - 36, WHITE); - - if ((framesCounter > 160) && ((framesCounter/40)%2)) DrawTextEx(font, "mouse click to start", (Vector2){ 325, 500 }, font.baseSize, 0, SKYBLUE); -} - -// Title Screen Unload logic -void UnloadTitleScreen(void) -{ - // Unload TITLE screen variables here! - UnloadTexture(texBackground); - UnloadTexture(texTitle); - UnloadTexture(texLogo); - - UnloadSound(fxStart); -} - -// Title Screen should finish? -int FinishTitleScreen(void) -{ - return finishScreen; -} \ No newline at end of file diff --git a/games/wave_collector/screens/screens.h b/games/wave_collector/screens/screens.h deleted file mode 100644 index 6e896d58b..000000000 --- a/games/wave_collector/screens/screens.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************************** -* -* raylib - Advance Game template -* -* Screens Functions Declarations (Init, Update, Draw, Unload) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#ifndef SCREENS_H -#define SCREENS_H - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- -typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -GameScreen currentScreen; -Font font; -Music music; -int endingStatus; // 1 - Win, 2 - Lose - -char *sampleFilename; // Required for custom music file - -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - -//---------------------------------------------------------------------------------- -// Logo Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitLogoScreen(void); -void UpdateLogoScreen(void); -void DrawLogoScreen(void); -void UnloadLogoScreen(void); -int FinishLogoScreen(void); - -//---------------------------------------------------------------------------------- -// Title Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitTitleScreen(void); -void UpdateTitleScreen(void); -void DrawTitleScreen(void); -void UnloadTitleScreen(void); -int FinishTitleScreen(void); - -//---------------------------------------------------------------------------------- -// Gameplay Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitGameplayScreen(void); -void UpdateGameplayScreen(void); -void DrawGameplayScreen(void); -void UnloadGameplayScreen(void); -int FinishGameplayScreen(void); - -//---------------------------------------------------------------------------------- -// Ending Screen Functions Declaration -//---------------------------------------------------------------------------------- -void InitEndingScreen(void); -void UpdateEndingScreen(void); -void DrawEndingScreen(void); -void UnloadEndingScreen(void); -int FinishEndingScreen(void); - -#ifdef __cplusplus -} -#endif - -#endif // SCREENS_H \ No newline at end of file diff --git a/games/wave_collector/wave_collector.c b/games/wave_collector/wave_collector.c deleted file mode 100644 index 64881816d..000000000 --- a/games/wave_collector/wave_collector.c +++ /dev/null @@ -1,308 +0,0 @@ -/******************************************************************************************* -* -* WAVE COLLECTOR [GLOBAL GAME JAM 2017] -* -* The ultimate wave particles collector is here! -* You must follow the wave and collect all the particles -* The level is actually the wave and the wave is the level! -* Be fast! Be smart! Be the best wave collector! -* -* This game has been created using raylib v1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2017 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include "screens/screens.h" // NOTE: Defines global variable: currentScreen - -#include - -#include // Required for: printf() -#include // Required for: strcpy() - -#if defined(PLATFORM_WEB) - #include -#endif - -//---------------------------------------------------------------------------------- -// Global Variables Definition (local to this module) -//---------------------------------------------------------------------------------- -const int screenWidth = 1280; -const int screenHeight = 720; - -// Required variables to manage screen transitions (fade-in, fade-out) -static float transAlpha = 0.0f; -static bool onTransition = false; -static bool transFadeOut = false; -static int transFromScreen = -1; -static int transToScreen = -1; - -// NOTE: Some global variables that require to be visible for all screens, -// are defined in screens.h (i.e. currentScreen) - -//---------------------------------------------------------------------------------- -// Local Functions Declaration -//---------------------------------------------------------------------------------- -static void ChangeToScreen(int screen); // No transition effect - -static void TransitionToScreen(int screen); -static void UpdateTransition(void); -static void DrawTransition(void); - -static void UpdateDrawFrame(void); // Update and Draw one frame - -//---------------------------------------------------------------------------------- -// Main entry point -//---------------------------------------------------------------------------------- -int main(int argc, char *argv[]) -{ - // Initialization - //--------------------------------------------------------- -#if defined(PLATFORM_DESKTOP) - // TODO: Support for dropped files on the exe - - // Support command line argument for custom music file - if (argc > 1) - { - // Just supporting an input argument parameter!!! o__O - - if ((IsFileExtension(argv[1], ".ogg")) || - (IsFileExtension(argv[1], ".wav"))) - { - if (sampleFilename != NULL) free(sampleFilename); - - sampleFilename = (char *)malloc(256); - strcpy(sampleFilename, argv[1]); - - printf("Custom audio file: %s", sampleFilename); - } - } -#endif - -#ifndef PLATFORM_ANDROID - SetConfigFlags(FLAG_MSAA_4X_HINT); -#endif - // Note windowTitle is unused on Android - InitWindow(screenWidth, screenHeight, "WAVE COLLECTOR [GGJ17]"); - - // Global data loading (assets that must be available in all screens, i.e. fonts) - InitAudioDevice(); - - font = LoadFont("resources/font.fnt"); - music = LoadMusicStream("resources/audio/wave.ogg"); - - SetMusicVolume(music, 1.0f); - - // Setup and Init first screen - currentScreen = LOGO; - InitLogoScreen(); - //InitTitleScreen(); - //InitGameplayScreen(); - //InitEndingScreen(); - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - UpdateDrawFrame(); - } -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - switch (currentScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Unload all global loaded data (i.e. fonts) here! - UnloadFont(font); - UnloadMusicStream(music); - - CloseAudioDevice(); // Close audio context - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//---------------------------------------------------------------------------------- -// Module specific Functions Definition -//---------------------------------------------------------------------------------- - -// Change to next screen, no transition -static void ChangeToScreen(int screen) -{ - // Unload current screen - switch (currentScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Init next screen - switch (screen) - { - case LOGO: InitLogoScreen(); break; - case TITLE: InitTitleScreen(); break; - case GAMEPLAY: InitGameplayScreen(); break; - case ENDING: InitEndingScreen(); break; - default: break; - } - - currentScreen = screen; -} - -// Define transition to next screen -static void TransitionToScreen(int screen) -{ - onTransition = true; - transFadeOut = false; - transFromScreen = currentScreen; - transToScreen = screen; - transAlpha = 0.0f; -} - -// Update transition effect -static void UpdateTransition(void) -{ - if (!transFadeOut) - { - transAlpha += 0.05f; - - // NOTE: Due to float internal representation, condition jumps on 1.0f instead of 1.05f - // For that reason we compare against 1.01f, to avoid last frame loading stop - if ((int)transAlpha >= 1) - { - transAlpha = 1.0f; - - // Unload current screen - switch (transFromScreen) - { - case LOGO: UnloadLogoScreen(); break; - case TITLE: UnloadTitleScreen(); break; - case GAMEPLAY: UnloadGameplayScreen(); break; - case ENDING: UnloadEndingScreen(); break; - default: break; - } - - // Load next screen - switch (transToScreen) - { - case LOGO: InitLogoScreen(); break; - case TITLE: InitTitleScreen(); break; - case GAMEPLAY: InitGameplayScreen(); break; - case ENDING: InitEndingScreen(); break; - default: break; - } - - currentScreen = transToScreen; - - // Activate fade out effect to next loaded screen - transFadeOut = true; - } - } - else // Transition fade out logic - { - transAlpha -= 0.05f; - - if ((int)transAlpha <= 0) - { - transAlpha = 0.0f; - transFadeOut = false; - onTransition = false; - transFromScreen = -1; - transToScreen = -1; - } - } -} - -// Draw transition effect (full-screen rectangle) -static void DrawTransition(void) -{ - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, transAlpha)); -} - -// Update and draw game frame -static void UpdateDrawFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - if (!onTransition) - { - switch(currentScreen) - { - case LOGO: - { - UpdateLogoScreen(); - - if (FinishLogoScreen()) TransitionToScreen(TITLE); - - } break; - case TITLE: - { - UpdateTitleScreen(); - - if (FinishTitleScreen() == 1) TransitionToScreen(GAMEPLAY); - - } break; - case GAMEPLAY: - { - UpdateGameplayScreen(); - - if (FinishGameplayScreen() == 1) TransitionToScreen(ENDING); - //else if (FinishGameplayScreen() == 2) TransitionToScreen(TITLE); - - } break; - case ENDING: - { - UpdateEndingScreen(); - - if (FinishEndingScreen() == 1) TransitionToScreen(TITLE); - - } break; - default: break; - } - } - else UpdateTransition(); // Update transition (fade-in, fade-out) - - // TODO: Review! It breaks the game... issues with audio buffering... - if (currentScreen != ENDING) UpdateMusicStream(music); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch(currentScreen) - { - case LOGO: DrawLogoScreen(); break; - case TITLE: DrawTitleScreen(); break; - case GAMEPLAY: DrawGameplayScreen(); break; - case ENDING: DrawEndingScreen(); break; - default: break; - } - - // Draw full screen rectangle in front of everything - if (onTransition) DrawTransition(); - - EndDrawing(); - //---------------------------------------------------------------------------------- -}