Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

Commit

Permalink
iOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
weimzh committed Nov 5, 2014
1 parent 5f6f785 commit 0fae9b3
Show file tree
Hide file tree
Showing 10 changed files with 1,202 additions and 7 deletions.
1 change: 0 additions & 1 deletion Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include "SDL.h"

static int audio_len = 0;
Expand Down
49 changes: 43 additions & 6 deletions BirdGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ static void *g_pSfxPoint = NULL;
static void *g_pSfxSwooshing = NULL;
static void *g_pSfxWing = NULL;

static bool g_bPauseGame = false;

#define GRAVITY 0.32f
#define WINGPOWER 5.2f
#define ROTATION 2.7f
Expand All @@ -86,7 +88,7 @@ extern "C" void RateApp();

static const char *MakeFileName(const char *path, bool bUserDir = false)
{
#ifdef __WINPHONE__
#if defined __WINPHONE__
static char buf[2][4096];
static int current = 0;
current ^= 1;
Expand All @@ -100,6 +102,25 @@ static const char *MakeFileName(const char *path, bool bUserDir = false)
mypath++;
strcat(buf[current], mypath);
return buf[current];
#elif defined __IPHONEOS__
static char buf[2][4096];
static int current = 0;
current ^= 1;
if (bUserDir)
{
char *p = SDL_GetPrefPath("", "");
strcpy(buf[current], p);
strcat(buf[current], path);
SDL_free(p);
}
else
{
char *p = SDL_GetBasePath();
strcpy(buf[current], p);
strcat(buf[current], "/");
strcat(buf[current], path);
}
return buf[current];
#else
return path;
#endif
Expand Down Expand Up @@ -204,6 +225,16 @@ static void UpdateEvents()
exit(0);
}
break;

#ifdef __IPHONEOS__
case SDL_APP_WILLENTERBACKGROUND:
g_bPauseGame = true;
break;

case SDL_APP_DIDENTERFOREGROUND:
g_bPauseGame = false;
break;
#endif
}
}
}
Expand Down Expand Up @@ -390,13 +421,13 @@ static void GameThink_Initial()
// user clicked "score" button
// TODO
}
else if (g_iMouseX > 105 && g_iMouseY > 275 && g_iMouseX < 105 + 64 && g_iMouseY < 275 + 32)
{
// user clicked "rate" button
else if (g_iMouseX > 105 && g_iMouseY > 275 && g_iMouseX < 105 + 64 && g_iMouseY < 275 + 32)
{
// user clicked "rate" button
#ifdef __WINPHONE__
RateApp();
RateApp();
#endif
}
}
}
}

Expand Down Expand Up @@ -836,6 +867,12 @@ int GameMain()
{
uiNextFrameTime += 1000 / 60;
}

if (g_bPauseGame)
{
continue;
}

FrameBegin();
switch (g_GameState)
{
Expand Down
1 change: 1 addition & 0 deletions Video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ void FrameBegin()
void FrameEnd()
{
SDL_SetRenderTarget(gpRenderer, NULL);

SDL_RenderCopy(gpRenderer, gpTexture, NULL, NULL);
SDL_RenderPresent(gpRenderer);
}
1 change: 1 addition & 0 deletions ios/SDL2/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Download SDL2 source code from http://libsdl.org/ and extract the code here.
1,117 changes: 1,117 additions & 0 deletions ios/SDLBird/SDLBird.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file added ios/SDLBird/SDLBird/Default-568h@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/SDLBird/SDLBird/Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/SDLBird/SDLBird/Default@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/SDLBird/SDLBird/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions ios/SDLBird/SDLBird/SDLBird-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>Icon</string>
<key>CFBundleIdentifier</key>
<string>com.weimzh.sdlbird</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<false/>
<key>UIFileSharingEnabled</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>

0 comments on commit 0fae9b3

Please sign in to comment.