2015-04-22 13:18:50 (edited by Genroa 2015-04-24 00:34:35)

LEARNING [1] : Robot Factory


This topic is the first a list of topics, made to learn how to program games, from the simpliest to RPGs. This is made to help you understanding the conception, how to design programs and/or games. All topics will follow the same schema.
If you want to ask questions about how to do some parts of this program, ask them here.

This subjects isn't made to help you learning the basics of programing like loops and conditions!


Never forget to read programing explanations before thinking about the game!



The Game

Difficulty Level: 1
Name of the game: "Robots Factory"
Subject: You are a robot factory controller, managing the conveyor belt to detect which robot is faulty.  Choose which one should be destroyed.

Information about the program:

  • Robots are coming from left to right

  • The factory built 25 robots

  • When a robot is in the center, press left key to leave it, or right key to burn it

  • If you don’t do anything, the factory system will choose to destroy the robot to prevent any error

  • You win the game if all good robots are left intact and all faulty robots are burnt

  • You can detect if a robot is faulty by hearing what sound it does

  • When launching program, an info message box tells you how to play the game

Notions:

  • using array objects

  • understanding what a game loop is

  • constants



Some help:

Array object
Array object can be seen like a list of elements of the same kind (here a robot list). An object is a representation of something that could be a real object or an abstract thing. Robots are objects; everything you want to be able to control in your game should be seen as an object.
Objects have attributes and methods (also called functions). Attribute are values which have a name and a type: a Player object may have a “name” attribute which is a string, and an “age” attribute which is a number.
Methods are functions stored in the object, often doing things with it. See objects like black boxes, which give you method to communicate with them.
A class is a construction plan of an object, defining its attributes and methods: its structure.

The array object is quite complex inside, but are really simple to use. This object gives us methods to add objects in the list, remove objects from it, get objects anywhere we want and even know the array length.
The BGT documentation gives us all the information we want to use.

Here, the array will represent our conveyor belt with robots in it!


Constants
Constants are constant values which represents important things of your program. They are used to make the code easier to read.



Game loop
Games are like any other program: they are made of an instruction list. To understand what a game loop is, you have to see the game like a scene, with objects in it. These objects are moving and interacting together. A game is simply a succession of instants: and from an instant to another, the game calculates interactions and moves between the two instants, and then shows you the new situation, the new scene.
The game loop is exactly this part of the game: this is the loop which gathers player commands and calculates the new situation of the scene. A game is only that: a loop which calculates the progression in time of the game. A game is always composed of a game loop. This is where the game is really running.



Some help about the program
The Robot Factory is basically composed of three parts:

  1. Creating robots

  2. The game loop (moving robots, counting points, gathering pressed keys…)

  3. Printing the score, telling if the player won or not


Ideas to improve your game if made it:

  • Easy: let the player choosing difficulty before beginning the game loop. The difficulty will make the robots moving faster

  • Medium: authorize errors. The number of possible errors before losing should change depending on the difficulty

  • Hard: make a level system! ( you may need to follow other parts of these topics before doing this  wink )


EDIT : people asked me to make the demo using the heat engine. Here's the link of a simple demo: https://www.dropbox.com/s/l6fwnybekhqhd … o.rar?dl=0

2015-04-23 05:17:14

Can you help us make this game with your BGT game engine?

2015-04-23 11:53:42

Yeah sure smile but it will obviously not look like all the explanations given here smile

I'll post it here

2015-04-23 12:55:00

Hi, how is your bgt base going?

I post sounds I record to freesound. Click here to visit my freesound page
I usually post game recordings to anyaudio. Click here to visit my anyaudio page

2015-04-23 13:00:38 (edited by Genroa 2015-04-23 16:23:42)

I have been stuck by the FMODEx wrapper, trying to give real 3D positionning to BGT, but for now it's a failure. I did a weapon system some weeks ago, without the bullets part.

I will post the demo of this "subject" here, made in one afternoon from scratch with my engine. The files will be quite complex but when you understood how it's working, it's really powerful. smile

The main reason of why i abandoned the wrapper for now is that it was randomly crashing the game when exiting, it was randomly crashing when loading sounds, and the bgt compiler couldn't compile the game (crashing, again).

EDIT: found a bug in BGT, solved the problem. I can now work on this very little demo

2015-04-23 20:24:40 (edited by Genroa 2015-04-24 00:34:02)

And here is the Robots Factory demo using the Heat Engine!

https://www.dropbox.com/s/l6fwnybekhqhd … o.rar?dl=0

Ugly sounds but it's a demo smile

The game only have one very simple level, but it is really easy to make new ones and to make a menu to choose!

2015-04-23 20:41:30

Hi,
I'll check this out as soon as I get home I'm on a school computer right now lol. I'm not sure how the heat engine works so tis will be good for me to learn basic games with it.

2015-04-23 20:50:12 (edited by Genroa 2015-04-24 00:33:42)

It may seem complicated, but you have to know that a lot of the files of the engine aren't used. Because this game doesn't use any weapons, for example. In fact, only a few files are used and I only created 4 files. All the other are the engine have not been touched. smile

EDIT : I changed the link of the demo game, with a correction : the game would not stop if the last robot of the serie was destroyed and not saved.

EDIT : Changed the file again, now saving and loading work correctly. Press S while in game to save the exact state. Then launch the game again, and the save will be loaded. If you take a look at the controler, you will notice that it takes 1 line to save the entire game, and 1 line to load the whole save file.

2015-04-26 14:32:07

So, what do you think of this demo?

2015-04-26 15:06:14

I have been looking at the demo and it seems very interesting. I am looking forward to creating one of my games using your engine smile

ReferenceError: Signature is not defined.