├── bluegin ├── jni │ ├── bluegin │ │ ├── src │ │ │ ├── bluegin.cpp │ │ │ ├── bluegin_common.cpp │ │ │ ├── bluegin_cinder.cpp │ │ │ ├── graphic.cpp │ │ │ └── sound.cpp │ │ ├── include │ │ │ └── bluegin │ │ │ │ ├── input.h │ │ │ │ ├── common.h │ │ │ │ ├── graphic.h │ │ │ │ ├── sound.h │ │ │ │ ├── android.h │ │ │ │ └── config.h │ │ └── Android.mk │ ├── Application.mk │ ├── Box2D │ │ ├── Box2D_v2.1.2 │ │ │ └── Box2D │ │ │ │ └── Box2D │ │ │ │ ├── Box2DConfig.cmake │ │ │ │ ├── Common │ │ │ │ ├── b2Settings.cpp │ │ │ │ ├── b2StackAllocator.h │ │ │ │ ├── b2BlockAllocator.h │ │ │ │ ├── b2Math.cpp │ │ │ │ └── b2StackAllocator.cpp │ │ │ │ ├── Dynamics │ │ │ │ ├── b2TimeStep.h │ │ │ │ ├── Contacts │ │ │ │ │ ├── b2CircleContact.h │ │ │ │ │ ├── b2PolygonContact.h │ │ │ │ │ ├── b2PolygonAndCircleContact.h │ │ │ │ │ ├── b2TOISolver.h │ │ │ │ │ ├── b2CircleContact.cpp │ │ │ │ │ ├── b2PolygonContact.cpp │ │ │ │ │ ├── b2PolygonAndCircleContact.cpp │ │ │ │ │ └── b2ContactSolver.h │ │ │ │ ├── b2ContactManager.h │ │ │ │ ├── b2WorldCallbacks.cpp │ │ │ │ ├── Joints │ │ │ │ │ └── b2WeldJoint.h │ │ │ │ └── b2Island.h │ │ │ │ ├── Collision │ │ │ │ ├── b2TimeOfImpact.h │ │ │ │ └── Shapes │ │ │ │ │ ├── b2CircleShape.h │ │ │ │ │ └── b2CircleShape.cpp │ │ │ │ └── Box2D.h │ │ └── Android.mk │ ├── flx │ │ ├── include │ │ │ └── flx │ │ │ │ ├── data │ │ │ │ ├── accelerometer.h │ │ │ │ ├── list.h │ │ │ │ ├── rect.h │ │ │ │ ├── matrix.h │ │ │ │ ├── anim.h │ │ │ │ ├── flash.h │ │ │ │ ├── quake.h │ │ │ │ ├── fade.h │ │ │ │ └── touch.h │ │ │ │ ├── phy │ │ │ │ ├── pworld.h │ │ │ │ ├── pgame.h │ │ │ │ ├── psprite.h │ │ │ │ └── pdebugdraw.h │ │ │ │ ├── FlxApp.h │ │ │ │ ├── game.h │ │ │ │ ├── render.h │ │ │ │ ├── tileblock.h │ │ │ │ ├── quadtree.h │ │ │ │ └── state.h │ │ ├── src │ │ │ ├── data │ │ │ │ ├── anim.cpp │ │ │ │ ├── rect.cpp │ │ │ │ ├── list.cpp │ │ │ │ ├── flash.cpp │ │ │ │ ├── quake.cpp │ │ │ │ ├── fade.cpp │ │ │ │ ├── matrix.cpp │ │ │ │ └── touch.cpp │ │ │ ├── state.cpp │ │ │ ├── phy │ │ │ │ ├── pworld.cpp │ │ │ │ └── psprite.cpp │ │ │ ├── tileblock.cpp │ │ │ └── FlxApp.cpp │ │ └── Android.mk │ ├── Android.mk │ ├── cinder │ │ ├── include │ │ │ └── cinder │ │ │ │ ├── Cinder_BlueGin.h │ │ │ │ ├── BSplineFit.h │ │ │ │ ├── app │ │ │ │ ├── Event.h │ │ │ │ └── ResizeEvent.h │ │ │ │ ├── Exception.h │ │ │ │ ├── Sphere.h │ │ │ │ ├── AxisAlignedBox.h │ │ │ │ ├── gl │ │ │ │ ├── Material.h │ │ │ │ └── DisplayList.h │ │ │ │ ├── PolyLine.h │ │ │ │ ├── BandedMatrix.h │ │ │ │ ├── Ray.h │ │ │ │ └── Perlin.h │ │ ├── Android.mk │ │ └── src │ │ │ ├── Exception.cpp │ │ │ ├── gl │ │ │ ├── Material.cpp │ │ │ └── DisplayList.cpp │ │ │ ├── PolyLine.cpp │ │ │ ├── Rand.cpp │ │ │ ├── Shape2d.cpp │ │ │ └── samples │ │ │ └── VBOSample │ │ │ └── VBOTest.cpp │ └── rapidxml │ │ └── rapidxml-1.13 │ │ └── license.txt ├── custom_rules.xml ├── examples │ ├── text_display.cpp │ └── sprite_basic.cpp ├── Common.mk ├── AndroidManifest.xml ├── project.properties ├── BlueGin.mk ├── Modules.mk └── src │ └── com │ └── expb │ └── bluegin │ ├── Native.java │ ├── TouchEventHandler.java │ ├── SingleTouchEventHandler.java │ ├── Accelerometer.java │ └── MultiTouchEventHandler.java ├── samples └── FlxMode │ ├── rebuild │ ├── data │ ├── bot.png │ ├── dirt.png │ ├── gibs.png │ ├── hit.mp3 │ ├── jet.png │ ├── jump.mp3 │ ├── mode.mp3 │ ├── asplode.mp3 │ ├── bullet.png │ ├── nokia.png │ ├── notch.png │ ├── shoot.mp3 │ ├── spawner.png │ ├── dirt_top.png │ ├── spaceman.png │ ├── bot_bullet.png │ ├── menu_hit_2.mp3 │ ├── spawner_gibs.png │ ├── tech_tiles.png │ ├── resources.pack │ ├── mode.oep │ └── nokia.fnt │ ├── res │ ├── values │ │ └── strings.xml │ └── layout │ │ └── main.xml │ ├── jni │ ├── Application.mk │ ├── include │ │ └── mode │ │ │ ├── Mode.h │ │ │ ├── MenuState.h │ │ │ ├── Bullet.h │ │ │ ├── BotBullet.h │ │ │ ├── PlayStateTiles.h │ │ │ ├── Bot.h │ │ │ ├── Spawner.h │ │ │ ├── Player.h │ │ │ └── PlayState.h │ ├── Android.mk │ └── src │ │ ├── ModeApp.cpp │ │ ├── BotBullet.cpp │ │ ├── Bullet.cpp │ │ └── Spawner.cpp │ ├── src │ └── com │ │ └── expb │ │ └── flxmode │ │ └── FlxModeActivity.java │ ├── project.properties │ ├── ant.properties │ └── AndroidManifest.xml ├── .hgignore ├── vc9 └── BlueGin │ ├── BlueGin.vsprops │ ├── BlueGin-debug.vsprops │ └── BlueGin.sln └── README /bluegin/jni/bluegin/src/bluegin.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/FlxMode/rebuild: -------------------------------------------------------------------------------- 1 | ndk-build && ant debug && adb -d install -r bin/FlxMode-debug.apk 2 | 3 | -------------------------------------------------------------------------------- /bluegin/jni/bluegin/include/bluegin/input.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace bluegin { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /samples/FlxMode/data/bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/bot.png -------------------------------------------------------------------------------- /samples/FlxMode/data/dirt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/dirt.png -------------------------------------------------------------------------------- /samples/FlxMode/data/gibs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/gibs.png -------------------------------------------------------------------------------- /samples/FlxMode/data/hit.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/hit.mp3 -------------------------------------------------------------------------------- /samples/FlxMode/data/jet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/jet.png -------------------------------------------------------------------------------- /samples/FlxMode/data/jump.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/jump.mp3 -------------------------------------------------------------------------------- /samples/FlxMode/data/mode.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/mode.mp3 -------------------------------------------------------------------------------- /samples/FlxMode/data/asplode.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/asplode.mp3 -------------------------------------------------------------------------------- /samples/FlxMode/data/bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/bullet.png -------------------------------------------------------------------------------- /samples/FlxMode/data/nokia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/nokia.png -------------------------------------------------------------------------------- /samples/FlxMode/data/notch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/notch.png -------------------------------------------------------------------------------- /samples/FlxMode/data/shoot.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/shoot.mp3 -------------------------------------------------------------------------------- /samples/FlxMode/data/spawner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/spawner.png -------------------------------------------------------------------------------- /samples/FlxMode/data/dirt_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/dirt_top.png -------------------------------------------------------------------------------- /samples/FlxMode/data/spaceman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/spaceman.png -------------------------------------------------------------------------------- /samples/FlxMode/data/bot_bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/bot_bullet.png -------------------------------------------------------------------------------- /samples/FlxMode/data/menu_hit_2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/menu_hit_2.mp3 -------------------------------------------------------------------------------- /samples/FlxMode/data/spawner_gibs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/spawner_gibs.png -------------------------------------------------------------------------------- /samples/FlxMode/data/tech_tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/safetydank/bluegin/HEAD/samples/FlxMode/data/tech_tiles.png -------------------------------------------------------------------------------- /bluegin/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_OPTIM := release 2 | APP_STL := gnustl_static 3 | APP_CPPFLAGS := -fexceptions -frtti 4 | APP_ABI := armeabi armeabi-v7a 5 | 6 | -------------------------------------------------------------------------------- /samples/FlxMode/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mode / Flx 4 | 5 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_OPTIM := release 2 | APP_STL := gnustl_static 3 | APP_CPPFLAGS := -fexceptions -frtti 4 | APP_ABI := armeabi armeabi-v7a 5 | 6 | -------------------------------------------------------------------------------- /bluegin/jni/Box2D/Box2D_v2.1.2/Box2D/Box2D/Box2DConfig.cmake: -------------------------------------------------------------------------------- 1 | get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 2 | include(${SELF_DIR}/Box2D-targets.cmake) 3 | get_filename_component(Box2D_INCLUDE_DIRS "${SELF_DIR}/../../include" ABSOLUTE) 4 | -------------------------------------------------------------------------------- /bluegin/custom_rules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/include/mode/Mode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Mode kinds of object (used for type identification in place of "is") 4 | enum { 5 | BOT, 6 | BOT_BULLET, 7 | BULLET, 8 | PLAYER, 9 | SPAWNER 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /bluegin/examples/text_display.cpp: -------------------------------------------------------------------------------- 1 | using namespace flx; 2 | 3 | void PlayState::create() 4 | { 5 | TextPtr text = Text::create(0, 0, FlxG.width, "Hello world!"); 6 | text->setSize(30.0f); 7 | text->setAlignment(ALIGN_RIGHT); 8 | add(text); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/data/accelerometer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace flx { 4 | 5 | struct Accelerometer 6 | { 7 | float x; 8 | float y; 9 | float z; 10 | 11 | void set(float ax, float ay, float az) { x = ax; y = ay; z = az; } 12 | }; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /bluegin/jni/Android.mk: -------------------------------------------------------------------------------- 1 | TOP_PATH := $(call my-dir) 2 | 3 | include $(TOP_PATH)/Box2D/Android.mk 4 | include $(TOP_PATH)/cinder/Android.mk 5 | include $(TOP_PATH)/bluegin/Android.mk 6 | include $(TOP_PATH)/flx/Android.mk 7 | 8 | all: box2d cinder bluegin flx 9 | 10 | .DEFAULT: all 11 | 12 | -------------------------------------------------------------------------------- /samples/FlxMode/src/com/expb/flxmode/FlxModeActivity.java: -------------------------------------------------------------------------------- 1 | package com.expb.flxmode; 2 | 3 | import com.expb.bluegin.BlueGinActivity; 4 | 5 | public class FlxModeActivity extends BlueGinActivity 6 | { 7 | static { 8 | System.loadLibrary("flxmode"); 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /bluegin/jni/bluegin/include/bluegin/common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cinder/gl/Texture.h" 4 | #include "cinder/Matrix.h" 5 | 6 | namespace bluegin { 7 | 8 | // High level asset interface 9 | ci::gl::Texture getTextureAsset(const char* name); 10 | void setModelView( const ci::Matrix44f &mtx ); 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /bluegin/Common.mk: -------------------------------------------------------------------------------- 1 | # STLport distribution path, for android - http://www.anddev.org/viewtopic.php?p=29939 2 | # STLPORT_DIST = /d/opt/android/stlport 3 | # STLPORT_INCLUDE = $(STLPORT_DIST)/stlport 4 | # STLPORT_CFLAGS = -D_STLP_USE_SIMPLE_NODE_ALLOC 5 | 6 | BOOST_INCLUDE = $(BOOST_SRC) 7 | BOOST_CFLAGS = -DBOOST_NO_EXCEPTIONS 8 | 9 | -------------------------------------------------------------------------------- /bluegin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 8 | 9 | -------------------------------------------------------------------------------- /bluegin/jni/flx/src/data/anim.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/data/anim.h" 2 | 3 | using namespace flx; 4 | using std::vector; 5 | 6 | Anim::Anim(std::string name, vector& frames, float frameRate, bool looped) 7 | : name(name), frames(frames), looped(looped) 8 | { 9 | delay = 0; 10 | if (frameRate > 0) 11 | delay = 1.0f / frameRate; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | assets/ 2 | ^bin/ 3 | ^libs/ 4 | ^obj/ 5 | tags 6 | \.sw[opn]$ 7 | /Debug/ 8 | /Release/ 9 | ^vc9/BlueGin/assets/ 10 | \.ncb$ 11 | \.obj$ 12 | \.pdb$ 13 | \.idb$ 14 | \.ncb$ 15 | \.suo$ 16 | \.user$ 17 | \.o$ 18 | \.o\.d$ 19 | \.a$ 20 | \.so$ 21 | \.class$ 22 | \.apk$ 23 | \.ap_$ 24 | \.dex$ 25 | local.properties 26 | \/R.java$ 27 | \/BlueGin.jar$ 28 | 29 | -------------------------------------------------------------------------------- /bluegin/jni/cinder/include/cinder/Cinder_BlueGin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "bluegin/bluegin.h" 4 | // #include "yasper.h" 5 | #include "boost/smart_ptr.hpp" 6 | 7 | using boost::shared_ptr; 8 | 9 | #define glBufferDataARB glBufferData 10 | #define glBufferSubDataARB glBufferSubData 11 | #define glMapBuffer glMapBufferOES 12 | #define glUnmapBuffer glUnmapBufferOES 13 | 14 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/include/mode/MenuState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "flx/state.h" 4 | #include "flx/emitter.h" 5 | #include "flx/button.h" 6 | 7 | class MenuState : public flx::State 8 | { 9 | private: 10 | flx::EmitterPtr _gibs; 11 | flx::ButtonPtr _b; 12 | flx::TextPtr _t1; 13 | flx::TextPtr _t2; 14 | bool _ok; 15 | bool _ok2; 16 | 17 | public: 18 | virtual void create(); 19 | virtual void update(); 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/data/list.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "flx/flx.h" 4 | 5 | namespace flx { 6 | 7 | class Object; 8 | class List; 9 | // typedef shared_ptr ListPtr; 10 | 11 | class List 12 | { 13 | public: 14 | Object* object; 15 | List* next; 16 | 17 | List() : object(NULL), next(NULL) { } 18 | ~List(); 19 | 20 | static List* create(); 21 | static void release(List*); 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /samples/FlxMode/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/data/rect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace flx { 4 | 5 | /** 6 | * Stores a rectangle. 7 | */ 8 | class Rect 9 | { 10 | public: 11 | Rect(double rx=0, double ry=0, double w=0, double h=0); 12 | virtual ~Rect(); 13 | 14 | void set(double rx, double ry, double rw, double rh); 15 | 16 | double x, y, width, height; 17 | 18 | double left(); 19 | double right(); 20 | double top(); 21 | double bottom(); 22 | }; 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /bluegin/jni/flx/src/data/rect.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/data/rect.h" 2 | 3 | using namespace flx; 4 | 5 | Rect::Rect(double rx, double ry, double w, double h) 6 | { 7 | set(rx, ry, w, h); 8 | } 9 | 10 | Rect::~Rect() { } 11 | 12 | double Rect::left() { return x; } 13 | double Rect::right() { return x + width; } 14 | double Rect::top() { return y; } 15 | double Rect::bottom() { return y + height; } 16 | 17 | void Rect::set(double rx, double ry, double w, double h) 18 | { 19 | x = rx; 20 | y = ry; 21 | width = w; 22 | height = h; 23 | } 24 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/include/mode/Bullet.h: -------------------------------------------------------------------------------- 1 | #include "flx/sprite.h" 2 | 3 | class Bullet : public flx::Sprite 4 | { 5 | public: 6 | Bullet(); 7 | 8 | virtual void update(); 9 | virtual void render(); 10 | virtual void hitLeft(Object& Contact, float Velocity); 11 | virtual void hitRight(Object& Contact, float Velocity); 12 | virtual void hitBottom(Object& Contact, float Velocity); 13 | virtual void hitTop(Object& Contact, float Velocity); 14 | virtual void kill(); 15 | void shoot(int X, int Y, int VelocityX, int VelocityY); 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/include/mode/BotBullet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "flx/sprite.h" 4 | 5 | class BotBullet : public flx::Sprite 6 | { 7 | public: 8 | BotBullet(); 9 | 10 | virtual void update(); 11 | virtual void hitLeft(flx::Object& Contact, float Velocity); 12 | virtual void hitRight(flx::Object& Contact, float Velocity); 13 | virtual void hitBottom(flx::Object& Contact, float Velocity); 14 | virtual void hitTop(flx::Object& Contact, float Velocity); 15 | virtual void kill(); 16 | 17 | void shoot(int X, int Y, int VelocityX, int VelocityY); 18 | }; 19 | -------------------------------------------------------------------------------- /bluegin/jni/flx/src/data/list.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/data/list.h" 2 | #include "flx/flxG.h" 3 | 4 | using namespace flx; 5 | 6 | extern FlxGlobal FlxG; 7 | 8 | List::~List() 9 | { 10 | if (next) { 11 | release(next); 12 | } 13 | } 14 | 15 | List* List::create() 16 | { 17 | void* address = FlxG.blockAllocator->Allocate(sizeof(List)); 18 | List* l = new(address) List(); 19 | return l; 20 | } 21 | 22 | void List::release(List* l) 23 | { 24 | if (l != NULL) { 25 | l->~List(); 26 | FlxG.blockAllocator->Free(static_cast(l), sizeof(List)); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /bluegin/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-10 15 | android.library=true 16 | 17 | -------------------------------------------------------------------------------- /samples/FlxMode/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-10 15 | android.library.reference.1=../../bluegin 16 | -------------------------------------------------------------------------------- /bluegin/BlueGin.mk: -------------------------------------------------------------------------------- 1 | # Rules for linking against native libraries supplied by bluegin 2 | # 3 | NATIVE_PATH := $(call my-dir) 4 | 5 | # Read Boost settings 6 | include $(NATIVE_PATH)/Common.mk 7 | 8 | BLUEGIN_INCLUDE := $(BOOST_INCLUDE) $(NATIVE_PATH)/jni/cinder/include $(NATIVE_PATH)/jni/bluegin/include $(NATIVE_PATH)/jni/flx/include $(NATIVE_PATH)/jni/Box2D/Box2D_v2.1.2/Box2D $(NATIVE_PATH)/jni/rapidxml/rapidxml-1.13 9 | BLUEGIN_CFLAGS := -DANDROID $(BOOST_CFLAGS) -DBLUEGIN -DCINDER_BLUEGIN -DRAPIDXML_NO_EXCEPTIONS -Werror -D__LITTLE_ENDIAN__ -D_GLIBCPP_USE_WCHAR_T 10 | BLUEGIN_LDLIBS := -L$(NATIVE_PATH)/obj/local/armeabi -lcinder -lflx -lbluegin -lbox2d -lGLESv1_CM -llog -ldl -lgcc 11 | 12 | -------------------------------------------------------------------------------- /bluegin/jni/bluegin/Android.mk: -------------------------------------------------------------------------------- 1 | # Bluegin library 2 | LOCAL_PATH := $(call my-dir) 3 | include $(CLEAR_VARS) 4 | include $(LOCAL_PATH)/../../BlueGin.mk 5 | 6 | LOCAL_MODULE := bluegin 7 | LOCAL_CFLAGS := $(BLUEGIN_CFLAGS) 8 | LOCAL_C_INCLUDES := $(BLUEGIN_INCLUDE) 9 | 10 | LOCAL_SRC_FILES := src/bluegin_jni.cpp \ 11 | src/bluegin_android.cpp \ 12 | src/bluegin_common.cpp \ 13 | src/app.cpp \ 14 | src/config.cpp \ 15 | src/graphic.cpp \ 16 | src/hgefont.cpp \ 17 | src/resourcemanager.cpp \ 18 | src/sound.cpp 19 | 20 | LOCAL_STATIC_LIBRARIES := libcinder libflx libBox2D 21 | LOCAL_LDLIBS := -lGLESv1_CM -llog -ldl 22 | 23 | include $(BUILD_STATIC_LIBRARY) 24 | 25 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/phy/pworld.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "flx/group.h" 4 | #include "flx/phy/pdebugdraw.h" 5 | #include "Box2D/Dynamics/b2World.h" 6 | 7 | namespace flx { 8 | 9 | /** Physics world */ 10 | class PWorld : public flx::Group 11 | { 12 | public: 13 | PWorld(ci::Vec2f gravity, bool doSleep=true, float pixelScale=30.0f); 14 | virtual ~PWorld(); 15 | 16 | virtual void update(); 17 | virtual void render(); 18 | 19 | void updatePhysics(); 20 | 21 | b2World* getWorld(); 22 | 23 | protected: 24 | b2World* _world; 25 | float _pixelScale; 26 | 27 | PDebugDrawPtr _debugDraw; 28 | }; 29 | 30 | typedef shared_ptr PWorldPtr; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/data/matrix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cinder/Vector.h" 4 | 5 | namespace flx { 6 | 7 | /** 8 | * Not used 9 | * 10 | * Will eventually replace Cinder's 4x4 matrices with 3x3 matrices, 11 | * for 2D transforms. 12 | */ 13 | class Matrix 14 | { 15 | // m[idx] 16 | // | m[0] m[3] m[6]| c -s 17 | // | m[1] m[4] m[7]| s c 18 | // | m[2] m[5] m[8]| 19 | 20 | private: 21 | float m[9]; 22 | 23 | public: 24 | Matrix(); 25 | void setToIdentity(); 26 | void translate(ci::Vec2f& pos); 27 | void rotate(float angle); 28 | void scale(ci::Vec2f& scaling); 29 | 30 | const ci::Vec2f operator*( const ci::Vec2f &rhs ) const; 31 | }; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /samples/FlxMode/data/resources.pack: -------------------------------------------------------------------------------- 1 | TexturePack sprites sprite.png 256 256 2 | dirt dirt.png 3 | dirt_top dirt_top.png 4 | gibs gibs.png 5 | notch notch.png 6 | spawner_gibs spawner_gibs.png 7 | spawner spawner.png 8 | tech_tiles tech_tiles.png 9 | spaceman spaceman.png 10 | bot bot.png 11 | jet jet.png 12 | bullet bullet.png 13 | bot_bullet bot_bullet.png 14 | 15 | Font nokia nokia.fnt nokia.png 16 | Music mode mode.mp3 17 | Sound SndJump jump.mp3 18 | Sound SndExplode asplode.mp3 19 | Sound SndExplode2 menu_hit_2.mp3 20 | Sound SndHit hit.mp3 21 | Sound SndShoot shoot.mp3 22 | Resource mode.oep 23 | Resource mode_level.oel 24 | 25 | -------------------------------------------------------------------------------- /bluegin/jni/flx/src/data/flash.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/data/flash.h" 2 | 3 | using namespace flx; 4 | using namespace ci; 5 | 6 | Flash::Flash() 7 | { 8 | exists = false; 9 | } 10 | 11 | void Flash::start(Color color, float Duration, void* FlashComplete, bool Force) 12 | { 13 | this->color = color; 14 | if (!Force && exists) return; 15 | _delay = Duration; 16 | // _complete = FlashComplete; 17 | alpha = 1; 18 | exists = true; 19 | } 20 | 21 | void Flash::stop() 22 | { 23 | exists = false; 24 | } 25 | 26 | void Flash::update(float elapsed) 27 | { 28 | alpha -= elapsed/_delay; 29 | if(alpha <= 0) 30 | { 31 | exists = false; 32 | // if(_complete != null) 33 | // _complete(); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/include/mode/PlayStateTiles.h: -------------------------------------------------------------------------------- 1 | #include "flx/tilemap.h" 2 | #include "flx/group.h" 3 | #include "flx/state.h" 4 | #include "flx/emitter.h" 5 | 6 | #include "mode/PlayState.h" 7 | #include "mode/Player.h" 8 | 9 | class PlayStateTiles : public ReloadableState 10 | { 11 | //major game objects 12 | flx::TilemapPtr _tilemap; 13 | flx::GroupPtr _bullets; 14 | flx::GroupPtr _spawners; 15 | flx::GroupPtr _bots; 16 | flx::GroupPtr _botBullets; 17 | shared_ptr _player; 18 | 19 | flx::EmitterPtr _littleGibs; 20 | flx::EmitterPtr _bigGibs; 21 | 22 | //meta groups, to help speed up collisions 23 | flx::GroupPtr _objects; 24 | flx::GroupPtr _enemies; 25 | 26 | virtual void create(); 27 | virtual void update(); 28 | }; 29 | 30 | -------------------------------------------------------------------------------- /samples/FlxMode/ant.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked into Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | 12 | # You can also use it define how the release builds are signed by declaring 13 | # the following properties: 14 | # 'key.store' for the location of your keystore and 15 | # 'key.alias' for the name of the key to use. 16 | # The password will be asked during the build when you use the 'release' target. 17 | 18 | jar.libs.dir=libs 19 | -------------------------------------------------------------------------------- /bluegin/Modules.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_MODULE := cinder-prebuilt 5 | LOCAL_SRC_FILES := obj/local/armeabi/libcinder.a 6 | LOCAL_EXPORT_LDLIBS := -lGLESv1_CM -llog 7 | include $(PREBUILT_STATIC_LIBRARY) 8 | 9 | include $(CLEAR_VARS) 10 | LOCAL_MODULE := box2d-prebuilt 11 | LOCAL_SRC_FILES := obj/local/armeabi/libbox2d.a 12 | include $(PREBUILT_STATIC_LIBRARY) 13 | 14 | include $(CLEAR_VARS) 15 | LOCAL_MODULE := bluegin-prebuilt 16 | LOCAL_SRC_FILES := obj/local/armeabi/libbluegin.a 17 | LOCAL_EXPORT_LDLIBS := -llog 18 | include $(PREBUILT_STATIC_LIBRARY) 19 | 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE := flx-prebuilt 22 | LOCAL_SRC_FILES := obj/local/armeabi/libflx.a 23 | LOCAL_EXPORT_LDLIBS := -llog 24 | include $(PREBUILT_STATIC_LIBRARY) 25 | 26 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/include/mode/Bot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "flx/sprite.h" 4 | #include "flx/emitter.h" 5 | #include "flx/object.h" 6 | #include "mode/Player.h" 7 | 8 | class Bot : public flx::Sprite 9 | { 10 | protected: 11 | flx::EmitterPtr _gibs; 12 | flx::EmitterPtr _jets; 13 | shared_ptr _player; 14 | float _timer; 15 | vector _b; 16 | static int _cb; 17 | float _shotClock; 18 | 19 | public: 20 | Bot(int xPos,int yPos,vector& Bullets,flx::EmitterPtr Gibs,shared_ptr ThePlayer); 21 | 22 | virtual void update(); 23 | virtual void render(); 24 | virtual void hurt(float Damage); 25 | virtual void kill(); 26 | virtual void reset(float X, float Y); 27 | 28 | protected: 29 | void shoot(); 30 | }; 31 | 32 | -------------------------------------------------------------------------------- /samples/FlxMode/data/mode.oep: -------------------------------------------------------------------------------- 1 | 2 | Mode Tilemap 3 | 4 | 640 5 | 480 6 | . 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # OpenGL lighting example 2 | # 3 | LOCAL_PATH := $(call my-dir) 4 | include $(CLEAR_VARS) 5 | include $(LOCAL_PATH)/../../../bluegin/BlueGin.mk 6 | 7 | LOCAL_MODULE := libflxmode 8 | LOCAL_CFLAGS := $(BLUEGIN_CFLAGS) 9 | LOCAL_C_INCLUDES := $(BLUEGIN_INCLUDE) jni/include 10 | 11 | LOCAL_SRC_FILES := src/Bot.cpp \ 12 | src/BotBullet.cpp \ 13 | src/Bullet.cpp \ 14 | src/MenuState.cpp \ 15 | src/ModeApp.cpp \ 16 | src/Player.cpp \ 17 | src/PlayState.cpp \ 18 | src/PlayStateTiles.cpp \ 19 | src/Spawner.cpp 20 | 21 | LOCAL_STATIC_LIBRARIES := cinder-prebuilt bluegin-prebuilt flx-prebuilt box2d-prebuilt 22 | # LOCAL_LDLIBS := $(BLUEGIN_LDLIBS) 23 | 24 | include $(BUILD_SHARED_LIBRARY) 25 | 26 | include $(LOCAL_PATH)/../../../bluegin/Modules.mk 27 | 28 | -------------------------------------------------------------------------------- /bluegin/jni/flx/src/state.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/state.h" 2 | #include "cinder/gl/gl.h" 3 | 4 | using namespace flx; 5 | using namespace ci; 6 | 7 | Color State::bgColor; 8 | 9 | State::State() 10 | { 11 | } 12 | 13 | State::~State() 14 | { 15 | } 16 | 17 | void State::create() 18 | { 19 | } 20 | 21 | void State::update() 22 | { 23 | defaultGroup.update(); 24 | } 25 | 26 | void State::collide() 27 | { 28 | defaultGroup.collide(defaultGroup); 29 | } 30 | 31 | void State::preProcess() 32 | { 33 | gl::clear(bgColor); 34 | } 35 | 36 | void State::render() 37 | { 38 | defaultGroup.render(); 39 | } 40 | 41 | void State::destroy() 42 | { 43 | defaultGroup.destroy(); 44 | } 45 | 46 | void State::add(ObjectPtr core) 47 | { 48 | defaultGroup.add(core); 49 | } 50 | 51 | void State::postProcess() 52 | { 53 | } 54 | 55 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/include/mode/Spawner.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "flx/sprite.h" 4 | #include "flx/group.h" 5 | #include "flx/object.h" 6 | #include "flx/emitter.h" 7 | #include "mode/Player.h" 8 | 9 | class Spawner : public flx::Sprite 10 | { 11 | private: 12 | float _timer; 13 | flx::GroupPtr _bots; 14 | vector& _botBullets; 15 | flx::EmitterPtr _botGibs; 16 | flx::EmitterPtr _gibs; 17 | shared_ptr _player; 18 | bool _open; 19 | 20 | public: 21 | // XXX replace shared pointers with references? 22 | Spawner(int X, int Y, flx::EmitterPtr Gibs, flx::GroupPtr Bots, vector& BotBullets, 23 | flx::EmitterPtr BotGibs, shared_ptr ThePlayer); 24 | 25 | void update(); 26 | void hurt(float Damage); 27 | void kill(); 28 | void makeBot(); 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /bluegin/jni/cinder/Android.mk: -------------------------------------------------------------------------------- 1 | # Cinder 2 | LOCAL_PATH := $(call my-dir) 3 | include $(CLEAR_VARS) 4 | include $(LOCAL_PATH)/../../BlueGin.mk 5 | 6 | LOCAL_MODULE := cinder 7 | LOCAL_CFLAGS := $(BLUEGIN_CFLAGS) 8 | LOCAL_C_INCLUDES := $(BLUEGIN_INCLUDE) 9 | 10 | LOCAL_SRC_FILES := src/gl/gl.cpp \ 11 | src/gl/Fbo.cpp \ 12 | src/gl/Light.cpp \ 13 | src/gl/Material.cpp \ 14 | src/gl/Texture.cpp \ 15 | src/gl/Vbo.cpp \ 16 | src/Area.cpp \ 17 | src/AxisAlignedBox.cpp \ 18 | src/BSpline.cpp \ 19 | src/Camera.cpp \ 20 | src/Color.cpp \ 21 | src/Exception.cpp \ 22 | src/Matrix.cpp \ 23 | src/Path2D.cpp \ 24 | src/Perlin.cpp \ 25 | src/PolyLine.cpp \ 26 | src/Rand.cpp \ 27 | src/Rect.cpp \ 28 | src/Shape2D.cpp \ 29 | src/Sphere.cpp \ 30 | src/TriMesh.cpp 31 | 32 | include $(BUILD_STATIC_LIBRARY) 33 | 34 | -------------------------------------------------------------------------------- /bluegin/src/com/expb/bluegin/Native.java: -------------------------------------------------------------------------------- 1 | package com.expb.bluegin; 2 | 3 | public class Native 4 | { 5 | // BlueGin native entry points 6 | public static native void initJNI(); 7 | public static native void create(); 8 | public static native void setup(); 9 | public static native void update(); 10 | public static native void draw(); 11 | public static native void cleanup(); 12 | public static native void pause(); 13 | public static native void resume(); 14 | 15 | public static native void addTouchEvent(int eventType, float x, float y, float px, float py, int id); 16 | public static native void addKeyEvent(boolean keyDown, int unicode, int modifiers, int keycode); 17 | 18 | public static native void setScreenSize(int width, int height); 19 | public static native void setTouches(); 20 | public static native void setKeys(); 21 | public static native void setAccelerometer(float x, float y, float z); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/include/mode/Player.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "flx/sprite.h" 4 | #include "flx/emitter.h" 5 | 6 | class Player : public flx::Sprite 7 | { 8 | private: 9 | int _jumpPower; 10 | vector& _bullets; 11 | int _curBullet; 12 | int _bulletVel; 13 | float _bulletDelay; 14 | bool _up; 15 | bool _down; 16 | float _restart; 17 | flx::EmitterPtr _gibs; 18 | flx::EmitterPtr _jets; 19 | 20 | public: 21 | Player(int X, int Y, vector& Bullets, flx::EmitterPtr Gibs); 22 | 23 | virtual void update(); 24 | virtual void render(); 25 | virtual void hitLeft(flx::Object& Contact, float Velocity); 26 | virtual void hitRight(flx::Object& Contact, float Velocity); 27 | virtual void hitTop(flx::Object& Contact, float Velocity); 28 | virtual void hitBottom(flx::Object& Contact, float Velocity); 29 | virtual void hurt(float Damage); 30 | virtual void kill(); 31 | }; 32 | -------------------------------------------------------------------------------- /bluegin/src/com/expb/bluegin/TouchEventHandler.java: -------------------------------------------------------------------------------- 1 | package com.expb.bluegin; 2 | 3 | import android.os.Build; 4 | import android.view.MotionEvent; 5 | 6 | import com.expb.bluegin.BlueGinInput; 7 | 8 | import com.expb.bluegin.MultiTouchEventHandler; 9 | import com.expb.bluegin.SingleTouchEventHandler; 10 | 11 | public abstract class TouchEventHandler 12 | { 13 | public abstract boolean onTouchEvent(MotionEvent ev); 14 | 15 | // Creates an appropriate touch handler depending on the OS version 16 | public static TouchEventHandler create(BlueGinInput input) 17 | { 18 | final int sdkVersion = Integer.parseInt(Build.VERSION.SDK); 19 | 20 | TouchEventHandler handler; 21 | 22 | if (sdkVersion < Build.VERSION_CODES.FROYO) { 23 | handler = new SingleTouchEventHandler(input); 24 | } else { 25 | handler = new MultiTouchEventHandler(input); 26 | } 27 | 28 | return handler; 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/phy/pgame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "bluegin/app.h" 4 | #include "flx/state.h" 5 | #include "flx/game.h" 6 | 7 | #include "cinder/Vector.h" 8 | #include "cinder/Camera.h" 9 | 10 | namespace bluegin { 11 | class App; 12 | } 13 | 14 | namespace flx { 15 | 16 | class PGame : public IGame 17 | { 18 | public: 19 | PGame(bluegin::BlueginApp& app, int viewWidth, int viewHeight, StatePtr initialState, ci::CameraOrtho& camera); 20 | 21 | virtual void switchState(StatePtr state); 22 | virtual void update(); 23 | virtual void draw(); 24 | 25 | virtual ci::Vec2f toViewCoords(ci::Vec2f pos); 26 | 27 | float _elapsed; 28 | float _total; 29 | bool _paused; 30 | bool _created; 31 | 32 | int _gameXOffset; 33 | int _gameYOffset; 34 | 35 | StatePtr _state; 36 | 37 | private: 38 | ci::CameraOrtho& _camera; 39 | bluegin::BlueginApp& mApp; 40 | 41 | bool _physicsDraw; 42 | }; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /bluegin/jni/flx/src/data/quake.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/flx.h" 2 | #include "flx/flxG.h" 3 | #include "flx/data/quake.h" 4 | 5 | using namespace flx; 6 | 7 | extern FlxGlobal FlxG; 8 | 9 | Quake::Quake() 10 | { 11 | start(0); 12 | } 13 | 14 | void Quake::start(float Intensity, float Duration) 15 | { 16 | stop(); 17 | _intensity = Intensity; 18 | _timer = Duration; 19 | } 20 | 21 | void Quake::stop() 22 | { 23 | x = 0; 24 | y = 0; 25 | _intensity = 0; 26 | _timer = 0; 27 | } 28 | 29 | void Quake::update() 30 | { 31 | if(_timer > 0) 32 | { 33 | _timer -= float(FlxG.elapsed); 34 | if(_timer <= 0) 35 | { 36 | _timer = 0; 37 | x = 0; 38 | y = 0; 39 | } 40 | else 41 | { 42 | x = (FlxU::random()*_intensity*FlxG.width*2-_intensity*FlxG.width); 43 | y = (FlxU::random()*_intensity*FlxG.height*2-_intensity*FlxG.height); 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/phy/psprite.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "flx/sprite.h" 4 | #include "flx/phy/pworld.h" 5 | 6 | #include "Box2D/Dynamics/b2Fixture.h" 7 | 8 | namespace flx { 9 | 10 | enum BodyType 11 | { 12 | STATIC, 13 | DYNAMIC, 14 | KINEMATIC 15 | }; 16 | 17 | /** Physics sprite */ 18 | class PSprite : public Sprite 19 | { 20 | public: 21 | PSprite(PWorldPtr world, BodyType bodyType, ci::Vec2f pos); 22 | virtual ~PSprite(); 23 | 24 | void createFixture(b2FixtureDef& fixtureDef); 25 | void createFixture(b2Shape& shape, float density); 26 | 27 | void setSize(float width, float height); 28 | 29 | virtual void update(); 30 | virtual void render(); 31 | 32 | virtual void calcOrigin(); 33 | 34 | protected: 35 | b2World* _world; 36 | b2Body* _body; 37 | b2Fixture* _fixture; 38 | 39 | private: 40 | void createBody(BodyType bodyType, ci::Vec2f pos); 41 | }; 42 | 43 | typedef shared_ptr PSpritePtr; 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/FlxApp.h: -------------------------------------------------------------------------------- 1 | #include "bluegin/app.h" 2 | #include "cinder/app/AccelEvent.h" 3 | #include "cinder/app/TouchEvent.h" 4 | #include "flx/game.h" 5 | 6 | namespace flx { 7 | 8 | const int SCREEN_WIDTH = 800; 9 | const int SCREEN_HEIGHT = 480; 10 | 11 | /** 12 | * A base class for Flx games, implemented as a Bluegin app. 13 | * 14 | * Performs common setup and writes Cinder input events to Flx. See FlxMode 15 | * for an example of use. 16 | * 17 | */ 18 | class FlxApp : public bluegin::BlueginApp 19 | { 20 | public: 21 | void update(); 22 | void draw(); 23 | 24 | void flxSetup(flx::GamePtr game); 25 | 26 | void touchesBegan(ci::app::TouchEvent event); 27 | void touchesMoved(ci::app::TouchEvent event); 28 | void touchesEnded(ci::app::TouchEvent event); 29 | void accelerated(ci::app::AccelEvent event); 30 | 31 | #ifndef ANDROID 32 | void prepareSettings( Settings *settings ); 33 | #endif 34 | 35 | protected: 36 | GamePtr mGame; 37 | }; 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /vc9/BlueGin/BlueGin.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 13 | 18 | 22 | 26 | 30 | 31 | -------------------------------------------------------------------------------- /bluegin/jni/bluegin/include/bluegin/graphic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cinder/gl/Texture.h" 4 | #include "cinder/Rect.h" 5 | 6 | namespace bluegin { 7 | 8 | class Graphic 9 | { 10 | public: 11 | Graphic(); 12 | Graphic(string texName, ci::Rectf sourceRect); 13 | // Graphic(ci::gl::Texture texture, ci::Rectf sourceRect); 14 | ~Graphic(); 15 | 16 | int getWidth(); 17 | int getHeight(); 18 | 19 | void setTexture(ci::gl::Texture& tex); 20 | ci::gl::Texture& getTexture(); 21 | ci::Rectf& getSourceRect(); 22 | ci::Rectf& getTextureRect(); 23 | 24 | ci::Rectf mapFrameRect(ci::Rectf& frameRect, bool flip=false); 25 | 26 | // source texture identifier 27 | string texName; 28 | 29 | protected: 30 | // source texture 31 | ci::gl::Texture mTexture; 32 | // graphic location in source rectangle 33 | ci::Rectf mSourceRect; 34 | // sourceRect as texture coordinates (texcoord mapping target) 35 | ci::Rectf mTexRect; 36 | }; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /samples/FlxMode/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 8 | 9 | 10 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc9/BlueGin/BlueGin-debug.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 13 | 19 | 23 | 27 | 31 | 32 | -------------------------------------------------------------------------------- /bluegin/jni/flx/Android.mk: -------------------------------------------------------------------------------- 1 | # Flixel-based 2D sprite engine 2 | # 3 | LOCAL_PATH := $(call my-dir) 4 | include $(CLEAR_VARS) 5 | include $(LOCAL_PATH)/../../BlueGin.mk 6 | 7 | LOCAL_MODULE := flx 8 | LOCAL_CFLAGS := $(BLUEGIN_CFLAGS) 9 | LOCAL_C_INCLUDES := $(BLUEGIN_INCLUDE) 10 | 11 | LOCAL_SRC_FILES := src/data/anim.cpp \ 12 | src/data/fade.cpp \ 13 | src/data/flash.cpp \ 14 | src/data/list.cpp \ 15 | src/data/quake.cpp \ 16 | src/data/rect.cpp \ 17 | src/data/touch.cpp \ 18 | src/phy/pdebugdraw.cpp \ 19 | src/phy/pgame.cpp \ 20 | src/phy/psprite.cpp \ 21 | src/phy/pworld.cpp \ 22 | src/button.cpp \ 23 | src/emitter.cpp \ 24 | src/flx.cpp \ 25 | src/flxG.cpp \ 26 | src/game.cpp \ 27 | src/group.cpp \ 28 | src/object.cpp \ 29 | src/quadtree.cpp \ 30 | src/render.cpp \ 31 | src/sound.cpp \ 32 | src/sprite.cpp \ 33 | src/state.cpp \ 34 | src/text.cpp \ 35 | src/tileblock.cpp \ 36 | src/tilemap.cpp \ 37 | src/FlxApp.cpp 38 | 39 | include $(BUILD_STATIC_LIBRARY) 40 | 41 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/phy/pdebugdraw.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "bluegin/bluegin.h" 4 | #include "cinder/Camera.h" 5 | #include 6 | 7 | struct b2AABB; 8 | 9 | namespace flx { 10 | 11 | class PDebugDraw : public b2DebugDraw 12 | { 13 | public: 14 | PDebugDraw(ci::Camera& camera); 15 | void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); 16 | void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); 17 | void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color); 18 | void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color); 19 | void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color); 20 | void DrawTransform(const b2Transform& xf); 21 | void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color); 22 | void DrawString(int x, int y, const char* string, ...); 23 | void DrawAABB(b2AABB* aabb, const b2Color& color); 24 | 25 | ci::Camera& camera; 26 | }; 27 | 28 | typedef shared_ptr PDebugDrawPtr; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /bluegin/jni/bluegin/src/bluegin_common.cpp: -------------------------------------------------------------------------------- 1 | #include "bluegin/app.h" 2 | #include "cinder/gl/Texture.h" 3 | 4 | #ifndef ANDROID 5 | #include "cinder/DataSource.h" 6 | #include "cinder/ImageSourcePng.h" 7 | #endif 8 | 9 | using namespace cinder; 10 | using namespace cinder::gl; 11 | 12 | namespace bluegin 13 | { 14 | 15 | void setModelView( const Matrix44f &mtx ) 16 | { 17 | glMatrixMode( GL_MODELVIEW ); 18 | glLoadMatrixf( mtx.m ); 19 | } 20 | 21 | // High level functions 22 | cinder::gl::Texture getTextureAsset(const char* name) 23 | { 24 | int width, height; 25 | width = height = 0; 26 | 27 | #ifdef ANDROID 28 | int texID = bluegin_load_texture(name, &width, &height); 29 | if (texID == 0 || width == 0 || height == 0) { 30 | return Texture(); 31 | } 32 | return Texture(GL_TEXTURE_2D, texID, width, height, true); 33 | #else 34 | // load from assets folder 35 | DataSourcePathRef path = DataSourcePath::createRef(string("assets\\")+string(name)); 36 | ImageSourceRef image = ImageSourcePng::createSourceRef(path); 37 | return Texture(image); 38 | #endif 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /bluegin/jni/flx/src/data/fade.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/data/fade.h" 2 | #include "cinder/gl/gl.h" 3 | 4 | using namespace ci; 5 | using namespace flx; 6 | 7 | Fade::Fade() : alpha(0) 8 | { 9 | // super(); 10 | // createGraphic(FlxG.width,FlxG.height,0,true); 11 | //scrollFactor.x = 0; 12 | //scrollFactor.y = 0; 13 | exists = false; 14 | } 15 | 16 | void Fade::start(Color color, float Duration, FadeCallback FadeComplete, bool Force) 17 | { 18 | if (!Force && exists) return; 19 | // fill(color); 20 | _delay = Duration; 21 | _color = color; 22 | _complete = FadeComplete; 23 | _completeData = NULL; 24 | alpha = 0; 25 | exists = true; 26 | } 27 | 28 | void Fade::stop() 29 | { 30 | exists = false; 31 | } 32 | 33 | void Fade::update(float elapsed) 34 | { 35 | alpha += elapsed / _delay; 36 | if (alpha >= 1) 37 | { 38 | alpha = 1; 39 | if(_complete != NULL) 40 | _complete(_completeData); 41 | } 42 | fadeColor = ColorA(_color.r, _color.g, _color.b, alpha); 43 | } 44 | 45 | void Fade::setCallbackData(void* data) 46 | { 47 | _completeData = data; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /samples/FlxMode/jni/src/ModeApp.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/FlxApp.h" 2 | 3 | #include "flx/flxG.h" 4 | #include "flx/game.h" 5 | #include "flx/state.h" 6 | #include "mode/PlayState.h" 7 | #include "mode/MenuState.h" 8 | 9 | #include "cinder/gl/gl.h" 10 | 11 | #include "bluegin/resourcemanager.h" 12 | 13 | using namespace flx; 14 | using namespace ci; 15 | using namespace ci::app; 16 | using namespace bluegin; 17 | 18 | extern FlxGlobal FlxG; 19 | 20 | class ModeApp : public FlxApp 21 | { 22 | public: 23 | void setup() 24 | { 25 | Vec2f zoom(2.0f, 2.0f); 26 | StatePtr initialState = StatePtr(new MenuState()); 27 | mGame = GamePtr(new Game(*this, 28 | getWindowWidth() / zoom.x, getWindowHeight() / zoom.y, 29 | initialState, zoom)); 30 | flxSetup(mGame); 31 | 32 | // Load all configured textures and sounds 33 | FlxG.resources->acquireAllTextures(); 34 | FlxG.resources->acquireAllSounds(); 35 | 36 | // Set default font 37 | FlxG.defaultFont = FlxG.resources->font("nokia").get(); 38 | 39 | gl::clear(); 40 | } 41 | }; 42 | 43 | CINDER_APP_BASIC( ModeApp, RendererGl ) 44 | 45 | -------------------------------------------------------------------------------- /bluegin/examples/sprite_basic.cpp: -------------------------------------------------------------------------------- 1 | using namespace ci; 2 | using namespace flx; 3 | 4 | class PlayState : public State 5 | { 6 | public: 7 | SpritePtr sprite; 8 | 9 | void PlayState::create() 10 | { 11 | ResourceManager& res = *(FlxG.resources); 12 | sprite = Sprite::create(FlxG.width/2, FlxG.height/2, res.graphic("ball")); 13 | sprite->velocity = Rand::randVec2f() * 20.0f; 14 | // Add sprite to the state's default group 15 | add(sprite); 16 | } 17 | 18 | void PlayState::update() 19 | { 20 | // Make a shortcut so we can use use dot notation 21 | Sprite& sp = *sprite; 22 | 23 | // Bounce when hitting the view edges 24 | if (sp.x < 0 || sp.x > FlxG.width) { 25 | sp.velocity.x = -sp.velocity.x; 26 | } 27 | else if (sp.y < 0 || sp.y > FlxG.height) { 28 | sp.velocity.y = -sp.velocity.y; 29 | } 30 | 31 | // Limit sprite position 32 | sp.x = math::clamp(sp.x, 0, FlxG.width); 33 | sp.y = math::clamp(sp.y, 0, FlxG.height); 34 | 35 | // Updates the state's default group 36 | State::update(); 37 | } 38 | }; 39 | 40 | -------------------------------------------------------------------------------- /bluegin/jni/flx/src/data/matrix.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/data/matrix.h" 2 | 3 | using namespace flx; 4 | using namespace ci; 5 | 6 | // 2d transformation matrix 7 | Matrix::Matrix() 8 | { 9 | for (int i=0; i < 9; ++i) 10 | m[i] = 0; 11 | } 12 | 13 | void Matrix::setToIdentity() 14 | { 15 | for (int i=0; i < 9; ++i) 16 | m[i] = 0; 17 | m[0] = 1.0f; m[4] = 1.0f; m[8] = 1.0f; 18 | } 19 | 20 | void Matrix::translate(ci::Vec2f& pos) 21 | { 22 | m[6] += pos.x * m[0] + pos.y * m[3]; 23 | m[7] += pos.y * m[1] + pos.y * m[4]; 24 | } 25 | 26 | void Matrix::rotate(float angle) 27 | { 28 | m[0] = m[0] * cos(angle) + m[3] * sin(angle); 29 | m[3] = m[0] * -sin(angle) + m[3] * cos(angle); 30 | m[1] = m[1] * cos(angle) + m[4] * sin(angle); 31 | m[4] = m[1] * -sin(angle) + m[4] * cos(angle); 32 | } 33 | 34 | void Matrix::scale(Vec2f& s) 35 | { 36 | m[0] *= s.x; 37 | m[1] *= s.x; 38 | m[2] *= s.x; 39 | m[3] *= s.y; 40 | m[4] *= s.y; 41 | m[5] *= s.y; 42 | } 43 | 44 | const Vec2f Matrix::operator*( const Vec2f &rhs ) const 45 | { 46 | return Vec2f(m[0] * rhs.x + m[3] * rhs.y + m[6], 47 | m[1] * rhs.x + m[4] * rhs.y + m[7]); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/data/anim.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace flx { 7 | 8 | /** 9 | * Just a helper structure for the FlxSprite animation system 10 | */ 11 | class Anim 12 | { 13 | public: 14 | /** 15 | * String name of the animation (e.g. "walk") 16 | */ 17 | std::string name; 18 | /** 19 | * Seconds between frames (basically the framerate) 20 | */ 21 | float delay; 22 | /** 23 | * A list of frames stored as int objects 24 | */ 25 | std::vector frames; 26 | /** 27 | * Whether or not the animation is looped 28 | */ 29 | bool looped; 30 | 31 | /** 32 | * Constructor 33 | * 34 | * @param Name What this animation should be called (e.g. "run") 35 | * @param Frames An array of numbers indicating what frames to play in what order (e.g. 1, 2, 3) 36 | * @param FrameRate The speed in frames per second that the animation should play at (e.g. 40) 37 | * @param Looped Whether or not the animation is looped or just plays once 38 | */ 39 | Anim(std::string name, std::vector& frames, float frameRate, bool looped=true); 40 | }; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/data/flash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cinder/Color.h" 4 | 5 | namespace flx { 6 | 7 | /** 8 | * This is a special effects utility class to help FlxGame do the 'flash' effect 9 | */ 10 | class Flash 11 | { 12 | protected: 13 | /** 14 | * How long the effect should last. 15 | */ 16 | float _delay; 17 | /** 18 | * Callback for when the effect is finished. 19 | */ 20 | float _complete; 21 | 22 | public: 23 | bool exists; 24 | float alpha; 25 | ci::Color color; 26 | 27 | /** 28 | * Constructor for this special effect 29 | */ 30 | Flash(); 31 | 32 | /** 33 | * Reset and trigger this special effect 34 | * 35 | * @param Color The color you want to use 36 | * @param Duration How long it takes for the flash to fade 37 | * @param FlashComplete A function you want to run when the flash finishes 38 | * @param Force Force the effect to reset 39 | */ 40 | void start(ci::Color color, float Duration=1.0f, void* FlashComplete=NULL, 41 | bool Force=false); 42 | 43 | /** 44 | * Stops and hides this screen effect. 45 | */ 46 | void stop(); 47 | 48 | /** 49 | * Updates and/or animates this special effect 50 | */ 51 | void update(float elapsed); 52 | }; 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /bluegin/jni/Box2D/Box2D_v2.1.2/Box2D/Box2D/Common/b2Settings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * Permission is granted to anyone to use this software for any purpose, 8 | * including commercial applications, and to alter it and redistribute it 9 | * freely, subject to the following restrictions: 10 | * 1. The origin of this software must not be misrepresented; you must not 11 | * claim that you wrote the original software. If you use this software 12 | * in a product, an acknowledgment in the product documentation would be 13 | * appreciated but is not required. 14 | * 2. Altered source versions must be plainly marked as such, and must not be 15 | * misrepresented as being the original software. 16 | * 3. This notice may not be removed or altered from any source distribution. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | b2Version b2_version = {2, 1, 2}; 23 | 24 | // Memory allocators. Modify these to use your own allocator. 25 | void* b2Alloc(int32 size) 26 | { 27 | return malloc(size); 28 | } 29 | 30 | void b2Free(void* mem) 31 | { 32 | free(mem); 33 | } 34 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/data/quake.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace flx { 4 | 5 | /** 6 | * This is a special effects utility class to help FlxGame do the 'quake' or screenshake effect. 7 | */ 8 | class Quake 9 | { 10 | protected: 11 | /** 12 | * The intensity of the quake effect: a percentage of the screen's size. 13 | */ 14 | float _intensity; 15 | /** 16 | * Set to countdown the quake time. 17 | */ 18 | float _timer; 19 | 20 | public: 21 | /** 22 | * The amount of X distortion to apply to the screen. 23 | */ 24 | int x; 25 | /** 26 | * The amount of Y distortion to apply to the screen. 27 | */ 28 | int y; 29 | 30 | /** 31 | * Constructor. 32 | */ 33 | Quake(); 34 | 35 | /** 36 | * Reset and trigger this special effect. 37 | * 38 | * @param Intensity Percentage of screen size representing the maximum distance that the screen can move during the 'quake'. 39 | * @param Duration The length in seconds that the "quake" should last. 40 | */ 41 | void start(float Intensity=0.05,float Duration=0.5); 42 | 43 | /** 44 | * Stops this screen effect. 45 | */ 46 | void stop(); 47 | 48 | /** 49 | * Updates and/or animates this special effect. 50 | */ 51 | void update(); 52 | }; 53 | 54 | } // namespace 55 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | BlueGin Game Engine 2 | =================== 3 | 4 | BlueGin is a C++ game engine for Android. 5 | 6 | - Based on a port of the Flixel game engine 7 | - Uses the Cinder framework for OpenGL rendering 8 | - Provides a manager for packing and accessing assets 9 | - Includes a desktop runtime, for testing and optimizing on PC at native speeds 10 | 11 | 12 | Recommended setup 13 | ----------------- 14 | 15 | BlueGin requires the Android native development kit (NDK) r8 for building. On 16 | the desktop it is linked with Cinder and Boost. The Android runtime requires 17 | Boost to build. 18 | 19 | 1. Install Cinder including Boost v1.48 (or newer) 20 | 21 | 2. Set an environment variable BOOST_SRC to point to your Boost path 22 | (e.g. /src/Cinder/boost) 23 | 24 | 3. Build BlueGin game engine (native and Java libraries) 25 | 26 | % cd bluegin 27 | % android update project --path . /* use android.bat on Windows */ 28 | % ndk-build 29 | % ant debug 30 | 31 | 4. Build individual samples 32 | 33 | % cd samples/ 34 | % python ../../tools/apack.py data /* for FlxMode only, see below */ 35 | % ndk-build 36 | % ant debug 37 | 38 | The asset packer script (tools/apack.py) requires Python and the Python Imaging 39 | Library. It copies assets specified in a resource.pack file and packs textures 40 | for sprite batching. Identifiers from a resource.pack file are used to select 41 | assets in code. 42 | 43 | 44 | -------------------------------------------------------------------------------- /bluegin/jni/Box2D/Box2D_v2.1.2/Box2D/Box2D/Dynamics/b2TimeStep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * Permission is granted to anyone to use this software for any purpose, 8 | * including commercial applications, and to alter it and redistribute it 9 | * freely, subject to the following restrictions: 10 | * 1. The origin of this software must not be misrepresented; you must not 11 | * claim that you wrote the original software. If you use this software 12 | * in a product, an acknowledgment in the product documentation would be 13 | * appreciated but is not required. 14 | * 2. Altered source versions must be plainly marked as such, and must not be 15 | * misrepresented as being the original software. 16 | * 3. This notice may not be removed or altered from any source distribution. 17 | */ 18 | 19 | #ifndef B2_TIME_STEP_H 20 | #define B2_TIME_STEP_H 21 | 22 | #include 23 | 24 | /// This is an internal structure. 25 | struct b2TimeStep 26 | { 27 | float32 dt; // time step 28 | float32 inv_dt; // inverse time step (0 if dt == 0). 29 | float32 dtRatio; // dt * inv_dt0 30 | int32 velocityIterations; 31 | int32 positionIterations; 32 | bool warmStarting; 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/data/fade.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cinder/Color.h" 4 | 5 | namespace flx { 6 | 7 | typedef void (*FadeCallback)(void*); 8 | 9 | class Fade 10 | { 11 | private: 12 | /** 13 | * How long the effect should last. 14 | */ 15 | float _delay; 16 | ci::Color _color; 17 | 18 | /** 19 | * Callback for when the effect is finished. 20 | */ 21 | // protected var _complete:Function; 22 | FadeCallback _complete; 23 | void* _completeData; 24 | 25 | public: 26 | float alpha; 27 | bool exists; 28 | 29 | ci::ColorA fadeColor; 30 | 31 | /** 32 | * Constructor initializes the fade object 33 | */ 34 | Fade(); 35 | 36 | /** 37 | * Reset and trigger this special effect 38 | * 39 | * @param Color The color you want to use 40 | * @param Duration How long it should take to fade the screen out 41 | * @param FadeComplete A function you want to run when the fade finishes 42 | * @param Force Force the effect to reset 43 | */ 44 | void start(ci::Color color, float Duration=1, FadeCallback FadeComplete=NULL, bool Force=false); 45 | 46 | /** 47 | * Stops and hides this screen effect. 48 | */ 49 | void stop(); 50 | 51 | /** 52 | * Updates and/or animates this special effect 53 | */ 54 | void update(float elapsed); 55 | 56 | void setCallbackData(void* data); 57 | }; 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /bluegin/jni/flx/src/phy/pworld.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/flxG.h" 2 | #include "flx/phy/pworld.h" 3 | 4 | using namespace ci; 5 | using namespace flx; 6 | 7 | const int velocityIterations = 6; 8 | const int positionIterations = 2; 9 | 10 | extern FlxGlobal FlxG; 11 | 12 | PWorld::PWorld(ci::Vec2f gravity, bool doSleep, float pixelScale) 13 | { 14 | _world = new b2World(b2Vec2(gravity.x, gravity.y), doSleep); 15 | _pixelScale = pixelScale; 16 | 17 | // Debug draw physics bodies 18 | _debugDraw = PDebugDrawPtr(new PDebugDraw(FlxG.camera)); 19 | unsigned int flags = 0; 20 | flags |= b2DebugDraw::e_shapeBit | 21 | b2DebugDraw::e_jointBit | 22 | b2DebugDraw::e_aabbBit | 23 | b2DebugDraw::e_pairBit | 24 | b2DebugDraw::e_centerOfMassBit; 25 | _debugDraw->SetFlags(flags); 26 | 27 | _world->SetDebugDraw(_debugDraw.get()); 28 | } 29 | 30 | PWorld::~PWorld() 31 | { 32 | delete _world; 33 | } 34 | 35 | void PWorld::updatePhysics() 36 | { 37 | const float timeStep = 1.0f / 60.0f; 38 | _world->Step(timeStep, velocityIterations, positionIterations); 39 | _world->ClearForces(); 40 | } 41 | 42 | void PWorld::update() 43 | { 44 | updatePhysics(); 45 | updateMembers(); 46 | updateFlickering(); 47 | } 48 | 49 | void PWorld::render() 50 | { 51 | _world->DrawDebugData(); 52 | Group::render(); 53 | } 54 | 55 | b2World* PWorld::getWorld() 56 | { 57 | return _world; 58 | } 59 | -------------------------------------------------------------------------------- /bluegin/src/com/expb/bluegin/SingleTouchEventHandler.java: -------------------------------------------------------------------------------- 1 | package com.expb.bluegin; 2 | 3 | import android.view.MotionEvent; 4 | import com.expb.bluegin.BlueGinInput; 5 | 6 | // Handles Touch events for versions of Android earlier than 2.2 (no multi-touch) 7 | public class SingleTouchEventHandler extends TouchEventHandler { 8 | BlueGinInput mInput = null; 9 | float prevX; 10 | float prevY; 11 | 12 | public SingleTouchEventHandler(BlueGinInput input) 13 | { 14 | mInput = input; 15 | prevX = prevY = 0; 16 | } 17 | 18 | public boolean onTouchEvent(MotionEvent ev) 19 | { 20 | final int action = ev.getAction(); 21 | final float x = ev.getX(); 22 | final float y = ev.getY(); 23 | 24 | switch (action) { 25 | // Touch began 26 | case MotionEvent.ACTION_DOWN: 27 | mInput.addTouchEvent(0, x, y, x, y, 0); 28 | prevX = x; 29 | prevY = y; 30 | break; 31 | 32 | // Touch moved 33 | case MotionEvent.ACTION_MOVE: 34 | mInput.addTouchEvent(1, x, y, prevX, prevY, 0); 35 | prevX = x; 36 | prevY = y; 37 | break; 38 | 39 | // Touch ended 40 | case MotionEvent.ACTION_UP: 41 | mInput.addTouchEvent(2, x, y, prevX, prevY, 0); 42 | break; 43 | } 44 | return true; 45 | } 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /bluegin/jni/Box2D/Box2D_v2.1.2/Box2D/Box2D/Dynamics/Contacts/b2CircleContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * Permission is granted to anyone to use this software for any purpose, 8 | * including commercial applications, and to alter it and redistribute it 9 | * freely, subject to the following restrictions: 10 | * 1. The origin of this software must not be misrepresented; you must not 11 | * claim that you wrote the original software. If you use this software 12 | * in a product, an acknowledgment in the product documentation would be 13 | * appreciated but is not required. 14 | * 2. Altered source versions must be plainly marked as such, and must not be 15 | * misrepresented as being the original software. 16 | * 3. This notice may not be removed or altered from any source distribution. 17 | */ 18 | 19 | #ifndef B2_CIRCLE_CONTACT_H 20 | #define B2_CIRCLE_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2CircleContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create(b2Fixture* fixtureA, b2Fixture* fixtureB, b2BlockAllocator* allocator); 30 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 31 | 32 | b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 33 | ~b2CircleContact() {} 34 | 35 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /bluegin/jni/Box2D/Box2D_v2.1.2/Box2D/Box2D/Dynamics/Contacts/b2PolygonContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * Permission is granted to anyone to use this software for any purpose, 8 | * including commercial applications, and to alter it and redistribute it 9 | * freely, subject to the following restrictions: 10 | * 1. The origin of this software must not be misrepresented; you must not 11 | * claim that you wrote the original software. If you use this software 12 | * in a product, an acknowledgment in the product documentation would be 13 | * appreciated but is not required. 14 | * 2. Altered source versions must be plainly marked as such, and must not be 15 | * misrepresented as being the original software. 16 | * 3. This notice may not be removed or altered from any source distribution. 17 | */ 18 | 19 | #ifndef B2_POLYGON_CONTACT_H 20 | #define B2_POLYGON_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2PolygonContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create(b2Fixture* fixtureA, b2Fixture* fixtureB, b2BlockAllocator* allocator); 30 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 31 | 32 | b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 33 | ~b2PolygonContact() {} 34 | 35 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "bluegin/app.h" 4 | #include "flx/state.h" 5 | #include "cinder/Vector.h" 6 | 7 | namespace bluegin { 8 | class App; 9 | } 10 | 11 | namespace flx { 12 | 13 | class IGame 14 | { 15 | public: 16 | /** 17 | * Switch from one State to another. 18 | * Usually called from FlxG. 19 | * 20 | * @param State The class name of the state you want (e.g. PlayState) 21 | */ 22 | virtual void switchState(StatePtr state) = 0; 23 | 24 | /** 25 | * This is the main game loop. It controls all the updating and rendering. 26 | */ 27 | virtual void update() = 0; 28 | 29 | /** 30 | * This is the main game loop. It controls all the updating and rendering. 31 | */ 32 | virtual void draw() = 0; 33 | 34 | // translate a point from screen coords to viewport coords 35 | virtual ci::Vec2f toViewCoords(ci::Vec2f pos) = 0; 36 | 37 | StatePtr _state; 38 | }; 39 | 40 | class Game : public IGame 41 | { 42 | public: 43 | Game(bluegin::BlueginApp& app, int gameSizeX, int gameSizeY, StatePtr initialState, ci::Vec2f zoom=ci::Vec2f(1.0f, 1.0f)); 44 | 45 | void switchState(StatePtr state); 46 | void update(); 47 | void draw(); 48 | 49 | double _elapsed; 50 | double _total; 51 | bool _paused; 52 | bool _created; 53 | 54 | int _gameXOffset; 55 | int _gameYOffset; 56 | ci::Vec2f _zoom; 57 | 58 | bluegin::BlueginApp& mApp; 59 | 60 | virtual ci::Vec2f toViewCoords(ci::Vec2f pos); 61 | }; 62 | 63 | typedef shared_ptr GamePtr; 64 | 65 | } 66 | -------------------------------------------------------------------------------- /bluegin/jni/flx/include/flx/render.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "bluegin/bluegin.h" 4 | #include "cinder/gl/Texture.h" 5 | #include "cinder/Color.h" 6 | #include "cinder/Matrix.h" 7 | 8 | // Rendering implementations 9 | namespace flx { 10 | 11 | class Sprite; 12 | class Tileblock; 13 | class Text; 14 | 15 | struct BatchState 16 | { 17 | /** The texture to bind */ 18 | ci::gl::Texture texture; 19 | /** Enables alpha blending */ 20 | bool alphaBlend; 21 | /** Enable vertex coloring */ 22 | bool colored; 23 | 24 | BatchState(); 25 | BatchState(ci::gl::Texture& t, bool pb, bool colored=false); 26 | }; 27 | 28 | /** 29 | * The default renderer interface used to draw Flx objects 30 | * 31 | * This implementation uses software transforms but tries to batch writes 32 | * to a vertex buffer 33 | */ 34 | class Renderer 35 | { 36 | public: 37 | Renderer(); 38 | ~Renderer(); 39 | 40 | void reset(); 41 | void render(); 42 | void drawBatch(); 43 | void setBatchState(BatchState& state); 44 | void renderQuad(ci::ColorA color, 45 | float width, float height, 46 | ci::Rectf& texRect, 47 | ci::Matrix44f* xform, ci::Vec2f* offset); 48 | 49 | protected: 50 | BatchState mBatchState; 51 | 52 | vector mPositions; 53 | vector mTexCoords; 54 | vector mColors; 55 | 56 | ci::ColorA* mFirstColor; 57 | ci::Vec2f* mFirstTexCoord; 58 | ci::Vec3f* mFirstPosition; 59 | 60 | int mIndexCount; 61 | }; 62 | 63 | typedef shared_ptr RendererPtr; 64 | 65 | }; 66 | -------------------------------------------------------------------------------- /bluegin/jni/flx/src/phy/psprite.cpp: -------------------------------------------------------------------------------- 1 | #include "flx/phy/psprite.h" 2 | 3 | using namespace ci; 4 | using namespace bluegin; 5 | using namespace flx; 6 | 7 | PSprite::PSprite(PWorldPtr world, BodyType bodyType, ci::Vec2f pos) 8 | : _world(world->getWorld()) 9 | { 10 | assert(_world); 11 | 12 | b2BodyDef bodyDef; 13 | switch (bodyType) { 14 | case DYNAMIC: 15 | bodyDef.type = b2_dynamicBody; 16 | break; 17 | case KINEMATIC: 18 | bodyDef.type = b2_kinematicBody; 19 | break; 20 | case STATIC: 21 | default: 22 | bodyDef.type = b2_staticBody; 23 | break; 24 | } 25 | bodyDef.position.Set(pos.x, pos.y); 26 | _body = _world->CreateBody(&bodyDef); 27 | } 28 | 29 | PSprite::~PSprite() 30 | { 31 | } 32 | 33 | void PSprite::createFixture(b2FixtureDef& fixtureDef) 34 | { 35 | _body->CreateFixture(&fixtureDef); 36 | } 37 | 38 | void PSprite::createFixture(b2Shape& shape, float density) 39 | { 40 | _body->CreateFixture(&shape, density); 41 | } 42 | 43 | void PSprite::setSize(float width, float height) 44 | { 45 | this->width = width; 46 | this->height = height; 47 | resetHelpers(); 48 | } 49 | 50 | void PSprite::update() 51 | { 52 | // XXX sync to physics xform 53 | b2Vec2 pos = _body->GetPosition(); 54 | x = pos.x - origin.x; y = pos.y - origin.y; 55 | angle = toDegrees(_body->GetAngle()); 56 | 57 | updateAnimation(); 58 | updateFlickering(); 59 | } 60 | 61 | void PSprite::render() 62 | { 63 | // Sprite::render(); 64 | } 65 | 66 | void PSprite::calcOrigin() 67 | { 68 | origin.x = width / 2; 69 | origin.y = height / 2; 70 | } 71 | -------------------------------------------------------------------------------- /bluegin/src/com/expb/bluegin/Accelerometer.java: -------------------------------------------------------------------------------- 1 | // A class to handle accelerometer input 2 | // 3 | // 4 | package com.expb.bluegin; 5 | 6 | import android.content.Context; 7 | import android.hardware.SensorManager; 8 | import android.hardware.Sensor; 9 | import android.hardware.SensorEvent; 10 | import android.hardware.SensorEventListener; 11 | 12 | public class Accelerometer implements SensorEventListener 13 | { 14 | private Sensor mAccel = null; 15 | private SensorManager mManager = null; 16 | 17 | private float[] mValues = { 0, 0, 0 }; 18 | 19 | public boolean updated = false; 20 | public float[] getValues() { updated = false; return mValues; } 21 | 22 | public Accelerometer(Context context) 23 | { 24 | mManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); 25 | mAccel = mManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); 26 | } 27 | 28 | public boolean available() 29 | { 30 | return (mAccel != null); 31 | } 32 | 33 | public void enable() 34 | { 35 | if (available()) { 36 | mManager.registerListener(this, mAccel, SensorManager.SENSOR_DELAY_GAME); 37 | } 38 | } 39 | 40 | public void disable() 41 | { 42 | mManager.unregisterListener(this); 43 | } 44 | 45 | public void onAccuracyChanged(Sensor sensor, int accuracy) 46 | { 47 | } 48 | 49 | public void onSensorChanged(SensorEvent event) 50 | { 51 | float[] sensed = event.values; 52 | for (int i=0; i < sensed.length && i < 3; ++i) { 53 | mValues[i] = sensed[i]; 54 | updated = true; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /bluegin/jni/cinder/include/cinder/BSplineFit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010, The Barbarian Group 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that 6 | the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this list of conditions and 9 | the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 11 | the following disclaimer in the documentation and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 15 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 16 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 17 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 18 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 19 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 20 | POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | #include "cinder/BandedMatrix.h" 28 | #include "cinder/BSpline.h" 29 | 30 | namespace cinder { 31 | 32 | template 33 | BSpline fitBSpline( const std::vector &samples, int degree, int outputSamples ); 34 | 35 | } // namespace cinder 36 | -------------------------------------------------------------------------------- /bluegin/jni/cinder/src/Exception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010, The Barbarian Group 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that 6 | the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this list of conditions and 9 | the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 11 | the following disclaimer in the documentation and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 15 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 16 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 17 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 18 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 19 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 20 | POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #include "cinder/Exception.h" 24 | #ifndef CINDER_BLUEGIN 25 | #include "cinder/Utilities.h" 26 | #endif 27 | 28 | namespace cinder { 29 | 30 | #ifndef CINDER_BLUEGIN 31 | Exception::Exception() 32 | : std::exception() 33 | { 34 | } 35 | #endif 36 | 37 | 38 | } // namespace cinder -------------------------------------------------------------------------------- /bluegin/jni/Box2D/Box2D_v2.1.2/Box2D/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * Permission is granted to anyone to use this software for any purpose, 8 | * including commercial applications, and to alter it and redistribute it 9 | * freely, subject to the following restrictions: 10 | * 1. The origin of this software must not be misrepresented; you must not 11 | * claim that you wrote the original software. If you use this software 12 | * in a product, an acknowledgment in the product documentation would be 13 | * appreciated but is not required. 14 | * 2. Altered source versions must be plainly marked as such, and must not be 15 | * misrepresented as being the original software. 16 | * 3. This notice may not be removed or altered from any source distribution. 17 | */ 18 | 19 | #ifndef B2_POLYGON_AND_CIRCLE_CONTACT_H 20 | #define B2_POLYGON_AND_CIRCLE_CONTACT_H 21 | 22 | #include 23 | 24 | class b2BlockAllocator; 25 | 26 | class b2PolygonAndCircleContact : public b2Contact 27 | { 28 | public: 29 | static b2Contact* Create(b2Fixture* fixtureA, b2Fixture* fixtureB, b2BlockAllocator* allocator); 30 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 31 | 32 | b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 33 | ~b2PolygonAndCircleContact() {} 34 | 35 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /bluegin/jni/bluegin/include/bluegin/sound.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace bluegin { 4 | 5 | enum SoundType { 6 | SOUND_TYPE, 7 | MUSIC_TYPE 8 | }; 9 | 10 | struct AudioSource 11 | { 12 | public: 13 | AudioSource(SoundType type, string path); 14 | 15 | SoundType type; 16 | string path; 17 | 18 | int soundID; 19 | }; 20 | 21 | typedef shared_ptr AudioSourcePtr; 22 | 23 | // Sound handles 24 | 25 | class Audio 26 | { 27 | public: 28 | Audio(AudioSourcePtr source); 29 | 30 | virtual void play() = 0; 31 | virtual void stop() = 0; 32 | virtual void pause() = 0; 33 | virtual void resume() = 0; 34 | virtual bool isPlaying() { return false; } 35 | void setVolume(float left, float right); 36 | void setLooping(bool loop); 37 | 38 | protected: 39 | virtual void updateSound() { } 40 | 41 | float mVolumeL, mVolumeR; 42 | bool mLoop; 43 | AudioSourcePtr mSource; 44 | }; 45 | 46 | class Sound : public Audio 47 | { 48 | public: 49 | Sound(AudioSourcePtr source, int streamID); 50 | // implementations 51 | virtual void play(); 52 | virtual void stop(); 53 | virtual void pause(); 54 | virtual void resume(); 55 | 56 | protected: 57 | int mStreamID; 58 | bool active; 59 | float lastPlayed; 60 | 61 | virtual void updateSound(); 62 | }; 63 | 64 | class Music : public Audio 65 | { 66 | public: 67 | Music(AudioSourcePtr source); 68 | virtual void play(); 69 | virtual void stop(); 70 | virtual void pause(); 71 | virtual void resume(); 72 | virtual bool isPlaying(); 73 | 74 | protected: 75 | }; 76 | 77 | typedef shared_ptr