Compare commits

..

54 commits

Author SHA1 Message Date
f85084ca20 new screenshots 2022-11-25 13:24:12 -05:00
3a904903e7 more snappy screen transitions 2022-11-25 12:48:31 -05:00
f2d4ce2f35 changed feather colors 2022-11-25 12:38:24 -05:00
5eab405baf added wall defense mechanic 2022-11-21 19:07:06 -05:00
ce2b4dbb6e added new hurt sprite by Allan 2022-11-21 18:09:56 -05:00
f5c589ce31 dummy 2 2022-11-20 20:16:32 -05:00
4c57c40c2a dummy commit 2022-11-20 20:11:23 -05:00
716ff3d83c removed enemy & fixed html5 build 2022-11-20 19:56:02 -05:00
3363f82097 overhauled firering system 2022-11-18 20:21:28 -05:00
1fcbdf6d0a added sine fw movement, smaller player, rf incs by 5, and a to-do list 2022-10-30 19:53:58 -04:00
9b2eff2b58 changed the amount of shoots on screen from 3 to 5 2022-10-23 16:51:39 -04:00
b897b23b1b added new title music & agnostic struct array compare function 2022-10-17 18:21:21 -04:00
b9ba62c4c8 fixed unlock system & added firework death 2022-10-09 19:05:30 -04:00
bc9239174a working on a better unlock system 2022-10-02 15:58:18 -04:00
b4b53ddedd added stats to level select and better firework amounts 2022-09-25 12:25:31 -04:00
3537a6d37e level unlocking and title music 2022-09-20 19:28:31 -04:00
2a84b5ae3e win conditions for levels 1 and 2 2022-09-19 21:28:10 -04:00
5c1073e21e basic level select screen 2022-09-04 11:15:22 -04:00
bd7108936d fixed text bugs 2022-08-31 15:15:32 -04:00
334c890bb3 better feather spawns 2022-08-31 14:08:31 -04:00
d18195e075 fireworks now spawn offscreen 2022-08-29 16:42:35 -04:00
d957830a23 better enemy pattern 2022-08-27 14:08:36 -04:00
a890911082 feathers now glide from right to left 2022-08-26 12:24:33 -04:00
0ef2658ff7 change firework speed range per level 2022-08-25 10:59:52 -04:00
293ed493b7 adding frame independence 2022-08-22 15:16:28 -04:00
fdc7a61f61 added fonts and music 2022-08-07 16:24:55 -04:00
afd288d573 adding fonts 2022-08-05 11:31:55 -04:00
685004ff7d cleaned timers 2022-08-02 09:38:36 -04:00
422b9f734e added ending screen 2022-07-28 12:02:47 -04:00
4b3c49bce2 added level system and enemy iframes 2022-07-26 19:12:36 -04:00
73874f90f8 adding level system 2022-07-25 15:21:52 -04:00
e3738c9b7f quick fix for the html5 build 2022-07-19 11:29:08 -04:00
502fa8a924 added options menu and fade-in 2022-07-19 11:04:05 -04:00
851a13ce0d enemy hurt sprite and shorter feather wait times 2022-07-15 12:59:37 -04:00
21915fc0df added attacks and the feather system 2022-07-08 16:00:38 -04:00
5635f5df55 added sound effects 2022-07-03 21:08:45 -04:00
2e55002c3c swaped hearts for feathers 2022-06-29 12:11:37 -04:00
5d45fea734 added iframes and better hitboxes 2022-06-26 19:43:39 -04:00
9588fc1417 mostly done with fireworks 2022-06-19 17:36:26 -04:00
968b06fbbc adding fireworks 2022-06-18 12:10:36 -04:00
b002fba1d3 overhauling the way the enemy works 2022-06-17 12:32:35 -04:00
e4b8831e8d added backgrounds 2022-06-16 22:17:26 -04:00
6672c7bb7d cleaner heart code and new date of build in the credits 2022-06-13 20:33:35 -04:00
2e3d37385b added health pickups and multiple source files 2022-06-12 13:49:42 -04:00
fb39864584 added gamepad support for Linux only 2022-06-11 16:10:58 -04:00
f6b4f20820 added debug mode 2022-05-30 12:16:22 -04:00
d40c51a4db added dash mechanic 2022-05-29 12:02:30 -04:00
f178ca3ae1 cleaned unnecessary gameReset calls & cleaned up some text 2022-05-23 20:19:55 -04:00
920c7c5a07 added FPS cap to the HTML5 version 2022-05-18 20:31:20 -04:00
794d00a4d7 added TITLE option on the gameover screen 2022-05-17 19:03:22 -04:00
26c96e3274 changed SOURCE CODE to MORE GAMES & fixed the dumb html5 scrolling bug 2022-05-15 13:05:38 -04:00
de4a89e231 cleaned gameReset function and added a hitbox toggle 2022-05-14 15:53:25 -04:00
523650660b added high scores 2022-05-03 20:17:40 -04:00
d6ecb4aff0 added a dedicated reset function to avoid memleaks 2022-04-30 12:06:03 -04:00
53 changed files with 11103 additions and 502 deletions

449
Makefile
View file

@ -1,8 +1,445 @@
clang :
clang src/Main.c -std=c99 -Wall -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -o Avoid
#**************************************************************************************************
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
# Copyright (c) 2013-2022 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.
#
#**************************************************************************************************
tcc :
tcc src/Main.c -std=c99 -Wall -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -o Avoid
.PHONY: all clean
gcc :
gcc src/Main.c -std=c99 -Wall -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -o Avoid
# Define required environment variables
#------------------------------------------------------------------------------------------------
# Define target platform: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB
PLATFORM ?= PLATFORM_DESKTOP
# Define project variables
PROJECT_NAME ?= Avoid
PROJECT_VERSION ?= 1.0
PROJECT_BUILD_PATH ?= .
RAYLIB_PATH ?= ~/raylib
# Locations of raylib.h and libraylib.a/libraylib.so
# NOTE: Those variables are only used for PLATFORM_OS: LINUX, BSD
RAYLIB_INCLUDE_PATH ?= /usr/local/include
RAYLIB_LIB_PATH ?= /usr/local/lib
# Library type compilation: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
# Build mode for project: DEBUG or RELEASE
BUILD_MODE ?= DEBUG
# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
# NOTE: This variable is only used for PLATFORM_OS: LINUX
USE_WAYLAND_DISPLAY ?= FALSE
# PLATFORM_WEB: Default properties
BUILD_WEB_ASYNCIFY ?= FALSE
BUILD_WEB_SHELL ?= html5/shell.html
BUILD_WEB_HEAP_SIZE ?= 134217728
BUILD_WEB_RESOURCES ?= TRUE
BUILD_WEB_RESOURCES_PATH ?= assets
# Use cross-compiler for PLATFORM_RPI
ifeq ($(PLATFORM),PLATFORM_RPI)
USE_RPI_CROSS_COMPILER ?= FALSE
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry
RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot
endif
endif
# 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
ifeq ($(PLATFORM),PLATFORM_DRM)
UNAMEOS = $(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS = LINUX
endif
endif
# RAYLIB_PATH adjustment for LINUX platform
# TODO: Do we really need this?
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_PREFIX ?= ..
RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
endif
endif
# Default path for raylib on Raspberry Pi
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
ifeq ($(PLATFORM),PLATFORM_DRM)
RAYLIB_PATH ?= /home/pi/raylib
endif
# Define raylib release directory for compiled library
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH ?= ~/emsdk
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
CLANG_PATH = $(EMSDK_PATH)/upstream/bin
PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit
NODE_PATH = $(EMSDK_PATH)/node/14.18.2_64bit/bin
export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH)
endif
# Define default C compiler: CC
#------------------------------------------------------------------------------------------------
CC = clang
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: MAKE
#------------------------------------------------------------------------------------------------
MAKE ?= make
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
MAKE = mingw32-make
endif
endif
ifeq ($(PLATFORM),PLATFORM_ANDROID)
MAKE = mingw32-make
endif
# Define compiler flags: CFLAGS
#------------------------------------------------------------------------------------------------
# -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)
# -Wno-unused-value ignore unused return values of some functions (i.e. fread())
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS = -std=c99 -Wall -Wno-missing-braces -Wunused-result -D_DEFAULT_SOURCE
ifeq ($(BUILD_MODE),DEBUG)
CFLAGS += -g -D_DEBUG
else
ifeq ($(PLATFORM),PLATFORM_WEB)
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
CFLAGS += -O3
else
CFLAGS += -Os
endif
else
CFLAGS += -s -O2
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,$(RAYLIB_RELEASE_PATH)
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS += -std=gnu99
endif
ifeq ($(PLATFORM),PLATFORM_DRM)
CFLAGS += -std=gnu99 -DEGL_NO_X11
endif
# Define include paths for required headers: INCLUDE_PATHS
# NOTE: Some external/extras libraries could be required (stb, physac, easings...)
#------------------------------------------------------------------------------------------------
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras
# Define additional directories containing required header files
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),BSD)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
endif
ifeq ($(PLATFORM_OS),LINUX)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vmcs_host/linux
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vcos/pthreads
endif
ifeq ($(PLATFORM),PLATFORM_DRM)
INCLUDE_PATHS += -I/usr/include/libdrm
endif
# Define library paths containing required libs: LDFLAGS
#------------------------------------------------------------------------------------------------
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# NOTE: The resource .rc 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),LINUX)
LDFLAGS += -L$(RAYLIB_LIB_PATH)
endif
ifeq ($(PLATFORM_OS),BSD)
LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
endif
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) (67108864 = 64MB)
# -s USE_PTHREADS=1 # multithreading support
# -s WASM=0 # disable Web Assembly, emitted by default
# -s ASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
# -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
# --source-map-base # allow debugging in browser with source map
LDFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -s FORCE_FILESYSTEM=1
# Build using asyncify
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
LDFLAGS += -s ASYNCIFY
endif
# Add resources building if required
ifeq ($(BUILD_WEB_RESOURCES),TRUE)
LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH)
endif
# Add debug mode flags if required
ifeq ($(BUILD_MODE),DEBUG)
LDFLAGS += -s ASSERTIONS=1 --profiling
endif
PROJECT_NAME ?= index
# Define a custom shell .html and output extension
LDFLAGS += --shell-file $(BUILD_WEB_SHELL)
EXT = .html
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib
endif
# Define libraries required on linking: LDLIBS
# NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
#------------------------------------------------------------------------------------------------
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
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
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
LDLIBS += -lvchiq_arm -lvcos
endif
endif
ifeq ($(PLATFORM),PLATFORM_DRM)
# Libraries for DRM compiling
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.a
endif
# Define source code object files required
#------------------------------------------------------------------------------------------------
PROJECT_SOURCE_PATH = src
PROJECT_SOURCE_FILES ?= \
$(PROJECT_SOURCE_PATH)/Main.c \
$(PROJECT_SOURCE_PATH)/Gameplay.c \
$(PROJECT_SOURCE_PATH)/Title.c \
$(PROJECT_SOURCE_PATH)/Credits.c \
$(PROJECT_SOURCE_PATH)/Gameover.c \
$(PROJECT_SOURCE_PATH)/Options.c \
$(PROJECT_SOURCE_PATH)/Ending.c \
$(PROJECT_SOURCE_PATH)/LevelSel.c \
$(PROJECT_SOURCE_PATH)/Gutils.c
# Define all object files from source files
OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
# Define processes to execute
#------------------------------------------------------------------------------------------------
# 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 -delete
rm -fv $(PROJECT_SOURCE_PATH)/*.o
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_DRM)
find . -type f -executable -delete
rm -fv *.o
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
del *.o *.html *.js
endif
@echo Cleaning done

445
Makefile.emscripten Normal file
View file

@ -0,0 +1,445 @@
#**************************************************************************************************
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
# Copyright (c) 2013-2022 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 environment variables
#------------------------------------------------------------------------------------------------
# Define target platform: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB
PLATFORM ?= PLATFORM_WEB
# Define project variables
PROJECT_NAME ?= index
PROJECT_VERSION ?= 1.0
PROJECT_BUILD_PATH ?= .
RAYLIB_PATH ?= ~/raylib
# Locations of raylib.h and libraylib.a/libraylib.so
# NOTE: Those variables are only used for PLATFORM_OS: LINUX, BSD
RAYLIB_INCLUDE_PATH ?= /usr/local/include
RAYLIB_LIB_PATH ?= /usr/local/lib
# Library type compilation: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
# Build mode for project: DEBUG or RELEASE
BUILD_MODE ?= RELEASE
# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
# NOTE: This variable is only used for PLATFORM_OS: LINUX
USE_WAYLAND_DISPLAY ?= FALSE
# PLATFORM_WEB: Default properties
BUILD_WEB_ASYNCIFY ?= FALSE
BUILD_WEB_SHELL ?= html5/shell.html
BUILD_WEB_HEAP_SIZE ?= 134217728
BUILD_WEB_RESOURCES ?= TRUE
BUILD_WEB_RESOURCES_PATH ?= assets
# Use cross-compiler for PLATFORM_RPI
ifeq ($(PLATFORM),PLATFORM_RPI)
USE_RPI_CROSS_COMPILER ?= FALSE
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry
RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot
endif
endif
# 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
ifeq ($(PLATFORM),PLATFORM_DRM)
UNAMEOS = $(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS = LINUX
endif
endif
# RAYLIB_PATH adjustment for LINUX platform
# TODO: Do we really need this?
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_PREFIX ?= ..
RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
endif
endif
# Default path for raylib on Raspberry Pi
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
ifeq ($(PLATFORM),PLATFORM_DRM)
RAYLIB_PATH ?= /home/pi/raylib
endif
# Define raylib release directory for compiled library
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH ?= ~/emsdk
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
CLANG_PATH = $(EMSDK_PATH)/upstream/bin
PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit
NODE_PATH = $(EMSDK_PATH)/node/14.18.2_64bit/bin
export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH)
endif
# Define default C compiler: CC
#------------------------------------------------------------------------------------------------
CC = clang
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: MAKE
#------------------------------------------------------------------------------------------------
MAKE ?= make
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
MAKE = mingw32-make
endif
endif
ifeq ($(PLATFORM),PLATFORM_ANDROID)
MAKE = mingw32-make
endif
# Define compiler flags: CFLAGS
#------------------------------------------------------------------------------------------------
# -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)
# -Wno-unused-value ignore unused return values of some functions (i.e. fread())
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS = -std=c99 -Wall -Wno-missing-braces -Wunused-result -D_DEFAULT_SOURCE
ifeq ($(BUILD_MODE),DEBUG)
CFLAGS += -g -D_DEBUG
else
ifeq ($(PLATFORM),PLATFORM_WEB)
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
CFLAGS += -O3
else
CFLAGS += -Os
endif
else
CFLAGS += -s -O2
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,$(RAYLIB_RELEASE_PATH)
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS += -std=gnu99
endif
ifeq ($(PLATFORM),PLATFORM_DRM)
CFLAGS += -std=gnu99 -DEGL_NO_X11
endif
# Define include paths for required headers: INCLUDE_PATHS
# NOTE: Some external/extras libraries could be required (stb, physac, easings...)
#------------------------------------------------------------------------------------------------
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras
# Define additional directories containing required header files
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),BSD)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
endif
ifeq ($(PLATFORM_OS),LINUX)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vmcs_host/linux
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vcos/pthreads
endif
ifeq ($(PLATFORM),PLATFORM_DRM)
INCLUDE_PATHS += -I/usr/include/libdrm
endif
# Define library paths containing required libs: LDFLAGS
#------------------------------------------------------------------------------------------------
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# NOTE: The resource .rc 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),LINUX)
LDFLAGS += -L$(RAYLIB_LIB_PATH)
endif
ifeq ($(PLATFORM_OS),BSD)
LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
endif
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) (67108864 = 64MB)
# -s USE_PTHREADS=1 # multithreading support
# -s WASM=0 # disable Web Assembly, emitted by default
# -s ASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
# -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
# --source-map-base # allow debugging in browser with source map
LDFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -s FORCE_FILESYSTEM=1
# Build using asyncify
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
LDFLAGS += -s ASYNCIFY
endif
# Add resources building if required
ifeq ($(BUILD_WEB_RESOURCES),TRUE)
LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH)
endif
# Add debug mode flags if required
ifeq ($(BUILD_MODE),DEBUG)
LDFLAGS += -s ASSERTIONS=1 --profiling
endif
PROJECT_NAME ?= index
# Define a custom shell .html and output extension
LDFLAGS += --shell-file $(BUILD_WEB_SHELL)
EXT = .html
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib
endif
# Define libraries required on linking: LDLIBS
# NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
#------------------------------------------------------------------------------------------------
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
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
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
LDLIBS += -lvchiq_arm -lvcos
endif
endif
ifeq ($(PLATFORM),PLATFORM_DRM)
# Libraries for DRM compiling
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.a
endif
# Define source code object files required
#------------------------------------------------------------------------------------------------
PROJECT_SOURCE_PATH = src
PROJECT_SOURCE_FILES ?= \
$(PROJECT_SOURCE_PATH)/Main.c \
$(PROJECT_SOURCE_PATH)/Gameplay.c \
$(PROJECT_SOURCE_PATH)/Title.c \
$(PROJECT_SOURCE_PATH)/Credits.c \
$(PROJECT_SOURCE_PATH)/Gameover.c \
$(PROJECT_SOURCE_PATH)/Options.c \
$(PROJECT_SOURCE_PATH)/Ending.c \
$(PROJECT_SOURCE_PATH)/LevelSel.c \
$(PROJECT_SOURCE_PATH)/Gutils.c
# Define all object files from source files
OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
# Define processes to execute
#------------------------------------------------------------------------------------------------
# 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 -delete
rm -fv $(PROJECT_SOURCE_PATH)/*.o
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_DRM)
find . -type f -executable -delete
rm -fv *.o
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
del *.o *.html *.js
endif
@echo Cleaning done

View file

@ -1,9 +1,7 @@
# Avoid
A dumb raylib test which you can play [here](https://canneddonuts.itch.io/avoid-the-game)
## To-do
- build guide/better Makefile
- fix the dumb bug when the ball gets stuck
## Preview
![Alt Text](./doc-assets/preview.gif)
![Alt Text](./doc-assets/preview.png)
![Alt Text](./doc-assets/preview1.png)
![Alt Text](./doc-assets/preview2.png)

17
TO_DO.md Normal file
View file

@ -0,0 +1,17 @@
# TO-DO
## Building
- build guide
## Gameplay
- cleaner hitboxes
- better patterns
- more levels
- more feather powers
- animations
## Art
- better art duh
## Music
- better gameplay music

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,884 @@
{
"format": "BeepBox",
"version": 9,
"scale": "normal :)",
"key": "F",
"introBars": 0,
"loopBars": 6,
"beatsPerBar": 8,
"ticksPerBeat": 4,
"beatsPerMinute": 120,
"layeredInstruments": false,
"patternInstruments": false,
"channels": [
{
"type": "pitch",
"instruments": [
{
"type": "FM",
"volume": 80,
"eqFilter": [],
"preset": 256,
"effects": [
"chord type",
"note filter",
"reverb"
],
"chord": "strum",
"noteFilter": [
{
"type": "low-pass",
"cutoffHz": 6727.17,
"linearGain": 0.5
}
],
"reverb": 33,
"fadeInSeconds": 0,
"fadeOutTicks": 48,
"algorithm": "1←2←3←4",
"feedbackType": "3⟲",
"feedbackAmplitude": 6,
"operators": [
{
"frequency": "1×",
"amplitude": 15
},
{
"frequency": "1×",
"amplitude": 6
},
{
"frequency": "5×",
"amplitude": 2
},
{
"frequency": "7×",
"amplitude": 4
}
],
"envelopes": [
{
"target": "noteFilterAllFreqs",
"envelope": "twang 1"
},
{
"target": "feedbackAmplitude",
"envelope": "twang 1"
}
]
}
],
"patterns": [
{
"notes": [
{
"pitches": [
41,
29
],
"points": [
{
"tick": 0,
"pitchBend": 0,
"volume": 100
},
{
"tick": 2,
"pitchBend": 0,
"volume": 100
}
],
"continuesLastPattern": false
},
{
"pitches": [
40
],
"points": [
{
"tick": 2,
"pitchBend": 0,
"volume": 100
},
{
"tick": 3,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
41
],
"points": [
{
"tick": 3,
"pitchBend": 0,
"volume": 100
},
{
"tick": 4,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
43
],
"points": [
{
"tick": 4,
"pitchBend": 0,
"volume": 100
},
{
"tick": 5,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
45
],
"points": [
{
"tick": 5,
"pitchBend": 0,
"volume": 100
},
{
"tick": 6,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
43
],
"points": [
{
"tick": 6,
"pitchBend": 0,
"volume": 100
},
{
"tick": 7,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
41
],
"points": [
{
"tick": 7,
"pitchBend": 0,
"volume": 100
},
{
"tick": 8,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
40,
28
],
"points": [
{
"tick": 8,
"pitchBend": 0,
"volume": 100
},
{
"tick": 12,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38
],
"points": [
{
"tick": 12,
"pitchBend": 0,
"volume": 100
},
{
"tick": 13,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38
],
"points": [
{
"tick": 13,
"pitchBend": 0,
"volume": 100
},
{
"tick": 14,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
40,
28
],
"points": [
{
"tick": 14,
"pitchBend": 0,
"volume": 100
},
{
"tick": 16,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38,
26
],
"points": [
{
"tick": 16,
"pitchBend": 0,
"volume": 100
},
{
"tick": 20,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
36
],
"points": [
{
"tick": 20,
"pitchBend": 0,
"volume": 100
},
{
"tick": 21,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
36
],
"points": [
{
"tick": 21,
"pitchBend": 0,
"volume": 100
},
{
"tick": 22,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38
],
"points": [
{
"tick": 22,
"pitchBend": 0,
"volume": 100
},
{
"tick": 23,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38
],
"points": [
{
"tick": 23,
"pitchBend": 0,
"volume": 100
},
{
"tick": 24,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
40,
28
],
"points": [
{
"tick": 24,
"pitchBend": 0,
"volume": 100
},
{
"tick": 32,
"pitchBend": 0,
"volume": 100
}
]
}
]
},
{
"notes": [
{
"pitches": [
41,
29
],
"points": [
{
"tick": 0,
"pitchBend": 0,
"volume": 100
},
{
"tick": 2,
"pitchBend": 0,
"volume": 100
}
],
"continuesLastPattern": false
},
{
"pitches": [
40
],
"points": [
{
"tick": 2,
"pitchBend": 0,
"volume": 100
},
{
"tick": 3,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38
],
"points": [
{
"tick": 3,
"pitchBend": 0,
"volume": 100
},
{
"tick": 4,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
36
],
"points": [
{
"tick": 4,
"pitchBend": 0,
"volume": 100
},
{
"tick": 5,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
33
],
"points": [
{
"tick": 5,
"pitchBend": 0,
"volume": 100
},
{
"tick": 6,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
36
],
"points": [
{
"tick": 6,
"pitchBend": 0,
"volume": 100
},
{
"tick": 7,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38
],
"points": [
{
"tick": 7,
"pitchBend": 0,
"volume": 100
},
{
"tick": 8,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
40,
28
],
"points": [
{
"tick": 8,
"pitchBend": 0,
"volume": 100
},
{
"tick": 12,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
43
],
"points": [
{
"tick": 12,
"pitchBend": 0,
"volume": 100
},
{
"tick": 13,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
43
],
"points": [
{
"tick": 13,
"pitchBend": 0,
"volume": 100
},
{
"tick": 14,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
40,
28
],
"points": [
{
"tick": 14,
"pitchBend": 0,
"volume": 100
},
{
"tick": 16,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38,
26
],
"points": [
{
"tick": 16,
"pitchBend": 0,
"volume": 100
},
{
"tick": 20,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
35
],
"points": [
{
"tick": 20,
"pitchBend": 0,
"volume": 100
},
{
"tick": 21,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
35
],
"points": [
{
"tick": 21,
"pitchBend": 0,
"volume": 100
},
{
"tick": 22,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38
],
"points": [
{
"tick": 22,
"pitchBend": 0,
"volume": 100
},
{
"tick": 23,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38
],
"points": [
{
"tick": 23,
"pitchBend": 0,
"volume": 100
},
{
"tick": 24,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
36,
24
],
"points": [
{
"tick": 24,
"pitchBend": 0,
"volume": 100
},
{
"tick": 32,
"pitchBend": 0,
"volume": 100
}
]
}
]
},
{
"notes": [
{
"pitches": [
41,
29
],
"points": [
{
"tick": 0,
"pitchBend": 0,
"volume": 100
},
{
"tick": 2,
"pitchBend": 0,
"volume": 100
}
],
"continuesLastPattern": false
},
{
"pitches": [
40,
28
],
"points": [
{
"tick": 8,
"pitchBend": 0,
"volume": 100
},
{
"tick": 12,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
40,
28
],
"points": [
{
"tick": 14,
"pitchBend": 0,
"volume": 100
},
{
"tick": 16,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38,
26
],
"points": [
{
"tick": 16,
"pitchBend": 0,
"volume": 100
},
{
"tick": 20,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
40,
28
],
"points": [
{
"tick": 24,
"pitchBend": 0,
"volume": 100
},
{
"tick": 32,
"pitchBend": 0,
"volume": 100
}
]
}
]
},
{
"notes": [
{
"pitches": [
41,
29
],
"points": [
{
"tick": 0,
"pitchBend": 0,
"volume": 100
},
{
"tick": 2,
"pitchBend": 0,
"volume": 100
}
],
"continuesLastPattern": false
},
{
"pitches": [
40,
28
],
"points": [
{
"tick": 8,
"pitchBend": 0,
"volume": 100
},
{
"tick": 12,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
40,
28
],
"points": [
{
"tick": 14,
"pitchBend": 0,
"volume": 100
},
{
"tick": 16,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
38,
26
],
"points": [
{
"tick": 16,
"pitchBend": 0,
"volume": 100
},
{
"tick": 20,
"pitchBend": 0,
"volume": 100
}
]
},
{
"pitches": [
36,
24
],
"points": [
{
"tick": 24,
"pitchBend": 0,
"volume": 100
},
{
"tick": 32,
"pitchBend": 0,
"volume": 100
}
]
}
]
},
{
"notes": []
},
{
"notes": []
},
{
"notes": []
},
{
"notes": []
}
],
"sequence": [
1,
2,
3,
2,
1,
4
],
"octaveScrollBar": 1
}
]
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
{"modelVersion":2,"piskel":{"name":"attack","description":"","fps":12,"height":10,"width":32,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":1,\"chunks\":[{\"layout\":[[0]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAKCAYAAADVTVykAAAAS0lEQVQ4jWNgIBP8/////9y5c/8jA1x8cu3AsJAYy4jhU2QxpZaTFDK0tBwGGFycnP7jwrS2fHA4YMCjYFAnQnwOoVs2xOcgavgUABeOG1DJQNZ1AAAAAElFTkSuQmCC\"}]}"],"hiddenFrames":[]}}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"modelVersion":2,"piskel":{"name":"cat","description":"","fps":12,"height":50,"width":50,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":2,\"chunks\":[{\"layout\":[[0],[1]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAyCAYAAACqNX6+AAABiklEQVR4nO3VS44CMQwE0Oy5/3WHWc0ItSDxp5wU7orkDR0S288NY7ysn8fjOYtxaDHlsnWtQHY3giWPY8sCsqMhp++nWR6QqqYwDATNmhT/H1XNYRgGumUBGWCYT3cJZCz/ROEo3jexCsT7dm4bDuPlpqZ57xkGbFaQMhTH5aGmIaBRDUAglKNUJFkVrHWiLJaJDucEB4sp/8liHxZzsp5m3R0EhtIdZBcGDKUzyG4MCIpAyFC6gpzESKF0BJnd8eme657XfbNnq3sEYgBZNRu1J/SmdAOxTr8lUN93oXQC8dxlbSTq+xAQtkDUEoFAnXErkEwTPRjZ824Bkm2eFyV7HhQkOlWZaewGMkVBgkSfZUAiDVx9vuu8diDRc5hCIIQhELIQCFkIhCxgING4O8g193Yg34bzLn+BEID85f21r/07EG8diIHKDtm1jjYgkToEIhCBWEEyezz7BCIQgQhEIOdDIGSxC6T6LIEIRCACIchPIA3raFPI6dwE0rSONoWczg0GonV+/QItl3L0EqklsAAAAABJRU5ErkJggg==\"}]}"],"hiddenFrames":[""]}}

View file

@ -0,0 +1 @@
{"modelVersion":2,"piskel":{"name":"feather","description":"","fps":12,"height":32,"width":14,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":1,\"chunks\":[{\"layout\":[[0]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAgCAYAAAAi7kmXAAAAc0lEQVQ4je2TSwrAIAxEPVvwmnPWdFUo08lHpNCFWQWZh28ExxDjNCpTQm0YwAsCkIPPoNpbmgCcb1/SbOmyGuu2NNUuYQ6ojlI30ix1IzU+Ox3/3TGDUyh6oG//Y1iwAjM4hbZABbege6aZT7M16ICb4AWUhhtQdcveMQAAAABJRU5ErkJggg==\"}]}"],"hiddenFrames":[""]}}

View file

@ -0,0 +1 @@
{"modelVersion":2,"piskel":{"name":"firework","description":"","fps":12,"height":10,"width":35,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":1,\"chunks\":[{\"layout\":[[0]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAKCAYAAAA+euenAAAAg0lEQVQ4jc3TMQrAIAwF0D90cewtehdHT95j9BS/gxhiUNEq1A8ZRDCPqMDm4d+AFD7OERG0ouYgCUOS58Uset3aIymY4MHgx2AC0ZgZEBARulIzu1Z9c4jFtAA9GAvQkOBjb95HNrluTC8IhTdTuzI9meqbmZlOCTOabX6TgFYc8iUv0pOYWiMhsUMAAAAASUVORK5CYII=\"}]}"],"hiddenFrames":[]}}

View file

@ -0,0 +1 @@
{"modelVersion":2,"piskel":{"name":"Health","description":"","fps":12,"height":32,"width":32,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":1,\"chunks\":[{\"layout\":[[0]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAZ0lEQVRYhe3OQQ4AIQgDQJ/g830qNz3rbhZEyDamTXqkTCkMwzDPdKXpOxiAVutrDQOn9+CAjyHvnQ4QETzAOqg9vhewWxcgsgQQYAGkQHYewwBCICePYQAuSORjGMAEMTQtvwPuygADDK9XgRU+4gAAAABJRU5ErkJggg==\"}]}"],"hiddenFrames":[""]}}

View file

@ -0,0 +1 @@
{"modelVersion":2,"piskel":{"name":"player","description":"","fps":12,"height":50,"width":50,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":3,\"chunks\":[{\"layout\":[[0],[1],[2]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAAAyCAYAAAC+jCIaAAAAAXNSR0IArs4c6QAABtxJREFUeF7tnDGvHEUMx+dEHkoauiA+AEJAQ0lHgaCgoECiSYUUEiG9z8FniISIIlHRRCJSSlCQ0qWkQ8AHQNBSRCTokO/ii+Ozx/asZ9/sZa+5d29nvTPj3/ztnZ3ZTVE+b9+4vP319uONdnz9/9oDtR4QwQGo3rrxuPx2+/Lu3BWwFaJoDxyBhVC98f6l8uejpzt7ANgKV7RrX+7yL4BFocJuAbhWsF5uSFpa7wJrVS1f1/61LdvXN6Wal3rK+K42dqlDJ0hqtaqW33kADJbW4PKU8V9x7JJusE5FtX4szwFA13xc6ioD5SSl4bbeO6C1t4yAUaA4DpbCjY2PXjsXWHD60hN5hOAj1hc/kd8aYFxpPLboZdDuaIp16eyVw1B4+uS/1KklN1gI1xITeQ0E6nwEjMJVU5qrATeAbbCLqjdKnkXBwr7IAiwE1lLh8oAFbdPUiwIWAYqC+/f2eWjUQutFhL1ecB2BBY2DOSztI00/QOIf7ZS558UALh4GtTpT9YLzIHcCoAAOL1hSWVQu6brXz8v2zi071/P0c9Qff3z3RDQ7Rb3E6YYaXDTXwtp88O1+IjXyeXjzGN6esEXAouqFUGHbEBj4ho8EGh6TjktwAVSffl7K/bultMJFYYr6486rsi6kgQUdUZt2wM5FuGrKFoEMy1LYsiGLgoVw1VSOw0WB4u1HAKHML5t9zgVlECr42wOWpkZRmDT/cMje/OJsVzTqj+qzQiskZoOFjf2m7KX5nZtXwg2qAR2FC0OiFUJ52NMUi5YD29+flwJKhZ8aWAhUFkDWwOeAXf93U2DgewGrggUX1+AB1eoBFkKFDc+EKwoWDYkWXNRRNFxKofLL833pCFRzAYXtkMCCY164xIfQYAAaYoW8bLg4VBSuFjnmo9J7d8jPA3XxgiWpF4cLwIpAhf6wVCbjuOYDtP1VOdvBZfnjKHmXRkY2QFoH8Ea9Vn7fFb1W3t19e0eLZJ9C5Q1x1E4ELq19WUql+SPDT5oPsE3oC8sfL0w3aHKbUWHPaLLAshpTu4YUBiOw0Dkur3rR+lCVglzqEHKUKQbIqaL+yPBTBKyaP3Zg1RrhASKrjAesVri0/CoCF1xbUjueT0g37whWL6igbhlgoS+5LyAEah8pkgwNFo3rtFHRkGjlVi1woWohVBQm+F8NLmyLdheoDfQaOJlQRYVCBGsUtYqOlAhcnrvBKFxYXwoR/q2BBefwPIvD1RICs9UqCpYURTajgQWVRBmOyq/WIV6w4Pxo/sTBAhue51s858IZ96WpFfY5H+hDgsUB+brYj4xq65o8YGn5kzV6pVBonYPKhVMOVLWWAJbHHytYjIKWqQiavHvUCiGmM+8IlwSWlT9Zxz2gR8qcDFif/Gwr1mcfyisDrMRd6lA6tdASHi0n0dUT/AF0FKy5oYK2efxx8orlDYMaDC0KVgNLWlAIcME5kGdxsCxwrOMW5C3HXYoFhkdM4GsNzr4jbOnclnMkqCQ71B8WONbxlnpGzxl+HsvboCWC5YWKD/RR566or1SwlqRaEaigXVNDoRf2aPiz7KJqjQ6W5g/XQ2irE+Y6vkSo8A7Qs8WM96MGl7XqZAR/VJfNzFVB6zqeZRqSjRHUagpYGEngG17Sgp8e6+AsH/DQB79ri/7UTUyjJPRRlaIdMAJY9x7sa+RZdlxz7tL8Ud0dN/dy2OiosEbZRYMFCfs/z8DKggvszL2aFK4ZjRqubZdTdoBYzpdgsmTWY7NlYtRj11sG7wIj69q9tpfgDxdY0OAfHpQtzG5Lu0RaRlDP7V+jQCXtxMlQriX4IwyWNKqiGyS5IiG03hFrlbuoEKjtpKZbvLDuU3OuWp+N4I8UsCxHW8d7gzV1WTGvP66punbruGXStAI+soHSfBMFtRDZrJrdZ7QeGbZPGiyuIBkhUltHZQ0ePC6pV4uKZThfq3OG7ZMHiytIS5ikgEpLXbxQSXB51sBL9jOcf+FgQSOgEtrSlGjH8vLZnURfiBYFiy+Zwbq2bomX+oYulWl5Z8MS/HFQLKwsAkR/94SK3uFMBRTPR7C0xyj8TXz8urXHL9F3LVhgYd7Fk/ml++MoFPIGZTm7Jru9wc1qA8+PWu/s+OK+2ttmluoPVbGynFHrmN6SntUGLfFuBQvs8fdh0cV+qOJ43cwUZC5/uJP3qU7iobVHp02to+f8jFDouU7vMr390R2suaW8p0OkUAjXi8w/9ayfx/Zc/ugOlqexSyiTNf+0hLZm1HEFy9GLPPzR/YDS3kCHyZMvsoJluJhDhdMD8I2Tmytcx524guXQDnrHJiXv/I7OYfLki6xgBV1MHyh3SNzhCcdJ+OR/2I1+kzo/vHkAAAAASUVORK5CYII=\"}]}"],"hiddenFrames":[""]}}

BIN
assets/bgm/02-Have-Hope.ogg Normal file

Binary file not shown.

BIN
assets/bgm/03-Boss.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
assets/fonts/ZadoBold.ttf Normal file

Binary file not shown.

BIN
assets/gfx/attack.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

BIN
assets/gfx/background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
assets/gfx/enemy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

BIN
assets/gfx/feather.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
assets/gfx/firework.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

BIN
assets/gfx/health.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 609 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

BIN
assets/sfx/boom.wav Normal file

Binary file not shown.

BIN
assets/sfx/feather.wav Normal file

Binary file not shown.

BIN
assets/sfx/hit.wav Normal file

Binary file not shown.

View file

@ -1,2 +0,0 @@
#!/bin/sh
emcc -o html5/index.html src/Main.c -Os -Wall /usr/local/lib/libraylib.a -I. -I/usr/local/include/raylib.h -L. -L/usr/local/lib/libraylib.a -s USE_GLFW=3 -DPLATFORM_WEB --preload-file assets/sfx/boing.wav --preload-file assets/gfx/player.png --shell-file html5/shell.html

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

BIN
doc-assets/preview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

BIN
doc-assets/preview1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

BIN
doc-assets/preview2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View file

@ -4,190 +4,36 @@
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Avoid: the game</title>
<title>Avoid</title>
<meta name="title" content="Avoid: the game">
<meta name="description" content="New HTML5 videogame, developed using raylib videogames library">
<meta name="title" content="Avoid">
<meta name="description" content="New raylib web videogame, developed using raylib videogames library">
<meta name="keywords" content="raylib, games, html5, programming, C, C++, library, learn, videogames">
<meta name="viewport" content="width=device-width">
<!-- Open Graph metatags for sharing -->
<meta property="og:title" content="Avoid: the game">
<meta property="og:title" content="Avoid">
<meta property="og:image:type" content="image/png">
<meta property="og:image" content="https://www.raylib.com/common/img/raylib_logo.png">
<meta property="og:site_name" content="raylib.com">
<meta property="og:url" content="https://www.raylib.com/games.html">
<meta property="og:description" content="New HTML5 videogame, developed using raylib videogames library">
<meta property="og:description" content="New raylib web videogame, developed using raylib videogames library">
<!-- Twitter metatags for sharing -->
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@raysan5">
<meta name="twitter:title" content="Avoid: the game">
<meta name="twitter:title" content="Avoid">
<meta name="twitter:image" content="https://www.raylib.com/common/raylib_logo.png">
<meta name="twitter:url" content="https://www.raylib.com/games.html">
<meta name="twitter:description" content="New HTML5 videogame, developed using raylib videogames library">
<meta name="twitter:description" content="New Avoid, developed using raylib videogames library">
<!-- Favicon -->
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
<style>
body {
font-family: arial;
margin: 0;
padding: none;
}
#header {
width: 100%;
height: 80px;
background-color: #888888;
}
/* NOTE: raylib logo is embedded in the page as base64 png image */
#logo {
width:64px;
height:64px;
float:left;
position:relative;
margin:10px;
background-image:url('data:image/png;base64,\
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADs\
MAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAA7JJREFUaEPtk0FyWzEMQ+37X7fZhxX4\
YY3AD1OKF1nkzTRlSBCCLeVBnvl/AUdaELOunPno1kts1kixdtEZKVs+xIxebBkZsVknn/L5nFGDLR8T4zVC9fX19S/+tTFijr\
YK4jUjbPUtqBHpnEE6PkZD7jQZV8n5Recw1XQKciZuPaEtR6UjNs5ENVGMsBVqpPtER0ZMOhpyp8m4YL4OjD9yxsyZxnQycfMJ\
ETNSzsRE1+dihK3YMiJmpHTW3xpmXPC6BXlCHfqnBlsjY5hxf/6EVEOM2BTEi0fYCX4ONSI6Kq3Blg/prIOMq2CsRur4KQ0x64\
SdjOufEDEdHZGOhmz5RDHCVqhRuQ86YsVskbc+GXchLiHnFyYH+UigQDVGnImbT8hwFkgLg2qiM8JO6Ylx1FNLa3DmYwqCTsZd\
4BPqGJG7MwKzpeiWKTKxXkLMVE3MSOmsdwxLH6Rd/wCCLSNDx6djeKfJuArGeoYamRHpaEjnCBYZVy8hZqo2GI36qPjsiOiMsB\
XGcev4Mx9TLGTchbgEjN/uz6jGrBvDjg+LTNx8Qp2CbG2xMKgmOiPslJ4Yxx+eSnSkzlosZNwFPiHl7FRTkLNRJm4+IeVM0ymI\
H42wE/wcKalQI4MRl4EW3p6VcRWMua8F6WjIlqZDxvVPiHQ6CjVbYkV9ohhhp/Rk1wiYgpyJ78i4CsZbjkb8Qx+ihvzu3RPaKo\
gZkY6GlEeMsKdPSOFIC8VoOusg44L5c+T8ouOoGhWbdWJ8tMi4egkxo4hoh2yNTGf3iIyr5Lyic4bRENXo+lvDjAt4C1Hk/OKt\
UaAj0+n4dMSZ2D+hrYJsaYh2SClG2jV9kJKKzhlGQ1SsW299Mq6C8dYZHTExo8fzieI5ivipYnYy7nwJqGKmOYyRwfiUBXITfh\
5qSHRGWEkfqJqURgvsdHyWYv7Ko8DnYYegk3EB00cxprdrJRzFd7YQzawu8L1GMTYS/KpPaAFTkIn1EmJmspJSs5xBzSyGhlkB\
mlxfNFiP5mw4wlbMh4F5Ddxp5jNINBdCEz9zPOC1zD7Q0HBdmXndwv0TMtydEdzlWJT4VZ8Qt9Qn4/onxMIwa5ZYGJU5yufBiC\
jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaBBfOTCGHM2aEbZi1+gO\
1XTWVXMnzrhAn5DSOZVsiQlHnSITKzGj6DeTcZWc/3oy7h9//PF4PL4BlvsWrb6RE+oAAAAASUVORK5CYII=');
}
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
div.emscripten { text-align: center; }
div.emscripten_border { border: 1px solid black; }
/* NOTE: Canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten {
border: 0px none;
background: black;
width: 100%;
}
.spinner {
height: 30px;
width: 30px;
margin: 0;
margin-top: 20px;
margin-left: 20px;
display: inline-block;
vertical-align: top;
-webkit-animation: rotation .8s linear infinite;
-moz-animation: rotation .8s linear infinite;
-o-animation: rotation .8s linear infinite;
animation: rotation 0.8s linear infinite;
border-left: 5px solid black;
border-right: 5px solid black;
border-bottom: 5px solid black;
border-top: 5px solid red;
border-radius: 100%;
background-color: rgb(245, 245, 245);
}
@-webkit-keyframes rotation {
from {-webkit-transform: rotate(0deg);}
to {-webkit-transform: rotate(360deg);}
}
@-moz-keyframes rotation {
from {-moz-transform: rotate(0deg);}
to {-moz-transform: rotate(360deg);}
}
@-o-keyframes rotation {
from {-o-transform: rotate(0deg);}
to {-o-transform: rotate(360deg);}
}
@keyframes rotation {
from {transform: rotate(0deg);}
to {transform: rotate(360deg);}
}
#status {
display: inline-block;
vertical-align: top;
margin-top: 30px;
margin-left: 20px;
font-weight: bold;
color: rgb(40, 40, 40);
}
#progress {
height: 0px;
width: 0px;
}
#controls {
display: inline-block;
float: right;
vertical-align: top;
margin-top: 15px;
margin-right: 20px;
}
#output {
width: 100%;
height: 140px;
margin: 0 auto;
margin-top: 10px;
display: block;
background-color: black;
color: rgb(37, 174, 38);
font-family: 'Lucida Console', Monaco, monospace;
outline: none;
}
input[type=button] {
background-color: lightgray;
border: 4px solid darkgray;
color: black;
text-decoration: none;
cursor: pointer;
width: 140px;
height: 50px;
}
input[type=button]:hover {
background-color: #f5f5f5ff;
border-color: black;
}
body { margin: 0px; }
canvas.emscripten { border: 0px none; background-color: black; }
</style>
</head>
<body>
<div id="header">
<a id="logo" href="https://www.raylib.com"></a>
<div class="spinner" id='spinner'></div>
<div class="emscripten" id="status">Downloading...</div>
<span id='controls'>
<span><input type="button" value="🖵 FULLSCREEN" onclick="Module.requestFullscreen(false, false)"></span>
<span><input type="button" id="btn-audio" value="🔇 SUSPEND" onclick="toggleAudio()"></span>
</span>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
</div>
</div>
<div class="emscripten_border">
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
</div>
<textarea id="output" rows="8"></textarea>
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
<script type='text/javascript'>
function saveFileFromMEMFSToDisk(memoryFSname, localFSname) // This can be called by C/C++ code
@ -207,122 +53,37 @@ jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaB
saveAs(blob, localFSname);
}
</script>
<script type='text/javascript'>
var statusElement = document.querySelector('#status');
var progressElement = document.querySelector('#progress');
var spinnerElement = document.querySelector('#spinner');
var Module = {
preRun: [],
postRun: [],
print: (function() {
var element = document.querySelector('#output');
if (element) element.value = ''; // Clear browser cache
return function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&amp;");
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//text = text.replace('\n', '<br>', 'g');
console.log(text);
if (element) {
element.value += text + "\n";
element.scrollTop = element.scrollHeight; // focus on bottom
}
};
})(),
printErr: function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
console.error(text);
},
canvas: (function() {
var canvas = document.querySelector('#canvas');
// As a default initial behavior, pop up an alert when webgl context is lost.
// To make your application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas;
})(),
setStatus: function(text) {
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.last.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
if (m && now - Module.setStatus.last.time < 30) return; // If this is a progress update, skip it if too soon
Module.setStatus.last.time = now;
Module.setStatus.last.text = text;
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = true;
spinnerElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
if (!text) spinnerElement.style.display = 'none';
</head>
<body>
<canvas class=emscripten id=canvas oncontextmenu=event.preventDefault() tabindex=-1></canvas>
<p id="output" />
<script>
var Module = {
print: (function() {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
return function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
console.log(text);
if (element) {
element.value += text + "\n";
element.scrollTop = element.scrollHeight; // focus on bottom
}
};
})(),
canvas: (function() {
var canvas = document.getElementById('canvas');
return canvas;
})()
};
document.onkeydown = function(evt) {
evt = evt || window.event;
var keyCode = evt.keyCode;
if (keyCode >= 37 && keyCode <= 40) {
return false;
}
statusElement.innerHTML = text;
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
},
//noInitialRun: true
};
Module.setStatus('Downloading...');
window.onerror = function() {
Module.setStatus('Exception thrown, see JavaScript console');
spinnerElement.style.display = 'none';
Module.setStatus = function(text) { if (text) Module.printErr('[post-exception status] ' + text); };
};
</script>
<!-- REF: https://developers.google.com/web/updates/2018/11/web-audio-autoplay -->
<script type='text/javascript'>
var audioBtn = document.querySelector('#btn-audio');
// An array of all contexts to resume on the page
const audioContexList = [];
(function() {
// A proxy object to intercept AudioContexts and
// add them to the array for tracking and resuming later
self.AudioContext = new Proxy(self.AudioContext, {
construct(target, args) {
const result = new target(...args);
audioContexList.push(result);
if (result.state == "suspended") audioBtn.value = "🔈 RESUME";
return result;
}
});
})();
function toggleAudio() {
var resumed = false;
audioContexList.forEach(ctx => {
if (ctx.state == "suspended") { ctx.resume(); resumed = true; }
else if (ctx.state == "running") ctx.suspend();
});
if (resumed) audioBtn.value = "🔇 SUSPEND";
else audioBtn.value = "🔈 RESUME";
}
</script>
{{{ SCRIPT }}}
</body>
};
</script>
{{{ SCRIPT }}}
</body>
</html>

142
include/README.md Normal file
View file

@ -0,0 +1,142 @@
<img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_logo_animation.gif" width="288px">
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's specially well suited for prototyping, tooling, graphical applications, embedded systems and education.
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.*
Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
---
<br>
[![GitHub contributors](https://img.shields.io/github/contributors/raysan5/raylib)](https://github.com/raysan5/raylib/graphs/contributors)
[![GitHub All Releases](https://img.shields.io/github/downloads/raysan5/raylib/total)](https://github.com/raysan5/raylib/releases)
[![GitHub commits since tagged version](https://img.shields.io/github/commits-since/raysan5/raylib/4.0.0)](https://github.com/raysan5/raylib/commits/master)
[![License](https://img.shields.io/badge/license-zlib%2Flibpng-blue.svg)](LICENSE)
[![Chat on Discord](https://img.shields.io/discord/426912293134270465.svg?logo=discord)](https://discord.gg/raylib)
[![GitHub stars](https://img.shields.io/github/stars/raysan5/raylib?style=social)](https://github.com/raysan5/raylib/stargazers)
[![Twitter Follow](https://img.shields.io/twitter/follow/raysan5?style=social)](https://twitter.com/raysan5)
[![Subreddit subscribers](https://img.shields.io/reddit/subreddit-subscribers/raylib?style=social)](https://www.reddit.com/r/raylib/)
[![Windows](https://github.com/raysan5/raylib/workflows/Windows/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AWindows)
[![Linux](https://github.com/raysan5/raylib/workflows/Linux/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3ALinux)
[![macOS](https://github.com/raysan5/raylib/workflows/macOS/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AmacOS)
[![Android](https://github.com/raysan5/raylib/workflows/Android/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AAndroid)
[![WebAssembly](https://github.com/raysan5/raylib/workflows/WebAssembly/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AWebAssembly)
[![CMakeBuilds](https://github.com/raysan5/raylib/workflows/CMakeBuilds/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3ACMakeBuilds)
[![Windows Examples](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml)
[![Linux Examples](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml)
features
--------
- **NO external dependencies**, all required libraries are [bundled into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
- Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!**
- Written in plain C code (C99) in PascalCase/camelCase notation
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3, 4.3 or ES 2.0**)
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
- Multiple **Fonts** formats supported (TTF, XNA fonts, AngelCode fonts)
- Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC)
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
- Flexible Materials system, supporting classic maps and **PBR maps**
- **Animated 3D models** supported (skeletal bones animation) (IQM)
- Shaders support, including model and **postprocessing** shaders.
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
- **VR stereo rendering** support with configurable HMD device parameters
- Huge examples collection with [+120 code examples](https://github.com/raysan5/raylib/tree/master/examples)!
- Bindings to [+50 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
- **Free and open source**.
basic example
--------------
This is a basic raylib example, it creates a window and it draws the text `"Congrats! You created your first window!"` in the middle of the screen. Check this example [running live on web here](https://www.raylib.com/examples/core/loader.html?name=core_basic_window).
```c
#include "raylib.h"
int main(void)
{
InitWindow(800, 450, "raylib [core] example - basic window");
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
}
CloseWindow();
return 0;
}
```
build and installation
----------------------
raylib binary releases for Windows, Linux, macOS, Android and HTML5 are available at the [Github Releases page](https://github.com/raysan5/raylib/releases).
raylib is also available via multiple [package managers](https://github.com/raysan5/raylib/issues/613) on multiple OS distributions.
#### Installing and building raylib on multiple platforms
[raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) contains detailed instructions on building and usage on multiple platforms.
- [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows)
- [Working on macOS](https://github.com/raysan5/raylib/wiki/Working-on-macOS)
- [Working on GNU Linux](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)
- [Working on Chrome OS](https://github.com/raysan5/raylib/wiki/Working-on-Chrome-OS)
- [Working on FreeBSD](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD)
- [Working on Raspberry Pi](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi)
- [Working for Android](https://github.com/raysan5/raylib/wiki/Working-for-Android)
- [Working for Web (HTML5)](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5))
- [Working anywhere with CMake](https://github.com/raysan5/raylib/wiki/Working-with-CMake)
*Note that Wiki is open for edit, if you find some issue while building raylib for your target platform, feel free to edit the Wiki or open and issue related to it.*
#### Setup raylib with multiple IDEs
raylib has been developed on Windows platform using [Notepad++](https://notepad-plus-plus.org/) and [MinGW GCC](https://www.mingw-w64.org/) compiler but it can be used with other IDEs on multiple platforms.
[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs.
*Note that there are lots of IDEs supported, some of the provided templates could require some review, please, if you find some issue with some template or you think they could be improved, feel free to send a PR or open a related issue.*
learning and docs
------------------
raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library and a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works.
Some additional documentation about raylib design can be found in raylib GitHub Wiki. Here the more relevant links:
- [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html)
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
- [raylib library design](https://github.com/raysan5/raylib/wiki)
- [raylib examples collection](https://github.com/raysan5/raylib/tree/master/examples)
- [raylib games collection](https://github.com/raysan5/raylib-games)
contact and networks
---------------------
raylib is present in several networks and raylib community is growing everyday. If you are using raylib and enjoying it, feel free to join us in any of these networks. The most active network is our [Discord server](https://discord.gg/raylib)! :)
- Webpage: [https://www.raylib.com](https://www.raylib.com)
- Discord: [https://discord.gg/raylib](https://discord.gg/raylib)
- Twitter: [https://www.twitter.com/raysan5](https://www.twitter.com/raysan5)
- Twitch: [https://www.twitch.tv/raysan5](https://www.twitch.tv/raysan5)
- Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
- Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
- YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/c/raylib)
license
-------
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.
raylib uses internally some libraries for window/graphics/inputs management and also to support different fileformats loading, all those libraries are embedded with and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies LICENSES](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on raylib Wiki for details.

27
src/Controls.h Normal file
View file

@ -0,0 +1,27 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Controls.h
- Author ~ Return0ne
- 2022
- *no license*
*/
#ifndef CONTROLS_HEADER
#define CONTROLS_HEADER
#define INPUT_UP_PRESSED IsKeyPressed(KEY_UP) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_FACE_UP)
#define INPUT_DOWN_PRESSED IsKeyPressed(KEY_DOWN) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN)
#define INPUT_LEFT_PRESSED IsKeyPressed(KEY_LEFT) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT)
#define INPUT_RIGHT_PRESSED IsKeyPressed(KEY_RIGHT) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)
#define INPUT_OPTION_PRESSED IsKeyPressed(KEY_ENTER) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_MIDDLE_RIGHT)
#define INPUT_FIRE_DOWN IsKeyDown(KEY_Z) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)
#define INPUT_LEFT_DOWN IsKeyDown(KEY_LEFT) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT)
#define INPUT_RIGHT_DOWN IsKeyDown(KEY_RIGHT) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)
#define INPUT_UP_DOWN IsKeyDown(KEY_UP) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_UP)
#define INPUT_DOWN_DOWN IsKeyDown(KEY_DOWN) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN)
#define INPUT_DASH_DOWN IsKeyDown(KEY_X) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)
#endif

48
src/Credits.c Normal file
View file

@ -0,0 +1,48 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Credits.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include "Screens.h"
#include "Controls.h"
#include "Gfx.h"
int finishfromCreditsScreen = 0;
void InitCreditsScreen(void)
{
finishfromCreditsScreen = 0;
}
void UpdateCreditsScreen(void)
{
if (INPUT_OPTION_PRESSED) finishfromCreditsScreen = 1;
}
void DrawCreditsScreen(void)
{
DrawTexture(background, 0, 0, DARKGRAY);
DrawText("CREDITS", 290, 20, 50, BLUE);
DrawText("Art by Mark and Allan", 10, 120, 40, BLUE);
DrawText("Programming by Mark", 10, 160, 40, BLUE);
DrawText("Powered by raylib 4.0", 10, 200, 40, BLUE);
DrawText("rFXgen used for sfx", 10, 235, 40, BLUE);
DrawText("A Canneddonuts project 2022", 10, 270, 40, BLUE);
DrawText(TextFormat("Build compiled on %s", __DATE__), 10, 310, 30, GREEN);
DrawText("Press 'ENTER' ", 10, 350, 30, WHITE);
}
int FinishCreditsScreen(void)
{
return finishfromCreditsScreen;
}
void UnloadCreditsScreen(void)
{
}

49
src/Ending.c Normal file
View file

@ -0,0 +1,49 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Ending.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include "Screens.h"
#include "Controls.h"
#include "Options.h"
#include "Music.h"
#include "Gfx.h"
int finishfromEndingScreen = 0;
Music Endingsong = { 0 };
void InitEndingScreen(void)
{
finishfromEndingScreen = 0;
Endingsong = LoadMusicStream("assets/bgm/01-Slipin-Sunday.ogg");
PlayMusicStream(Endingsong);
}
void UpdateEndingScreen(void)
{
if (!mute) UpdateMusicStream(Endingsong);
if (INPUT_OPTION_PRESSED) finishfromEndingScreen = 1;
}
void DrawEndingScreen(void)
{
DrawTexture(background, 0, 0, GOLD);
DrawText("THANK YOU SO MUCH FOR PLAYING!!!", 10, 10, 40, GOLD);
DrawTextEx(ZadoBold, "Canneddonuts 2022", (Vector2){ 380, 400 }, 40, 2, WHITE);
DrawTextEx(ZadoBold, "Press 'ENTER'", (Vector2){ 5, 400 }, 40, 2, WHITE);
}
void UnloadEndingScreen(void)
{
UnloadMusicStream(Endingsong);
}
int FinishEndingScreen(void)
{
return finishfromEndingScreen;
}

62
src/Gameover.c Normal file
View file

@ -0,0 +1,62 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Gameover.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include "Screens.h"
#include "Options.h"
#include "Controls.h"
#include "Music.h"
#include "Gfx.h"
int gameoverSelected = 0, finishfromGameoverScreen = 0;
Music Gameoversong = { 0 };
void InitGameoverScreen(void)
{
gameoverSelected = 0;
finishfromGameoverScreen = 0;
Gameoversong = LoadMusicStream("assets/bgm/02-Have-Hope.ogg");
PlayMusicStream(Gameoversong);
}
void UpdateGameoverScreen(void)
{
if (!mute) UpdateMusicStream(Gameoversong);
if (INPUT_UP_PRESSED) gameoverSelected++;
if (INPUT_DOWN_PRESSED) gameoverSelected--;
if (gameoverSelected > 0) gameoverSelected--;
if (gameoverSelected < -1) gameoverSelected++;
if ((gameoverSelected == 0) && (INPUT_OPTION_PRESSED))
{ StopMusicStream(Gameoversong); finishfromGameoverScreen = 2; }
if ((gameoverSelected == -1) && (INPUT_OPTION_PRESSED))
{ StopMusicStream(Gameoversong); finishfromGameoverScreen = 1; }
}
void DrawGameoverScreen(void)
{
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLACK);
DrawText("GAME OVER", 170, 10, 80, RED);
if (gameoverSelected == 0) DrawTextEx(ZadoBold, "RETRY", (Vector2){ 340, 200 }, 40, 2, WHITE);
else DrawTextEx(ZadoBold, "RETRY", (Vector2){ 340, 200 }, 40, 2, RED);
if (gameoverSelected == -1) DrawTextEx(ZadoBold, "TITLE", (Vector2){ 345, 250 }, 40, 2, WHITE);
else DrawTextEx(ZadoBold, "TITLE", (Vector2){ 345, 250 }, 40, 2, RED);
}
int FinishGameoverScreen(void)
{
return finishfromGameoverScreen;
}
void UnloadGameoverScreen(void)
{
UnloadMusicStream(Gameoversong);
}

400
src/Gameplay.c Normal file
View file

@ -0,0 +1,400 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Gameplay.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include <math.h>
#include "Screens.h"
#include "Controls.h"
#include "Options.h"
#include "Gstructs.h"
#include "Stats.h"
#include "Timers.h"
#include "Music.h"
#include "Gfx.h"
#define MAX_FIREWORKS 10
#define MAX_SHOOTS 5
struct Actor player = { 0 };
//struct Actor enemy = { 0 };
struct Attack fireworks[MAX_FIREWORKS] = { 0 };
struct Attack shoot[MAX_SHOOTS] = { 0 };
struct Item feather = { 0 };
Sound fxfeather = { 0 };
Sound fxboom = { 0 };
bool pause;
bool DebugMode;
int fireworkAmount = 0;
int GI_callcount = 0;
//int trigMov;
int score = 0, bestscore = 0, finishfromGameplayScreen = 0, greenfeathers = 0;
Music Gameplaysong = { 0 };
void LoadGamplayScreen(void)
{
player.fxhit = LoadSound("assets/sfx/hit.wav");
// enemy.fxhit = LoadSound("assets/sfx/boom.wav");
fxboom = LoadSound("assets/sfx/boom.wav");
player_sprite = LoadTexture("assets/gfx/player.png");
enemy_sprite = LoadTexture("assets/gfx/enemy.png");
fxfeather = LoadSound("assets/sfx/feather.wav");
feather_sprite = LoadTexture("assets/gfx/feather.png");
attack_sprite = LoadTexture("assets/gfx/attack.png");
firework_sprite = LoadTexture("assets/gfx/firework.png");
// Gameplaysong = LoadMusicStream("assets/bgm/03-Boss.ogg");
}
void InitGameplayScreen(void)
{
// PlayMusicStream(Gameplaysong);
finishfromGameplayScreen = 0;
nextlevel = level + 1;
globalTimer = 0;
if (player.hp < 1) player.hp = 1;
player.currentframe = 0;
player.speed = 300.0f;
if (GI_callcount < 1) {
player.frameRec = (Rectangle) {
player.hitbox.x,
player.hitbox.y,
(float) player_sprite.width/3,
(float) player_sprite.height
};
}
player.hitbox = (Rectangle) {
0,
100,
(float) player_sprite.width/3 - 20,
(float) player_sprite.height - 20
};
player.iframetimer = 0;
player.in = false;
player.color = RAYWHITE;
/* enemy.currentframe = 0;
enemy.hp = 20;
enemy.speed = 200.0f;
if (GI_callcount < 1) {
enemy.frameRec = (Rectangle) {
enemy.hitbox.x,
enemy.hitbox.y,
(float) enemy_sprite.width/2,
(float) enemy_sprite.height
};
}
enemy.hitbox = (Rectangle) {
690,
20,
(float) enemy_sprite.width/2,
(float) enemy_sprite.height
};
enemy.color = RAYWHITE;
enemy.in = false;
enemy.iframetimer = 0;*/
feather.hitbox = (Rectangle) {
GetScreenWidth() - feather_sprite.width,
GetRandomValue(0, GetScreenHeight() - feather_sprite.height),
(float) feather_sprite.width,
(float) feather_sprite.height
};
feather.active = false;
feather.power = 0;
for (int i = 0; i < MAX_FIREWORKS; i++) {
fireworks[i].active = 1;
fireworks[i].hp = 5;
fireworks[i].hitbox = (Rectangle) {
GetScreenWidth() + firework_sprite.width,
0,
(float) firework_sprite.width/2 + 10,
(float) firework_sprite.height
};
fireworks[i].hitbox.y = GetRandomValue(0, GetScreenHeight() - firework_sprite.height);
switch (level) {
case LEVEL1: fireworks[i].speed.x = GetRandomValue(100, 200); break;
case LEVEL2: fireworks[i].speed.x = GetRandomValue(200, 300); break;
case LEVEL3: fireworks[i].speed.x = GetRandomValue(250, 350); break;
}
fireworks[i].color = RAYWHITE;
}
for (int i = 0; i < MAX_SHOOTS; i++) {
shoot[i].hitbox = (Rectangle) {
player.hitbox.x,
player.hitbox.y,
(float) attack_sprite.width,
(float) attack_sprite.height
};
shoot[i].speed.x = 5000.f;
shoot[i].speed.y = 0;
shoot[i].active = false;
shoot[i].color = GREEN;
}
switch (level) {
case LEVEL1: fireworkAmount = 100; break;
case LEVEL2: fireworkAmount = 150; break;
case LEVEL3: fireworkAmount = 100; break;
}
pause = 0;
DebugMode = 0;
pauseTimer = 0;
GI_callcount++;
}
void ResetFeather(void)
{
feather.power = 0;
feather.hitbox.x = GetScreenWidth() + feather_sprite.width;
feather.hitbox.y = GetRandomValue(0, GetScreenHeight() - feather_sprite.height);
feather.active = false;
}
void UpdateGameplayScreen(void)
{
if (INPUT_OPTION_PRESSED) pause = !pause;
// code to end the game
if (CheckAttackActivity(fireworks, 0, MAX_FIREWORKS) && level < 2) {
StopMusicStream(Gameplaysong);
levelunlocked[nextlevel] = true;
finishfromGameplayScreen = 4;
} else if (CheckAttackActivity(fireworks, 0, MAX_FIREWORKS) && level == 2) {
StopMusicStream(Gameplaysong);
finishfromGameplayScreen = 3;
}
// if (!mute) UpdateMusicStream(Gameplaysong);
if (!pause) {
// Controls
if (INPUT_LEFT_DOWN) player.hitbox.x -= GetFrameTime() * player.speed;
if (INPUT_RIGHT_DOWN) player.hitbox.x += GetFrameTime() * player.speed;
if (INPUT_UP_DOWN) player.hitbox.y -= GetFrameTime() * player.speed;
if (INPUT_DOWN_DOWN) player.hitbox.y += GetFrameTime() * player.speed;
if (INPUT_DASH_DOWN) {
player.speed = 600.0f;
if (player.currentframe != 1) player.currentframe = 2;
} else player.speed = 300.0f;
if (INPUT_FIRE_DOWN) {
for (int i = 0; i < MAX_SHOOTS; i++) {
if (!shoot[i].active) {
shoot[i].hitbox.x = player.hitbox.x;
shoot[i].hitbox.y = player.hitbox.y + player.hitbox.height/4;
shoot[i].active = true;
break;
}
}
}
// Update sprite positions
player.sprite_pos = (Vector2){ player.hitbox.x, player.hitbox.y };
player.frameRec.x = (float)player.currentframe*(float)player_sprite.width/3;
feather.sprite_pos = (Vector2){ feather.hitbox.x, feather.hitbox.y };
/*enemy.sprite_pos = (Vector2){ enemy.hitbox.x, enemy.hitbox.y };
enemy.frameRec.x = (float)enemy.currentframe*(float)enemy_sprite.width/2;*/
for (int i = 0; i < MAX_FIREWORKS; i++) {
fireworks[i].sprite_pos = (Vector2){ fireworks[i].hitbox.x, fireworks[i].hitbox.y };
}
for (int i = 0; i < MAX_SHOOTS; i++) {
shoot[i].sprite_pos = (Vector2){ shoot[i].hitbox.x, shoot[i].hitbox.y };
}
// Player wall collision
if ((player.hitbox.x + player.hitbox.width) >= GetScreenWidth()) player.hitbox.x = GetScreenWidth() - player.hitbox.width;
else if (player.hitbox.x <= 0) player.hitbox.x = 0;
if ((player.hitbox.y + player.hitbox.height) >= GetScreenHeight()) player.hitbox.y = GetScreenHeight() - player.hitbox.height;
else if (player.hitbox.y <= 0) player.hitbox.y = 0;
// Update Timers
scoreTimer += 60 * GetFrameTime();
score = (int)scoreTimer;
globalTimer += 10 * GetFrameTime();
// pass the address of each struct to the UpdateiFrameTimer function
UpdateiFrameTimer(&player);
// UpdateiFrameTimer(&enemy);
greenfeathers = player.hp;
// Debug stuff
if (IsKeyPressed(KEY_D)) DebugMode = !DebugMode;
if (IsKeyPressed(KEY_G)) finishfromGameplayScreen = 1;
if (IsKeyPressed(KEY_Q)) finishfromGameplayScreen = 4;
if (IsKeyPressed(KEY_EQUAL)) level++;
if (IsKeyPressed(KEY_MINUS)) level--;
// call gameover when killed
if (player.hp < 1) { StopMusicStream(Gameplaysong); finishfromGameplayScreen = 1; }
// Red feather logic
for (int i = 0; i < MAX_SHOOTS; i++) {
if (shoot[i].active) {
shoot[i].hitbox.x += shoot[i].speed.x * GetFrameTime();
}
if (shoot[i].hitbox.x + shoot[i].hitbox.width >= GetScreenWidth() + attack_sprite.width) shoot[i].active = false;
}
// Feather spawn logic
if (level == LEVEL3) { if ((int) globalTimer % 10 == 0) feather.active = true; }
else { if ((int) globalTimer % 30 == 0) feather.active = true; }
switch (feather.power) {
case 0: feather.color = RED; break;
}
if (feather.active) {
if (((feather.hitbox.x + -feather_sprite.width) > GetScreenWidth()
|| (feather.hitbox.x <= -feather_sprite.width))) ResetFeather();
if (CheckCollisionRecs(player.hitbox, feather.hitbox)) {
switch (feather.power) {
case 0: player.hp++; break;
}
if (!mute) PlaySoundMulti(fxfeather);
ResetFeather();
}
feather.hitbox.x -= 300.0f * GetFrameTime();
}
// Enemy logic
/* if (level == 2) {
if ((int)globalTimer % 40 == 0) enemy.hitbox.y = GetRandomValue(0, GetScreenHeight() - enemy_sprite.height);
if (CheckCollisionRecs(player.hitbox, enemy.hitbox)) DamageActor(&player);
for (int i = 0; i < MAX_SHOOTS; i++) {
if (CheckCollisionRecs(shoot[i].hitbox, enemy.hitbox) && shoot[i].active) {
DamageActor(&enemy);
scoreTimer += 300;
enemy.hitbox.y = GetRandomValue(0, GetScreenHeight());
shoot[i].active = false;
}
if (((shoot[i].hitbox.x + -attack_sprite.width) > GetScreenWidth()
|| (shoot[i].hitbox.x <= -attack_sprite.width))) shoot[i].active = 0;
}
if (enemy.hp < 1) { level++; enemy.hp = 5; }
}*/
// Firework logic
for (int i = 0; i < MAX_FIREWORKS; i++) {
if (CheckCollisionRecs(player.hitbox, fireworks[i].hitbox)) {
DamageActor(&player);
fireworks[i].active = 0;
}
for (int j = 0; j < MAX_SHOOTS; j++) {
if (CheckCollisionRecs(shoot[j].hitbox, fireworks[i].hitbox) && shoot[j].active) {
// if (!mute) PlaySoundMulti(enemy.fxhit);
fireworks[i].color = BLACK;
shoot[j].active = 0;
fireworks[i].hp--;
scoreTimer += 300;
} else fireworks[i].color = RAYWHITE;
}
switch (fireworks[i].active) {
case 0:
fireworks[i].hitbox.x = GetScreenWidth() + firework_sprite.width;
fireworks[i].hp = 5;
if (fireworkAmount > 0) { /*fireworkAmount--;*/ fireworks[i].active = 1; }
fireworks[i].hitbox.y = GetRandomValue(0, GetScreenHeight() - firework_sprite.height);
/* switch (level) {
case LEVEL1: fireworks[i].speed.x = GetFrameTime() break;
case LEVEL2: fireworks[i].speed.x = GetRandomValue(400, 600); break;
case LEVEL3: fireworks[i].speed.x = GetRandomValue(800, 1000); break;
} */
break;
case 1:
if (fireworks[i].hp < 1) { fireworkAmount--; fireworks[i].active = 0; if (!mute) PlaySoundMulti(fxboom); }
// trigMov = sin(2*PI/20*fireworks[i].hitbox.x) * 200;
fireworks[i].hitbox.x -= fireworks[i].speed.x * GetFrameTime();
// fireworks[i].hitbox.y += trigMov*GetFrameTime();
// Firework wall collision
if (((fireworks[i].hitbox.x + -firework_sprite.width) > GetScreenWidth()
|| (fireworks[i].hitbox.x <= -firework_sprite.width))) { fireworks[i].active = 0; player.hp--; fireworkAmount--; }
break;
}
}
} else pauseTimer += 60 * GetFrameTime();
}
void DrawGameplayScreen(void)
{
switch (level) {
case LEVEL1: DrawTexture(background, 0, 0, RAYWHITE); break;
case LEVEL2: DrawTexture(background, 0, 0, ORANGE); break;
case LEVEL3: DrawTexture(background, 0, 0, RED); break;
}
if (DebugMode) {
DrawFPS(10, 430);
DrawRectangleLines(player.hitbox.x, player.hitbox.y, player.hitbox.width, player.hitbox.height, BLUE);
DrawRectangleLines(feather.hitbox.x, feather.hitbox.y, feather.hitbox.width, feather.hitbox.height, WHITE);
//DrawRectangleLines(enemy.hitbox.x, enemy.hitbox.y, enemy.hitbox.width, enemy.hitbox.height, BLACK);
for (int i = 0; i < MAX_FIREWORKS; i++) {
DrawRectangleLines(fireworks[i].hitbox.x, fireworks[i].hitbox.y, fireworks[i].hitbox.width, fireworks[i].hitbox.height, BLACK);
}
for (int i = 0; i < MAX_SHOOTS; i++) {
DrawRectangleLines(shoot[i].hitbox.x, shoot[i].hitbox.y, shoot[i].hitbox.width, shoot[i].hitbox.height, GREEN);
}
// DrawText(TextFormat("enemy.hitbox.y: %f", enemy.hitbox.y), 10, 200, 20, GREEN);
// DrawText(TextFormat("enemy.speed: %f", enemy.speed), 10, 220, 20, GREEN);
DrawText(TextFormat("globalTimer: %f", globalTimer), 10, 240, 20, GREEN);
DrawText(TextFormat("firework_sprite.width: %d", firework_sprite.width), 10, 260, 20, GREEN);
DrawText(TextFormat("player.iframetimer: %f", player.iframetimer), 10, 280, 20, GREEN);
DrawText(TextFormat("player.in: %d", player.in), 10, 300, 20, GREEN);
DrawText(TextFormat("feather.active: %d", feather.active), 10, 320, 20, GREEN);
DrawText(TextFormat("GetTime(): %f", GetTime()), 10, 340, 20, GREEN);
DrawText(TextFormat("fireworkAmount: %d", fireworkAmount), 10, 360, 20, GREEN);
}
if (feather.active) DrawTexture(feather_sprite, feather.sprite_pos.x, feather.sprite_pos.y, feather.color);
for (int i = 0; i < MAX_FIREWORKS; i++) {
DrawTexture(firework_sprite, fireworks[i].sprite_pos.x, fireworks[i].sprite_pos.y, fireworks[i].color);
}
for (int i = 0; i < MAX_SHOOTS; i++) {
if (shoot[i].active) DrawTexture(attack_sprite, shoot[i].sprite_pos.x, shoot[i].sprite_pos.y, shoot[i].color);
}
// if (level == 2) DrawTextureRec(enemy_sprite, enemy.frameRec, enemy.sprite_pos, enemy.color);
DrawTextureRec(player_sprite, player.frameRec, player.sprite_pos, player.color);
DrawTexture(feather_sprite, 0, 0, RED);
DrawText(TextFormat("= %i", player.hp), 30, 30, 30, RED);
// if (level == 2) DrawText(TextFormat("ENEMY HP: %i", enemy.hp), GetScreenWidth() - 380, 0, 20, RED);
// DrawText(TextFormat("FIREWORKS LEFT: %i", fireworkAmount), GetScreenWidth() - 240, 0, 20, GREEN);
if (score > 500000) DrawText(TextFormat("SCORE: %i", score), 10, 65, 30, (Color){ 222, 181, 0, 255 });
else DrawText(TextFormat("SCORE: %i", score), 10, 65, 30, BLUE);
if (pause && (((int)pauseTimer/30)%2)) DrawTextEx(ZadoBold, "PAUSED", (Vector2){ 280, 160 }, 60, 2, WHITE);
}
void UnloadGameplayScreen(void)
{
UnloadSound(player.fxhit);
// UnloadSound(enemy.fxhit);
UnloadSound(fxboom);
UnloadSound(fxfeather);
UnloadTexture(player_sprite);
UnloadTexture(feather_sprite);
UnloadTexture(enemy_sprite);
UnloadTexture(firework_sprite);
UnloadTexture(attack_sprite);
UnloadMusicStream(Gameplaysong);
}
int FinishGameplayScreen(void)
{
return finishfromGameplayScreen;
}

20
src/Gfx.h Normal file
View file

@ -0,0 +1,20 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Gfx.h
- Author ~ Return0ne
- 2022
- *no license*
*/
#ifndef GFX_HEADER
#define GFX_HEADER
extern Texture2D background;
extern Texture2D player_sprite;
extern Texture2D feather_sprite;
extern Texture2D enemy_sprite;
extern Texture2D firework_sprite;
extern Texture2D attack_sprite;
extern Font ZadoBold;
#endif

46
src/Gstructs.h Normal file
View file

@ -0,0 +1,46 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Gstructs.h
- Author ~ Return0ne
- 2022
- *no license*
*/
#ifndef GAMESTRUCTS_HEADER
#define GAMESTRUCTS_HEADER
struct Actor {
float speed;
int hp;
int currentframe;
float iframetimer;
Vector2 sprite_pos;
Rectangle frameRec;
Rectangle hitbox;
Color color;
Sound fxhit;
bool in;
};
struct Item {
Vector2 sprite_pos;
Rectangle hitbox;
bool active;
Color color;
int power;
};
struct Attack {
Vector2 sprite_pos;
Rectangle hitbox;
Vector2 speed;
int active;
int hp;
Color color;
};
void DamageActor(struct Actor *actor);
void UpdateiFrameTimer(struct Actor *actor);
bool CheckAttackActivity(struct Attack attack[], int val, int max);
#endif

54
src/Gutils.c Normal file
View file

@ -0,0 +1,54 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Gutils.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include "Gstructs.h"
#include "Timers.h"
#include "Options.h"
float pauseTimer;
float globalTimer;
float scoreTimer;
void DamageActor(struct Actor *actor)
{
if (!actor->in) {
actor->hp--;
if (!mute) PlaySoundMulti(actor->fxhit);
actor->in = true;
}
actor->currentframe = 1;
}
void UpdateiFrameTimer(struct Actor *actor)
{
// here we use pointers to avoid duplicating code
if (actor->in) {
actor->iframetimer += GetFrameTime();
actor->currentframe = 1;
if ((int)globalTimer % 2 == 0) actor->color = GRAY;
else actor->color = RAYWHITE;
if (actor->iframetimer > 2) {
actor->in = false;
actor->iframetimer = 0;
}
} else { actor->color = RAYWHITE; actor->currentframe = 0; }
}
bool CheckAttackActivity(struct Attack attack[], int val, int max)
{
int matches = 0;
for (int i = 0; i < max; i++) {
if (attack[i].active == val) matches++;
}
if (matches == max) return true;
else return false;
}

69
src/LevelSel.c Normal file
View file

@ -0,0 +1,69 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ LevelSel.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include "Screens.h"
#include "Stats.h"
#include "Controls.h"
#include "Gfx.h"
int finishfromLevelSelScreen = 0, levelSelected = 0, nextlevel = 1;
bool levelunlocked[3] = {1, 0 , 0};
void InitLevelSelScreen(void)
{
feather_sprite = LoadTexture("assets/gfx/feather.png");
finishfromLevelSelScreen = 0;
}
void UpdateLevelSelScreen(void)
{
if (INPUT_LEFT_PRESSED) levelSelected--;
if (INPUT_RIGHT_PRESSED) if (levelunlocked[levelSelected+1]) levelSelected++;
if (levelSelected < 0) levelSelected++;
if (levelSelected > 2) levelSelected--;
if ((levelSelected == 0) && (INPUT_OPTION_PRESSED)) { level = LEVEL1; finishfromLevelSelScreen = 1; }
if ((levelSelected == 1) && (INPUT_OPTION_PRESSED)) { level = LEVEL2; finishfromLevelSelScreen = 1; }
if ((levelSelected == 2) && (INPUT_OPTION_PRESSED)) { level = LEVEL3; finishfromLevelSelScreen = 1; }
}
void DrawLevelSelScreen(void)
{
DrawTexture(background, 0, 0, GRAY);
DrawTexture(feather_sprite, 0, 0, RED);
DrawText(TextFormat("= %i", greenfeathers), 30, 30, 30, RED);
if (score > 500000) DrawText(TextFormat("SCORE: %i", score), 10, 65, 30, (Color){ 222, 181, 0, 255 });
else DrawText(TextFormat("SCORE: %i", score), 10, 65, 30, BLUE);
if (levelSelected == 0) DrawText("1", 100, 220, 60, WHITE);
else DrawText("1", 100, 220, 60, GREEN);
if (levelSelected == 1) DrawText("2", 200, 220, 60, WHITE);
else if (levelunlocked[1]) DrawText("2", 200, 220, 60, GREEN);
else DrawText("2", 200, 220, 60, GRAY);
if (levelSelected == 2) DrawText("3", 300, 220, 60, WHITE);
else if (levelunlocked[2]) DrawText("3", 300, 220, 60, RED);
else DrawText("3", 300, 220, 60, GRAY);
// printf("%d, %d, %d\n", levelunlocked[0], levelunlocked[1], levelunlocked[2]);
// printf("%d\n", levelunlocked[nextlevel]);
}
void UnloadLevelSelScreen(void)
{
UnloadTexture(feather_sprite);
}
int FinishLevelSelScreen(void)
{
return finishfromLevelSelScreen;
}

View file

@ -1,271 +1,243 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Main.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include "Screens.h"
#include "Options.h"
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
// screen variables
static const int screenWidth = 800;
static const int screenHeight = 450;
// Gamescreens
typedef enum GameScreen { TITLE = 0, GAMEPLAY, GAMEOVER, CREDITS } GameScreen;
static float transAlpha = 0.0f;
static bool onTransition = false;
static bool transFadeOut = false;
static int transFromScreen = -1;
static int transToScreen = -1;
// structs
typedef struct Ball {
Vector2 position;
Vector2 speed;
float radius;
float growth;
Color color;
bool active;
} Ball;
GameScreen currentScreen = 0;
Levels level = 0;
typedef struct Player {
Texture2D sprite;
int currentframe;
Vector2 sprite_pos;
Rectangle frameRec;
Rectangle hitbox;
int hp;
} Player;
// Game variables
static GameScreen currentScreen = { 0 };
static Sound fxbounce = { 0 };
static Player player = { 0 };
static Ball ball = { 0 };
static bool pause;
static bool mute;
static int pauseTimer;
static int BallFrameCounter;
static int selected = 0;
Texture2D background;
Texture2D player_sprite;
Texture2D feather_sprite;
Texture2D enemy_sprite;
Texture2D firework_sprite;
Texture2D attack_sprite;
Font ZadoBold;
// Game functions
static void GameInit(void);
static void UpdateGame(void);
static void DrawGame(void);
static void UpdateDrawFrame(void);
static void UnloadGame(void);
static void gameSetup(void);
static void update_draw_frame(void);
static void unloadGame(void);
static void transition_to_screen(int screen);
static void update_transition(void);
static void draw_transition(void);
int main(void)
{
SetConfigFlags(FLAG_VSYNC_HINT);
InitWindow(screenWidth, screenHeight, "Avoid");
InitAudioDevice();
GameInit();
gameSetup();
#if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
emscripten_set_main_loop(update_draw_frame, 60, 1);
#else
SetTargetFPS(60);
SetTargetFPS(60);
while (!WindowShouldClose()) UpdateDrawFrame();
while (!WindowShouldClose()) update_draw_frame();
#endif
UnloadGame();
unloadGame();
CloseAudioDevice();
CloseWindow();
return 0;
}
void GameInit(void)
void gameSetup(void)
{
// asset loading & setting of variable values
currentScreen = TITLE;
level = LEVEL1;
background = LoadTexture("assets/gfx/background.png");
ZadoBold = LoadFontEx("assets/fonts/ZadoBold.ttf", 96, 0, 110);
InitTitleScreen();
fxbounce = LoadSound("assets/sfx/boing.wav");
SetMasterVolume(0.2);
player.sprite = LoadTexture("assets/gfx/player.png");
player.currentframe = 0;
player.hp = 30;
player.frameRec = (Rectangle) {
0.0f,
0.0f,
(float) player.sprite.width/2,
(float) player.sprite.height
};
player.hitbox = (Rectangle) {
GetScreenWidth()/2.0f - 30,
GetScreenHeight()/2.0f - 30,
70,
70
};
ball.position = (Vector2){ 50, 50 };
ball.radius = 20;
ball.growth = 2;
ball.speed = (Vector2){ 400.0f, 400.0f };
ball.color = MAROON;
ball.active = true;
pause = 0;
mute = 0;
pauseTimer = 0;
BallFrameCounter = 0;
SetMasterVolume(0.5);
}
void UpdateGame(void)
static void transition_to_screen(int screen)
{
if ((IsKeyDown(KEY_LEFT_ALT)) && (IsKeyPressed(KEY_F))) ToggleFullscreen();
onTransition = true;
transFadeOut = false;
transFromScreen = currentScreen;
transToScreen = screen;
transAlpha = 0.0f;
}
switch(currentScreen) {
case TITLE:
if (IsKeyPressed(KEY_UP)) selected++;
if (IsKeyPressed(KEY_DOWN)) selected--;
if (selected > 0) selected--;
if (selected < -2) selected++;
static void update_transition(void)
{
if (!transFadeOut) {
transAlpha += GetFrameTime();
if ((selected == 0) && (IsKeyPressed(KEY_ENTER))) currentScreen = GAMEPLAY;
if ((selected == -1) && (IsKeyPressed(KEY_ENTER))) currentScreen = CREDITS;
if ((selected == -2) && (IsKeyPressed(KEY_ENTER))) OpenURL("https://gitdab.com/Canneddonuts/Avoid.git");
break;
case GAMEPLAY:
if (transAlpha > 1) {
transAlpha = 1;
if (IsKeyPressed(KEY_M)) mute = !mute;
switch (transFromScreen) {
case TITLE: UnloadTitleScreen(); break;
case GAMEPLAY: UnloadGameplayScreen(); break;
case GAMEOVER: UnloadGameoverScreen(); break;
case CREDITS: UnloadCreditsScreen(); break;
case OPTIONS: UnloadOptionsScreen(); break;
case ENDING: UnloadEndingScreen(); break;
case LEVELSEL: UnloadLevelSelScreen(); break;
default: break;
}
if (IsKeyPressed(KEY_ENTER)) pause = !pause;
switch (transToScreen) {
case TITLE: InitTitleScreen(); break;
case GAMEPLAY: LoadGamplayScreen(); InitGameplayScreen(); break;
case GAMEOVER: InitGameoverScreen(); break;
case CREDITS: InitCreditsScreen(); break;
case OPTIONS: InitOptionsScreen(); break;
case ENDING: InitEndingScreen(); break;
case LEVELSEL: InitLevelSelScreen(); break;
default: break;
}
if (!pause) {
// Controls
if (IsKeyDown(KEY_LEFT)) player.hitbox.x -= GetFrameTime() * 300.0f;
if (IsKeyDown(KEY_RIGHT)) player.hitbox.x += GetFrameTime() * 300.0f;
if (IsKeyDown(KEY_UP)) player.hitbox.y -= GetFrameTime() * 300.0f;
if (IsKeyDown(KEY_DOWN)) player.hitbox.y += GetFrameTime() * 300.0f;
currentScreen = transToScreen;
player.sprite_pos = (Vector2){ player.hitbox.x, player.hitbox.y };
player.frameRec.x = (float)player.currentframe*(float)player.sprite.width/2;
transFadeOut = true;
}
} else {
transAlpha -= GetFrameTime();
// Player to da wallz collies
if ((player.hitbox.x + player.hitbox.width) >= GetScreenWidth()) player.hitbox.x = GetScreenWidth() - player.hitbox.width;
else if (player.hitbox.x <= 0) player.hitbox.x = 0;
if ((player.hitbox.y + player.hitbox.height) >= GetScreenHeight()) player.hitbox.y = GetScreenHeight() - player.hitbox.height;
else if (player.hitbox.y <= 0) player.hitbox.y = 0;
if (IsKeyPressed(KEY_D)) ball.active = !ball.active;
if (IsKeyPressed(KEY_R)) { GameInit(); currentScreen = TITLE; }
if (ball.active) {
BallFrameCounter++;
// moveiement oof the balls
ball.position.x += GetFrameTime() * ball.speed.x;
ball.position.y += GetFrameTime() * ball.speed.y;
// Ballz to da wallz collies
if ((ball.position.x >= (GetScreenWidth() - ball.radius)) || (ball.position.x <= ball.radius)) {
ball.speed.x *= -1.0f;
if (!mute) PlaySoundMulti(fxbounce);
}
if ((ball.position.y >= (GetScreenHeight() - ball.radius)) || (ball.position.y <= ball.radius)) {
ball.speed.y *= -1.0f;
if (!mute) PlaySoundMulti(fxbounce);
}
if (CheckCollisionCircleRec(ball.position, ball.radius, player.hitbox)) {
player.hp--;
player.currentframe = 1;
} else player.currentframe = 0;
if (ball.radius <= 100) ball.radius += GetFrameTime() * ball.growth;
}
if (player.hp <= 0) currentScreen = GAMEOVER;
}
else pauseTimer++;
break;
case GAMEOVER:
if (IsKeyPressed(KEY_ENTER)) {
GameInit();
currentScreen = GAMEPLAY;
}
break;
case CREDITS:
if (IsKeyPressed(KEY_ENTER)) currentScreen = TITLE;
default: break;
if (transAlpha < 0) {
transAlpha = 0.0f;
transFadeOut = false;
onTransition = false;
transFromScreen = -1;
transToScreen = -1;
}
}
}
void DrawGame(void)
static void draw_transition(void)
{
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha));
}
static void update_draw_frame(void)
{
if (IsKeyPressed(KEY_M)) mute = !mute;
if ((IsKeyDown(KEY_LEFT_ALT)) && (IsKeyPressed(KEY_F))) { ToggleFullscreen(); fullscreen = !fullscreen; }
// printf("%f\n", GetFrameTime());
// printf("%f\n", transAlpha);
if (!onTransition) {
switch (currentScreen) {
case TITLE: {
UpdateTitleScreen();
switch (FinishTitleScreen()) {
case 1: transition_to_screen(CREDITS); break;
case 2: transition_to_screen(LEVELSEL); break;
case 3: transition_to_screen(OPTIONS); break;
}
} break;
case CREDITS: {
UpdateCreditsScreen();
if (FinishCreditsScreen() == 1) transition_to_screen(TITLE);
} break;
case GAMEPLAY: {
UpdateGameplayScreen();
switch (FinishGameplayScreen()) {
case 1: transition_to_screen(GAMEOVER); break;
case 2: transition_to_screen(TITLE); break;
case 3: transition_to_screen(ENDING); break;
case 4: transition_to_screen(LEVELSEL); break;
}
} break;
case GAMEOVER: {
UpdateGameoverScreen();
if (FinishGameoverScreen() == 1) transition_to_screen(TITLE);
else if (FinishGameoverScreen() == 2) transition_to_screen(GAMEPLAY);
} break;
case OPTIONS: {
UpdateOptionsScreen();
if (FinishOptionsScreen() == 1) transition_to_screen(TITLE);
} break;
case ENDING: {
UpdateEndingScreen();
if (FinishEndingScreen() == 1) transition_to_screen(TITLE);
} break;
case LEVELSEL: {
UpdateLevelSelScreen();
if (FinishLevelSelScreen() == 1) transition_to_screen(GAMEPLAY);
} break;
default: break;
}
} else update_transition();
BeginDrawing();
ClearBackground(RAYWHITE);
ClearBackground(RAYWHITE);
switch(currentScreen) {
case TITLE:
DrawRectangle(0, 0, screenWidth, screenHeight, ORANGE);
DrawText("Controls", 10, 10, 30, PURPLE);
DrawText("Press the arrow keys to move", 10, 40, 10, RED);
DrawText("Press 'ENTER' to pause", 10, 60, 10, RED);
DrawText("Press 'M' to mute", 10, 80, 10, RED);
DrawText("Press 'Left-ALT' + 'F' for full screen", 10, 100, 10, RED);
DrawText("Press 'R' to restart", 10, 120, 10, RED);
DrawText("Press 'ENTER' to select an option", 10, 140, 10, RED);
DrawText("Avoid", 330, 20, 50, BLUE);
if (selected == 0) DrawText("PLAY", 360, 220, 20, WHITE);
else DrawText("PLAY", 360, 220, 20, BLUE);
switch (currentScreen) {
case TITLE: DrawTitleScreen(); break;
case CREDITS: DrawCreditsScreen(); break;
case GAMEPLAY: DrawGameplayScreen(); break;
case GAMEOVER: DrawGameoverScreen(); break;
case OPTIONS: DrawOptionsScreen(); break;
case ENDING: DrawEndingScreen(); break;
case LEVELSEL: DrawLevelSelScreen(); break;
default: break;
}
if (selected == -1) DrawText("CREDITS", 340, 240, 20, WHITE);
else DrawText("CREDITS", 340, 240, 20, BLUE);
// DrawText(TextFormat("GetTime(): %f", GetTime()), 10, 320, 20, GREEN);
if (selected == -2) DrawText("SOURCE CODE", 315, 260, 20, WHITE);
else DrawText("SOURCE CODE", 315, 260, 20, BLUE);
break;
case GAMEPLAY:
DrawRectangle(0, 0, screenWidth, screenHeight, BLACK);
DrawFPS(10, 430);
DrawText(TextFormat("HP: %i", player.hp), 10, 10, 20, RED);
DrawText(TextFormat("BALL FRAMES: %i", BallFrameCounter), 10, 30, 20, BLUE);
DrawText(TextFormat("BALL SIZE: %f", ball.radius), 10, 50, 20, PINK);
if (ball.active) DrawCircleV(ball.position, (float)ball.radius, ball.color);
// DrawRectangleRec(player.hitbox, BLUE);
DrawTextureRec(player.sprite, player.frameRec, player.sprite_pos, WHITE);
if (pause && ((pauseTimer/30)%2)) DrawText("PAUSED", 330, 190, 30, PURPLE);
break;
case GAMEOVER:
DrawRectangle(0, 0, screenWidth, screenHeight, BLUE);
DrawText("GAMEOVER", 250, 20, 50, RED);
DrawText("PRESS ENTER TO RESET", 270, 220, 20, WHITE);
break;
case CREDITS:
DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
DrawText("Avoid", 330, 20, 50, PINK);
DrawText("Programming by M-C-O-B", 10, 210, 20, BLUE);
DrawText("Morale support by Tobi/Tobrella and Jelly_man", 10, 240, 20, BLUE);
DrawText("Powered by raylib 4.0", 10, 270, 20, BLUE);
DrawText("A Canneddonuts project 2022", 10, 310, 40, RED);
DrawText("Press 'ENTER' ", 10, 350, 20, WHITE);
break;
default: break;
}
if (onTransition) draw_transition();
EndDrawing();
}
void UpdateDrawFrame(void)
static void unloadGame(void)
{
UpdateGame();
DrawGame();
}
switch (currentScreen) {
case TITLE: UnloadTitleScreen(); break;
case GAMEPLAY: UnloadGameplayScreen(); break;
case GAMEOVER: UnloadGameoverScreen(); break;
case CREDITS: UnloadCreditsScreen(); break;
case OPTIONS: UnloadOptionsScreen(); break;
case ENDING: UnloadEndingScreen(); break;
case LEVELSEL: UnloadLevelSelScreen(); break;
default: break;
}
void UnloadGame(void)
{
UnloadSound(fxbounce);
UnloadTexture(player.sprite);
UnloadFont(ZadoBold);
UnloadTexture(background);
}

17
src/Music.h Normal file
View file

@ -0,0 +1,17 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Music.h
- Author ~ Return0ne
- 2022
- *no license*
*/
#ifndef MUSIC_HEADER
#define MUSIC_HEADER
extern Music Endingsong;
extern Music Gameoversong;
extern Music Gameplaysong;
extern Music Titlesong;
#endif

68
src/Options.c Normal file
View file

@ -0,0 +1,68 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Options.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include "Screens.h"
#include "Gfx.h"
#include "Controls.h"
#include "Options.h"
int optionsSelected = 0, finishfromOptionsScreen = 0, mute = 0, fullscreen = 0;
void InitOptionsScreen(void)
{
finishfromOptionsScreen = 0;
optionsSelected = 0;
}
void UpdateOptionsScreen(void)
{
if (INPUT_UP_PRESSED) optionsSelected++;
if (INPUT_DOWN_PRESSED) optionsSelected--;
if (optionsSelected > 0) optionsSelected--;
if (optionsSelected < -2) optionsSelected++;
if ((optionsSelected == 0) && (INPUT_OPTION_PRESSED)) finishfromOptionsScreen = 1;
if ((optionsSelected == -1) && (INPUT_OPTION_PRESSED)) mute = !mute;
if ((optionsSelected == -2) && (INPUT_OPTION_PRESSED)) { ToggleFullscreen(); fullscreen = !fullscreen; }
}
void DrawOptionsScreen(void)
{
DrawTexture(background, 0, 0, DARKGRAY);
DrawTextEx(ZadoBold, "OPTIONS", (Vector2){ 300, 20 }, 50, 2, BLUE);
if (optionsSelected == 0) DrawText("Back", 20, 170, 40, WHITE);
else DrawText("Back", 20, 170, 40, RED);
if (optionsSelected == -1) {
DrawText("Mute", 20, 220, 40, WHITE);
DrawText(TextFormat("<%i>", mute), 250, 220, 40, WHITE);
}
else {
DrawText("Mute", 20, 220, 40, BLUE);
DrawText(TextFormat("<%i>", mute), 250, 220, 40, BLUE);
}
if (optionsSelected == -2) {
DrawText("Fullscreen", 20, 270, 40, WHITE);
DrawText(TextFormat("<%i>", fullscreen), 250, 270, 40, WHITE);
}
else {
DrawText("Fullscreen", 20, 270, 40, BLUE);
DrawText(TextFormat("<%i>", fullscreen), 250, 270, 40, BLUE);
}
}
void UnloadOptionsScreen(void)
{
}
int FinishOptionsScreen(void)
{
return finishfromOptionsScreen;
}

15
src/Options.h Normal file
View file

@ -0,0 +1,15 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Options.h
- Author ~ Return0ne
- 2022
- *no license*
*/
#ifndef OPTIONS_HEADER
#define OPTIONS_HEADER
extern int mute;
extern int fullscreen;
#endif

64
src/Screens.h Normal file
View file

@ -0,0 +1,64 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Screens.h
- Author ~ Return0ne
- 2022
- *no license*
*/
#ifndef SCREENS_HEADER
#define SCREENS_HEADER
typedef enum GameScreen { TITLE = 0, GAMEPLAY, GAMEOVER, CREDITS, OPTIONS, ENDING, LEVELSEL } GameScreen;
typedef enum Levels { LEVEL1 = 0, LEVEL2, LEVEL3 } Levels;
extern GameScreen currentScreen;
extern Levels level;
extern int nextlevel;
extern bool levelunlocked[3];
void InitTitleScreen(void);
void UpdateTitleScreen(void);
void DrawTitleScreen(void);
void UnloadTitleScreen(void);
int FinishTitleScreen(void);
void InitGameplayScreen(void);
void UpdateGameplayScreen(void);
void DrawGameplayScreen(void);
void UnloadGameplayScreen(void);
void LoadGamplayScreen(void);
int FinishGameplayScreen(void);
void InitCreditsScreen(void);
void UpdateCreditsScreen(void);
void DrawCreditsScreen(void);
void UnloadCreditsScreen(void);
int FinishCreditsScreen(void);
void InitGameoverScreen(void);
void UpdateGameoverScreen(void);
void DrawGameoverScreen(void);
void UnloadGameoverScreen(void);
int FinishGameoverScreen(void);
void InitOptionsScreen(void);
void UpdateOptionsScreen(void);
void DrawOptionsScreen(void);
void UnloadOptionsScreen(void);
int FinishOptionsScreen(void);
void InitEndingScreen(void);
void UpdateEndingScreen(void);
void DrawEndingScreen(void);
void UnloadEndingScreen(void);
int FinishEndingScreen(void);
void InitLevelSelScreen(void);
void UpdateLevelSelScreen(void);
void DrawLevelSelScreen(void);
void UnloadLevelSelScreen(void);
int FinishLevelSelScreen(void);
#endif

15
src/Stats.h Normal file
View file

@ -0,0 +1,15 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Stats.h
- Author ~ Return0ne
- 2022
- *no license*
*/
#ifndef STATS_HEADER
#define STATS_HEADER
extern int score;
extern int greenfeathers;
#endif

16
src/Timers.h Normal file
View file

@ -0,0 +1,16 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Timers.h
- Author ~ Return0ne
- 2022
- *no license*
*/
#ifndef TIMERS_HEADER
#define TIMERS_HEADER
extern float pauseTimer;
extern float globalTimer;
extern float scoreTimer;
#endif

74
src/Title.c Normal file
View file

@ -0,0 +1,74 @@
/*
- Avoid ~ a game by Canneddonuts
- Filename ~ Title.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include "Screens.h"
#include "Controls.h"
#include "Music.h"
#include "Options.h"
#include "Gfx.h"
int titleSelected = 0, finishfromTitleScreen = 0;
Music Titlesong = { 0 };
void InitTitleScreen(void)
{
titleSelected = 0;
finishfromTitleScreen = 0;
Titlesong = LoadMusicStream("assets/bgm/04-Distant-Misadventure.ogg");
PlayMusicStream(Titlesong);
}
void UpdateTitleScreen(void)
{
if (!mute) UpdateMusicStream(Titlesong);
if (INPUT_UP_PRESSED) titleSelected++;
if (INPUT_DOWN_PRESSED) titleSelected--;
if (titleSelected > 0) titleSelected--;
if (titleSelected < -2) titleSelected++;
if ((titleSelected == 0) && (INPUT_OPTION_PRESSED)) { StopMusicStream(Titlesong); finishfromTitleScreen = 2; }
if ((titleSelected == -1) && (INPUT_OPTION_PRESSED)) { StopMusicStream(Titlesong); finishfromTitleScreen = 1; }
if ((titleSelected == -2) && (INPUT_OPTION_PRESSED)) { StopMusicStream(Titlesong); finishfromTitleScreen = 3; }
}
void DrawTitleScreen(void)
{
DrawTexture(background, 0, 0, GRAY);
DrawTextEx(ZadoBold, "Avoid", (Vector2){ 300, 0 }, 80, 5, BLUE);
DrawText("Controls", 5, 10, 30, BLUE);
DrawText("Press the arrow keys or 'DPAD' to move and 'X' to dash", 5, 40, 10, WHITE);
DrawText("Press 'ENTER' or 'START' to pause", 5, 60, 10, WHITE);
DrawText("Press 'M' to mute", 5, 80, 10, WHITE);
DrawText("Press 'Left-ALT' + 'F' for full screen", 5, 100, 10, WHITE);
DrawText("Press 'R' to restart", 5, 120, 10, WHITE);
DrawText("Press 'ENTER' or 'START' to select an option", 5, 140, 10, WHITE);
DrawText("Press 'Z' or 'A' on a gamepad to shoot", 5, 160, 10, WHITE);
DrawText("Press 'Q' to return to level select", 5, 180, 10, WHITE);
DrawText("Remember to shoot down the fireworks.", 5, 200, 10, RED);
// DrawText("Ver: 0.1", 680, 420, 30, WHITE);
if (titleSelected == 0) DrawTextEx(ZadoBold,"PLAY", (Vector2){ 360, 220 }, 30, 2, WHITE);
else DrawTextEx(ZadoBold,"PLAY", (Vector2){ 360, 220 }, 30, 2, BLUE);
if (titleSelected == -1) DrawTextEx(ZadoBold, "CREDITS", (Vector2){ 330, 250 }, 30, 2, WHITE);
else DrawTextEx(ZadoBold, "CREDITS", (Vector2){ 330, 250 }, 30, 2, BLUE);
if (titleSelected == -2) DrawTextEx(ZadoBold, "OPTIONS", (Vector2){ 330, 280 }, 30, 2, WHITE);
else DrawTextEx(ZadoBold, "OPTIONS", (Vector2){ 330, 280 }, 30, 2, BLUE);
}
void UnloadTitleScreen(void)
{
UnloadMusicStream(Titlesong);
}
int FinishTitleScreen(void)
{
return finishfromTitleScreen;
}