Friday, 16 April 2010

HOW TO make a little computer game.

The easiest way to make a little computer game.

Hi! Today I'd like to tell you how to create a little text's game on computer. You will impress all your friends or make you call "a geek".

So, to do that you just need one software that every windows' users have: blocnote. Personnaly, I use Notepad++ to edit my software.

I. What's the programmation?

The programmation is the way to create video games. All right, you don't gon na make a 3D's game like GTA with this tutorial, but you'll learn the basis.
To programm, you (just?) have think. You have just to write "if something then something".
To help you, there are "the variables". That's can be a number, a string, or a function.

Then, you have to write "if variable == 1 then something happen".

With the programming language we gonna learn, you'll just be able to write somme texts or do to some basics things.
We'll learn how to ask the user something and put his answer on a sentence.

II. Let' dev' !
Open blocnote (or another text's editor).

1. Prepare your source code

.At the first line you'll have to write:

@ echo off

If don't put this line, windows will print the path to your directory at each line.

Without @ echo off

With @ echo off

.If you don't close your code, your soft will close immediatly. The most use way to resolve this is to put "pause" at the end. You'll have an annoying text:

Don't worry! I've a solution! Just write "set /p =" instead "pause ". I'll explain you later what is it.

.To make your game working you have to save it at "mygame.txt". Rename the extension in .bat instead .txt and double-click...
Your source code is ready!

2. Print a text
We can begin to do a game. Indeed, just to print a text. The function to print a text is "echo yourtext".
Let see the source code:

@ echo off

echo Hi everybody!
set /p =

and the result:

Wahou! Unbelievable!

3. Ask the user something

. For the first time, we'll use the variable. To set a variable, you must writte "set".

If it's a number you'll write "set /a nameofthevariable="1" ".
If the variable is a string, just write "set nameofthevariable=Hi everybody".

But if you want to ask the user a variable use this: "set /p nameofthevariable=texttoprint"
To use this variable, write %nameofthevariable% .

Now, we'll write our soft. The aim is to ask the user his name and his age.

@ echo off
set /p name=Hi! What's your name?
echo %name%? What a beautiful name
set /p age=How old are you?
echo you've only %age% ! You are young
echo It's all for today! If you have more questions, don't hesitate to ask me.
set /p =Press a key to quit.

III. Conclusion

Hier is the *bat:

And... The game I've done (+ or -):

No comments:

Post a Comment