Beginners Tutorial 2 learn how to declare a variable

Learn how to make certain types of games and use gameEditor.

Beginners Tutorial 2 learn how to declare a variable

Postby krenisis » Mon Jun 28, 2010 5:08 am

Welcome I know many of you have seen wierd looking codes like this
if(jump==1)

yvelocity=-10;
jump=0;

And you wondered , where is that jump in the variables/functions list? Why is it not working in my game , but it works in the demo.
Now I will explain step by step in full detail how to declare a variable ,so you can use it in your game.

Go to the top of your screen where it has a tab called script.Click on that tab and a big menu will open up.
The menu will say Global code.
Ok now type this in the menu jump;
Now on the lower part of the menu it has the word name and next to it a space ... in the space next to name type move.
Now there is a tab under that, that says variables. Click on that and a small window opens up // click add and a smaller windows opens up put this
name: jump
array dont put anything
save group: move
Click add and close the small window....now where it says add next to where you type the word move click on the add and the words dissapear.
Now click close and save your game.
The process you just did is called declaring a variable.
If you have any questions just ask
krenisis
 
Posts: 606
Joined: Sat Jul 25, 2009 3:27 pm
Score: 51 Give a positive score

Re: Beginners Tutorial 2 learn how to declare a variable

Postby Bee-Ant » Mon Jun 28, 2010 2:09 pm

For local variable like that you don't need to save it into any group...
Just let it blank...
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Beginners Tutorial 2 learn how to declare a variable

Postby krenisis » Mon Jun 28, 2010 2:42 pm

Bee-Ant wrote:For local variable like that you don't need to save it into any group...
Just let it blank...


Ok bee-ant
1) If they learn how to save/load then they have to do it this way in the future so its better they do it now.
2) Please dont confuse beginners , they dont know what local variable is. This is the best way for them, thanks.
Tutorial Database for all beginners click this link
viewtopic.php?f=4&t=8680
krenisis
 
Posts: 606
Joined: Sat Jul 25, 2009 3:27 pm
Score: 51 Give a positive score

Re: Beginners Tutorial 2 learn how to declare a variable

Postby Bee-Ant » Mon Jun 28, 2010 3:43 pm

That's why...should you really need to save "jump" variable ???
I think not...better you save "health", "live", "locationX', "locationY", etc...
And since this topic teach about variables, I think newbies should know the difference between global and local/actor variable as soon as possible...
Don't let them make the wrong concept over them :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Beginners Tutorial 2 learn how to declare a variable

Postby krenisis » Mon Jun 28, 2010 4:19 pm

Yes I do think newbies should learn global and local. I see we come from 2 ways of thinking. After looking over post the last 2 months , I planned how I would write a tutorial.
From what questions I have seen raised and answered , determined which style I write in. I noticed if you tell a person who is just starting out , ok here is how you do it and give them different senarios , they will be confused. If I tell a new person who never coded before of this is local variable which will be specific actor based and this is global which can be used universally and then jump into more details, they think Game Editor
is hard to use. Add the tutorial to that and the person will quit.
So many people asked how to declare a variable, I decided it would be best just to answer that specific question. That way they can jump right into making the game, rather than stressing is this local or global? Your right and Iam right , we just have different styles, which make us unique .
krenisis
 
Posts: 606
Joined: Sat Jul 25, 2009 3:27 pm
Score: 51 Give a positive score

Re: Beginners Tutorial 2 learn how to declare a variable

Postby JUNIORGAMER » Wed Dec 01, 2010 8:59 pm

Thanks for the tutorial. Bee-Ant if you want users to learn your way then make your own tutorial. I'm really starting not to like you. :x
RCM Productions
JUNIORGAMER
 
Posts: 30
Joined: Tue Oct 12, 2010 9:09 pm
Location: World 1-1
Score: 3 Give a positive score

Re: Beginners Tutorial 2 learn how to declare a variable

Postby Bee-Ant » Wed Dec 01, 2010 10:19 pm

JUNIORGAMER wrote:I'm really starting not to like you. :x

That's your problem. I'm okay :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Beginners Tutorial 2 learn how to declare a variable

Postby lcl » Wed Dec 01, 2010 11:00 pm

Bee-Ant wrote:
JUNIORGAMER wrote:I'm really starting not to like you. :x

That's your problem. I'm okay :D

:lol: :lol: :lol:
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Beginners Tutorial 2 learn how to declare a variable

Postby NightOfHorror » Thu Dec 30, 2010 9:38 pm

lcl wrote:
Bee-Ant wrote:
JUNIORGAMER wrote:I'm really starting not to like you. :x

That's your problem. I'm okay :D

:lol: :lol: :lol:

Reading that made my day.
viewtopic.php?f=2&t=12136
"I have not failed. I just found 10,000 ways that wont work." quoted by Thomas Edison.
Over the year, I decided my motto for me is I am knowledgeable, but not practical.
User avatar
NightOfHorror
 
Posts: 1823
Joined: Fri Aug 27, 2010 2:50 am
Location: Cedar Hill, MO, of the USA
Score: 51 Give a positive score

Re: Beginners Tutorial 2 learn how to declare a variable

Postby TGKG » Sat Dec 24, 2011 3:40 pm

Hello guys,
Nice topic "Declaring variables"
Question:
I did not understand the following statement right at the very beginning "Ok now type this in the menu jump;"
How can I type "Jump;" in the menu??? I think what you meant to say is type "jump;" (without the quotes) in the large Global code editor window that appears. Is that correct?

Next question:
I understand that this is a simple example, however Please explain the purpose of the name "move".
If I understand correctly, to create a global variable or variables I have to create a name for that global code. In your case you wrote the code "jump;" and saved it with the name "move".
Do I use the name "move" anywhere in my program/script or do I just use the global variables?

My guess is that the name "move" is not used and that assigning a name to my global code allows me to write a variety of global code and organize it using names like "move"?

Thank you
TGKG
 
Posts: 23
Joined: Tue Nov 15, 2011 3:20 am
Score: 0 Give a positive score

Re: Beginners Tutorial 2 learn how to declare a variable

Postby skydereign » Sat Dec 24, 2011 7:38 pm

Yeah, this tutorial isn't the clearest it can be. In fact it does things that don't really make sense (the move referenced is for a savegroup [but who would save if you can jump or not?]). Here are the two ways to declare global variables. The first being adding code to the global code space. To get to the global code space, click [Global code] from either the script editor, or just the menu bar. Then type in this code.
Global Code
Code: Select all
int jump;

When you type the above code, you need to add a name to the script (via the name region) and then click [Add]. When that succeeds you will have a variable named jump.

The other way is to go to the script editor, and click the [Variables] button then [Add]. A window named "Add New Variable" should pop up. Type in the name of the variable you want (in your case jump). You can leave the rest as it is, since all you want is a global integer that you don't want to save. Lastly click [Add] then [Close].
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest