瀏覽代碼

Review templates for Android

- Removed useless templates
- Reviewed all Makefiles
- Rework some code for Android support
- Added resources to advance template
raysan5 8 年之前
父節點
當前提交
0d8a994d95

+ 157 - 154
templates/advance_game/Makefile

@@ -1,6 +1,6 @@
 #**************************************************************************************************
 #
-#   raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
+#   raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
 #
 #   Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
 #
@@ -23,29 +23,30 @@
 
 .PHONY: all clean
 
-# define raylib platform to compile for
-# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
+# Define required raylib variables
 # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
 PLATFORM ?= PLATFORM_DESKTOP
+RAYLIB_PATH ?= ..\..
+PROJECT_NAME ?= advance_game
 
-# define NO to use OpenAL Soft as static library (shared by default)
-SHARED_OPENAL ?= NO
+# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
+# NOTE: Libraries should be provided in the selected form
+RAYLIB_LIBTYPE ?= STATIC
+OPENAL_LIBTYPE ?= STATIC
 
+# On PLATFORM_WEB force OpenAL Soft shared library
 ifeq ($(PLATFORM),PLATFORM_WEB)
-    SHARED_OPENAL = NO
+    OPENAL_LIBTYPE = SHARED
 endif
 
-# define raylib directory for include and library
-RAYLIB_PATH ?= C:\raylib\raylib
-
-# determine PLATFORM_OS in case PLATFORM_DESKTOP selected
+# 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
         LIBPATH=win32
     else
-        UNAMEOS:=$(shell uname)
+        UNAMEOS=$(shell uname)
         ifeq ($(UNAMEOS),Linux)
             PLATFORM_OS=LINUX
             LIBPATH=linux
@@ -58,214 +59,220 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
     endif
 endif
 
-# define compiler: gcc for C program, define as g++ for C++
-ifeq ($(PLATFORM),PLATFORM_WEB)
-    # define emscripten compiler
-    CC = emcc
-else
-ifeq ($(PLATFORM_OS),OSX)
-    # define llvm compiler for mac
-    CC = clang
-else
-    # define default gcc compiler
-    CC = gcc
+ifeq ($(PLATFORM),PLATFORM_RPI)
+    # RPI cross-compiler
+    RPI_CROSS_COMPILE ?= NO
 endif
+
+ifeq ($(PLATFORM),PLATFORM_WEB)
+    # Emscripten required variables
+    EMSDK_PATH = C:/emsdk
+    EMSCRIPTEN_VERSION = 1.37.9
+    CLANG_VERSION=e1.37.9_64bit
+    PYTHON_VERSION=2.7.5.3_64bit
+    NODE_VERSION=4.1.1_64bit
+    export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
+    EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
 endif
 
-# define compiler flags:
-#  -O2                  defines optimization level
-#  -Og                  enable debugging
-#  -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)
-#  -fgnu89-inline       declaring inline functions support (GCC optimized)
-#  -Wno-missing-braces  ignore invalid warning (GCC bug 53119)
-#  -D_DEFAULT_SOURCE    use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
+# Define raylib release directory for compiled library
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
     ifeq ($(PLATFORM_OS),WINDOWS)
-        CFLAGS = -O2 -s -Wall -std=c99
+        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32
     endif
     ifeq ($(PLATFORM_OS),LINUX)
-        CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE
+        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux
     endif
     ifeq ($(PLATFORM_OS),OSX)
-        CFLAGS = -O2 -s -Wall -std=c99
+        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx
     endif
 endif
 ifeq ($(PLATFORM),PLATFORM_WEB)
-    CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=67108864 --profiling --preload-file resources
-    # -O2                         # if used, also set --memory-init-file 0
-    # --memory-init-file 0        # to avoid an external memory initialization code file (.mem)
-    # -s ALLOW_MEMORY_GROWTH=1    # to allow memory resizing
-    # -s TOTAL_MEMORY=16777216    # to specify heap memory size (default = 16MB)
-    # --preload-file file.res     # embbed file.res resource into .data file
+    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
 endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
-    CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline
+    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/rpi
 endif
-#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
 
-# define raylib release directory for compiled library
+# Define default C compiler: gcc
+CC = gcc
+
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32
-    endif
-    ifeq ($(PLATFORM_OS),LINUX)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux
-    endif
     ifeq ($(PLATFORM_OS),OSX)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx
+        # OSX default compiler
+        CC = clang
     endif
 endif
-ifeq ($(PLATFORM),PLATFORM_WEB)
-    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5
-endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
-    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi
+    ifeq ($(RPI_CROSS_COMPILE),YES)
+        # RPI cross-compiler
+        CC = armv6j-hardfloat-linux-gnueabi-gcc
+    endif
+endif
+ifeq ($(PLATFORM),PLATFORM_WEB)
+    # HTML5 emscripten compiler
+    CC = emcc
 endif
 
-# define any directories containing required header files
-INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external 
+# Define default make program: Mingw32-make
+MAKE = mingw32-make
 
-ifeq ($(PLATFORM),PLATFORM_RPI)
-    INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
-endif
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        # external libraries headers
-        # GLFW3
-            INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include
-        # OpenAL Soft
-            INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include
-    endif
     ifeq ($(PLATFORM_OS),LINUX)
-        # you may optionally create this directory and install raylib 
-        # and related headers there. Edit ../src/Makefile appropriately.
-            INCLUDES += -I/usr/local/include/raylib
+        MAKE = make
     endif
-    ifeq ($(PLATFORM_OS),OSX)
-        # additional directories for MacOS
+endif
+
+# Define compiler flags:
+#  -O1                  defines optimization level
+#  -Og                  enable debugging
+#  -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)
+#  -fgnu89-inline       declaring inline functions support (GCC optimized)
+#  -Wno-missing-braces  ignore invalid warning (GCC bug 53119)
+#  -D_DEFAULT_SOURCE    use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
+CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
+
+# Additional flags for compiler (if desired)
+#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
+ifeq ($(PLATFORM),PLATFORM_DESKTOP)
+    ifeq ($(PLATFORM_OS),LINUX)
+        CFLAGS += -no-pie -D_DEFAULT_SOURCE
     endif
 endif
+ifeq ($(PLATFORM),PLATFORM_RPI)
+    CFLAGS += -std=gnu99
+endif
+ifeq ($(PLATFORM),PLATFORM_WEB)
+    # -O2                        # if used, also set --memory-init-file 0
+    # --memory-init-file 0       # to avoid an external memory initialization code file (.mem)
+    # -s ALLOW_MEMORY_GROWTH=1   # to allow memory resizing
+    # -s TOTAL_MEMORY=16777216   # to specify heap memory size (default = 16MB)
+    # -s USE_PTHREADS=1          # multithreading support
+    CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s TOTAL_MEMORY=16777216 --preload-file resources
+endif
 
-# define library paths containing required libs
-LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src 
+# Define include paths for required headers
+# NOTE: Several external required libraries (stb and others)
+INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
 
+# Define additional directories containing required header files
 ifeq ($(PLATFORM),PLATFORM_RPI)
-    LFLAGS += -L/opt/vc/lib
+    # RPI requried libraries
+    INCLUDE_PATHS += -I/opt/vc/include
+    INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
+    INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
 endif
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    # add standard directories for GNU/Linux
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        # external libraries to link with
-        # GLFW3
-            LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH)
-        # OpenAL Soft
-            LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH)
-    endif
+
+# Define library paths containing required libs
+LDFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src 
+
+ifeq ($(PLATFORM),PLATFORM_RPI)
+    LDFLAGS += -L/opt/vc/lib
 endif
 
-# define any libraries to link into executable
+# Define any libraries required on linking
 # if you want to link libraries (libname.so or libname.a), use the -lname
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),LINUX)
-        # libraries for Debian GNU/Linux desktop compiling
-        # requires the following packages:
-        # libglfw3-dev libopenal-dev libegl1-mesa-dev
-        LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
-        # on XWindow requires also below libraries
-        LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
-    else
-    ifeq ($(PLATFORM_OS),OSX)
-        # libraries for OSX 10.9 desktop compiling
-        # requires the following packages:
-        # libglfw3-dev libopenal-dev libegl1-mesa-dev
-        LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
-    else
-        # libraries for Windows desktop compiling
+    ifeq ($(PLATFORM_OS),WINDOWS)
+        # Libraries for Windows desktop compiling
         # NOTE: GLFW3 and OpenAL Soft libraries should be installed
-        LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
-        # if static OpenAL Soft required, define the corresponding libs
-        ifeq ($(SHARED_OPENAL),NO)
-            LIBS += -lopenal32 -lwinmm
-            CFLAGS += -Wl,-allow-multiple-definition
+        LDLIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
+
+        # Define required flags and libs for OpenAL Soft STATIC/SHARED usage
+        # NOTE: ALLIBS flag only required for raylib Win32 SHARED library building
+        ifeq ($(OPENAL_LIBTYPE),STATIC)
+            LDLIBS += -lopenal32 -lwinmm
+            CFLAGS += -DAL_LIBTYPE_STATIC -Wl,-allow-multiple-definition
         else
-            LIBS += -lopenal32dll
+            LDLIBS += -lopenal32dll
         endif
     endif
+    ifeq ($(PLATFORM_OS),LINUX)
+        # Libraries for Debian GNU/Linux desktop compiling
+        # NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
+        LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
+        
+        # On XWindow requires also below libraries
+        LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
+    endif
+    ifeq ($(PLATFORM_OS),OSX)
+        # Libraries for OSX 10.9 desktop compiling
+        # NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
+        LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
     endif
 endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
-    # libraries for Raspberry Pi compiling
-    # NOTE: OpenAL Soft library should be installed (libopenal1 package)
-    LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
+    # Libraries for Raspberry Pi compiling
+    # NOTE: Required packages: libopenal1
+    LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
 endif
 ifeq ($(PLATFORM),PLATFORM_WEB)
-    # NOTE: Set the correct path to libraylib.bc
-    LIBS = $(RAYLIB_RELEASE)/libraylib.bc
+    # Libraries for web (HTML5) compiling
+    LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc
 endif
 
-# define additional parameters and flags for windows
+# Define additional parameters and flags for windows
 ifeq ($(PLATFORM_OS),WINDOWS)
-    # resources file contains windows exe icon
+    # resources file contains raylib icon for windows .exe
     # -Wl,--subsystem,windows hides the console window
     WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
 endif
 
+# Define output extension to generate a .html file using provided shell
 ifeq ($(PLATFORM),PLATFORM_WEB)
     EXT = .html
     WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
 endif
 
-# define all screen object files required
-SCREENS = \
-	screens/screen_logo.o \
-	screens/screen_title.o \
-	screens/screen_options.o \
-	screens/screen_gameplay.o \
-	screens/screen_ending.o \
-
-# typing 'make' will invoke the default target entry called 'all',
-# in this case, the 'default' target entry is advance_game
-all: advance_game
+# Define all source files required
+PROJECT_SOURCE_FILES ?= advance_game.c \
+                        screens/screen_logo.c \
+                        screens/screen_title.c \
+                        screens/screen_options.c \
+                        screens/screen_gameplay.c \
+                        screens/screen_ending.c
 
-# compile template - advance_game
-advance_game: advance_game.c $(SCREENS)
-	$(CC) -o $@$(EXT) $< $(SCREENS) $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+# Define all object files from source files
+OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
 
-# compile screen LOGO
-screens/screen_logo.o: screens/screen_logo.c
-	$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
-
-# compile screen TITLE
-screens/screen_title.o: screens/screen_title.c
-	$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
+# 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
 
-# compile screen OPTIONS
-screens/screen_options.o: screens/screen_options.c
-	$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
+# Default target entry
+# NOTE: We call this Makefile target or Makefile.Android target
+all:
+	$(MAKE) $(MAKEFILE_PARAMS)
 
-# compile screen GAMEPLAY
-screens/screen_gameplay.o: screens/screen_gameplay.c
-	$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
+# Project target defined by PROJECT_NAME
+$(PROJECT_NAME): $(OBJS)
+	$(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(WINFLAGS)
 
-# compile screen ENDING
-screens/screen_ending.o: screens/screen_ending.c
-	$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -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 everything
 clean:
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),OSX)
-		find . -type f -perm +ugo+x -delete
-		rm -f *.o
-    else
+    ifeq ($(PLATFORM_OS),WINDOWS)
+		del *.o *.exe /s
+    endif
     ifeq ($(PLATFORM_OS),LINUX)
 		find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
-    else
-		del *.o *.exe /s
     endif
+    ifeq ($(PLATFORM_OS),OSX)
+		find . -type f -perm +ugo+x -delete
+		rm -f *.o
     endif
 endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
@@ -277,7 +284,3 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
 endif
 	@echo Cleaning done
 
-# instead of defining every module one by one, we can define a pattern
-# this pattern below will automatically compile every module defined on $(OBJS)
-#%.exe : %.c
-#	$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM)

+ 287 - 0
templates/advance_game/Makefile.Android

@@ -0,0 +1,287 @@
+#**************************************************************************************************
+#
+#   raylib makefile for Android project (APK building)
+#
+#   Copyright (c) 2017 Ramon Santamaria (@raysan5)
+#
+#   This software is provided "as-is", without any express or implied warranty. In no event
+#   will the authors be held liable for any damages arising from the use of this software.
+#
+#   Permission is granted to anyone to use this software for any purpose, including commercial
+#   applications, and to alter it and redistribute it freely, subject to the following restrictions:
+#
+#     1. The origin of this software must not be misrepresented; you must not claim that you
+#     wrote the original software. If you use this software in a product, an acknowledgment
+#     in the product documentation would be appreciated but is not required.
+#
+#     2. Altered source versions must be plainly marked as such, and must not be misrepresented
+#     as being the original software.
+#
+#     3. This notice may not be removed or altered from any source distribution.
+#
+#**************************************************************************************************
+
+# Define required raylib variables
+PLATFORM ?= PLATFORM_ANDROID
+RAYLIB_PATH ?= ..\..
+
+# Required path variables
+# NOTE: JAVA_HOME must be set to JDK
+ANDROID_HOME = C:/android-sdk
+ANDROID_NDK = C:/android-ndk
+ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16
+ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/26.0.2
+ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
+JAVA_HOME = C:/PROGRA~1/Java/jdk1.8.0_144
+
+# Android project configuration variables
+PROJECT_NAME ?= raylib_game
+PROJECT_LIBRARY_NAME ?= main
+PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME)
+PROJECT_RESOURCES_PATH ?= resources
+PROJECT_SOURCE_FILES ?= raylib_game.c
+
+# Some source files are placed in directories, when compiling to some 
+# output directory other than source, that directory must pre-exist.
+# Here we get a list of required folders that need to be created on
+# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors.
+PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES)))
+
+# Android app configuration variables
+APP_LABEL_NAME ?= rGame
+APP_COMPANY_NAME ?= raylib
+APP_PRODUCT_NAME ?= rgame
+APP_VERSION_CODE ?= 1
+APP_VERSION_NAME ?= 1.0
+APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png
+APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png
+APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png
+APP_SCREEN_ORIENTATION ?= landscape
+APP_KEYSTORE_PASS ?= raylib
+
+# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
+RAYLIB_LIBTYPE ?= STATIC
+OPENAL_LIBTYPE ?= STATIC
+RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
+OPENAL_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
+
+# Shared libs must be added to APK if required
+# NOTE: Generated NativeLoader.java automatically load those libraries
+ifeq ($(RAYLIB_LIBTYPE),SHARED)
+    PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so 
+endif
+ifeq ($(OPENAL_LIBTYPE),SHARED)
+    PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
+endif
+
+# Compiler and archiver
+# NOTE: GCC is being deprectated in Android NDK r16
+CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-gcc
+AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
+
+# Compiler flags for arquitecture
+CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
+# Compilation functions attributes options
+CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
+# Compiler options for the linker
+CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes
+# Preprocessor macro definitions
+CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=16
+
+# Paths containing required header files
+INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src/external/android/native_app_glue
+
+# Linker options
+LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a 
+LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings 
+# Force linking of library module to define symbol
+LDFLAGS += -u ANativeActivity_onCreate
+# Library paths containing required libs
+LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/armeabi-v7a
+
+# Define any libraries to link into executable
+# if you want to link libraries (libname.so or libname.a), use the -lname
+LDLIBS = -lraylib -lnative_app_glue -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
+
+# Generate target objects list from PROJECT_SOURCE_FILES
+OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
+
+# Android APK building process... some steps required...
+# NOTE: typing 'make' will invoke the default target entry called 'all',
+all: create_temp_project_dirs \
+     copy_project_required_libs \
+     copy_project_resources \
+     generate_loader_script \
+     generate_android_manifest \
+     generate_apk_keystore \
+     config_project_package \
+     compile_native_app_glue \
+     compile_project_code \
+     compile_project_class \
+     compile_project_class_dex \
+     create_project_apk_package \
+     sign_project_apk_package \
+     zipalign_project_apk_package
+
+# Create required temp directories for APK building
+create_temp_project_dirs:
+	if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH) 
+	if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj
+	if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src
+	if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com
+	if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)
+	if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME)
+	if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib
+	if not exist $(PROJECT_BUILD_PATH)\lib\armeabi-v7a mkdir $(PROJECT_BUILD_PATH)\lib\armeabi-v7a
+	if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin
+	if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res
+	if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi
+	if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi
+	if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi
+	if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values
+	if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets
+	if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens
+	$(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir)))
+
+define create_dir
+    if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1)
+endef
+    
+# Copy required shared libs for integration into APK
+# NOTE: If using shared libs they are loaded by generated NativeLoader.java
+copy_project_required_libs:
+ifeq ($(RAYLIB_LIBTYPE),SHARED)
+	copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so 
+endif
+ifeq ($(OPENAL_LIBTYPE),SHARED)
+	copy /Y $(OPENAL_LIB_PATH)\libopenal.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.so
+endif
+ifeq ($(RAYLIB_LIBTYPE),STATIC)
+	copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a 
+endif
+ifeq ($(OPENAL_LIBTYPE),STATIC)
+	copy /Y $(OPENAL_LIB_PATH)\libopenal.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.a
+endif
+
+# Copy project required resources: strings.xml, icon.png, assets
+# NOTE: Required strings.xml is generated and game resources are copied to assets folder
+copy_project_resources:
+	copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y
+	copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y
+	copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y
+	@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/res/values/strings.xml
+	@echo ^<resources^>^<string name="app_name"^>$(APP_LABEL_NAME)^</string^>^</resources^> >> $(PROJECT_BUILD_PATH)/res/values/strings.xml
+	if exist $(PROJECT_RESOURCES_PATH) xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets /Y /E /F
+
+# Generate NativeLoader.java to load required shared libraries
+# NOTE: Probably not the bet way to generate this file... but it works.
+generate_loader_script:
+	@echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+	@echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+	@echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+	@echo     static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+ifeq ($(OPENAL_LIBTYPE),SHARED)
+	@echo         System.loadLibrary("openal"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+endif
+ifeq ($(RAYLIB_LIBTYPE),SHARED)
+	@echo         System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+endif
+	@echo         System.loadLibrary("raylib_game"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java 
+	@echo     } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+	@echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+    
+# Generate AndroidManifest.xml with all the required options
+# NOTE: Probably not the bet way to generate this file... but it works.
+generate_android_manifest:
+	@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo ^<manifest xmlns:android="http://schemas.android.com/apk/res/android" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo         package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)"  >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo         android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo     ^<uses-sdk android:minSdkVersion="16" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo     ^<uses-feature android:glEsVersion="0x00020000" android:required="true" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo     ^<application android:allowBackup="false" android:label="@string/app_name" android:icon="@drawable/icon" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo         ^<activity android:name="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME).NativeLoader" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             ^<meta-data android:name="android.app.lib_name" android:value="$(PROJECT_LIBRARY_NAME)" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             ^<intent-filter^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo                 ^<action android:name="android.intent.action.MAIN" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo                 ^<category android:name="android.intent.category.LAUNCHER" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             ^</intent-filter^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo         ^</activity^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo     ^</application^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo ^</manifest^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+
+# Generate storekey for APK signing: $(PROJECT_NAME).keystore
+# NOTE: Configure here your Distinguished Names (-dname) if required!
+generate_apk_keystore: 
+	if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA
+
+# Config project package and resource using AndroidManifest.xml and res/values/strings.xml
+# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java
+config_project_package:
+	$(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-16/android.jar
+
+# Compile native_app_glue code as static library: obj/libnative_app_glue.a
+compile_native_app_glue:
+	$(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS)
+	$(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o
+
+# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so 
+compile_project_code: $(OBJS)
+	$(CC) -o $(PROJECT_BUILD_PATH)/lib/armeabi-v7a/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS)
+
+# Compile all .c files required into object (.o) files
+# NOTE: Those files will be linked into a shared library
+$(PROJECT_BUILD_PATH)/obj/%.o:%.c
+	$(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot 
+    
+# Compile project .java code into .class (Java bytecode) 
+compile_project_class:
+	$(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-16/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+
+# Compile .class files into Dalvik executable bytecode (.dex)
+# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT)
+compile_project_class_dex:
+	$(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj
+
+# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk
+# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so
+# NOTE: Use -A resources to define additional directory in which to find raw asset files
+create_project_apk_package:
+	$(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-16/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin
+	cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/armeabi-v7a/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS)
+
+# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk 
+sign_project_apk_package:
+	$(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key
+
+# Create zip-aligned APK package: $(PROJECT_NAME).apk 
+zipalign_project_apk_package:
+	$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk
+
+# Install $(PROJECT_NAME).apk to default emulator/device
+# NOTE: Use -e (emulator) or -d (device) parameters if required
+install:
+	$(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk
+
+# Monitorize output log coming from device, only raylib tag
+logcat:
+	$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
+	$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
+    
+# Install and monitorize $(PROJECT_NAME).apk to default emulator/device
+deploy:
+	$(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk
+	$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
+	$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
+
+#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W
+
+# Clean everything
+clean:
+	del $(PROJECT_BUILD_PATH)\* /f /s /q
+	rmdir $(PROJECT_BUILD_PATH) /s /q
+	@echo Cleaning done

+ 195 - 130
templates/advance_game/advance_game.c

@@ -8,7 +8,7 @@
 *   This game has been created using raylib (www.raylib.com)
 *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 *
-*   Copyright (c) 2014 Ramon Santamaria (@raysan5)
+*   Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
 *
 ********************************************************************************************/
 
@@ -19,23 +19,36 @@
     #include "android_native_app_glue.h"
 #endif
 
+#if defined(PLATFORM_WEB)
+    #include <emscripten/emscripten.h>
+#endif
+
 //----------------------------------------------------------------------------------
 // Global Variables Definition (local to this module)
 //----------------------------------------------------------------------------------
+const int screenWidth = 800;
+const int screenHeight = 450;
 
 // Required variables to manage screen transitions (fade-in, fade-out)
-float transAlpha = 0;
-bool onTransition = false;
-bool transFadeOut = false;
-int transFromScreen = -1;
-int transToScreen = -1;
+static float transAlpha = 0.0f;
+static bool onTransition = false;
+static bool transFadeOut = false;
+static int transFromScreen = -1;
+static int transToScreen = -1;
+
+// NOTE: Some global variables that require to be visible for all screens,
+// are defined in screens.h (i.e. currentScreen)
     
 //----------------------------------------------------------------------------------
 // Local Functions Declaration
 //----------------------------------------------------------------------------------
-void TransitionToScreen(int screen);
-void UpdateTransition(void);
-void DrawTransition(void);
+static void ChangeToScreen(int screen);     // No transition effect
+
+static void TransitionToScreen(int screen);
+static void UpdateTransition(void);
+static void DrawTransition(void);
+
+static void UpdateDrawFrame(void);          // Update and Draw one frame
 
 //----------------------------------------------------------------------------------
 // Main entry point
@@ -46,133 +59,122 @@ void android_main(struct android_app *app)
 int main(void)
 #endif
 {
-	// Initialization
-	//---------------------------------------------------------
-    const int screenWidth = 800;
-    const int screenHeight = 450;
-
+    // Initialization
+    //---------------------------------------------------------
 #if defined(PLATFORM_ANDROID)
     InitWindow(screenWidth, screenHeight, app);
 #else
-    InitWindow(screenWidth, screenHeight, "raylib template - standard game");
+    InitWindow(screenWidth, screenHeight, "raylib template - advance game");
 #endif
-    // TODO: Load global data here (assets that must be available in all screens, i.e. fonts)
+
+    // Global data loading (assets that must be available in all screens, i.e. fonts)
+    InitAudioDevice();
+
+    font = LoadSpriteFont("resources/mecha.png");
+    music = LoadMusicStream("resources/ambient.ogg");
+    fxCoin = LoadSound("resources/coin.wav");
     
+    SetMusicVolume(music, 1.0f);
+    PlayMusicStream(music);
+
     // Setup and Init first screen
     currentScreen = LOGO;
     InitLogoScreen();
-    
-	SetTargetFPS(60);
-	//----------------------------------------------------------
+
+#if defined(PLATFORM_WEB)
+    emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
+#else
+    SetTargetFPS(60);   // Set our game to run at 60 frames-per-second
+    //--------------------------------------------------------------------------------------
 
     // Main game loop
     while (!WindowShouldClose())    // Detect window close button or ESC key
     {
-        // Update
-        //----------------------------------------------------------------------------------
-        if (!onTransition)
-        {
-            switch(currentScreen) 
-            {
-                case LOGO: 
-                {
-                    UpdateLogoScreen();
-                    
-                    if (FinishLogoScreen()) TransitionToScreen(TITLE);
-                    
-                } break;
-                case TITLE: 
-                {
-                    UpdateTitleScreen();
-                    
-                    if (FinishTitleScreen() == 1) TransitionToScreen(OPTIONS);
-                    else if (FinishTitleScreen() == 2) TransitionToScreen(GAMEPLAY);
-
-                } break;
-                case OPTIONS:
-                {
-                    UpdateOptionsScreen();
-                    
-                    if (FinishOptionsScreen()) TransitionToScreen(TITLE);
-
-                } break;
-                case GAMEPLAY:
-                { 
-                    UpdateGameplayScreen();
-                    
-                    if (FinishGameplayScreen()) TransitionToScreen(ENDING);
-  
-                } break;
-                case ENDING: 
-                {
-                    UpdateEndingScreen();
-                    
-                    if (FinishEndingScreen()) TransitionToScreen(TITLE);
-
-                } break;
-                default: break;
-            }
-        }
-        else
-        {
-            // Update transition (fade-in, fade-out)
-            UpdateTransition();
-        }
-        //----------------------------------------------------------------------------------
-        
-        // Draw
-        //----------------------------------------------------------------------------------
-        BeginDrawing();
-        
-            ClearBackground(RAYWHITE);
-            
-            switch(currentScreen) 
-            {
-                case LOGO: DrawLogoScreen(); break;
-                case TITLE: DrawTitleScreen(); break;
-                case OPTIONS: DrawOptionsScreen(); break;
-                case GAMEPLAY: DrawGameplayScreen(); break;
-                case ENDING: DrawEndingScreen(); break;
-                default: break;
-            }
-            
-            if (onTransition) DrawTransition();
-        
-            //DrawFPS(10, 10);
-        
-        EndDrawing();
-        //----------------------------------------------------------------------------------
+        UpdateDrawFrame();
     }
+#endif
 
     // De-Initialization
     //--------------------------------------------------------------------------------------
     
-    // TODO: Unload all global loaded data (i.e. fonts) here!
+    // Unload current screen data before closing
+    switch (currentScreen)
+    {
+        case LOGO: UnloadLogoScreen(); break;
+        case TITLE: UnloadTitleScreen(); break;
+        case GAMEPLAY: UnloadGameplayScreen(); break;
+        case ENDING: UnloadEndingScreen(); break;
+        default: break;
+    }
+    
+    // Unload all global loaded data (i.e. fonts) here!
+    UnloadSpriteFont(font);
+    UnloadMusicStream(music);
+    UnloadSound(fxCoin);
+
+    CloseAudioDevice();     // Close audio context
     
-    CloseWindow();        // Close window and OpenGL context
+    CloseWindow();          // Close window and OpenGL context
     //--------------------------------------------------------------------------------------
 #if !defined(PLATFORM_ANDROID)
     return 0;
 #endif
 }
 
-void TransitionToScreen(int screen)
+//----------------------------------------------------------------------------------
+// Module specific Functions Definition
+//----------------------------------------------------------------------------------
+
+// Change to next screen, no transition
+static void ChangeToScreen(int screen)
+{
+    // Unload current screen
+    switch (currentScreen)
+    {
+        case LOGO: UnloadLogoScreen(); break;
+        case TITLE: UnloadTitleScreen(); break;
+        case GAMEPLAY: UnloadGameplayScreen(); break;
+        case ENDING: UnloadEndingScreen(); break;
+        default: break;
+    }
+    
+    // Init next screen
+    switch (screen)
+    {
+        case LOGO: InitLogoScreen(); break;
+        case TITLE: InitTitleScreen(); break;
+        case GAMEPLAY: InitGameplayScreen(); break;
+        case ENDING: InitEndingScreen(); break;
+        default: break;
+    }
+    
+    currentScreen = screen;
+}
+
+// Define transition to next screen
+static void TransitionToScreen(int screen)
 {
     onTransition = true;
+    transFadeOut = false;
     transFromScreen = currentScreen;
     transToScreen = screen;
+    transAlpha = 0.0f;
 }
 
-void UpdateTransition(void)
+// Update transition effect
+static void UpdateTransition(void)
 {
     if (!transFadeOut)
     {
-        transAlpha += 0.01;
-
-        if (transAlpha >= 1.0)
+        transAlpha += 0.02f;
+        
+        // NOTE: Due to float internal representation, condition jumps on 1.0f instead of 1.05f
+        // For that reason we compare against 1.01f, to avoid last frame loading stop
+        if (transAlpha > 1.01f)
         {
-            transAlpha = 1.0;
+            transAlpha = 1.0f;
         
+            // Unload current screen
             switch (transFromScreen)
             {
                 case LOGO: UnloadLogoScreen(); break;
@@ -183,46 +185,29 @@ void UpdateTransition(void)
                 default: break;
             }
             
+            // Load next screen
             switch (transToScreen)
             {
-                case LOGO:
-                {
-                    InitLogoScreen(); 
-                    currentScreen = LOGO; 
-                } break;
-                case TITLE: 
-                {
-                    InitTitleScreen();
-                    currentScreen = TITLE;                  
-                } break;
-                case OPTIONS:
-                {
-                    InitOptionsScreen(); 
-                    currentScreen = OPTIONS;
-                } break;
-                case GAMEPLAY:
-                {
-                    InitGameplayScreen(); 
-                    currentScreen = GAMEPLAY;
-                } break;
-                case ENDING:
-                {
-                    InitEndingScreen(); 
-                    currentScreen = ENDING;
-                } break;
+                case LOGO: InitLogoScreen(); break;
+                case TITLE: InitTitleScreen(); break;
+                case GAMEPLAY: InitGameplayScreen(); break;
+                case ENDING: InitEndingScreen(); break;
                 default: break;
             }
             
+            currentScreen = transToScreen;
+            
+            // Activate fade out effect to next loaded screen
             transFadeOut = true;
         }
     }
     else  // Transition fade out logic
     {
-        transAlpha -= 0.01f;
+        transAlpha -= 0.02f;
         
-        if (transAlpha <= 0)
+        if (transAlpha < -0.01f)
         {
-            transAlpha = 0;
+            transAlpha = 0.0f;
             transFadeOut = false;
             onTransition = false;
             transFromScreen = -1;
@@ -231,7 +216,87 @@ void UpdateTransition(void)
     }
 }
 
-void DrawTransition(void)
+// Draw transition effect (full-screen rectangle)
+static void DrawTransition(void)
 {
     DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha));
+}
+
+// Update and draw game frame
+static void UpdateDrawFrame(void)
+{
+    // Update
+    //----------------------------------------------------------------------------------
+    UpdateMusicStream(music);       // NOTE: Music keeps playing between screens
+    
+    if (!onTransition)
+    {
+        switch(currentScreen) 
+        {
+            case LOGO: 
+            {
+                UpdateLogoScreen();
+                
+                if (FinishLogoScreen()) TransitionToScreen(TITLE);
+
+            } break;
+            case TITLE: 
+            {
+                UpdateTitleScreen();
+                    
+                if (FinishTitleScreen() == 1) TransitionToScreen(OPTIONS);
+                else if (FinishTitleScreen() == 2) TransitionToScreen(GAMEPLAY);
+
+            } break;
+            case OPTIONS:
+            {
+                UpdateOptionsScreen();
+                    
+                if (FinishOptionsScreen()) TransitionToScreen(TITLE);
+
+            } break;
+            case GAMEPLAY:
+            {
+                UpdateGameplayScreen();
+                
+                if (FinishGameplayScreen() == 1) TransitionToScreen(ENDING);
+                //else if (FinishGameplayScreen() == 2) TransitionToScreen(TITLE);
+
+            } break;
+            case ENDING:
+            { 
+                UpdateEndingScreen();
+                
+                if (FinishEndingScreen() == 1) TransitionToScreen(TITLE);
+
+            } break;
+            default: break;
+        }
+    }
+    else UpdateTransition();    // Update transition (fade-in, fade-out)
+    //----------------------------------------------------------------------------------
+    
+    // Draw
+    //----------------------------------------------------------------------------------
+    BeginDrawing();
+        
+        ClearBackground(RAYWHITE);
+            
+        switch(currentScreen) 
+        {
+            case LOGO: DrawLogoScreen(); break;
+            case TITLE: DrawTitleScreen(); break;
+            case OPTIONS: DrawOptionsScreen(); break;
+            case GAMEPLAY: DrawGameplayScreen(); break;
+            case ENDING: DrawEndingScreen(); break;
+            default: break;
+        }
+         
+        // Draw full screen rectangle in front of everything
+        if (onTransition) DrawTransition();
+        
+        //DrawFPS(10, 10);
+        
+    EndDrawing();
+    //----------------------------------------------------------------------------------
 }

二進制
templates/advance_game/resources/mecha.png


+ 5 - 4
templates/advance_game/screens/screen_ending.c

@@ -51,10 +51,11 @@ void UpdateEndingScreen(void)
 {
     // TODO: Update ENDING screen variables here!
 
-    // Press enter to return to TITLE screen
-    if (IsKeyPressed(KEY_ENTER))
+    // Press enter or tap to return to TITLE screen
+    if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
     {
         finishScreen = 1;
+        PlaySound(fxCoin);
     }
 }
 
@@ -63,8 +64,8 @@ void DrawEndingScreen(void)
 {
     // TODO: Draw ENDING screen here!
     DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE);
-    DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
-    DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 160, 220, 20, DARKBLUE);
+    DrawTextEx(font, "ENDING SCREEN", (Vector2){ 20, 10 }, font.baseSize*3, 4, DARKBLUE);
+    DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, DARKBLUE);
 }
 
 // Ending Screen Unload logic

+ 6 - 5
templates/advance_game/screens/screen_gameplay.c

@@ -4,7 +4,7 @@
 *
 *   Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
 *
-*   Copyright (c) 2014 Ramon Santamaria (@raysan5)
+*   Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
 *
 *   This software is provided "as-is", without any express or implied warranty. In no event
 *   will the authors be held liable for any damages arising from the use of this software.
@@ -51,10 +51,11 @@ void UpdateGameplayScreen(void)
 {
     // TODO: Update GAMEPLAY screen variables here!
 
-    // Press enter to change to ENDING screen
-    if (IsKeyPressed(KEY_ENTER))
+    // Press enter or tap to change to ENDING screen
+    if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
     {
         finishScreen = 1;
+        PlaySound(fxCoin);
     }
 }
 
@@ -63,8 +64,8 @@ void DrawGameplayScreen(void)
 {
     // TODO: Draw GAMEPLAY screen here!
     DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), PURPLE);
-    DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
-    DrawText("PRESS ENTER to JUMP to ENDING SCREEN", 170, 220, 20, MAROON);
+    DrawTextEx(font, "GAMEPLAY SCREEN", (Vector2){ 20, 10 }, font.baseSize*3, 4, MAROON);
+    DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, MAROON);
 }
 
 // Gameplay Screen Unload logic

+ 10 - 2
templates/advance_game/screens/screen_logo.c

@@ -34,6 +34,8 @@
 static int framesCounter;
 static int finishScreen;
 
+static Texture2D logo;
+
 //----------------------------------------------------------------------------------
 // Logo Screen Functions Definition
 //----------------------------------------------------------------------------------
@@ -44,6 +46,8 @@ void InitLogoScreen(void)
     // TODO: Initialize LOGO screen variables here!
     framesCounter = 0;
     finishScreen = 0;
+    
+    logo = LoadTexture("resources/raylib_logo.png");
 }
 
 // Logo Screen Update logic
@@ -64,14 +68,18 @@ void UpdateLogoScreen(void)
 void DrawLogoScreen(void)
 {
     // TODO: Draw LOGO screen here!
-    DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY);
-    DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY);
+    DrawTextEx(font, "LOGO SCREEN", (Vector2){ 20, 10 }, font.baseSize*3, 4, GRAY);
+    DrawText("WAIT for 2 SECONDS...", 290, 400, 20, GRAY);
+    
+    DrawTexture(logo, GetScreenWidth()/2 - logo.width/2, 100, WHITE);
 }
 
 // Logo Screen Unload logic
 void UnloadLogoScreen(void)
 {
     // TODO: Unload LOGO screen variables here!
+    
+    UnloadTexture(logo);
 }
 
 // Logo Screen should finish?

+ 6 - 5
templates/advance_game/screens/screen_title.c

@@ -4,7 +4,7 @@
 *
 *   Title Screen Functions Definitions (Init, Update, Draw, Unload)
 *
-*   Copyright (c) 2014 Ramon Santamaria (@raysan5)
+*   Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
 *
 *   This software is provided "as-is", without any express or implied warranty. In no event
 *   will the authors be held liable for any damages arising from the use of this software.
@@ -51,11 +51,12 @@ void UpdateTitleScreen(void)
 {
     // TODO: Update TITLE screen variables here!
 
-    // Press enter to change to GAMEPLAY screen
-    if (IsKeyPressed(KEY_ENTER))
+    // Press enter or tap to change to GAMEPLAY screen
+    if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
     {
         //finishScreen = 1;   // OPTIONS
         finishScreen = 2;   // GAMEPLAY
+        PlaySound(fxCoin);
     }
 }
 
@@ -64,8 +65,8 @@ void DrawTitleScreen(void)
 {
     // TODO: Draw TITLE screen here!
     DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN);
-    DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
-    DrawText("PRESS ENTER to JUMP to GAMEPLAY SCREEN", 160, 220, 20, DARKGREEN);
+    DrawTextEx(font, "TITLE SCREEN", (Vector2){ 20, 10 }, font.baseSize*3, 4, DARKGREEN);
+    DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN);
 }
 
 // Title Screen Unload logic

+ 5 - 2
templates/advance_game/screens/screens.h

@@ -4,7 +4,7 @@
 *
 *   Screens Functions Declarations (Init, Update, Draw, Unload)
 *
-*   Copyright (c) 2014 Ramon Santamaria (@raysan5)
+*   Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
 *
 *   This software is provided "as-is", without any express or implied warranty. In no event
 *   will the authors be held liable for any damages arising from the use of this software.
@@ -29,12 +29,15 @@
 //----------------------------------------------------------------------------------
 // Types and Structures Definition
 //----------------------------------------------------------------------------------
-typedef enum GameScreen { LOGO, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen;
+typedef enum GameScreen { LOGO = 0, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen;
 
 //----------------------------------------------------------------------------------
 // Global Variables Definition
 //----------------------------------------------------------------------------------
 GameScreen currentScreen;
+SpriteFont font;
+Music music;
+Sound fxCoin;
 
 #ifdef __cplusplus
 extern "C" {            // Prevents name mangling of functions

+ 0 - 255
templates/basic_game/Makefile

@@ -1,255 +0,0 @@
-#**************************************************************************************************
-#
-#   raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
-#
-#   Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
-#
-#   This software is provided "as-is", without any express or implied warranty. In no event
-#   will the authors be held liable for any damages arising from the use of this software.
-#
-#   Permission is granted to anyone to use this software for any purpose, including commercial
-#   applications, and to alter it and redistribute it freely, subject to the following restrictions:
-#
-#     1. The origin of this software must not be misrepresented; you must not claim that you
-#     wrote the original software. If you use this software in a product, an acknowledgment
-#     in the product documentation would be appreciated but is not required.
-#
-#     2. Altered source versions must be plainly marked as such, and must not be misrepresented
-#     as being the original software.
-#
-#     3. This notice may not be removed or altered from any source distribution.
-#
-#**************************************************************************************************
-
-.PHONY: all clean
-
-# define raylib platform to compile for
-# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
-# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
-PLATFORM ?= PLATFORM_DESKTOP
-
-# define NO to use OpenAL Soft as static library (shared by default)
-SHARED_OPENAL ?= NO
-
-ifeq ($(PLATFORM),PLATFORM_WEB)
-    SHARED_OPENAL = NO
-endif
-
-# define raylib directory for include and library
-RAYLIB_PATH ?= C:\raylib\raylib
-
-# 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
-        LIBPATH=win32
-    else
-        UNAMEOS:=$(shell uname)
-        ifeq ($(UNAMEOS),Linux)
-            PLATFORM_OS=LINUX
-            LIBPATH=linux
-        else
-        ifeq ($(UNAMEOS),Darwin)
-            PLATFORM_OS=OSX
-            LIBPATH=osx
-        endif
-        endif
-    endif
-endif
-
-# define compiler: gcc for C program, define as g++ for C++
-ifeq ($(PLATFORM),PLATFORM_WEB)
-    # define emscripten compiler
-    CC = emcc
-else
-ifeq ($(PLATFORM_OS),OSX)
-    # define llvm compiler for mac
-    CC = clang
-else
-    # define default gcc compiler
-    CC = gcc
-endif
-endif
-
-# define compiler flags:
-#  -O2                  defines optimization level
-#  -Og                  enable debugging
-#  -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)
-#  -fgnu89-inline       declaring inline functions support (GCC optimized)
-#  -Wno-missing-braces  ignore invalid warning (GCC bug 53119)
-#  -D_DEFAULT_SOURCE    use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        CFLAGS = -O2 -s -Wall -std=c99
-    endif
-    ifeq ($(PLATFORM_OS),LINUX)
-        CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE
-    endif
-    ifeq ($(PLATFORM_OS),OSX)
-        CFLAGS = -O2 -s -Wall -std=c99
-    endif
-endif
-ifeq ($(PLATFORM),PLATFORM_WEB)
-    CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=67108864 --profiling --preload-file resources
-    # -O2                         # if used, also set --memory-init-file 0
-    # --memory-init-file 0        # to avoid an external memory initialization code file (.mem)
-    # -s ALLOW_MEMORY_GROWTH=1    # to allow memory resizing
-    # -s TOTAL_MEMORY=16777216    # to specify heap memory size (default = 16MB)
-    # --preload-file file.res     # embbed file.res resource into .data file
-endif
-ifeq ($(PLATFORM),PLATFORM_RPI)
-    CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline
-endif
-#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
-
-# define raylib release directory for compiled library
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32
-    endif
-    ifeq ($(PLATFORM_OS),LINUX)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux
-    endif
-    ifeq ($(PLATFORM_OS),OSX)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx
-    endif
-endif
-ifeq ($(PLATFORM),PLATFORM_WEB)
-    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5
-endif
-ifeq ($(PLATFORM),PLATFORM_RPI)
-    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi
-endif
-
-# define any directories containing required header files
-INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external 
-
-ifeq ($(PLATFORM),PLATFORM_RPI)
-    INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
-endif
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        # external libraries headers
-        # GLFW3
-            INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include
-        # OpenAL Soft
-            INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include
-    endif
-    ifeq ($(PLATFORM_OS),LINUX)
-        # you may optionally create this directory and install raylib 
-        # and related headers there. Edit ../src/Makefile appropriately.
-            INCLUDES += -I/usr/local/include/raylib
-    endif
-    ifeq ($(PLATFORM_OS),OSX)
-        # additional directories for MacOS
-    endif
-endif
-
-# define library paths containing required libs
-LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src 
-
-ifeq ($(PLATFORM),PLATFORM_RPI)
-    LFLAGS += -L/opt/vc/lib
-endif
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    # add standard directories for GNU/Linux
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        # external libraries to link with
-        # GLFW3
-            LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH)
-        # OpenAL Soft
-            LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH)
-    endif
-endif
-
-# define any libraries to link into executable
-# if you want to link libraries (libname.so or libname.a), use the -lname
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),LINUX)
-        # libraries for Debian GNU/Linux desktop compiling
-        # requires the following packages:
-        # libglfw3-dev libopenal-dev libegl1-mesa-dev
-        LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
-        # on XWindow requires also below libraries
-        LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
-    else
-    ifeq ($(PLATFORM_OS),OSX)
-        # libraries for OSX 10.9 desktop compiling
-        # requires the following packages:
-        # libglfw3-dev libopenal-dev libegl1-mesa-dev
-        LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
-    else
-        # libraries for Windows desktop compiling
-        # NOTE: GLFW3 and OpenAL Soft libraries should be installed
-        LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
-        # if static OpenAL Soft required, define the corresponding libs
-        ifeq ($(SHARED_OPENAL),NO)
-            LIBS += -lopenal32 -lwinmm
-            CFLAGS += -Wl,-allow-multiple-definition
-        else
-            LIBS += -lopenal32dll
-        endif
-    endif
-    endif
-endif
-ifeq ($(PLATFORM),PLATFORM_RPI)
-    # libraries for Raspberry Pi compiling
-    # NOTE: OpenAL Soft library should be installed (libopenal1 package)
-    LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
-endif
-ifeq ($(PLATFORM),PLATFORM_WEB)
-    # NOTE: Set the correct path to libraylib.bc
-    LIBS = $(RAYLIB_RELEASE)/libraylib.bc
-endif
-
-# define additional parameters and flags for windows
-ifeq ($(PLATFORM_OS),WINDOWS)
-    # resources file contains windows exe icon
-    # -Wl,--subsystem,windows hides the console window
-    WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
-endif
-
-ifeq ($(PLATFORM),PLATFORM_WEB)
-    EXT = .html
-    WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
-endif
-
-# typing 'make' will invoke the default target entry called 'all',
-# in this case, the 'default' target entry is basic_game
-all: basic_game
-
-# compile template - basic_game
-basic_game: basic_game.c
-	$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-
-# clean everything
-clean:
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),OSX)
-		find . -type f -perm +ugo+x -delete
-		rm -f *.o
-    else
-    ifeq ($(PLATFORM_OS),LINUX)
-		find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
-    else
-		del *.o *.exe /s
-    endif
-    endif
-endif
-ifeq ($(PLATFORM),PLATFORM_RPI)
-	find . -type f -executable -delete
-	rm -f *.o
-endif
-ifeq ($(PLATFORM),PLATFORM_WEB)
-	del *.o *.html *.js
-endif
-	@echo Cleaning done
-
-# instead of defining every module one by one, we can define a pattern
-# this pattern below will automatically compile every module defined on $(OBJS)
-#%.exe : %.c
-#	$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM)

+ 0 - 152
templates/basic_game/basic_game.c

@@ -1,152 +0,0 @@
-/*******************************************************************************************
-*
-*   raylib - Basic Game template
-*
-*   <Game title>
-*   <Game description>
-*
-*   This game has been created using raylib v1.2 (www.raylib.com)
-*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
-*
-*   Copyright (c) 2014 Ramon Santamaria (@raysan5)
-*
-********************************************************************************************/
-
-#include "raylib.h"
-
-//----------------------------------------------------------------------------------
-// Types and Structures Definition
-//----------------------------------------------------------------------------------
-typedef enum GameScreen { LOGO, TITLE, GAMEPLAY, ENDING } GameScreen;
-
-//----------------------------------------------------------------------------------
-// Main entry point
-//----------------------------------------------------------------------------------
-int main()
-{
-    // Initialization
-    //--------------------------------------------------------------------------------------
-    const int screenWidth = 800;
-    const int screenHeight = 450;
-    const char windowTitle[30] = "<game name goes here>";
-    
-    InitWindow(screenWidth, screenHeight, windowTitle);
-
-    GameScreen currentScreen = LOGO;
-
-    // TODO: Initialize all required variables and load all required data here!
-
-    int framesCounter = 0;          // Useful to count frames
-
-    SetTargetFPS(60);               // Set desired framerate (frames-per-second)
-    //--------------------------------------------------------------------------------------
-    
-    // Main game loop
-    while (!WindowShouldClose())    // Detect window close button or ESC key
-    {
-        // Update
-        //----------------------------------------------------------------------------------
-        switch(currentScreen) 
-        {
-            case LOGO: 
-            {
-                // TODO: Update LOGO screen variables here!
-
-                framesCounter++;    // Count frames
-
-                // Wait for 2 seconds (120 frames) before jumping to TITLE screen
-                if (framesCounter > 120)
-                {
-                    currentScreen = TITLE;
-                }
-            } break;
-            case TITLE: 
-            {
-                // TODO: Update TITLE screen variables here!
-
-                // Press enter to change to GAMEPLAY screen
-                if (IsKeyPressed(KEY_ENTER))
-                {
-                    currentScreen = GAMEPLAY;
-                }
-            } break;
-            case GAMEPLAY:
-            { 
-                // TODO: Update GAMEPLAY screen variables here!
-
-                // Press enter to change to ENDING screen
-                if (IsKeyPressed(KEY_ENTER))
-                {
-                    currentScreen = ENDING;
-                } 
-            } break;
-            case ENDING: 
-            {
-                // TODO: Update ENDING screen variables here!
-
-                // Press enter to return to TITLE screen
-                if (IsKeyPressed(KEY_ENTER))
-                {
-                    currentScreen = TITLE;
-                }  
-            } break;
-            default: break;
-        }
-        //----------------------------------------------------------------------------------
-        
-        // Draw
-        //----------------------------------------------------------------------------------
-        BeginDrawing();
-        
-            ClearBackground(RAYWHITE);
-            
-            switch(currentScreen) 
-            {
-                case LOGO: 
-                {
-                    // TODO: Draw LOGO screen here!
-                    DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY);
-                    DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY);
-                    
-                } break;
-                case TITLE: 
-                {
-                    // TODO: Draw TITLE screen here!
-                    DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
-                    DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
-                    DrawText("PRESS ENTER to JUMP to GAMEPLAY SCREEN", 160, 220, 20, DARKGREEN);
-                    
-                } break;
-                case GAMEPLAY:
-                { 
-                    // TODO: Draw GAMEPLAY screen here!
-                    DrawRectangle(0, 0, screenWidth, screenHeight, PURPLE);
-                    DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
-                    DrawText("PRESS ENTER to JUMP to ENDING SCREEN", 170, 220, 20, MAROON);
-
-                } break;
-                case ENDING: 
-                {
-                    // TODO: Draw ENDING screen here!
-                    DrawRectangle(0, 0, screenWidth, screenHeight, BLUE);
-                    DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
-                    DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 160, 220, 20, DARKBLUE);
-                    
-                } break;
-                default: break;
-            }
-        
-        EndDrawing();
-        //----------------------------------------------------------------------------------
-    }
-
-    // De-Initialization
-    //--------------------------------------------------------------------------------------
-    
-    // TODO: Unload all loaded data (textures, fonts, audio) here!
-    
-    CloseWindow();        // Close window and OpenGL context
-    //--------------------------------------------------------------------------------------
-    
-    return 0;
-}

+ 155 - 133
templates/simple_game/Makefile

@@ -1,6 +1,6 @@
 #**************************************************************************************************
 #
-#   raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
+#   raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
 #
 #   Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
 #
@@ -23,29 +23,30 @@
 
 .PHONY: all clean
 
-# define raylib platform to compile for
-# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
+# Define required raylib variables
 # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
 PLATFORM ?= PLATFORM_DESKTOP
+RAYLIB_PATH ?= ..\..
+PROJECT_NAME ?= simple_game
 
-# define NO to use OpenAL Soft as static library (shared by default)
-SHARED_OPENAL ?= NO
+# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
+# NOTE: Libraries should be provided in the selected form
+RAYLIB_LIBTYPE ?= STATIC
+OPENAL_LIBTYPE ?= STATIC
 
+# On PLATFORM_WEB force OpenAL Soft shared library
 ifeq ($(PLATFORM),PLATFORM_WEB)
-    SHARED_OPENAL = NO
+    OPENAL_LIBTYPE = SHARED
 endif
 
-# define raylib directory for include and library
-RAYLIB_PATH ?= C:\raylib\raylib
-
-# determine PLATFORM_OS in case PLATFORM_DESKTOP selected
+# 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
         LIBPATH=win32
     else
-        UNAMEOS:=$(shell uname)
+        UNAMEOS=$(shell uname)
         ifeq ($(UNAMEOS),Linux)
             PLATFORM_OS=LINUX
             LIBPATH=linux
@@ -58,190 +59,215 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
     endif
 endif
 
-# define compiler: gcc for C program, define as g++ for C++
-ifeq ($(PLATFORM),PLATFORM_WEB)
-    # define emscripten compiler
-    CC = emcc
-else
-ifeq ($(PLATFORM_OS),OSX)
-    # define llvm compiler for mac
-    CC = clang
-else
-    # define default gcc compiler
-    CC = gcc
+ifeq ($(PLATFORM),PLATFORM_RPI)
+    # RPI cross-compiler
+    RPI_CROSS_COMPILE ?= NO
 endif
+
+ifeq ($(PLATFORM),PLATFORM_WEB)
+    # Emscripten required variables
+    EMSDK_PATH = C:/emsdk
+    EMSCRIPTEN_VERSION = 1.37.9
+    CLANG_VERSION=e1.37.9_64bit
+    PYTHON_VERSION=2.7.5.3_64bit
+    NODE_VERSION=4.1.1_64bit
+    export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
+    EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
 endif
 
-# define compiler flags:
-#  -O2                  defines optimization level
-#  -Og                  enable debugging
-#  -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)
-#  -fgnu89-inline       declaring inline functions support (GCC optimized)
-#  -Wno-missing-braces  ignore invalid warning (GCC bug 53119)
-#  -D_DEFAULT_SOURCE    use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
+# Define raylib release directory for compiled library
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
     ifeq ($(PLATFORM_OS),WINDOWS)
-        CFLAGS = -O2 -s -Wall -std=c99
+        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32
     endif
     ifeq ($(PLATFORM_OS),LINUX)
-        CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE
+        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux
     endif
     ifeq ($(PLATFORM_OS),OSX)
-        CFLAGS = -O2 -s -Wall -std=c99
+        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx
     endif
 endif
 ifeq ($(PLATFORM),PLATFORM_WEB)
-    CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=67108864 --profiling --preload-file resources
-    # -O2                         # if used, also set --memory-init-file 0
-    # --memory-init-file 0        # to avoid an external memory initialization code file (.mem)
-    # -s ALLOW_MEMORY_GROWTH=1    # to allow memory resizing
-    # -s TOTAL_MEMORY=16777216    # to specify heap memory size (default = 16MB)
-    # --preload-file file.res     # embbed file.res resource into .data file
+    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
 endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
-    CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline
+    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/rpi
 endif
-#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
 
-# define raylib release directory for compiled library
+# Define default C compiler: gcc
+CC = gcc
+
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32
-    endif
-    ifeq ($(PLATFORM_OS),LINUX)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux
-    endif
     ifeq ($(PLATFORM_OS),OSX)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx
+        # OSX default compiler
+        CC = clang
     endif
 endif
-ifeq ($(PLATFORM),PLATFORM_WEB)
-    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5
-endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
-    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi
+    ifeq ($(RPI_CROSS_COMPILE),YES)
+        # RPI cross-compiler
+        CC = armv6j-hardfloat-linux-gnueabi-gcc
+    endif
+endif
+ifeq ($(PLATFORM),PLATFORM_WEB)
+    # HTML5 emscripten compiler
+    CC = emcc
 endif
 
-# define any directories containing required header files
-INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external 
+# Define default make program: Mingw32-make
+MAKE = mingw32-make
 
-ifeq ($(PLATFORM),PLATFORM_RPI)
-    INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
-endif
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        # external libraries headers
-        # GLFW3
-            INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include
-        # OpenAL Soft
-            INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include
-    endif
     ifeq ($(PLATFORM_OS),LINUX)
-        # you may optionally create this directory and install raylib 
-        # and related headers there. Edit ../src/Makefile appropriately.
-            INCLUDES += -I/usr/local/include/raylib
+        MAKE = make
     endif
-    ifeq ($(PLATFORM_OS),OSX)
-        # additional directories for MacOS
+endif
+
+# Define compiler flags:
+#  -O1                  defines optimization level
+#  -Og                  enable debugging
+#  -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)
+#  -fgnu89-inline       declaring inline functions support (GCC optimized)
+#  -Wno-missing-braces  ignore invalid warning (GCC bug 53119)
+#  -D_DEFAULT_SOURCE    use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
+CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
+
+# Additional flags for compiler (if desired)
+#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
+ifeq ($(PLATFORM),PLATFORM_DESKTOP)
+    ifeq ($(PLATFORM_OS),LINUX)
+        CFLAGS += -no-pie -D_DEFAULT_SOURCE
     endif
 endif
+ifeq ($(PLATFORM),PLATFORM_RPI)
+    CFLAGS += -std=gnu99
+endif
+ifeq ($(PLATFORM),PLATFORM_WEB)
+    # -O2                        # if used, also set --memory-init-file 0
+    # --memory-init-file 0       # to avoid an external memory initialization code file (.mem)
+    # -s ALLOW_MEMORY_GROWTH=1   # to allow memory resizing
+    # -s TOTAL_MEMORY=16777216   # to specify heap memory size (default = 16MB)
+    # -s USE_PTHREADS=1          # multithreading support
+    CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s TOTAL_MEMORY=16777216 --preload-file resources
+endif
 
-# define library paths containing required libs
-LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src 
+# Define include paths for required headers
+# NOTE: Several external required libraries (stb and others)
+INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
 
+# Define additional directories containing required header files
 ifeq ($(PLATFORM),PLATFORM_RPI)
-    LFLAGS += -L/opt/vc/lib
+    # RPI requried libraries
+    INCLUDE_PATHS += -I/opt/vc/include
+    INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
+    INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
 endif
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    # add standard directories for GNU/Linux
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        # external libraries to link with
-        # GLFW3
-            LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH)
-        # OpenAL Soft
-            LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH)
-    endif
+
+# Define library paths containing required libs
+LDFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src 
+
+ifeq ($(PLATFORM),PLATFORM_RPI)
+    LDFLAGS += -L/opt/vc/lib
 endif
 
-# define any libraries to link into executable
+# Define any libraries required on linking
 # if you want to link libraries (libname.so or libname.a), use the -lname
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),LINUX)
-        # libraries for Debian GNU/Linux desktop compiling
-        # requires the following packages:
-        # libglfw3-dev libopenal-dev libegl1-mesa-dev
-        LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
-        # on XWindow requires also below libraries
-        LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
-    else
-    ifeq ($(PLATFORM_OS),OSX)
-        # libraries for OSX 10.9 desktop compiling
-        # requires the following packages:
-        # libglfw3-dev libopenal-dev libegl1-mesa-dev
-        LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
-    else
-        # libraries for Windows desktop compiling
+    ifeq ($(PLATFORM_OS),WINDOWS)
+        # Libraries for Windows desktop compiling
         # NOTE: GLFW3 and OpenAL Soft libraries should be installed
-        LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
-        # if static OpenAL Soft required, define the corresponding libs
-        ifeq ($(SHARED_OPENAL),NO)
-            LIBS += -lopenal32 -lwinmm
-            CFLAGS += -Wl,-allow-multiple-definition
+        LDLIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
+
+        # Define required flags and libs for OpenAL Soft STATIC/SHARED usage
+        # NOTE: ALLIBS flag only required for raylib Win32 SHARED library building
+        ifeq ($(OPENAL_LIBTYPE),STATIC)
+            LDLIBS += -lopenal32 -lwinmm
+            CFLAGS += -DAL_LIBTYPE_STATIC -Wl,-allow-multiple-definition
         else
-            LIBS += -lopenal32dll
+            LDLIBS += -lopenal32dll
         endif
     endif
+    ifeq ($(PLATFORM_OS),LINUX)
+        # Libraries for Debian GNU/Linux desktop compiling
+        # NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
+        LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
+        
+        # On XWindow requires also below libraries
+        LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
+    endif
+    ifeq ($(PLATFORM_OS),OSX)
+        # Libraries for OSX 10.9 desktop compiling
+        # NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
+        LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
     endif
 endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
-    # libraries for Raspberry Pi compiling
-    # NOTE: OpenAL Soft library should be installed (libopenal1 package)
-    LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
+    # Libraries for Raspberry Pi compiling
+    # NOTE: Required packages: libopenal1
+    LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
 endif
 ifeq ($(PLATFORM),PLATFORM_WEB)
-    # NOTE: Set the correct path to libraylib.bc
-    LIBS = $(RAYLIB_RELEASE)/libraylib.bc
+    # Libraries for web (HTML5) compiling
+    LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc
 endif
 
-# define additional parameters and flags for windows
+# Define additional parameters and flags for windows
 ifeq ($(PLATFORM_OS),WINDOWS)
-    # resources file contains windows exe icon
+    # resources file contains raylib icon for windows .exe
     # -Wl,--subsystem,windows hides the console window
     WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
 endif
 
+# Define output extension to generate a .html file using provided shell
 ifeq ($(PLATFORM),PLATFORM_WEB)
     EXT = .html
     WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
 endif
 
-# typing 'make' will invoke the default target entry called 'all',
-# in this case, the 'default' target entry is simple_game
-all: simple_game
+# Define all source files required
+PROJECT_SOURCE_FILES ?= simple_game.c
+
+# Define all object files from source files
+OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
+
+# For Android platform we call a custom Makefile.Android
+ifeq ($(PLATFORM),PLATFORM_ANDROID)
+    MAKEFILE_PARAMS = -f Makefile.Android 
+    export PROJECT_NAME
+    export PROJECT_SOURCE_FILES
+else
+    MAKEFILE_PARAMS = $(PROJECT_NAME)
+endif
+
+# Default target entry
+# NOTE: We call this Makefile target or Makefile.Android target
+all:
+	$(MAKE) $(MAKEFILE_PARAMS)
 
-# compile template - simple_game
-simple_game: simple_game.c screens.o
-	$(CC) -o $@$(EXT) $< screens.o $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+# Project target defined by PROJECT_NAME
+$(PROJECT_NAME): $(OBJS)
+	$(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(WINFLAGS)
 
-# compile screens
-screens.o: screens.c
-	$(CC) -c $< $(CFLAGS) $(INCLUDES) -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 everything
 clean:
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),OSX)
-		find . -type f -perm +ugo+x -delete
-		rm -f *.o
-    else
+    ifeq ($(PLATFORM_OS),WINDOWS)
+		del *.o *.exe /s
+    endif
     ifeq ($(PLATFORM_OS),LINUX)
 		find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
-    else
-		del *.o *.exe /s
     endif
+    ifeq ($(PLATFORM_OS),OSX)
+		find . -type f -perm +ugo+x -delete
+		rm -f *.o
     endif
 endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
@@ -253,7 +279,3 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
 endif
 	@echo Cleaning done
 
-# instead of defining every module one by one, we can define a pattern
-# this pattern below will automatically compile every module defined on $(OBJS)
-#%.exe : %.c
-#	$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM)

+ 287 - 0
templates/simple_game/Makefile.Android

@@ -0,0 +1,287 @@
+#**************************************************************************************************
+#
+#   raylib makefile for Android project (APK building)
+#
+#   Copyright (c) 2017 Ramon Santamaria (@raysan5)
+#
+#   This software is provided "as-is", without any express or implied warranty. In no event
+#   will the authors be held liable for any damages arising from the use of this software.
+#
+#   Permission is granted to anyone to use this software for any purpose, including commercial
+#   applications, and to alter it and redistribute it freely, subject to the following restrictions:
+#
+#     1. The origin of this software must not be misrepresented; you must not claim that you
+#     wrote the original software. If you use this software in a product, an acknowledgment
+#     in the product documentation would be appreciated but is not required.
+#
+#     2. Altered source versions must be plainly marked as such, and must not be misrepresented
+#     as being the original software.
+#
+#     3. This notice may not be removed or altered from any source distribution.
+#
+#**************************************************************************************************
+
+# Define required raylib variables
+PLATFORM ?= PLATFORM_ANDROID
+RAYLIB_PATH ?= ..\..
+
+# Required path variables
+# NOTE: JAVA_HOME must be set to JDK
+ANDROID_HOME = C:/android-sdk
+ANDROID_NDK = C:/android-ndk
+ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16
+ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/26.0.2
+ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
+JAVA_HOME = C:/PROGRA~1/Java/jdk1.8.0_144
+
+# Android project configuration variables
+PROJECT_NAME ?= raylib_game
+PROJECT_LIBRARY_NAME ?= main
+PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME)
+PROJECT_RESOURCES_PATH ?= resources
+PROJECT_SOURCE_FILES ?= raylib_game.c
+
+# Some source files are placed in directories, when compiling to some 
+# output directory other than source, that directory must pre-exist.
+# Here we get a list of required folders that need to be created on
+# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors.
+PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES)))
+
+# Android app configuration variables
+APP_LABEL_NAME ?= rGame
+APP_COMPANY_NAME ?= raylib
+APP_PRODUCT_NAME ?= rgame
+APP_VERSION_CODE ?= 1
+APP_VERSION_NAME ?= 1.0
+APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png
+APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png
+APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png
+APP_SCREEN_ORIENTATION ?= landscape
+APP_KEYSTORE_PASS ?= raylib
+
+# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
+RAYLIB_LIBTYPE ?= STATIC
+OPENAL_LIBTYPE ?= STATIC
+RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
+OPENAL_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
+
+# Shared libs must be added to APK if required
+# NOTE: Generated NativeLoader.java automatically load those libraries
+ifeq ($(RAYLIB_LIBTYPE),SHARED)
+    PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so 
+endif
+ifeq ($(OPENAL_LIBTYPE),SHARED)
+    PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
+endif
+
+# Compiler and archiver
+# NOTE: GCC is being deprectated in Android NDK r16
+CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-gcc
+AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
+
+# Compiler flags for arquitecture
+CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
+# Compilation functions attributes options
+CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
+# Compiler options for the linker
+CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes
+# Preprocessor macro definitions
+CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=16
+
+# Paths containing required header files
+INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src/external/android/native_app_glue
+
+# Linker options
+LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a 
+LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings 
+# Force linking of library module to define symbol
+LDFLAGS += -u ANativeActivity_onCreate
+# Library paths containing required libs
+LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/armeabi-v7a
+
+# Define any libraries to link into executable
+# if you want to link libraries (libname.so or libname.a), use the -lname
+LDLIBS = -lraylib -lnative_app_glue -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
+
+# Generate target objects list from PROJECT_SOURCE_FILES
+OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
+
+# Android APK building process... some steps required...
+# NOTE: typing 'make' will invoke the default target entry called 'all',
+all: create_temp_project_dirs \
+     copy_project_required_libs \
+     copy_project_resources \
+     generate_loader_script \
+     generate_android_manifest \
+     generate_apk_keystore \
+     config_project_package \
+     compile_native_app_glue \
+     compile_project_code \
+     compile_project_class \
+     compile_project_class_dex \
+     create_project_apk_package \
+     sign_project_apk_package \
+     zipalign_project_apk_package
+
+# Create required temp directories for APK building
+create_temp_project_dirs:
+	if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH) 
+	if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj
+	if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src
+	if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com
+	if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)
+	if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME)
+	if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib
+	if not exist $(PROJECT_BUILD_PATH)\lib\armeabi-v7a mkdir $(PROJECT_BUILD_PATH)\lib\armeabi-v7a
+	if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin
+	if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res
+	if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi
+	if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi
+	if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi
+	if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values
+	if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets
+	if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens
+	$(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir)))
+
+define create_dir
+    if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1)
+endef
+    
+# Copy required shared libs for integration into APK
+# NOTE: If using shared libs they are loaded by generated NativeLoader.java
+copy_project_required_libs:
+ifeq ($(RAYLIB_LIBTYPE),SHARED)
+	copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so 
+endif
+ifeq ($(OPENAL_LIBTYPE),SHARED)
+	copy /Y $(OPENAL_LIB_PATH)\libopenal.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.so
+endif
+ifeq ($(RAYLIB_LIBTYPE),STATIC)
+	copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a 
+endif
+ifeq ($(OPENAL_LIBTYPE),STATIC)
+	copy /Y $(OPENAL_LIB_PATH)\libopenal.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.a
+endif
+
+# Copy project required resources: strings.xml, icon.png, assets
+# NOTE: Required strings.xml is generated and game resources are copied to assets folder
+copy_project_resources:
+	copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y
+	copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y
+	copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y
+	@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/res/values/strings.xml
+	@echo ^<resources^>^<string name="app_name"^>$(APP_LABEL_NAME)^</string^>^</resources^> >> $(PROJECT_BUILD_PATH)/res/values/strings.xml
+	if exist $(PROJECT_RESOURCES_PATH) xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets /Y /E /F
+
+# Generate NativeLoader.java to load required shared libraries
+# NOTE: Probably not the bet way to generate this file... but it works.
+generate_loader_script:
+	@echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+	@echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+	@echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+	@echo     static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+ifeq ($(OPENAL_LIBTYPE),SHARED)
+	@echo         System.loadLibrary("openal"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+endif
+ifeq ($(RAYLIB_LIBTYPE),SHARED)
+	@echo         System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+endif
+	@echo         System.loadLibrary("raylib_game"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java 
+	@echo     } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+	@echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+    
+# Generate AndroidManifest.xml with all the required options
+# NOTE: Probably not the bet way to generate this file... but it works.
+generate_android_manifest:
+	@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo ^<manifest xmlns:android="http://schemas.android.com/apk/res/android" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo         package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)"  >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo         android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo     ^<uses-sdk android:minSdkVersion="16" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo     ^<uses-feature android:glEsVersion="0x00020000" android:required="true" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo     ^<application android:allowBackup="false" android:label="@string/app_name" android:icon="@drawable/icon" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo         ^<activity android:name="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME).NativeLoader" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             ^<meta-data android:name="android.app.lib_name" android:value="$(PROJECT_LIBRARY_NAME)" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             ^<intent-filter^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo                 ^<action android:name="android.intent.action.MAIN" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo                 ^<category android:name="android.intent.category.LAUNCHER" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo             ^</intent-filter^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo         ^</activity^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo     ^</application^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+	@echo ^</manifest^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
+
+# Generate storekey for APK signing: $(PROJECT_NAME).keystore
+# NOTE: Configure here your Distinguished Names (-dname) if required!
+generate_apk_keystore: 
+	if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA
+
+# Config project package and resource using AndroidManifest.xml and res/values/strings.xml
+# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java
+config_project_package:
+	$(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-16/android.jar
+
+# Compile native_app_glue code as static library: obj/libnative_app_glue.a
+compile_native_app_glue:
+	$(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS)
+	$(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o
+
+# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so 
+compile_project_code: $(OBJS)
+	$(CC) -o $(PROJECT_BUILD_PATH)/lib/armeabi-v7a/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS)
+
+# Compile all .c files required into object (.o) files
+# NOTE: Those files will be linked into a shared library
+$(PROJECT_BUILD_PATH)/obj/%.o:%.c
+	$(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot 
+    
+# Compile project .java code into .class (Java bytecode) 
+compile_project_class:
+	$(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-16/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+
+# Compile .class files into Dalvik executable bytecode (.dex)
+# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT)
+compile_project_class_dex:
+	$(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj
+
+# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk
+# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so
+# NOTE: Use -A resources to define additional directory in which to find raw asset files
+create_project_apk_package:
+	$(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-16/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin
+	cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/armeabi-v7a/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS)
+
+# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk 
+sign_project_apk_package:
+	$(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key
+
+# Create zip-aligned APK package: $(PROJECT_NAME).apk 
+zipalign_project_apk_package:
+	$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk
+
+# Install $(PROJECT_NAME).apk to default emulator/device
+# NOTE: Use -e (emulator) or -d (device) parameters if required
+install:
+	$(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk
+
+# Monitorize output log coming from device, only raylib tag
+logcat:
+	$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
+	$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
+    
+# Install and monitorize $(PROJECT_NAME).apk to default emulator/device
+deploy:
+	$(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk
+	$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
+	$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
+
+#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W
+
+# Clean everything
+clean:
+	del $(PROJECT_BUILD_PATH)\* /f /s /q
+	rmdir $(PROJECT_BUILD_PATH) /s /q
+	@echo Cleaning done

+ 0 - 195
templates/simple_game/screens.c

@@ -1,195 +0,0 @@
-/**********************************************************************************************
-*
-*   raylib - Simple Game template
-*
-*   Screens Functions Definitions (Init, Update, Draw, Unload)
-*
-*   Copyright (c) 2014 Ramon Santamaria (@raysan5)
-*
-*   This software is provided "as-is", without any express or implied warranty. In no event
-*   will the authors be held liable for any damages arising from the use of this software.
-*
-*   Permission is granted to anyone to use this software for any purpose, including commercial
-*   applications, and to alter it and redistribute it freely, subject to the following restrictions:
-*
-*     1. The origin of this software must not be misrepresented; you must not claim that you
-*     wrote the original software. If you use this software in a product, an acknowledgment
-*     in the product documentation would be appreciated but is not required.
-*
-*     2. Altered source versions must be plainly marked as such, and must not be misrepresented
-*     as being the original software.
-*
-*     3. This notice may not be removed or altered from any source distribution.
-*
-**********************************************************************************************/
-
-#include "raylib.h"
-#include "screens.h"
-
-//----------------------------------------------------------------------------------
-// Global Variables Definition (visible to other modules)
-//----------------------------------------------------------------------------------
-GameScreen currentScreen = LOGO;
-
-//----------------------------------------------------------------------------------
-// Global Variables Definition (local to this module)
-//----------------------------------------------------------------------------------
-
-// Logo screen global variables
-static int framesCounter;
-
-// Title screen global variables
-
-// Gameplay screen global variables
-
-// Ending screen global variables
-
-//----------------------------------------------------------------------------------
-// Logo Screen Functions Definition
-//----------------------------------------------------------------------------------
-
-// Logo Screen Initialization logic
-void InitLogoScreen(void)
-{
-    // TODO: Initialize LOGO screen variables here!
-    framesCounter = 0;
-}
-
-// Logo Screen Update logic
-void UpdateLogoScreen(void)
-{
-    // TODO: Update LOGO screen variables here!
-
-    framesCounter++;    // Count frames
-
-    // Wait for 2 seconds (120 frames) before jumping to TITLE screen
-    if (framesCounter > 120)
-    {
-        currentScreen = TITLE;
-    }
-}
-
-// Logo Screen Draw logic
-void DrawLogoScreen(void)
-{
-    // TODO: Draw LOGO screen here!
-    DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY);
-    DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY);
-}
-
-// Logo Screen Unload logic
-void UnloadLogoScreen(void)
-{
-    // TODO: Unload LOGO screen variables here!
-}
-
-//----------------------------------------------------------------------------------
-// Title Screen Functions Definition
-//----------------------------------------------------------------------------------
-
-// Title Screen Initialization logic
-void InitTitleScreen(void)
-{
-    // TODO: Initialize TITLE screen variables here!
-}
-
-// Title Screen Update logic
-void UpdateTitleScreen(void)
-{
-    // TODO: Update TITLE screen variables here!
-
-    // Press enter to change to GAMEPLAY screen
-    if (IsKeyPressed(KEY_ENTER))
-    {
-        currentScreen = GAMEPLAY;
-    }
-}
-
-// Title Screen Draw logic
-void DrawTitleScreen(void)
-{
-    // TODO: Draw TITLE screen here!
-    DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN);
-    DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
-    DrawText("PRESS ENTER to JUMP to GAMEPLAY SCREEN", 160, 220, 20, DARKGREEN);
-}
-
-// Title Screen Unload logic
-void UnloadTitleScreen(void)
-{
-    // TODO: Unload TITLE screen variables here!
-}
-
-//----------------------------------------------------------------------------------
-// Gameplay Screen Functions Definition
-//----------------------------------------------------------------------------------
-
-// Gameplay Screen Initialization logic
-void InitGameplayScreen(void)
-{
-    // TODO: Initialize GAMEPLAY screen variables here!
-}
-
-// Gameplay Screen Update logic
-void UpdateGameplayScreen(void)
-{
-    // TODO: Update GAMEPLAY screen variables here!
-
-    // Press enter to change to ENDING screen
-    if (IsKeyPressed(KEY_ENTER))
-    {
-        currentScreen = ENDING;
-    }
-}
-
-// Gameplay Screen Draw logic
-void DrawGameplayScreen(void)
-{
-    // TODO: Draw GAMEPLAY screen here!
-    DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), PURPLE);
-    DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
-    DrawText("PRESS ENTER to JUMP to ENDING SCREEN", 170, 220, 20, MAROON);
-}
-
-// Gameplay Screen Unload logic
-void UnloadGameplayScreen(void)
-{
-    // TODO: Unload GAMEPLAY screen variables here!
-}
-
-//----------------------------------------------------------------------------------
-// Ending Screen Functions Definition
-//----------------------------------------------------------------------------------
-
-// Ending Screen Initialization logic
-void InitEndingScreen(void)
-{
-    // TODO: Initialize ENDING screen variables here!
-}
-
-// Ending Screen Update logic
-void UpdateEndingScreen(void)
-{
-    // TODO: Update ENDING screen variables here!
-
-    // Press enter to return to TITLE screen
-    if (IsKeyPressed(KEY_ENTER))
-    {
-        currentScreen = TITLE;
-    }
-}
-
-// Ending Screen Draw logic
-void DrawEndingScreen(void)
-{
-    // TODO: Draw ENDING screen here!
-    DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE);
-    DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
-    DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 160, 220, 20, DARKBLUE);
-}
-
-// Ending Screen Unload logic
-void UnloadEndingScreen(void)
-{
-    // TODO: Unload ENDING screen variables here!
-}

+ 0 - 74
templates/simple_game/screens.h

@@ -1,74 +0,0 @@
-/**********************************************************************************************
-*
-*   raylib - Simple Game template
-*
-*   Screens Functions Declarations (Init, Update, Draw, Unload)
-*
-*   Copyright (c) 2014 Ramon Santamaria (@raysan5)
-*
-*   This software is provided "as-is", without any express or implied warranty. In no event
-*   will the authors be held liable for any damages arising from the use of this software.
-*
-*   Permission is granted to anyone to use this software for any purpose, including commercial
-*   applications, and to alter it and redistribute it freely, subject to the following restrictions:
-*
-*     1. The origin of this software must not be misrepresented; you must not claim that you
-*     wrote the original software. If you use this software in a product, an acknowledgment
-*     in the product documentation would be appreciated but is not required.
-*
-*     2. Altered source versions must be plainly marked as such, and must not be misrepresented
-*     as being the original software.
-*
-*     3. This notice may not be removed or altered from any source distribution.
-*
-**********************************************************************************************/
-
-#ifndef SCREENS_H
-#define SCREENS_H
-
-//----------------------------------------------------------------------------------
-// Types and Structures Definition
-//----------------------------------------------------------------------------------
-typedef enum GameScreen { LOGO, TITLE, GAMEPLAY, ENDING } GameScreen;
-
-#ifdef __cplusplus
-extern "C" {            // Prevents name mangling of functions
-#endif
-
-//----------------------------------------------------------------------------------
-// Logo Screen Functions Declaration
-//----------------------------------------------------------------------------------
-void InitLogoScreen(void);
-void UpdateLogoScreen(void);
-void DrawLogoScreen(void);
-void UnloadLogoScreen(void);
-
-//----------------------------------------------------------------------------------
-// Title Screen Functions Declaration
-//----------------------------------------------------------------------------------
-void InitTitleScreen(void);
-void UpdateTitleScreen(void);
-void DrawTitleScreen(void);
-void UnloadTitleScreen(void);
-
-//----------------------------------------------------------------------------------
-// Gameplay Screen Functions Declaration
-//----------------------------------------------------------------------------------
-void InitGameplayScreen(void);
-void UpdateGameplayScreen(void);
-void DrawGameplayScreen(void);
-void UnloadGameplayScreen(void);
-
-//----------------------------------------------------------------------------------
-// Ending Screen Functions Declaration
-//----------------------------------------------------------------------------------
-void InitEndingScreen(void);
-void UpdateEndingScreen(void);
-void DrawEndingScreen(void);
-void UnloadEndingScreen(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // SCREENS_H

+ 102 - 36
templates/simple_game/simple_game.c

@@ -5,47 +5,53 @@
 *   <Game title>
 *   <Game description>
 *
-*   This game has been created using raylib (www.raylib.com)
+*   This game has been created using raylib v1.2 (www.raylib.com)
 *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 *
-*   raylib - Copyright (c) 2014 Ramon Santamaria (@raysan5)
+*   Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
 *
 ********************************************************************************************/
 
 #include "raylib.h"
 
-#include "screens.h"
+#if defined(PLATFORM_ANDROID)
+    #include "android_native_app_glue.h"
+#endif
 
 //----------------------------------------------------------------------------------
-// Global Variables Defined in other modules
+// Types and Structures Definition
 //----------------------------------------------------------------------------------
-extern GameScreen currentScreen;    // Defined in screens.c
+typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen;
 
 //----------------------------------------------------------------------------------
 // Main entry point
 //----------------------------------------------------------------------------------
+#if defined(PLATFORM_ANDROID)
+void android_main(struct android_app *app) 
+#else
 int main(void)
+#endif
 {
-	// Initialization
-	//---------------------------------------------------------
+    // Initialization
+    //--------------------------------------------------------------------------------------
     const int screenWidth = 800;
     const int screenHeight = 450;
-	const char windowTitle[30] = "<game name goes here>";
 
-    InitWindow(screenWidth, screenHeight, windowTitle);
+#if defined(PLATFORM_ANDROID)
+    InitWindow(screenWidth, screenHeight, app);
+#else
+    InitWindow(screenWidth, screenHeight, "raylib template - simple game");
+#endif
 
-    // Initialize all screens
-    InitLogoScreen();
-    InitTitleScreen();
-    InitGameplayScreen();
-    InitEndingScreen();
+    GameScreen currentScreen = LOGO;
 
-    // Define first screen
-    currentScreen = LOGO;
-    
-	SetTargetFPS(60);
-	//----------------------------------------------------------
+    // TODO: Initialize all required variables and load all required data here!
 
+    int framesCounter = 0;          // Useful to count frames
+
+    SetTargetFPS(60);               // Set desired framerate (frames-per-second)
+    //--------------------------------------------------------------------------------------
+    
     // Main game loop
     while (!WindowShouldClose())    // Detect window close button or ESC key
     {
@@ -53,10 +59,48 @@ int main(void)
         //----------------------------------------------------------------------------------
         switch(currentScreen) 
         {
-            case LOGO:      UpdateLogoScreen(); break;      // Update LOGO currentScreen
-            case TITLE:     UpdateTitleScreen(); break;     // Update TITLE currentScreen
-            case GAMEPLAY:  UpdateGameplayScreen(); break;  // Update GAMEPLAY currentScreen
-            case ENDING:    UpdateEndingScreen(); break;       // Update END currentScreen
+            case LOGO: 
+            {
+                // TODO: Update LOGO screen variables here!
+
+                framesCounter++;    // Count frames
+
+                // Wait for 2 seconds (120 frames) before jumping to TITLE screen
+                if (framesCounter > 120)
+                {
+                    currentScreen = TITLE;
+                }
+            } break;
+            case TITLE: 
+            {
+                // TODO: Update TITLE screen variables here!
+
+                // Press enter to change to GAMEPLAY screen
+                if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
+                {
+                    currentScreen = GAMEPLAY;
+                }
+            } break;
+            case GAMEPLAY:
+            { 
+                // TODO: Update GAMEPLAY screen variables here!
+
+                // Press enter to change to ENDING screen
+                if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
+                {
+                    currentScreen = ENDING;
+                } 
+            } break;
+            case ENDING: 
+            {
+                // TODO: Update ENDING screen variables here!
+
+                // Press enter to return to TITLE screen
+                if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
+                {
+                    currentScreen = TITLE;
+                }  
+            } break;
             default: break;
         }
         //----------------------------------------------------------------------------------
@@ -69,15 +113,40 @@ int main(void)
             
             switch(currentScreen) 
             {
-                case LOGO:      DrawLogoScreen(); break;        // Draw LOGO currentScreen
-                case TITLE:     DrawTitleScreen(); break;       // Draw TITLE currentScreen
-                case GAMEPLAY:  DrawGameplayScreen(); break;    // Draw GAMEPLAY currentScreen
-                case ENDING:    DrawEndingScreen(); break;         // Draw END currentScreen
+                case LOGO: 
+                {
+                    // TODO: Draw LOGO screen here!
+                    DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY);
+                    DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY);
+                    
+                } break;
+                case TITLE: 
+                {
+                    // TODO: Draw TITLE screen here!
+                    DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
+                    DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
+                    DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN);
+                    
+                } break;
+                case GAMEPLAY:
+                { 
+                    // TODO: Draw GAMEPLAY screen here!
+                    DrawRectangle(0, 0, screenWidth, screenHeight, PURPLE);
+                    DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
+                    DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, MAROON);
+
+                } break;
+                case ENDING: 
+                {
+                    // TODO: Draw ENDING screen here!
+                    DrawRectangle(0, 0, screenWidth, screenHeight, BLUE);
+                    DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
+                    DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, DARKBLUE);
+                    
+                } break;
                 default: break;
             }
         
-            DrawFPS(screenWidth - 100, 20);
-        
         EndDrawing();
         //----------------------------------------------------------------------------------
     }
@@ -85,14 +154,11 @@ int main(void)
     // De-Initialization
     //--------------------------------------------------------------------------------------
     
-    // Unload all loaded data (textures, fonts, audio)
-    UnloadLogoScreen();
-    UnloadTitleScreen();
-    UnloadGameplayScreen();
-    UnloadEndingScreen();
+    // TODO: Unload all loaded data (textures, fonts, audio) here!
     
     CloseWindow();        // Close window and OpenGL context
     //--------------------------------------------------------------------------------------
-	
+#if !defined(PLATFORM_ANDROID)
     return 0;
-}
+#endif
+}

+ 23 - 22
templates/standard_game/Makefile

@@ -78,20 +78,20 @@ endif
 # Define raylib release directory for compiled library
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
     ifeq ($(PLATFORM_OS),WINDOWS)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32
+        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32
     endif
     ifeq ($(PLATFORM_OS),LINUX)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux
+        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux
     endif
     ifeq ($(PLATFORM_OS),OSX)
-        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx
+        RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx
     endif
 endif
 ifeq ($(PLATFORM),PLATFORM_WEB)
-    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5
+    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
 endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
-    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi
+    RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/rpi
 endif
 
 # Define default C compiler: gcc
@@ -101,7 +101,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
     ifeq ($(PLATFORM_OS),OSX)
         # OSX default compiler
         CC = clang
-	endif
+    endif
 endif
 ifeq ($(PLATFORM),PLATFORM_RPI)
     ifeq ($(RPI_CROSS_COMPILE),YES)
@@ -120,7 +120,7 @@ MAKE = mingw32-make
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
     ifeq ($(PLATFORM_OS),LINUX)
         MAKE = make
-	endif
+    endif
 endif
 
 # Define compiler flags:
@@ -151,7 +151,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
     # -s ALLOW_MEMORY_GROWTH=1   # to allow memory resizing
     # -s TOTAL_MEMORY=16777216   # to specify heap memory size (default = 16MB)
     # -s USE_PTHREADS=1          # multithreading support
-    CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling TOTAL_MEMORY=16777216 --preload-file resources
+    CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s TOTAL_MEMORY=16777216 --preload-file resources
 endif
 
 # Define include paths for required headers
@@ -227,29 +227,30 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
     WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
 endif
 
-# Define all object files required
-PROJECT_SOURCE_FILES = standard_game.c\
-                       screens/screen_logo.c \
-                       screens/screen_title.c \
-                       screens/screen_options.c \
-                       screens/screen_gameplay.c \
-                       screens/screen_ending.c
-               
-OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
+# Define all source files required
+PROJECT_SOURCE_FILES ?= standard_game.c \
+                        screens/screen_logo.c \
+                        screens/screen_title.c \
+                        screens/screen_options.c \
+                        screens/screen_gameplay.c \
+                        screens/screen_ending.c
 
-CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
+# Define all object files from source files
+OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
 
+# For Android platform we call a custom Makefile.Android
 ifeq ($(PLATFORM),PLATFORM_ANDROID)
-    CURRENT_MAKEFILE = Makefile.Android 
+    MAKEFILE_PARAMS = -f Makefile.Android 
     export PROJECT_NAME
     export PROJECT_SOURCE_FILES
 else
-    CURRENT_MAKEFILE += -n $(PROJECT_NAME)
+    MAKEFILE_PARAMS = $(PROJECT_NAME)
 endif
 
 # Default target entry
-all: 
-	$(MAKE) -f $(CURRENT_MAKEFILE)
+# NOTE: We call this Makefile target or Makefile.Android target
+all:
+	$(MAKE) $(MAKEFILE_PARAMS)
 
 # Project target defined by PROJECT_NAME
 $(PROJECT_NAME): $(OBJS)

+ 3 - 3
templates/standard_game/Makefile.Android

@@ -30,7 +30,7 @@ RAYLIB_PATH ?= ..\..
 ANDROID_HOME = C:/android-sdk
 ANDROID_NDK = C:/android-ndk
 ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16
-ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/26.0.1
+ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/26.0.2
 ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
 JAVA_HOME = C:/PROGRA~1/Java/jdk1.8.0_144
 
@@ -144,7 +144,7 @@ create_temp_project_dirs:
 	$(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir)))
 
 define create_dir
-    if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1)
+	if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1)
 endef
     
 # Copy required shared libs for integration into APK
@@ -171,7 +171,7 @@ copy_project_resources:
 	copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y
 	@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/res/values/strings.xml
 	@echo ^<resources^>^<string name="app_name"^>$(APP_LABEL_NAME)^</string^>^</resources^> >> $(PROJECT_BUILD_PATH)/res/values/strings.xml
-	xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets /Y /E /F
+	if exist $(PROJECT_RESOURCES_PATH) xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets /Y /E /F
 
 # Generate NativeLoader.java to load required shared libraries
 # NOTE: Probably not the bet way to generate this file... but it works.

+ 2 - 2
templates/standard_game/screens/screen_ending.c

@@ -52,7 +52,7 @@ void UpdateEndingScreen(void)
     // TODO: Update ENDING screen variables here!
 
     // Press enter to return to TITLE screen
-    if (IsKeyPressed(KEY_ENTER))
+    if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
     {
         finishScreen = 1;
     }
@@ -64,7 +64,7 @@ void DrawEndingScreen(void)
     // TODO: Draw ENDING screen here!
     DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE);
     DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE);
-    DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 160, 220, 20, DARKBLUE);
+    DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 120, 220, 20, DARKBLUE);
 }
 
 // Ending Screen Unload logic

+ 2 - 2
templates/standard_game/screens/screen_gameplay.c

@@ -52,7 +52,7 @@ void UpdateGameplayScreen(void)
     // TODO: Update GAMEPLAY screen variables here!
 
     // Press enter to change to ENDING screen
-    if (IsKeyPressed(KEY_ENTER))
+    if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
     {
         finishScreen = 1;
     }
@@ -64,7 +64,7 @@ void DrawGameplayScreen(void)
     // TODO: Draw GAMEPLAY screen here!
     DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), PURPLE);
     DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON);
-    DrawText("PRESS ENTER to JUMP to ENDING SCREEN", 170, 220, 20, MAROON);
+    DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, MAROON);
 }
 
 // Gameplay Screen Unload logic

+ 2 - 2
templates/standard_game/screens/screen_title.c

@@ -52,7 +52,7 @@ void UpdateTitleScreen(void)
     // TODO: Update TITLE screen variables here!
 
     // Press enter to change to GAMEPLAY screen
-    if (IsKeyPressed(KEY_ENTER))
+    if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
     {
         //finishScreen = 1;   // OPTIONS
         finishScreen = 2;   // GAMEPLAY
@@ -65,7 +65,7 @@ void DrawTitleScreen(void)
     // TODO: Draw TITLE screen here!
     DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN);
     DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN);
-    DrawText("PRESS ENTER to JUMP to GAMEPLAY SCREEN", 160, 220, 20, DARKGREEN);
+    DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN);
 }
 
 // Title Screen Unload logic

+ 5 - 5
templates/standard_game/standard_game.c

@@ -8,7 +8,7 @@
 *   This game has been created using raylib (www.raylib.com)
 *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 *
-*   raylib - Copyright (c) 2014 Ramon Santamaria (@raysan5)
+*   Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
 *
 ********************************************************************************************/
 
@@ -28,8 +28,8 @@ void android_main(struct android_app *app)
 int main(void)
 #endif
 {
-	// Initialization
-	//---------------------------------------------------------
+    // Initialization
+    //---------------------------------------------------------
     const int screenWidth = 800;
     const int screenHeight = 450;
 
@@ -45,8 +45,8 @@ int main(void)
     currentScreen = LOGO;   // NOTE: currentScreen is defined in screens.h as a global variable
     InitLogoScreen();
     
-	SetTargetFPS(60);
-	//----------------------------------------------------------
+    SetTargetFPS(60);
+    //----------------------------------------------------------
 
     // Main game loop
     while (!WindowShouldClose())    // Detect window close button or ESC key