image directory structure:
├── resources
│ └── images
│ └── mario
│ ├── mario-run-0001.png
│ ├── mario-run-0002.png
│ └── mario-run-0003.png
James Doig's Blog
Monday 25 February 2013
Animated Mario sprite with game{closure} + coffeescript
Just a quick one; an animated sprite in game{closure} using coffee script:
Sunday 17 February 2013
More coffeescript + game{clojure} ...
Today I ported game{closure}'s animated trail example to coffeescript.
For anyone wondering, the work flow I'm using is:
Create a new game project:
Create a coffeescript directory:
Watch and auto-compile coffeescript to js and copy to the projects /src directory
For anyone wondering, the work flow I'm using is:
Create a new game project:
$ cd ~/devkit/projects/
$ basil init <game-name>
Create a coffeescript directory:
$ mkdir ~/devkit/projects/<game-name>/coffee
Watch and auto-compile coffeescript to js and copy to the projects /src directory
$ cd ~/devkit/projects/<game-name>/coffee
$ coffee --watch --compile --output ../src/ .
Run sdk web frontend
$ basil serve
Start hacking at your application.
$ emacs ~/devkit/projects/<game-name>/coffee/Application.coffee
And here is the code:
Saturday 16 February 2013
GameClosure & CoffeeScript
Yesterday a colleague pointed me a very interesting game engine called GameClosure that can compile Javascript and HTML down to native code for mobile devices.
Never wanting to touch Javascript after having discovered the wonders of CoffeeScript I took a quick look at how to get a hello-world example working with CoffeeScript & GameClojure... here's the code:
A couple of points of note here are:
Hopefully it's this easy with, non-trivial, GameClosure applications.
Never wanting to touch Javascript after having discovered the wonders of CoffeeScript I took a quick look at how to get a hello-world example working with CoffeeScript & GameClojure... here's the code:
A couple of points of note here are:
- exports is backtick-escaped so as to render directly to javascript as the engine requires exports to have global scope.
- CoffeeScript's implementation of inheritance replaces GameClosures 'Class(<super class>, func...' inheritance helper function (and is much nicer IMO) as seen in their javascript implementation of hello-world.
Hopefully it's this easy with, non-trivial, GameClosure applications.
Sunday 20 January 2013
Haxe & HaxePunk
I've had a lot of fun looking into cool stuff this new year and having made a move into the gaming industry; with my first job based around the development of a small, tablet based, casual game I've been looking into multi-platform, 2D, off the shelf, games engines.
I came across a project called Haxe (pronounced: Hex) that uses a language which is a derivative of ActionScript3 that compiles to native code for Android, IOS, Blackberry, Windows, Linux and Mac as well as Flash or HTML5 + Javascript... Which is pretty awesome in my opinion.
http://haxe.org/
HaxePunk is a Haxe port of the FlashPunk game engine which is extremely handy as it means there is a wealth of resources and tutorials on developing games with it.
Haxe Punk: http://haxepunk.com/
FlashPunk learning resources: http://flashpunk.net/learn/
I ran into a couple of problems while setting up my environment on OSX so I'll cover installing Haxe plus a couple of the problems I had here:
#1 Download Haxe here: http://haxe.org/download.
#2 Run these from the command prompt (you may need to sudo these, depending on your setup):
haxelib install jeash
haxelib install actuate
haxelib install nme
haxelib run nme setup
haxelib run nme setup android
#3 The last line will start up the android SDK installer, but the one it downloads will need upgrading. After the auto update remember to reopen the android SDK installer and select the version 8 API then download and install before continuing on with the setup script.
#4 The Haxe language bindings for MonoDevelop 3.0 didn't show up for me in:
MonoDevelop > Add-ins > Gallery
So I downloaded them manually from: http://addins. monodevelop.com/Beta/Mac/3.0/ MonoDevelop.HaxeBinding-0.4.0. mpack
#5 When targeting IOS in MonoDevelop the IDE just hung. So I tried from the command prompt with:
$ sudo haxelib run nme test "project.nmml" ios -simulator
From the directory containing my project.nmml.
This provided me with a meaningful error about the compiler not being able to find clang++ this, I think, was due to me having XCode 4.2 intalled .
Make a note of the directory it was looking for clang++ in then run:
$ which clang++ to find out where clang++ is on your system (/usr/bin/clang++ on my system) and symlink it to the directory that you made note of earlier.
Rerun: $ sudo haxelib run nme test "project.nmml" ios -simulator
If it works then you should be ok to target iOS from MonoDevelop again, without it hanging this time.
#6 If you're having performance problems with HaxePunk on Android check out this Stackoverflow post
I came across a project called Haxe (pronounced: Hex) that uses a language which is a derivative of ActionScript3 that compiles to native code for Android, IOS, Blackberry, Windows, Linux and Mac as well as Flash or HTML5 + Javascript... Which is pretty awesome in my opinion.
http://haxe.org/
HaxePunk is a Haxe port of the FlashPunk game engine which is extremely handy as it means there is a wealth of resources and tutorials on developing games with it.
Haxe Punk: http://haxepunk.com/
FlashPunk learning resources: http://flashpunk.net/learn/
I ran into a couple of problems while setting up my environment on OSX so I'll cover installing Haxe plus a couple of the problems I had here:
#1 Download Haxe here: http://haxe.org/download.
#2 Run these from the command prompt (you may need to sudo these, depending on your setup):
haxelib install jeash
haxelib install actuate
haxelib install nme
haxelib run nme setup
haxelib run nme setup android
#3 The last line will start up the android SDK installer, but the one it downloads will need upgrading. After the auto update remember to reopen the android SDK installer and select the version 8 API then download and install before continuing on with the setup script.
#4 The Haxe language bindings for MonoDevelop 3.0 didn't show up for me in:
MonoDevelop > Add-ins > Gallery
So I downloaded them manually from: http://addins.
#5 When targeting IOS in MonoDevelop the IDE just hung. So I tried from the command prompt with:
$ sudo haxelib run nme test "project.nmml" ios -simulator
From the directory containing my project.nmml.
This provided me with a meaningful error about the compiler not being able to find clang++ this, I think, was due to me having XCode 4.2 intalled .
Make a note of the directory it was looking for clang++ in then run:
$ which clang++ to find out where clang++ is on your system (/usr/bin/clang++ on my system) and symlink it to the directory that you made note of earlier.
Rerun: $ sudo haxelib run nme test "project.nmml" ios -simulator
If it works then you should be ok to target iOS from MonoDevelop again, without it hanging this time.
#6 If you're having performance problems with HaxePunk on Android check out this Stackoverflow post
Setting up D v2.061 on OSX (Mountain Lion)... rdmd not installing.
I've recently been playing with the D language on my MacBook and found the latest dmg (v 2.061) from: http://dlang.org/download.html did not install rdmd or the D shell.
The sollution to this was to download the "all platforms" zip file, from the D downloads page, then following the guide here: http://dlang.org/dmd-osx.html
Once this is done you can use the #!/usr/local/bin/rdmd shebang at the top of your .d files.
Note: this differs slightly from the one used in the tutorials at : http://www.informit.com/articles/article.aspx?p=1381876 (which uses #!/use/bin/rdmd)
This may have just been a problem specific to my particular system and/or setup, I'm not sure... But if not I hope this helps someone.
The sollution to this was to download the "all platforms" zip file, from the D downloads page, then following the guide here: http://dlang.org/dmd-osx.html
Once this is done you can use the #!/usr/local/bin/rdmd shebang at the top of your .d files.
Note: this differs slightly from the one used in the tutorials at : http://www.informit.com/articles/article.aspx?p=1381876 (which uses #!/use/bin/rdmd)
This may have just been a problem specific to my particular system and/or setup, I'm not sure... But if not I hope this helps someone.
D
I read an article about functional programming in C++ by John Carmack (of Doom fame) last week and while it did little to warm me to C++ the article was very interesting and covered the the virtues of immutability and pure functions as they can be applied by anyone in almost any language.
http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/
In the article John mentions a programming language called D, so having enjoyed the article I took the time to check it out.
There was a lot to like about D: It has 'immutable' and 'pure' keywords, anonymous functions and closures, a garbage collector, built in tools for concurrency, unit testing, contract coding (pre and post conditions, etc). It also compiles to native code and can introp with C and extend Python (Pyd: http://pyd.dsource.org/index.html)
I'm liking a lot of what I'm seeing about D ... More posts on D to come.
http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/
In the article John mentions a programming language called D, so having enjoyed the article I took the time to check it out.
There was a lot to like about D: It has 'immutable' and 'pure' keywords, anonymous functions and closures, a garbage collector, built in tools for concurrency, unit testing, contract coding (pre and post conditions, etc). It also compiles to native code and can introp with C and extend Python (Pyd: http://pyd.dsource.org/index.html)
I'm liking a lot of what I'm seeing about D ... More posts on D to come.
Setting up Ubuntu (12.04 LTS) in VirtualBox under OSX Mountain Lion
I've recently needed to run an Ubuntu VM on my 2012 Mac Book Pro (Retina) and being a cheapskate I reached for VirtualBox.
Initial installation is fairly easy but I immediately ran into a whole host of problems:
- The newest version of Ubuntu (12.10) desktop requires 3D acceleration so it runs like crap.
- I can't see my Mac's Documents folder that I had marked as a shared folder in VirtualBox's settings.
- I couldn't ssh into the VM.
So to save anyone else the trouble I thought I would document the steps I went through here.
#1 System Configuration
Download Ubuntu 12.04 LTS (instead of 12.10). OK so it's not the latest version but not having to wait 2 seconds for the Ubuntu desktop to respond is vital to not loosing patience with the whole setup.
I chose 12.04 LTS 64 bit which is in the downloads section just bellow the download link for the latest version, here (Note: 32-bit is selected by default): http://www.ubuntu.com/download/desktop.
Using VirtualBox (https://www.virtualbox.org/) I set up a VM with the following configuration:
* General
Name: Ubuntu
* System
RAM: 2048 GB
HDD: 8GB , Virtual Disk Image (VDI), dynamically allocated
CPU: 2 x CPU (though this causes a non-optimal settings warning, not sure why).
* Network
Type: NAT
Port forwarding (under 'Advanced' tab in networking):
name: 'ssh'
host port: 2222
guest port: 22
* Shared Folders
Name: Documents, Path : /Users/jamesdoig/Documents
Do not check "Auto mount" (as it's bugged)
#2 Installation
* Under Settings -> Storage place the Ubuntu .iso into the CD/DVD drive and start the virtual machine.
* Go through the Ubuntu installation procedure.
I chose the: English: Macintosh, international keyboard layout to match my Mac Books kb layout.
* Once you have booted into the operating system and logged in: From the virtual box menu select: Device-> Install Guest Additions. Follow the on screen prompts.
* Reboot your VM.
#3 Folder sharing setup
* Sign into Ubuntu and open up a terminal,
Make a directory in /media to mount your shared folder to:
$ sudo mkdir /media/shared
Mount the shared folder (In my case Documents) :
$ sudo mount -t vboxsf Documents /media/shared
This will mount your Documents folder at /media/shared but you will have permission problems.
* Still in your Ubuntu VM terminal do:
$ cat /etc/passwd
and make note of the numbers that appear in the entry for your login name:
e.g: james:x:1000:1000:james,,,:/home/james:/bin/bash
So 1000 in my case.
* Now using your text editor of choice (I installed emacs by this point) :
$ sudo emacs /etc/fstab
and add the line:
Documents /media/shared vboxsf uid=1000,gid=1000,nodev,noexec,nosuid,auto,rw 0 0
Where uid & gid = the number you noted earlier,
'Documents' is the name of the folder you shared in VirtualBox
And '/media/shared' is the mount point your created earlier.
* Reboot your VM.
#4 SSH setup
Open up the Ubuntu terminal and do:
$ sudo apt-get install openssh-server
I'd rebooted the VM a lot during this process so can't be sure if this step also required it.
Now you should be able ssh into your Ubuntu VM from your Mac terminal with:
$ ssh -p 2222 <your login name>@127.0.0.1
#5 Running the VM in headless mode and SSHing in
This step isn't required but I did it for convenience:
In your Mac terminal:
Edit your ~/.bash_profile
e.g: $ emacs ~/.bash_profile
And add the following:
alias ubu='ssh -p 2222 james@127.0.0.1'
alias uvm='VBoxHeadless --startvm "Ubuntu"'
alias uvmx='VBoxManage controlvm "Ubuntu" poweroff'
Where "Ubuntu" is the name you gave the VM in Virtual box.
Also pick aliases that work for you.
Using these I can launch my VM headlessly (Without launching the GUI and VM desktop) from the terminal with: $ uvm
Shut down the vm with: $ uvmx
And ssh into the vm with: $ ubu
Subscribe to:
Posts (Atom)