Skip to content

Cutscene using squirrel scripting

The last 2 weeks or so, I’ve been working on an update for Weston Westie, and one of the things coming out with the update is cutscenes.
I’ve been integrating Squirrel Scripting into the engine, as I thought would make things easier if I used a scripting language.
After the initial painful process of making it work on Samsung Wave, creating some bindings between C++ and Squirrel, things started to pick up.
In Weston Westie, cutscenes are mostly a series of still images, playing some sounds, some fading out/in, the occasional moving background, etc.
Using coroutines, the cutscene scripting is done in a serial way, unaware of the game loop.

One of the simple cutscenes I’ve done so far.

The scripting for this particular scene goes kind of like this (simplified version)…

function SailAway()
{
	// Load needed resources...
	local imgDash = resourcemanager.Get(ResourceType.IMAGE, "Sequences_Debut_Dash");
	local imgWestonOnFire = resourcemanager.Get(ResourceType.IMAGE, "Sequences_Debut_WestonOnFire");
	local imgEnd1Shore = resourcemanager.Get(ResourceType.IMAGE, "Sequences_End1Shore");
	local sngDetermination = resourcemanager.Get(ResourceType.SOUND, "Determination");
	// ...

	// Create a UI Scene to use
	local scene = CUIScene.Create();
	scene.Activate();

	// Create two widgets to display a background, and a front image
	local back = CWidget.Create(scene.GetRootWidget());
	local front = CWidget.Create(scene.GetRootWidget());

	// Setup the images
	back.SetBackgroundImage(imgWestonOnFire, CColour4.WHITE);
	front.SetBackgroundImage(imgDash, CColour4.WHITE);

	// Setup background and foreground images movement using some helper classes
	// ...

	//
	// First part - Weston appearing, with the "fire" background
	//

	// play introduction song as weston appears
	local sngH = soundmanager.Play(sngDetermination, false);
	TickFor(2.0); // animate everything for 2 seconds
	// starts a fade out on the song, that takes 4 seconds
	soundmanager.SetFade(sngH, 0, 4.0);
	TickFor(1.0); // animate for 1.0

	//
	// Second part - weston surprised
	//

	// Show weston surprised at shore
	front.SetBackgroundImage(imgEnd1Shore, CColour4.WHITE);
	// Play "surprised" sound
	soundmanager.Play(sndWhat, false);
	TickFor(1.0);

	// .. and the list goes on, serially showing images,
	// playing sounds, fading, etc

}

My engine doesn’t have any specific support for cutscenes, or fancy editors, so each cutscene is basically handcoded.

I do have some utility code to automate a fade in/ou, or move an image around for example.

I use mostly C++, so I’m used to strongly typed languages. Using a scripting language like squirrel is a bit painful at start, as the compiler isn’t much of a help catching mistakes. On the other hand, it does force you to pay more attention on what you’re doing.

Overall, I’m happy with squirrel. The library is relatively small, and with a bit of effort you can find your way around.

In the future I’ll probably try some other scripting languages, particularly Lua, since it’s so widespread in the games industry, or AngelScript, which is not that widespread, but has a nice feature set and it’s closer to C++.

Music Disk

Some time ago (2007 I think), I mentioned that czPlayer has origins in an old sound system I coded for a Music Disk, back in 1998.
I managed to find a zip file with that same Music Disk, and wrap it with DOSBox, so that anyone can take a look, as it wouldn’t run in modern PCs.

You can download it here.
Just unpack to a folder, and run the “LaunchPH5_5” batch script. It will automatically launch PH5.5 running inside DOSBox.

I coded pretty much everything apart from a really nice graphics library I got from a book, and most of the work was done during 1998 Summer holidays. Some of the awesome features (in 1997-1998 at least):

  • Runs in VGA VESA mode, 800×600, with support for Linear Frame Buffer. (Sounds like Chinese to you? If not, then you’re getting old)
  • Optimized 256 colour palette.
  • Coded in good old Watcom C++ for DOS, and runs in protected mode (uses PMODE/W)
  • The sound system itself was quite nice, support a couple of things not commonly found:
    • Critical mixing functions coded in hand optimized assembly
    • Support from SB Mono to SB 16.
    • Support for Gravis Ultrasound, both hardware mixing, or software mixing, to work around the hardware voices limitation.
    • Mono, Stereo, 8 and 16 bits support
    • Fixed point mixing
    • Quite decent Impulse Tracker format support

The art was done by a friend of mine.
Music was done by that same friend, and a friend of his, whom I never met, using Impulse Tracker.
Two of the songs were mine, but not as good as the other ones, since after all I was the coder!

Just look at these awesome screen shots!
Keep in mind that’s from 1998, using a 800×600 8bits display mode

Sound Setup Screen

Coded in ASCII mode. Look at those amazing shadows Smile

ph5_5_002

 

Start-up screen

The awesome start-up screen, calculating some really useful lookup tables.
Also, note the 800×600 video mode, at 8 bits. Live wasn’t easy.

ph5_5_003

User Interface (Trance Zone)

The UI was divided in two zones
The background art was indeed nice. The way everything fits on top is a bit crude without antialiasing, because with just 256 colours, it was a limited palette to choose from.
The spheres with the song names were faded in and out in a cycle.

ph5_5_004

Trip-Hop Zone

And the other zone, which we could scroll to. It had a complete different set of colours, which didn’t help. Both zone colours came from the same 256 colour palette.

ph5_5_011

Some options

I had some options for sound and the graphics. Turning off interpolation would only have an effect if using software mixing of course.

ph5_5_018

Credits

Notice the transparency of the dialog box. As all the other screenshots, still using the same colour palette.

ph5_5_020

 

Conclusion

That was the first project I started, finished, and released.
Also, the first project using the original czPlayer. The current version still has a bit of that code, but most of it has been refactored.
It’s an interesting experience to look at code I wrote >12 years ago, with a complete coding style.
Was an interesting thing to work on. I remember sitting down with my friend to discuss details and take a look at each other’s work.
Also, I remember a particular day I was brainstorming about display modes, and If I could go for 16bits/24bits mode, which would look a lot nicer, but would require a lot more CPU at that time.

These were the specs of the computer I used for coding:

  • Pentium 233 MMX
  • 32 MB
  • About 20 MB of Hard Drive space, for code and assets
  • SB16 clone, and a GUS sound cards
  • Cirrus Logic Laguna 5464 PCI graphics card

Going freelance again

After all that’s been happening at Realtime Worlds, I’ve decided to give another stab at going freelance for a while.
I’ve been pondering it for a while, but faced with the recent events (APB’s lackluster sales, Realtime Worlds going into administration), I’ve pretty much decided that’s the way to go, at least for a while.
Main reason is that I’m pretty much done with APB. I do love the game, and at this moment I have >200hours, but on a job perspective it doesn’t offer me the satisfaction it used to, like when I was designing and implementing the Music Studio sound system, or designing and implementing the sound prioritization we have on top of Wwise.
Also, I want to gain more experience in other areas (other than Audio).
With the hiring spree that happened here in Dundee after the news about Realtime Worlds, I did had to turn down a few interviews with some interesting Studios, but I feel it was the right thing to do.
I want to step back a little and decide where to go from here, instead of rushing to another job.
Like for example, I did enjoyed working on my lastest hobby project Weston Westie, developed with my friend and CEO at BitRabbit, for the brand new Samsung Wave, which is the first device with the Bada OS.
I did all the coding myself, except for the thin framework BitRabbit provided ( RabbitFactory ) which abstracts all the platform details, and was a nice way to play around with things I normally don’t, like OpenGL ES, basic AI, UI, Gameplay, etc.
Although Weston Westie was launched in July, we’ve done basically no marketing, as we want to polish it for the first update (improve textures, put some eye candy, experiment with a different control method).
At this moment, I have some work lined up with Jenkins Software, whom I’ve worked with in the past.
I get to work from home (like I did before), which is nice bonus. :)
The job itself is to revise,update and improve RakNet’s documentation.
This particular contract doesn’t actually involve much coding, and some programmers at heart might find it dead boring, but personally I see it as great opportunity to get paid to learn something valuable.
Positive things I see coming out of this:
  • With the high demand for multiplayer games, knowing RakNet library inside out will surely stand out on my CV. I can always say… “After all I wrote the documentation. ;)
  • I get to practice actual writting, since English is not my native language. I think it’s ok, but there’s always room for improvement.
  • Working from home does have some benefits. I can work any time I want, as long as the job gets done. That helps when I need to so something within typical business hours.
  • With the knowledge I’ll get from RakNet, I can write some Raknet code samples, and post them here, generating traffic.

On top of all this, since I’ve decided to go freelance, some funny synchronicities happened recently.

  • Bitrabbit might have some more freelance coming up my way
  • Today went to a workshop for videogames startups, and some interesting things happened:
    • Lots of good tips on running a business, PR, Marketing, etc
    • Some old friend from Realtime Worls is planning a startup, and since we’re both planning on staying in Dundee, some work might come my way.
    • One other friend was there, and reminded me to join him and a few other developers for an apparently weekly Wednesday talk (in a local pub), which I knew about, but never actually attended.