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:
Creating robots
The game loop (moving robots, counting points, gathering pressed keys…)
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 )
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