Issue 86 February 4 2010

A Leg Up to Building Your Own Games
Derbrill share source code and tips to get you started

by Malte Pfaff-Brill

As you may know my company has been writing games for quite a while. Using our animationEngine, we have been able to create fast, fun, award-winning games using Revolution.

We've reached a point where we feel we want to pass on our knowledge. We have learned so many techniques that you could benefit from! Here is an example of the gems we want to share:

Predictable random numbers!

This sounds like a contradiction in itself, doesn't it? If you go for random numbers, you usually want them to be well, random. However, as you may know, in computer development random numbers are not really random. Rev is blessed with a seeded random number generator. And we will use that to our advantage when writing gaming techniques.

When we were developing drops, the undo system in the first version was very crude. It could be exploited to cheat in the game play. Players were using undo after columns were cleared. New drops came up and those were different each time they used undo. We had to fix that. So how would you go about fixing that? First we considered storing the new drops that appeared in a variable and reusing that list, once an undo has happened. But then we came up with something far more elegant:

New drops are defined basically by the icon of the button that displays them. We obviously wanted those to be set up random, so a code snippet could look like:

set the icon of the templateButton to the ID of image (any item \
       of "red,blue,yellow,green" &".png") of cd "artwork"

Using this is a repeat loop along with a create button statement generated nicely randomized drops. So how could we remember which colors were used, without storing a massive list of colors?

Randomseed to the rescue! Lets switch back to numbers for simplicity here: Create a button and set its script to:

on mouseUp
   answer random(10)
end mouseUp 

Compile and click it a few times. Looks random, right? Now go back to the script and change it to:

on mouseUp
   set the randomSeed to 1000
   answer random(9)
end mouseUp 

Surprise surprise. We now have the Dilbert version of a random number generator.

It is the same number (9) all the time. This way you can predict randomness. All you need to do is remember the seed value. Less memory use, less overhead. Of course this does not work for numbers only. Seeding also affects the any statement. :-)

-- always yellow
set the randomseed to 1000
put any item of "red,green,blue,yellow" 
While we are preparing new tutorials and gems to share from the things we learned, we are offering a source-code, heavily commented version of our game projects. We will let you build your own version of our games. Our first release is drops!, our bestseller game. You may obtain a non exclusive license to the sources for an introductory price of $59 ($79 as of Feb. 14th).

We are moving our business plan towards stronger support for animationEngine and chartsEngine. They remain essential libraries of all the software we write. We have a strong user base. We have eager plans to make them better. We also have plans to offer more exciting stuff to the community. As part of that strategy, we will sell the sources of games we wrote that were solely funded by us. This will fund the development of more cool stuff. We plan to do more tutorials. During the time we spent developing games we learned so many techniques, that are not only useful in games, but also translate to other software. Using animation in user interfaces is one of the examples.

So what is in the package?
Most importantly, a full-fledged commercial award-winning game!

Including:
- all logic
- all artwork and all audio.

We have heavily commented the source code so each segment of code is clearly explained. This lets you quickly learn how to create a game like drops and how to make changes.

We make it easy for you to sell your project. Included in the product, you get the code to create a High Scores and Recent Players Score webpage.
You also get a serial number generator you can adapt for your own needs. We want you to succeed! We also include 5 free support incidents geared to the game to get you up and running.

With the purchase of Drops! The Source Code edition, you may:
  • Freely modify the source code you obtained from us.
  • Distribute compiled applications, both as standalone application and revLet from the source and derivates thereof royalty free.
  • Use artwork and audio files contained in the stack, excluding only the Drops! logo.
  • Take snippets of the code and move them to other projects, as long as you do not make the sources available.

You may not distribute the source code, or derivates thereof, unless those sources were completely written by you. This extends, but is not limited to the upload of stacks to revOnline and posting excerpts of code written by us to any revolution user group or other entity. Nor may you call your standalone application Drops!.

What else do you need to get up and running?
On top of the drops source code edition you will need a copy of animationEngine (2.9 or higher is required) to make the stack work.

I hope you liked the small excursion into gaming techniques. I hope to come up with more tutorials like this in the future.

You will see below the free online version of drops! which you are welcome to play with as much as you like. Beware, its addictive...

All the best,

Malte

About the Author

Malte Brill is long time Revolution User and revSelect pioneer. CEO of derbrill Multimedia and CTO of awesomemegamightygames.

Main Menu

What's New

Crossgrade to Rev