From 6e5ceaa30d577dd2e2e8b03c3d9eb16680d6834e Mon Sep 17 00:00:00 2001 From: victorfisac Date: Wed, 30 Dec 2015 03:12:52 +0100 Subject: Fixed Android compilation with 1.3 updates - Fixed Android MakeFile adding gestures module. - Fixed Android project template functions names. - Updated compiled library and header. --- templates/android_project/jni/basic_game.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'templates/android_project/jni/basic_game.c') diff --git a/templates/android_project/jni/basic_game.c b/templates/android_project/jni/basic_game.c index 987599a8..bf2d5d02 100644 --- a/templates/android_project/jni/basic_game.c +++ b/templates/android_project/jni/basic_game.c @@ -70,7 +70,7 @@ void android_main(struct android_app *app) // TODO: Update TITLE screen variables here! // Press enter to change to GAMEPLAY screen - if (IsScreenTouched()) + if (IsGestureDetected()) { PlaySound(fx); currentScreen = GAMEPLAY; @@ -81,7 +81,7 @@ void android_main(struct android_app *app) // TODO: Update GAMEPLAY screen variables here! // Press enter to change to ENDING screen - if (IsScreenTouched()) + if (IsGestureDetected()) { PlaySound(fx); currentScreen = ENDING; @@ -92,7 +92,7 @@ void android_main(struct android_app *app) // TODO: Update ENDING screen variables here! // Press enter to return to TITLE screen - if (IsScreenTouched()) + if (IsGestureDetected()) { PlaySound(fx); currentScreen = TITLE; -- cgit v1.2.3 From 8e30bd1f697b793babd183b6d172cdbd7b679d80 Mon Sep 17 00:00:00 2001 From: victorfisac Date: Wed, 30 Dec 2015 04:43:24 +0100 Subject: Fixed and improved android template - Added gestures module functions. - Fixed screen tap detection. --- templates/android_project/jni/basic_game.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'templates/android_project/jni/basic_game.c') diff --git a/templates/android_project/jni/basic_game.c b/templates/android_project/jni/basic_game.c index bf2d5d02..482011a0 100644 --- a/templates/android_project/jni/basic_game.c +++ b/templates/android_project/jni/basic_game.c @@ -30,8 +30,9 @@ void android_main(struct android_app *app) const int screenHeight = 450; GameScreen currentScreen = LOGO; - + InitWindow(screenWidth, screenHeight, app); + InitGesturesSystem(app); // TODO: Initialize all required variables and load all required data here! @@ -50,7 +51,7 @@ void android_main(struct android_app *app) while (!WindowShouldClose()) // Detect window close button or ESC key { // Update - //---------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------- switch(currentScreen) { case LOGO: @@ -70,7 +71,7 @@ void android_main(struct android_app *app) // TODO: Update TITLE screen variables here! // Press enter to change to GAMEPLAY screen - if (IsGestureDetected()) + if (GetGestureType() == GESTURE_TAP) { PlaySound(fx); currentScreen = GAMEPLAY; @@ -81,8 +82,8 @@ void android_main(struct android_app *app) // TODO: Update GAMEPLAY screen variables here! // Press enter to change to ENDING screen - if (IsGestureDetected()) - { + if (GetGestureType() == GESTURE_TAP) + { PlaySound(fx); currentScreen = ENDING; } @@ -92,7 +93,7 @@ void android_main(struct android_app *app) // TODO: Update ENDING screen variables here! // Press enter to return to TITLE screen - if (IsGestureDetected()) + if (GetGestureType() == GESTURE_TAP) { PlaySound(fx); currentScreen = TITLE; @@ -100,6 +101,8 @@ void android_main(struct android_app *app) } break; default: break; } + + UpdateGestures(); //---------------------------------------------------------------------------------- // Draw -- cgit v1.2.3 From 46ea55659393447c33c412cf19a42deecebaa98e Mon Sep 17 00:00:00 2001 From: raysan5 Date: Thu, 31 Dec 2015 13:34:45 +0100 Subject: Gestures system is automatically Init and Updated --- templates/android_project/jni/basic_game.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'templates/android_project/jni/basic_game.c') diff --git a/templates/android_project/jni/basic_game.c b/templates/android_project/jni/basic_game.c index 482011a0..e8a7e67a 100644 --- a/templates/android_project/jni/basic_game.c +++ b/templates/android_project/jni/basic_game.c @@ -32,7 +32,6 @@ void android_main(struct android_app *app) GameScreen currentScreen = LOGO; InitWindow(screenWidth, screenHeight, app); - InitGesturesSystem(app); // TODO: Initialize all required variables and load all required data here! @@ -51,7 +50,7 @@ void android_main(struct android_app *app) while (!WindowShouldClose()) // Detect window close button or ESC key { // Update - //---------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------- switch(currentScreen) { case LOGO: @@ -101,8 +100,6 @@ void android_main(struct android_app *app) } break; default: break; } - - UpdateGestures(); //---------------------------------------------------------------------------------- // Draw -- cgit v1.2.3 From 3a739c38c591687d0e298a85f1e7bfe4666076bd Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 3 Jan 2016 13:01:42 +0100 Subject: Updated Android project template --- templates/android_project/assets/ambient.ogg | Bin 0 -> 2672956 bytes templates/android_project/jni/basic_game.c | 6 +++++- templates/android_project/jni/include/raylib.h | 26 +++++++++++++++++-------- templates/android_project/jni/libs/libraylib.a | Bin 1536620 -> 1617368 bytes 4 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 templates/android_project/assets/ambient.ogg (limited to 'templates/android_project/jni/basic_game.c') diff --git a/templates/android_project/assets/ambient.ogg b/templates/android_project/assets/ambient.ogg new file mode 100644 index 00000000..af7f836e Binary files /dev/null and b/templates/android_project/assets/ambient.ogg differ diff --git a/templates/android_project/jni/basic_game.c b/templates/android_project/jni/basic_game.c index e8a7e67a..8a0413c3 100644 --- a/templates/android_project/jni/basic_game.c +++ b/templates/android_project/jni/basic_game.c @@ -43,7 +43,9 @@ void android_main(struct android_app *app) int framesCounter = 0; // Used to count frames - //SetTargetFPS(60); // Not required on Android, already locked to 60 fps + PlayMusicStream("ambient.ogg"); + + SetTargetFPS(60); // Not required on Android, already locked to 60 fps //-------------------------------------------------------------------------------------- // Main game loop @@ -51,6 +53,8 @@ void android_main(struct android_app *app) { // Update //---------------------------------------------------------------------------------- + UpdateMusicStream(); + switch(currentScreen) { case LOGO: diff --git a/templates/android_project/jni/include/raylib.h b/templates/android_project/jni/include/raylib.h index 4eefa3ea..864a240a 100644 --- a/templates/android_project/jni/include/raylib.h +++ b/templates/android_project/jni/include/raylib.h @@ -1,6 +1,6 @@ /********************************************************************************************** * -* raylib 1.3.0 (www.raylib.com) +* raylib 1.4.0 (www.raylib.com) * * A simple and easy-to-use library to learn videogames programming * @@ -70,7 +70,7 @@ #endif #if defined(PLATFORM_ANDROID) - #include // Defines android_app struct + typedef struct android_app; // Define android_app struct (android_native_app_glue.h) #endif //---------------------------------------------------------------------------------- @@ -291,6 +291,8 @@ typedef struct SpriteFont { int numChars; // Number of characters int *charValues; // Characters values array Rectangle *charRecs; // Characters rectangles within the texture + Vector2 *charOffsets; // Characters offsets (on drawing) + int *charAdvanceX; // Characters x advance (on drawing) } SpriteFont; // Camera type, defines a camera position/orientation in 3d space @@ -430,6 +432,17 @@ typedef enum { GESTURE_PINCH_OUT = 1024 } Gestures; +typedef enum { TOUCH_UP, TOUCH_DOWN, TOUCH_MOVE } TouchAction; + +// Gesture events +// NOTE: MAX_TOUCH_POINTS fixed to 4 +typedef struct { + int touchAction; + int pointCount; + int pointerId[4]; + Vector2 position[4]; +} GestureEvent; + // Camera system modes typedef enum { CAMERA_CUSTOM = 0, CAMERA_FREE, CAMERA_ORBITAL, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON } CameraMode; @@ -569,16 +582,11 @@ Vector2 GetTouchPosition(void); // Returns touch positio //------------------------------------------------------------------------------------ // Gestures and Touch Handling Functions (Module: gestures) //------------------------------------------------------------------------------------ -Vector2 GetRawTouchPosition(void); // Get touch position (raw) -#if defined(PLATFORM_WEB) -void InitGesturesSystem(void); // Init gestures system (web) -#elif defined(PLATFORM_ANDROID) -void InitGesturesSystem(struct android_app *app); // Init gestures system (android) -#endif void UpdateGestures(void); // Update gestures detected (must be called every frame) bool IsGestureDetected(void); // Check if a gesture have been detected int GetGestureType(void); // Get latest detected gesture void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags +void ProcessGestureEvent(GestureEvent event); // Process gesture event and translate it into gestures float GetGestureDragIntensity(void); // Get gesture drag intensity float GetGestureDragAngle(void); // Get gesture drag angle @@ -654,6 +662,7 @@ Color *GetImageData(Image image); Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two) void ImageFormat(Image *image, int newFormat); // Convert image data to desired format +void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) Image ImageCopy(Image image); // Create an image duplicate (useful for transformations) void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle void ImageResize(Image *image, int newWidth, int newHeight); // Resize and image (bilinear filtering) @@ -692,6 +701,7 @@ Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, int fontSize, int void DrawFPS(int posX, int posY); // Shows current FPS on top-left corner const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed' +const char *SubText(const char *text, int position, int length); // Get a piece of a text string //------------------------------------------------------------------------------------ // Basic 3d Shapes Drawing Functions (Module: models) diff --git a/templates/android_project/jni/libs/libraylib.a b/templates/android_project/jni/libs/libraylib.a index 35d3e07d..14e10ab7 100644 Binary files a/templates/android_project/jni/libs/libraylib.a and b/templates/android_project/jni/libs/libraylib.a differ -- cgit v1.2.3