diff options
| author | raysan5 <[email protected]> | 2017-10-14 12:25:08 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2017-10-14 12:25:08 +0200 |
| commit | 0d8a994d9570c29780f4bb6977e8d52d538bba72 (patch) | |
| tree | 35562178f0ed80d1f1f25f6afa4e8532050cd9ab /templates/standard_game | |
| parent | d012316b87a5b1de44f7e9f0df88fc274c619e6f (diff) | |
| download | raylib-0d8a994d9570c29780f4bb6977e8d52d538bba72.tar.gz raylib-0d8a994d9570c29780f4bb6977e8d52d538bba72.zip | |
Review templates for Android
- Removed useless templates
- Reviewed all Makefiles
- Rework some code for Android support
- Added resources to advance template
Diffstat (limited to 'templates/standard_game')
| -rw-r--r-- | templates/standard_game/Makefile | 45 | ||||
| -rw-r--r-- | templates/standard_game/Makefile.Android | 6 | ||||
| -rw-r--r-- | templates/standard_game/screens/screen_ending.c | 4 | ||||
| -rw-r--r-- | templates/standard_game/screens/screen_gameplay.c | 4 | ||||
| -rw-r--r-- | templates/standard_game/screens/screen_title.c | 4 | ||||
| -rw-r--r-- | templates/standard_game/standard_game.c | 10 |
6 files changed, 37 insertions, 36 deletions
diff --git a/templates/standard_game/Makefile b/templates/standard_game/Makefile index 73205b38..201012e8 100644 --- a/templates/standard_game/Makefile +++ b/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) diff --git a/templates/standard_game/Makefile.Android b/templates/standard_game/Makefile.Android index 98efdeec..16220709 100644 --- a/templates/standard_game/Makefile.Android +++ b/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. diff --git a/templates/standard_game/screens/screen_ending.c b/templates/standard_game/screens/screen_ending.c index de16fc8f..56d37d12 100644 --- a/templates/standard_game/screens/screen_ending.c +++ b/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 diff --git a/templates/standard_game/screens/screen_gameplay.c b/templates/standard_game/screens/screen_gameplay.c index e6e45156..e64d6c5f 100644 --- a/templates/standard_game/screens/screen_gameplay.c +++ b/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 diff --git a/templates/standard_game/screens/screen_title.c b/templates/standard_game/screens/screen_title.c index c9700e8b..67a51a0f 100644 --- a/templates/standard_game/screens/screen_title.c +++ b/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 diff --git a/templates/standard_game/standard_game.c b/templates/standard_game/standard_game.c index f95087f7..d8264f71 100644 --- a/templates/standard_game/standard_game.c +++ b/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 |
