[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
EDP-Pascal
This is basically what my formula for making a game is:
  1. Have an Idea (duh!)
  2. Work out how you want to implement it
  3. Create your "Game Engine" (See below)
  4. Create the graphics to fit into your games
  5. Gogogogogogogogo
  6. Woops I found a bug...
  7. Finally, it is complete.
The basic game engine needs to be able to take input and continually update what is going on in the game. We did this by using a repeat loop. (Well, this is functionally the same as how Event Driven Programing works! We keep checking for any form of user input, and then respond to it. EDP allows the user to have a choice to do more then one thing at a time. Our loop allows the user to do so as well.)

Let me show you how we would go about making a "Game Engine". What I mean by a game engine is the internal working of the game. This is how we do it:
  • We define our types
  • We make procedures that can deal with those types
  • We allow those types to deal with each other (The snake collides with the wall)
  • We allow the user to deal with those types (Input)
According to this definition, the game engine for a text driven graphical interface will be very similar to the game engine for a pixel based graphical engine differing only in their drawing routines. Both the Snake in our text based Snake game and the Ball in our graphical based Arkanoid game, were sprites. They stored their own location and all the info needed for them to be drawn. The games were otherwise the same - We had to check the snake for collisions with itself and walls and we had to check the ball with collisions with the bricks and the "Cursor". All this said, I can tell you that this is the essence of the concept of event driven programming: Do whatever is needed to be done behind the scenes, all the while waiting for the user to press a key or move/click the mouse. Therefore, I say, EDP is the driving force behind game programming in pascal. Although pascal is essentially a sequential language, you can add the same [i]functionality[/i] of EDP as Delphi has by using a loop. (I made a program that had a mouse, buttons, textboxes and checkboxes all using pascal and Asphixias graphics library.)

Notes about specific game types:

I'd suggest that you read denthors pascal graphics tutorials in order that you can make nice games with good graphics. Things like page flipping and so on are important in order to get smooth graphics in your games.

Point and click, Adventure games:

The trick to making adventure games (with regard to programming) is that every screen is an entity unto itself. Therefore, create a type called "Screen" and add things like
    • "name" - The name of the file containing the graphical image for the file.
    • "hotspots" - An array of locations that when clicked on will call a procedure that knows how to deal with that specific location in that area. so that if the mouse was clicked, the program will call a procedure that will, for example, pick up the thing clicked on.
    • "Exit points" - Similar to "hotspots", but this contains what will happen if a person clicks on a door - what screen will now appear...
What you will do, is save all your screens into a file and as the user flits between one screen and the next, load up the next screen from the file. This gets around the big problem of pascals/DOSes memory limitations. Another type that will probably be needed is to make the player. It will contain things like "current image" (For animating - you need to quickly switch between pictures) and an array that holds the current inventory and one that has some info about what has been done... At the end of this article is a link to a program that I made that incorporates the screens idea.

Action Games

These games come in many forms, but they generally follow the Arkanoid and snake approach. Have a delay and update the playing screen. If the user pressed something, like and arrow key, change the direction of the in-game object. Racing games and flight sims fall under this category (Although the graphics can be complicated...).

Role playing game

This kind of game usually has a "MDI" (Multiple Document Interface). You will have the screen on the side showing the characters current stats and a screen showing the map and a screen showing what is directly in front of the player. These kind of games are usually tile based (the player might not see this, but in memory they save the map as an array of segments with data for each tile. (At least for most games)). What you could do is create an array of Char the size of the map. Then make yourself a "Key" that says what each letter stands for and then you can create your maps in a text file and draw your map based on it (Each character can represent a few features stuck together.). Or, you can make your array based on a more complicated type (which contains the full information of each tile), but that means that you are going to have to write a program to create your own maps. Then you should make your database of monsters and work out how you are going to implement the usual "RPG" style fighting. Is your RPG going to be a first person shooter or Dungeon hack or is it going to be something like Mordor?

To conclude

All the concepts I have mentioned above can be and are applied to games written in all languages. In "Visual languages" like Visual Basic or Delphi, we don't need to add our own repeat loop, just use a timer and overload the on paint command. And just to remain true to my header I must answer the question: "Who needs Delphi?". What is Delphi? it is "Pascal for Windows". Windows is an event driven operating system. Events caused by mouse clicks - not only by keyboard (well, maybe also by timers, but that is beyond the scope of this article.). Based on what I have said, we can create a more true to DOS version of event driven programming - just code in that main loop and you are there!!!

I presented code for Arkanoid as a supplement to one of my previous articles. But over there I only presented the basic code for the game. Here is a more complete version that includes more advanced concepts such as fonts and mouse use which were discussed previously. Here you can find a word search maker program made in pascal, using many of the things which I mentioned above. It is a good example of what I mean when I say that you can implement EDP in Pascal.

Thanks for reading and enjoy your game programming.

Relman

last edited (September 28, 2005) by Relman, Number of views: 5754, Current Rev: 6 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.