HTML 5 Canvas for FreePascal/Delphi

I’ve been working on a proof-of-concept for the last couple of hours. With HTML 5 being more and more stable and HTML5 games slowly becoming an alternative to Flash games, I was looking for a way to port existing games for the Web platform.

HTML 5 Canvas seems like a good choice for the graphics output, so began a low-level implementation. At the moment it is just a proof-of-concept, it can just draw different types of shapes in different colors and I’m not sure if I’m gonna develop it any further or even if the way I took was the right one.

Currently it works like this: Compile an example with

fpc -Mdelphi filename.dpr

or

fpc -Mobjfpc filename.dpr

which results in a compiled executable. Execute it and you get a html- and a javascript-file. Just open the html-file and you should see the result.

It comes with three examples. Download here (5 kB)
Every example from https://developer.mozilla.org/en/Canvas_tutorial/Basic_usage and https://developer.mozilla.org/en/Canvas_tutorial%3aDrawing_shapes should work if translated to Pascal.

Read More

ElysionKronos for Thorium

I think I’ve already mentioned the Thorium scripting language here in this blog.

So without further ado, here is a preview version of ElysionKronos for Thorium: Click to download (2,1 MB)
It is very easy to use and if you have used Java/JavaScript and/or Unity3D before, ElysionKronos for Thorium will be really familiar to you.

It comes with five little examples (/samples folder), a short readme on the general usage and a PDF containing documention for functions of some classes.
Currently there is just a Win32 binary included, but you can recompile it for Linux and Mac OS X (well, just Intel platforms on Mac OS X). If you compile it for Mac OS X you have to add

{$PIC OFF}

somewhere in the thorium.pas.

Thorium itself is licensed under the MPL 1.1 or GPL/LGPL license, the Elysion Frameworks and ElysionKronos for Thorium are licensed under the MIT or MPL license. Parts of the Elysion Frameworks might be licensed under a different license.

Read More

Thorium Scripting Language

So, I’ve been playing around with the Thorium scripting language lately. It’s a great project and I’m in the process of integrating Thorium into the Elysion frameworks.
The best feature is that I can use my Pascal classes directly in my script (if my class is derived from TThoriumPersistent and RegisterRTTIType is called with the correct parameters). I can declare the properties in my class and call these properties from my Thorium script without worrying about anything else.

This is a quick’n'dirty script I put together:

loadlibrary "core.std.io"
loadlibrary "elysion.kronos"

private elSprite sprite;
private elSprite sprite2;
private float angle;
private int al;

public void initialize()
{
	angle = 0;
	al = 0;

	sprite = elSprite.create();
	sprite.loadfromfile("test.png");
	sprite.x = 128;
	sprite.y = 128;

	sprite2 = elSprite.create();
	sprite2.loadfromfile("test.png");
	sprite2.x = 256;
	sprite2.y = 256;
	printf("Initialize\n");
}

public void render()
{
	sprite.draw();
	sprite2.draw();
	printf("Render\n");
}

public void update()
{
	printf("Update\n");
	angle++;
	if (angle == 360) angle = 0;
	sprite2.rotation = angle;

	al++;
	sprite.alpha = (al mod 255);

	if (sprite2.onmouseover) sprite2.visible = false;
		else sprite2.visible = true;
}

And here is the obligatory screenshot:

Graphics are loaned from Ari Feldman’s Spritelib GPL.

Read More

Play The City @ Linux Info Day 2010

This post would only interest you if you are living in Germany and/or are willing to travel to Augsburg, Bavaria on the 27th of March 2010. Play The City (Link to german page) is an application I’m developing with a few of my fellow students since last semester.
As for the technical side, you may have already guessed or read on my blog post from about half a year ago we are using FreePascal and SDL (and the Elysion Frameworks of course).
The big news is that we are going to show Play The City on the Linux Info Day (german link again) this year. We are probably distributing some Play The City Live-CDs, you can watch and talk with us live and you can try the application for yourself.

Read More

Simple iPhone example using FreePascal and SDL

I’ve made a quick how-to on how to set up a simple iPhone example using FreePascal and SDL and run it with the iPhone simulator.

Please watch in HD. There are englisch and german subtitles available on Youtube.
Video Link on Youtube: http://www.youtube.com/watch?v=Hm4UIPl1GqA
Video Link on Vimeo: http://www.vimeo.com/9522466

The example source code can be downloaded here: http://www.freeze-dev.de/files/SDLiPhoneFPC_Colors.zip

The SDL 1.3 iPhone header I provide in this example is still incomplete and at best Alpha.

Also I’m using ElysionLogger from the Elysion Frameworks Subversion repository to create a HTML log file in the directory of the application bundle. If you don’t any log files to be created, delete ElysionLogger from the uses clause and any calls that begin with TelLogger.getInstance.

Update
If you rather develop with Lazarus, you might want to try this project file, which allows you to install the application on the iPhone Simulator right out of the Lazarus IDE. You need Lazarus 0.9.29 and the iPhone Laz Extension (http://wiki.freepascal.org/iPhone_Laz_Extension).
http://www.freeze-dev.de/files/SDLiPhoneLaz_Colors.zip

Read More