__________ .__ .___________ \______ \____ ______ |__| __| _/ _____/_____ _____ ____ | _|__ \ \____ \| |/ __ / \ ___\__ \ / \_/ __ \ | | \/ __ \| |_> > / /_/ \ \_\ \/ __ \| Y Y \ ___/ |____|_ (____ / __/|__\____ |\______ (____ /__|_| /\___ > \/ \/|__| \/ \/ \/ \/ \/
RapidGame is a commandline tool for Mac and Windows (Linux support is planned) which:
A game project templating system for creating cross-platform games for a variety of game engines, including cocos2d-x, cocos2d-js, Unity, Corona and Appcelerator Titanium. The default game template creates a simple Breakout clone with a menu and game scene.
Prefer somebody explaining and showing it? Check out the overview video.
There's no need to clone this repo, just install RapidGame:
sudo npm install rapidgame -g
Or, on Windows leave off the
npm install rapidgame -g
And, create a cocos2d-x game named "HeckYeah". Make sure to run Command Prompt or Cygwin as administrator when doing this on Windows!
rapidgame create cocos2dx "HeckYeah" org.myorg.heckyeah
Or, a Unity game named "ZombieMatrix":
rapidgame create unity "ZombieMatrix" com.myompany.zombiematrix
For usage instructions:
The templates have:
The project creator makes a copy of one of the templates, does a search and replace on the game title & package name, then installs any required modules. Viola. Your own rapidly-created game ready to go. Here's some example output from running the project creator:
$ rapidgame create Corona "SwordBall" org.myorg.swordball Rapidly creating a game Engine: Corona Template: TwoScene Copying project files Setting project name: Sword Ball Setting package name: org.myorg.swordball Done Congratulations on creating a Corona game! Run it by opening the `main.lua` file in the Corona Simulator. Ready to code? Start with the `main.lua` file.
The library prebuilder creates static libraries that virtually eliminate build times for the cocos2d-x engine (the native portion of cocos2d-js). With hundreds of source files to be compiled, building cocos2d-x for just one platform can take at least five minutes. This can be a real time sink, especially when switching from the simulator to device triggers a rebuild.
The prebuilder automatically downloads the latest cocos2d-js, patches it to ensure that it is bug-free, then prebuilds cocos2d-x for all possible platforms, configurations and architectures. It is then possible to compile and link native cocos2d-x games in seconds. Even better, the project creator will absolutely symlink to the location of the prebuilt libraries so your game projects stay lightweight and can be moved easily.
A project created by RapidGame uses exactly the same underlying API as cocos2d-x / cocos2d-js. One can still get the running scene, for example, like this
RapidGame extends upon the cocos2d-js API with the Game object. This object provides methods which are commonly used in game development, but were missing from cocos2d-js at the time of writing.
Game.rand(5), for example, returns a random integer between 0 and 5.
While the underlying API stays the same, the file / folder structure of a project created by RapidGame is different than that of a "normal" cocos2d-js project. A normal project is created with the
cocos new -p com.mycompany.mygame -l js -d MyGame
This results in a project folder approximately 500 MB which contains all the files necessary to build cocos2d-x from scratch. Subfolders include:
By contrast, a RapidGame project is only 2 MB (because it symlinks to cocos2d-html5 and the prebuilt cocos2d-x libraries) and has a more organized folder structure:
Inside the project files there are other differences. Take the Xcode project as an example. The normal cocos2d-js project is setup to build all of cocos2d-x, depends on several sub-projects (Targets > Build Phases > Target Dependencies) and references several User Header Search Paths (example:
$(SRCROOT)/../../js-bindings/cocos2d-x) within the
The RapidGame project is more efficient, relying on the symlinked
lib folder. Instead of depending on sub-projects and rebuilding all of cocos2d-x, it uses two Other Linker Flags to include the prebuilt cocos2d-x libraries (
-lcocos2dx-prebuilt) and specifies an additional Library Search Path in which to find them:
$(SRCROOT)/../lib/cocos2d/x/lib/$(CONFIGURATION)-iOS/$(PLATFORM_NAME). User Header Search Paths also use the symlink,
$(SRCROOT)/../lib/cocos2d/x/include/cocos, so that by simply swapping the
lib folder one can upgrade to a newer prebuilt version of cocos2d-js/x.
The command to prebuild cocos2d-x static libraries used by cocos2d-js on native platforms:
When the command is finished, you'll have a directory (
RapidGame can be used on any platform that is capable of running Node.js.
The cocos2dx library prebuilder currently works on the following development platforms:
Linux support is planned.
The following environment variables must be present in order to prebuild Android libraries. Consider adding these to your login profile. For example, on Mac add these lines to the bottom of your
export ANDROID_SDK_ROOT=~/path/to/android/sdk export NDK_ROOT=~/path/to/android/ndk/
Or, on Windows add these to the bottom of your Cygwin
~/.bash_profile (note that the forward slashes are correct):
Android SDK APIs must be downloaded for the target platform and the minimum supported platform. The template project's target is currently API 18 and minimum is API 10. This can be done by going to Android Studio -> Configure -> SDK Manager -> [Select and install appropriate packages].
rapidgamecommand must be run in an admin console. This allows symlinks to be properly created, otherwise what should be symlinks will become regular folders and the prebuild command will fail.
rapidgame prebuildmust be run via Cygwin and Cygwin must be installed in the root directory
C:\cygwin. The "Devel" category of packages should be downloaded in addition to the defaults when running setup.
Thanks to Samuel Ørsnæs for getting the Android build working in Windows!
If you are just using cocos2d-x or you have your own custom project layout, you can still use the prebuilt libraries. Use this command to create a symlink to the libraries directory:
cd MyGame && rapidgame init .
Then setup your Xcode target to reference the headers. Example:
USER_HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/../lib/cocos2d/x/include/cocos $(SRCROOT)/../lib/cocos2d/x/include/cocos/2d ...
And the libraries:
LIBRARY_SEARCH_PATHS = $(SRCROOT)/../lib/cocos2d/x/lib/$(CONFIGURATION)-iOS/$(PLATFORM_NAME)
Then link with the library:
OTHER_LDFLAGS = -lcocos2dx-prebuilt
It's possible to create your own game templates. Here's the step-by-step instructions:
Create your game directory. If your game is called "ZombieMatrix", name the directory
Use the name of your game throughout your game project. RapidGame will automatically search and replace the title in most types of source and project files.
If you'd like a file or directory renamed, make sure it starts with your game's title. For example, if you have
ZombieMatrix.xcodeproj it will get changed to
Whenever there's an instance of your package name, replace the beginning with
com.wizardfu., lowercase the title and remove any punctuation, so
com.wizardfu.zombierevolution. This will get changed by the templating system when creating new game projects.
Copy your game template to the
templates/<engine> directory of RapidGame. On Mac / Linux this is
/usr/local/lib/node_modules/rapidgame. You can use the
npm prefix -g command to determine where Node modules are installed on your system. If you're on Mac OS X, the template is for Unity and it's called "ZombieMatrix" then the final directory would be
Your template is now ready for testing. Try it out like this:
rapidgame create <engine> MyNewGame com.mycompany.mynewgame -t "ZombieMatrix".
Submit pull requests or open issues as you see fit.
RapidGame is licensed under the MIT license.