Tuesday, August 11, 2009

2009 PGD Annual Video Announcement

It's been a while... not only for this competition, but for me making videos as well... Here it is a bit late, but in good form. The 2009 PGD Annual Game Development Competition Video Announcement!

Monday, July 13, 2009

2009 PGD Annual Game Development Competition

It's finally back!!! :D This year the theme is Arcadia; create your own arcade game for a chance to make 1st Place and show off your game at the next Independent Game Festival.

These competitions are seriously fun and very rewarding. Nevermind all the prizes that you can win (books from Cengage Learning, content development tools and commercial games by other Pascal developers) but at the end of it all you end up with a fulling functional and polished game ready to be enhanced for release soon after. :)

Plus at the end once the judges have scored all the games for placement of the 1st, 2nd and 3rd place teams, there are still 4 Excellence awards to be presented to the games which deserve it the most. Categories for these are Best Graphics, Best Music & Sound, Most Innovative and the Jan Horn Award for most promising newcomer.

I love these events and I'm sure you will enjoy it too, if for nothing else just to play some fun games made by the top Pascal developers. ;)

Pascal Gamer Magazine - Issue 1

Issue 1 of Pascal Gamer magazine is finally published!

The first feature is an interview with Sascha Willems and a very visual preview of his latest game, Projekt W. Also in the first issue is Allegro.pas, Delphi Live! 2009 coverage, commercial game development with Frank van Gent, game reviews and more.

Get it at www.pascalgamer.com!

Tuesday, March 17, 2009

'Pascal Gamer' Concept Cover

Well after seeing that there had been very little exposure of Pascal-based projects since PGD had it's major upgrade, I decided to take up the magazine project that had been started under the name 'Delphi Gamer' a while back. I'm asking for content from those that can write something about game development, their own experiences or projects or tricks and tips for graphics, audio or library specific topics.

The cover you see to the right is only a concept and will most likely drastically change by the time the issue is out. Please tell me what you think. Any ideas about content or the magazine it's self are most welcome.



You can read the PGD forum thread about the new online magazine here: http://www.pascalgamedevelopment.com/forum/index.php?topic=5670.0

Sunday, March 15, 2009

I made Water!

I've been pondering making some actual 3D water effect for my latest project, Garland's Quest for quite some time now. Well I've finally gotten around to doing it. Actually this is my first actual 3D program so yay for me! :)



I have used 2 layers; 1st is an animation using Caustics lighting, the 2nd layer goes on top and uses a static texture that is instead drawn on a wavy sinusoidal shaped plane consisting of a 40 x 40 grid. (3200 triangles) I gave the 2nd layer a transparency of 40%. Looks much nicer in motion than as a still image, but the above image is the best I could do on short notice.


Caustics Generator:

Free Caustics Generator program


Water Demo:

Download (1 MB)

Wednesday, March 11, 2009

Canceled Projects: Cyber-Crisis

This was my first crack at doing a 2D platformer. I had a gritty back story and whole plot line planned out for it. Unfortunately it fell prey to a common mistake I made in all my earlier projects, it was a content nightmare!

Yes, what you see is great and amazing looking, but that just doesn't do it when you cannot pay for or do the amount of graphical work required that goes with this type of game.

The graphics that I'm showing off here are from that of Keirren Small, a very talented fellow who also worked with me on one of my current projects, Garland's Quest. Together we designed the main character's look based off some random artwork that I gathered to generate ideas and tell my story. He did an amazing job and this game would have been quite the eye candy if we had the time and money to complete it. Unfortunately only these concept images and the start of a platform engine remain.


Brief Synopsis

You are a prototype robot based on revolutionary new technology developed by a brilliant scientist who had intended to use it for good and honourable purposes.

However as fate would have it, the good doctor was hunted down, killed and his research stolen by a militant organization ran by a power-hungry madman. Fortunately for you, and for all that is decent still, the good doctor found out of those wanting his demise and put in place emergency measures to be carried out in case of such an even.

In the evacuation however, the escaping convoy carrying his prototype work was attacked and was assumed lost.

60 years later, you wake up to find a darker world that awaits you.


Concept Imagery





Game Engine Source

Download (1.4 MB)

Feel free to download and make use of my source. Please credit me if you do! It is written in Object Pascal. You'll need to get Lazarus and JEDI-SDL to compile it. Uses OpenGL for graphics and SDL for the rest. Enjoy!


More About the Project

I had posted quite a bit on my plans throughout the making of the project. Feel free to have a look to see how my creative process was working for me back then.

My old post on PGD

Monday, March 9, 2009

Artillery Game Tutorial: Part 2 - The Dirt

Introduction

Hey guys, now that the intro and all the dull stuff is over with, we can get right into the goods! Playing in the dirt. :D

In this first lesson I'm going to show you how to generate a nice random 2D battle ground for your tanks to kill each other in. You'll be able to then display it on top of your sky background that will either be a single color or the nice bitmap I've included or one of your own making.

OK enough with the explanations, lets get right into the code!


Some More Files

OK, I know that I've already given you some files to start with in the intro, but these ones will be the beef of our game code now. Here is what they are for;

GameConstantsUnit.pas -- All the default settings for our game.
GameObjectUnit.pas -- Houses all our game objects. As I mentioned before in the intro we'll be using OOP.




Game Constants

Lets get this one out of the way shall we? I'll be supplying this file at the end of this tutorial, but if you wish you make simply copy and paste the following code into the file named GameConstantsUnit.pas.

unit GameConstantsUnit;

interface

const
  LandSmoothing  = 50;
  LandVariation  = 60;
  LandHighest    = 500;
  LandLowest     = 1;

implementation

end.


I will explain these values later on as they are needed.


TBattlefield Object

This is our battlefield object which we will make generate our dirt.

type
  TBattlefield = class(TObject)
    Width, Height: Integer;
    LandHeight: Array[0 .. 1024] of Integer;
    LandColor, SkyColor: Cardinal;

    isBGImage: Boolean;
    Background: PSDL_Surface; // Background Graphic

    constructor Init(ScreenWidth, ScreenHeight: Integer; Land, Sky: Cardinal; useBGImage: Boolean; BGImageFile: String);
    procedure GenerateLand(Highest, Lowest, Variation: Integer);
    procedure SmoothenLand(SmoothSize: Integer); // Tries to smoothen rough generated land!
    procedure DrawSky(GameScreen: PSDL_Surface);
    procedure DrawLand(GameScreen: PSDL_Surface);
  end;


Init() will create the battlefield object!
GenerateLand() will do the initial generation of the shape of the land.
SmoothenLand() will help make the land more usable in the game.
DrawSky() will draw our sky background.
DrawLand() will draw the land we generate.


Initializing The Battlefield

I don't see a need to go into great depth here so here is the function straight out.

constructor TBattlefield.Init(ScreenWidth, ScreenHeight: Integer; Land, Sky: Cardinal; useBGImage: Boolean; BGImageFile: String);
begin
     Width := ScreenWidth;
     Height := ScreenHeight;

     LandColor  := Land;
     SkyColor   := Sky;
     isBGImage := useBGImage;

     // Load Background
     if (useBGImage) then
        Background := LoadImage('images\\' + BGImageFile, False);
end;


ScreenWidth & ScreenHeight are the dimensions of the game screen you'll be using.
Land & Sky are the colors of the land and sky.
useBGImage is the switch for using a bitmap instead of a solid single color for the sky background.
BGImageFile is the filename within the images directory of the bitmap to load into the Background surface.


Initial Generation

To generate our land we're going to go through it in a couple of passes. Once to get the general shape and then again afterward to make it a little more practical for the game's use. But for now lets look at how we'll get the basic 'shape' of the land we want.

GenerateLand() uses 2 values to keep the surface of the dirt with a high and a low range. There are Highest and Lowest.

Have a look at this example to see what effect this has...



Notice how the peeks will never go above the Highest value and the valleys will never go below the Lowest value?


Now we have to figure out the rate of which we the land will vary as we go along the surface. We could simply use a random value between Lowest and Highest but that wouldn't produce a very nice shape for our land.

Instead what we'll do is have a Variation value that will govern the change in the heights of each segment of land from left to right. Each segment will be 1 pixel wide for the most precise effect!

Here's our function...

procedure TBattlefield.GenerateLand(Highest, Lowest, Variation: Integer);
var i: Integer;
    rand: Real;
begin
end;


So lets go from left to right as this is most logical way. We should start with a totally random value between the Lowest and Highest as a starting height to work from.

     LandHeight[0] := Lowest + Round(Random * (Highest - Lowest));


Of course we will want the land to randomly go higher and lower so we'll allow the new height of each segment to either go up or down within the range of Variation.

     for i := 1 to Width - 1 do
     begin
          repeat
            rand := Random;
            LandHeight[i] := Round(LandHeight[i - 1] + (rand * Variation) - Variation / 2);
            if (LandHeight[i] < Lowest) then
               LandHeight[i] := Lowest;
          until (LandHeight[i] <= Highest);
     end;


Here you see we cycle through each segment along the x-axis and calculate a height for the land based on the previous calculated height.

If the land travels higher than the Highest range, it will recalculate another random height until it fits under the required range. Also when a height value is created lower than Lowest it will, instead of recalculating the height, level the height to the Lowest value.

Both high and low values are treated this way to simulate peeks and valleys in a more realistic way.

Our completed function should look like this...

procedure TBattlefield.GenerateLand(Highest, Lowest, Variation: Integer);
var i: Integer;
    rand: Real;
begin
     LandHeight[0] := Lowest + Round(Random * (Highest - Lowest));
     for i := 1 to Width - 1 do
     begin
          repeat
            rand := Random;
            LandHeight[i] := Round(LandHeight[i - 1] + (rand * Variation) - Variation / 2);
            if (LandHeight[i] < Lowest) then
               LandHeight[i] := Lowest;
          until (LandHeight[i] <= Highest);
     end;
end;



Smoothen Out The Land

So now we have our land, but it's very jagged, ugly and unusable. Worry not! This can be done quite easily with a 2nd pass on the land height values. :)

The technique that I will be using to create more usable land will involve passing through a set of the initial generated land. It'll take a number of segment values from the left and right sides of the current segment and calculate an average which it will be changed to. The value SmoothSize will determine the amount of samples on each side.

You will also notice that we must stay within the bounds of the screen so we will be checking that the code that gathers the average from other segments does not drift off the screen.

This will be our function to do this...

procedure TBattlefield.SmoothenLand(SmoothSize: Integer);
var i, j: Integer;
    Mass, NumOfMassSamples: Integer;
begin
     for i := 0 to Width - 1 do
     begin
          // Get average height of selected area...
          Mass := 0;
          NumOfMassSamples := 0;
          for j := i - SmoothSize to i + SmoothSize do
              if (j > 0) and (j < Width - 1) then // Samples must be in bounds!
              begin
                   inc(NumOfMassSamples);
                   Mass := Mass + LandHeight[j];
              end;

          // Resize LandHeight element
          LandHeight[i] := Round(Mass / NumOfMassSamples);
     end;
end;


Mass is the total added height of all of the segments within the SmoothSize area including it's own height.
NumOfMassSamples is the count of how many actual samples were taken regardless of the value feed into SmoothSize.

This should give you a relatively nicer result and land that you can actually use to place tanks on and have them accurately aim and fire at each other.


Drawing It

Ok so now that we've got our nice land generating functions, I'm sure that you'll want to actually see it in action. So here is our drawing code...

procedure TBattlefield.DrawLand(GameScreen: PSDL_Surface);
var
  i: Integer;
begin
     // Land
     for i := 0 to Width - 1 do
         SDL_DrawLine(GameScreen, i, Height - 1, i, Height - 1 - LandHeight[i], LandColor);
end;


NOTE: It makes use of the sdlutils unit so make sure that it's included in the uses path of GameObjectUnit.pas

Pretty simple huh? :)

The DrawSky function is rather simple too. It will either draw a solid sky color or a stored bitmap surface.

procedure TBattlefield.DrawSky(GameScreen: PSDL_Surface);
begin
     if (isBGImage) then
         DrawBackgound(GameScreen, Background)
     else
         SDL_FillRect(GameScreen, PSDLRect(0, 0, 800, 600), SkyColor);
end;



Putting It All Together

Now we'll create our battlefield object, run the land generator and draw everything to the screen.

In scorch2d.lpr add the following under var at the top of the code...

  // Level Data
  Level: TBattlefield;


While there, also remove the following line of code...

Background: PSDL_Surface; // Background Graphic


It will be replaced by TBattlefield.Background and is no longer needed for testing.

Find the ProgramCreate; procedure and remove the 2 following lines of code.

     // Load Background
     Background := LoadImage('images\\DesertEclipse.bmp', False);


Go down to the main code block and add the following code after ProgramCreate;...

     Level := TBattlefield.Init(GameScreen.w, GameScreen.h, $229900, $0000ee, True, 'DesertEclipse.bmp');
     Level.GenerateLand(LandHighest, LandLowest, LandVariation);
     Level.SmoothenLand(LandSmoothing);


Now the only thing left to do is add the code to draw the sky background and generated land. Find DrawScreen; and add this as the top 2 lines...

     Level.DrawSky(GameScreen);
     Level.DrawLand(GameScreen);


That should do it. Considering you pieced TBattlefield together properly you should be able to press F9 to compile and run the code. Remember that it's the Esc key to quit!


The Source

Here is the complete updated source that shows how it's all done together.

Download the source files here!


End of Part 2

So now we have our randomly generated dirt to place tanks on and plow shells into. In the next part I'll be showing you how to place our tanks randomly about the land we've generated and do so in a smart manner.

Until then, play with the code a little bit and see what else you can do with it. There is lots of room for innovation here.

Suggestions, helpful code snippets and kudos are welcome! :)