Permalink
Browse files

Initial push

  • Loading branch information...
jcayzac committed Feb 22, 2012
0 parents commit 62e8b80aa2ed6e840fe7f4caad3c97e426705ba4
Showing with 9,836 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. BIN assets.7z
  3. BIN external.7z
  4. +215 −0 gamesrc/LittleBombers.cpp
  5. +48 −0 gamesrc/LittleBombers.h
  6. BIN iphone/Default.png
  7. +32 −0 iphone/LittleBombers-Info.plist
  8. +1,419 −0 iphone/LittleBombers.xcodeproj/jcayzac.mode1v3
  9. +510 −0 iphone/LittleBombers.xcodeproj/jcayzac.pbxuser
  10. +759 −0 iphone/LittleBombers.xcodeproj/project.pbxproj
  11. +7 −0 iphone/LittleBombers.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  12. BIN ...mbers.xcodeproj/project.xcworkspace/xcuserdata/jcayzac.xcuserdatad/UserInterfaceState.xcuserstate
  13. +8 −0 ...Bombers.xcodeproj/project.xcworkspace/xcuserdata/jcayzac.xcuserdatad/WorkspaceSettings.xcsettings
  14. +84 −0 iphone/LittleBombers.xcodeproj/xcuserdata/jcayzac.xcuserdatad/xcschemes/LittleBombers.xcscheme
  15. +22 −0 iphone/LittleBombers.xcodeproj/xcuserdata/jcayzac.xcuserdatad/xcschemes/xcschememanagement.plist
  16. +121 −0 iphone/MainWindow.xib
  17. BIN iphone/icon.png
  18. +104 −0 iphone/src/BackgroundMusic.mm
  19. +58 −0 iphone/src/IPod.cpp
  20. +8 −0 iphone/src/IPod.h
  21. +465 −0 iphone/src/main.mm
  22. +70 −0 src/Base.h
  23. +64 −0 src/FileSystem.cpp
  24. +36 −0 src/FileSystem.h
  25. +31 −0 src/Game.cpp
  26. +66 −0 src/Game.h
  27. +54 −0 src/Loader.cpp
  28. +31 −0 src/Loader.h
  29. +205 −0 src/Model.cpp
  30. +253 −0 src/Model.h
  31. +41 −0 src/Platform.cpp
  32. +13 −0 src/Platform.h
  33. +38 −0 src/ResourceFile.cpp
  34. +34 −0 src/ResourceFile.h
  35. +36 −0 src/Texture.cpp
  36. +16 −0 src/Texture.h
  37. +13 −0 src/Types.h
  38. +27 −0 src/audio/BackgroundMusic.h
  39. +114 −0 src/audio/Sound.cpp
  40. +30 −0 src/audio/Sound.h
  41. +235 −0 src/audio/devices/OpenAL.cpp
  42. +34 −0 src/audio/devices/OpenAL.h
  43. +87 −0 src/codecs/Codec.cpp
  44. +86 −0 src/codecs/Codec.h
  45. +147 −0 src/codecs/audio/AppleAudio.cpp
  46. +23 −0 src/codecs/audio/AppleAudio.h
  47. +21 −0 src/codecs/audio/AudioBase.cpp
  48. +27 −0 src/codecs/audio/AudioBase.h
  49. +118 −0 src/codecs/audio/Vorbis.cpp
  50. +21 −0 src/codecs/audio/Vorbis.h
  51. +31 −0 src/geometry/cone.h
  52. +11 −0 src/geometry/geometry.h
  53. +66 −0 src/geometry/intersection.h
  54. +17 −0 src/geometry/lowlevel/implementation.h
  55. +298 −0 src/geometry/lowlevel/implementations/default.h
  56. +103 −0 src/geometry/lowlevel/implementations/neon.h
  57. +102 −0 src/geometry/lowlevel/implementations/vfp.h
  58. +47 −0 src/geometry/matrix.h
  59. +22 −0 src/geometry/sphere.h
  60. +47 −0 src/geometry/vec3f.h
  61. +917 −0 src/pvrt/PVRTDecompress.cpp
  62. +53 −0 src/pvrt/PVRTDecompress.h
  63. +231 −0 src/pvrt/PVRTGlobal.h
  64. +162 −0 src/pvrt/PVRTTexture.cpp
  65. +370 −0 src/pvrt/PVRTTexture.h
  66. +482 −0 src/pvrt/PVRTTextureAPI.cpp
  67. +62 −0 src/pvrt/PVRTTextureAPI.h
  68. +323 −0 src/pvrt/PVRTglesExt.cpp
  69. +349 −0 src/pvrt/PVRTglesExt.h
  70. +4 −0 src/renderers/OpenGLES11Renderer.cpp
  71. +14 −0 src/renderers/OpenGLES11Renderer.h
  72. +4 −0 src/scene/Camera.cpp
  73. +28 −0 src/scene/Camera.h
  74. +23 −0 src/scene/Class.cpp
  75. +41 −0 src/scene/Class.h
  76. +4 −0 src/scene/Instance.cpp
  77. +19 −0 src/scene/Instance.h
  78. +36 −0 src/utility/Buffer.cpp
  79. +33 −0 src/utility/Buffer.h
  80. +4 −0 src/utility/countable_list.cpp
  81. +78 −0 src/utility/countable_list.h
  82. +21 −0 src/utility/tribool.h
@@ -0,0 +1,3 @@
+.DS_Store
+build
+
BIN assets.7z
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,215 @@
+#include "LittleBombers.h"
+
+// Game factory
+Game* Game::createGame() { return new (nothrow) LittleBombers; }
+
+
+
+void LittleBombers::restartMusic() {
+ DEBUG_LOG("[LittleBombers] (Re)starting background music…");
+ if (mBackgroundMusic) mBackgroundMusic->play(0,1);
+}
+
+bool LittleBombers::init(float width, float height) {
+ _characterX = 0;
+ _characterTargetX = 0;
+ _characterRotationY = 90;
+ _cameraZ = 0;
+ _cameraTargetZ = 0;
+ _controlX = 0;
+
+ // ★★★★★★★★★★★ Load resources ★★★★★★★★★★★
+
+ // Background music
+ mBackgroundMusic.reset(new (nothrow) BackgroundMusic);
+ if (mBackgroundMusic) {
+ if (!mBackgroundMusic->init("City Night Crowd.mp4")) {
+ DEBUG_LOG("[LittleBombers] Can't start background music…");
+ return false;
+ }
+ mBackgroundMusic->playbackEndedSignal.connect(boost::bind(&LittleBombers::restartMusic, this));
+ restartMusic();
+ }
+ else {
+ DEBUG_LOG("[LittleBombers] Can't alloc background music…");
+ }
+
+
+ for (int i=0; i<10; ++i)
+ if (!mStageModel[i].init("Stage1a.md2"))
+ return false;
+
+ for (int i=0; i<8; ++i) {
+ if (!mCharacterModel[i].init("megaman.md2"))
+ return false;
+ mCharacterModel[i].setAnimation(ModelT::ANIM_WAVE);
+ }
+ if (!mStageTexture.init("Stage1a_Grid.pvr"))
+ return false;
+ if (!mCharacterTexture.init("megaman.pvr"))
+ return false;
+
+
+ if (!mFX.init("Crickets.ogg", true))
+ return false;
+
+ setupPerspective(.1f, 1000.f, 60.f, width, height);
+
+ // Setup opengl
+ glEnableClientState( GL_VERTEX_ARRAY);
+ glEnableClientState( GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState( GL_NORMAL_ARRAY);
+ // glEnable( GL_BLEND);
+ // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ // Normals are encoded as bytes whose value is -127..+127,
+ // so we need them to be normalized:
+ glEnable(GL_NORMALIZE);
+ // Scale the texture matrix so that -32767..+32767 gets normalized to -1..+1:
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ const float fiou = 1.f/32767.f;
+ glScalef(fiou, fiou, 1.f);
+ glMatrixMode(GL_MODELVIEW);
+
+ glEnable( GL_TEXTURE_2D);
+ glCullFace(GL_BACK);
+
+ externalAudio.connect(boost::bind(&LittleBombers::externalAudioHandler, this, _1));
+ touchesBegan.connect(boost::bind(&LittleBombers::touchesBeganHandler, this, _1));
+ touchesEnded.connect(boost::bind(&LittleBombers::touchesEndedHandler, this, _1));
+ touchesMoved.connect(boost::bind(&LittleBombers::touchesMovedHandler, this, _1));
+
+ GLint alphaBits;
+ glGetIntegerv(GL_ALPHA_BITS, &alphaBits);
+ return true;
+}
+void LittleBombers::update(float elapsed) {
+ for (int i=0; i<10; ++i)
+ mStageModel[i].update(elapsed);
+
+ for (int i=0; i<8; ++i)
+ mCharacterModel[i].update(elapsed);
+
+ _cameraTargetZ = -0.f - fabsf(_characterX * 2.13f);
+ _cameraZ += (_cameraTargetZ - _cameraZ) * 0.1f;
+
+ _characterTargetX += _controlX * elapsed * 20;
+ _characterX += (_characterTargetX - _characterX) * 0.6f;
+
+
+}
+
+void LittleBombers::draw() const {
+ glClearColor( 0, 0.0f, 0.12f, 1);
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glEnable(GL_DEPTH_TEST);
+
+ // Setup Camera
+ glMatrixMode( GL_MODELVIEW);
+ glLoadIdentity();
+
+// if (isLandscape)
+// glRotatef( -90, 0, 0, 1 );
+
+ glTranslatef( 0, -5, _cameraZ);
+ glRotatef( -45.0f, 1, 0, 0 );
+ glRotatef( -90.0f, 0, 0, 1 );
+
+ // Lights
+ static GLfloat lightPosition[4] = { 0, 20, 0, 1};
+ static GLfloat lightDefuse[4] = { 1, 1, 1, 1};
+ static GLfloat lightAmbient[4] = { 0.8, 0.8, 0.8, 1};
+
+ glDisable(GL_LIGHTING);
+ glDisable(GL_LIGHT0);
+
+ glEnable( GL_LIGHTING);
+ glEnable( GL_LIGHT0);
+ glLightfv( GL_LIGHT0, GL_DIFFUSE, lightDefuse);
+ glLightfv( GL_LIGHT0, GL_AMBIENT, lightAmbient);
+ glLightf( GL_LIGHT0, GL_SPOT_EXPONENT, 50);
+ glLightfv( GL_LIGHT0, GL_POSITION, lightPosition);
+
+ // Draw Stage
+ mStageTexture.bind(0);
+ const VertexBufferT& stageVB = mStageModel[0].renderBuffer();
+ for (int x=-5; x<=5; ++x) {
+ for (int y=-2; y<=2; ++y) {
+ glPushMatrix();
+ glTranslatef(y*64, x*64, 0);
+ glScalef( 2, 2, 2);
+ //processRenderBuffer(mStageModel[(y+1)*3+x+1].renderBuffer());
+ processRenderBuffer(stageVB);
+ glPopMatrix();
+ }
+ }
+
+ // Draw Character
+ mCharacterTexture.bind(0);
+ glPushMatrix();
+ glTranslatef( -8, _characterX, 2.5f);
+ glRotatef( _characterRotationY, 0, 0, 1);
+ glScalef( 0.119f, 0.119f, 0.119f);
+ processRenderBuffer(mCharacterModel[0].renderBuffer());
+ glPopMatrix();
+
+ const VertexBufferT& modelVB = mCharacterModel[1].renderBuffer();
+ for (int i=1; i<8; ++i) {
+ glPushMatrix();
+ glTranslatef( -8, i*4, 2.5f);
+ glScalef( 0.12f, 0.12f, 0.12f);
+ //processRenderBuffer(mCharacterModel[i].renderBuffer());
+ processRenderBuffer(modelVB);
+ glPopMatrix();
+ }
+
+ glDisable( GL_LIGHT0);
+ glDisable( GL_LIGHTING);
+
+}
+
+
+void LittleBombers::saveState() {
+}
+bool LittleBombers::loadState() {
+ return true;
+}
+void LittleBombers::clear() {
+}
+
+
+
+void LittleBombers::touchesBeganHandler(const std::vector<TouchEvent>& touches) {
+ const TouchEvent& touch = touches[0];
+
+ _controlX = (touch.screenX / 160.f) - 1;
+ _characterRotationY = _controlX > 0 ? 90 : -90;
+
+ mCharacterModel[0].setAnimation(ModelT::ANIM_MOVE);
+ mCharacterModel[0].setFpsScale(fabsf(_controlX));
+
+ mFX.play();
+}
+
+void LittleBombers::touchesEndedHandler(const std::vector<TouchEvent>& touches) {
+ mCharacterModel[0].setAnimation(ModelT::ANIM_WAVE);
+ _controlX = 0;
+ _characterRotationY = 0;
+}
+
+void LittleBombers::touchesMovedHandler(const std::vector<TouchEvent>& touches) {
+ const TouchEvent& touch = touches[0];
+ _controlX = (touch.screenX / 160.0f) - 1;
+ _characterRotationY = _controlX > 0 ? 90 : -90;
+
+ mCharacterModel[0].setFpsScale(fabsf(_controlX));
+
+}
+
+void LittleBombers::externalAudioHandler(bool systemIsPlaying) {
+ if (systemIsPlaying && mBackgroundMusic) mBackgroundMusic->stop();
+ else restartMusic();
+}
+
+
+
@@ -0,0 +1,48 @@
+#if !defined(UUID_26908E249C8B4E55B4104ABA2191C54F)
+#define UUID_26908E249C8B4E55B4104ABA2191C54F
+
+#include "Game.h"
+#include "Model.h"
+#include "Texture.h"
+#include "Sound.h"
+#include "BackgroundMusic.h"
+#include "OpenGLES11Renderer.h"
+
+class LittleBombers: protected Game {
+public:
+ void restartMusic();
+
+ // From Game
+ bool init(float width, float height);
+ void update(float elapsed);
+ void draw() const;
+ void saveState();
+ bool loadState();
+ void clear();
+
+private:
+ // Event handlers
+ void touchesBeganHandler(const std::vector<TouchEvent>& touches);
+ void touchesEndedHandler(const std::vector<TouchEvent>& touches);
+ void touchesMovedHandler(const std::vector<TouchEvent>& touches);
+ void externalAudioHandler(bool systemIsPlaying);
+
+private:
+ ModelT mStageModel[100], mCharacterModel[8];
+ TextureT mStageTexture, mCharacterTexture;
+
+
+ boost::shared_ptr<BackgroundMusic> mBackgroundMusic;
+
+
+ SoundFX mFX;
+ GLfloat _characterRotationY;
+ GLfloat _controlX;
+ GLfloat _characterX;
+ GLfloat _characterTargetX;
+ GLfloat _cameraZ;
+ GLfloat _cameraTargetZ;
+};
+
+#endif // UUID_26908E249C8B4E55B4104ABA2191C54F
+
Binary file not shown.
@@ -0,0 +1,32 @@
+<?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>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string>icon.png</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.mobake.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>NSMainNibFile</key>
+ <string>MainWindow</string>
+ <key>NSMainNibFile~ipad</key>
+ <string>MainWindow-iPad</string>
+</dict>
+</plist>
Oops, something went wrong.

0 comments on commit 62e8b80

Please sign in to comment.