Variable Sizes and Global Code

Game Editor comments and discussion.

Variable Sizes and Global Code

Postby darokstar » Sun Jun 15, 2008 6:49 am

Hello everypeoples :D I was wondering 3 things
1. How do you use global code?
2. How do you use variable sizes?
3. PIE!!! :D
I may be an idiot but that doesnt mean im dumb
darokstar
 
Posts: 13
Joined: Sat Jun 07, 2008 5:51 am
Score: 0 Give a positive score

Re: Variable Sizes and Global Code

Postby Thanx » Mon Jun 23, 2008 8:28 am

Here:
I'm not sure what you mean by variable sizes, if you could give me one more detail about that, I think I can help you in that too.
About Global code: This is space for code, that you can use, if e.g. Let's say you have some loooong code to write in an actor's some event, and you plan to use then same loooong code in some other places. Now I expect you don't want to write down, or even copy-paste that code so many times, we humans just don't like that.
So you open Global code, and write the code there, in a function, give the code-snipet a name, and now you can use that function in the actor events, just by typing 10 characters!

If you'd happen not to know what a function is: it has a name, with which they call (use) it. It might need parameters, and it might return values.
e.g. the rand function
you call it with e.g. rand(100). 100 is a parameter, and the return value will be a random number between 0 and 100.
That's about it, and of course
darokstar wrote:3. PIE!!! :D
http://www.youtube.com/watch?v=XyXexDJBv58
http://www.youtube.com/watch?v=Be4__gww1xQ
These are me and playing the piano (second one with a friend/fellow student)
Hope you watch and enjoy!
User avatar
Thanx
 
Posts: 314
Joined: Sat Jan 26, 2008 10:07 pm
Location: Home sweet home! :)
Score: 24 Give a positive score

Re: Variable Sizes and Global Code

Postby darokstar » Wed Jun 25, 2008 9:08 am

You know when you create a new variable then you switch array to Yes and then you type in a size thats what I meant by variable sizes and by the way I understand what global code does I just dont get how to use it :( ... SMILEYS!!! :D :) :? :( :x
I may be an idiot but that doesnt mean im dumb
darokstar
 
Posts: 13
Joined: Sat Jun 07, 2008 5:51 am
Score: 0 Give a positive score

Re: Variable Sizes and Global Code

Postby Thanx » Wed Jun 25, 2008 11:28 am

k, sorry, answering your signature: understood, you're not dumb, only an idiot! :D cheers!
Back to global codes:
If you declare a function, variable, struct, or anything else in Global code, it's as though the variable were among the GE created variables, functions etc. Therefore you can use them where-ever in code, as all otherthings, without needing to declare any other things!

Variable sizes:
Those are what are called arrays;
Arrays are like a bucket of variables you pick up from the ground and belong together for some reason. The size is the number telling GE how many variables you picked up.
Example: Let's say you were to create a hightmap for a board in GE, for whatever reason.
You create a variable called hights (or whatever) and then let's say you give it a size: say 9, which would be for like a 3x3 board, ut can be anything.
That is like crating 9 variables:
Here's the trick:
you've now created hights[0], heights[1], heights[2], etc.... heights[8]. No heights[9], cause we started from 0!!! Watch out for that.
Each has it's OWN value, which doesn't effect the other values in the array!
That's the basics to it, but you can really mess around with them, and get many aches and pains in the process...
btw: Variable sizes actually in programming means something quite different, so it's unluck to ask that from a programmer, he might not think of arrays.
Cheers, hope I helped now! :) :D :wink:
http://www.youtube.com/watch?v=XyXexDJBv58
http://www.youtube.com/watch?v=Be4__gww1xQ
These are me and playing the piano (second one with a friend/fellow student)
Hope you watch and enjoy!
User avatar
Thanx
 
Posts: 314
Joined: Sat Jan 26, 2008 10:07 pm
Location: Home sweet home! :)
Score: 24 Give a positive score

Re: Variable Sizes and Global Code

Postby DST » Wed Jun 25, 2008 2:02 pm

About arrays:

Two great uses for arrays are instances where we have a lot of data to save and we don't want to make 50 separate variables. We can also use it to automate numbers for us, like in the following example.

In a bowling game, the pins have a position, and each turn, they need to return to their original positions. Now I might change the screen setup over time, and move the pins in editor mode, so instead of using a specific xy, I just make two arrays in global script:
pinx[10];
piny[10];

Then on pin>createactor
pinx[cloneindex]=x;
piny[cloneindex]=y;

and then, when they're all knocked down, i reset their animations and say:
x=pinx[cloneindex];
y=piny[cloneindex];

And i don't have to worry about their xy's at all. The array takes care of it for me.

Another is a strategy game where you might have 20 or 40 types of units; and each one has a maxarmor, maxhealth, maxattack, etc. We don't want 300 variables, its clunky and wasteful, so we make an array;

maxarmor[40];
maxhealth[40];
maxdamage[40];

And each unit has a different position in the array, for example, villagers have maxhealth[0], warriors have maxhealth[1], etc. etc.

We can convert that to an actor variable for the fighting, as in warrior>createactor:
health=maxhealth[1];

and now the warrior has a health variable to fight with.

Advantages here:
-reduces the number of variables we need
-since its a global set of variables, we can save them!
-we can put as many players as we want, as in
maxhealth[160]; now has enough slots for 4 players to have up to 40 unit types each, with separate values for each (as player1 might upgrade his warriors before player2).
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Variable Sizes and Global Code

Postby darokstar » Thu Jun 26, 2008 7:19 am

Tanks and no I dont mean thanks I MEAN TANKS! Tanks :D
Oh fine thanks :x
I may be an idiot but that doesnt mean im dumb
darokstar
 
Posts: 13
Joined: Sat Jun 07, 2008 5:51 am
Score: 0 Give a positive score

Re: Variable Sizes and Global Code

Postby DST » Thu Jun 26, 2008 7:57 am

Love the ads for Squareland Wars 2!
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Variable Sizes and Global Code

Postby Thanx » Thu Jun 26, 2008 10:32 am

Thanx DST! :D I'm trying to finish it before my next camp... So it's comming soon!
I'm pretty sure the game will meet the quality of the ads! :D :mrgreen:
http://www.youtube.com/watch?v=XyXexDJBv58
http://www.youtube.com/watch?v=Be4__gww1xQ
These are me and playing the piano (second one with a friend/fellow student)
Hope you watch and enjoy!
User avatar
Thanx
 
Posts: 314
Joined: Sat Jan 26, 2008 10:07 pm
Location: Home sweet home! :)
Score: 24 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron