Thoughts about data control

You must understand the Game Editor concepts, before post here.

Re: Thoughts about data control

Postby DST » Sun May 30, 2010 6:10 am

(Edit: If you missed it, read the last post on the previous page)
Tell your variables to go home.

When you have many events in your script, it is best to send them all home whenever possible. That is, try to keep them all in the same place.

Every time you use an event, you put a piece of code inside a menu somewhere. And every time you wish to access/modify that code, you have to go find it.

It's better to build one house and have as many events living there as the house can hold. Upgrade it to an apartment building by using case switches.

Many of you have already found, that if you have a keydown>left>
xvelocity=-2;
and you do this for each key, then decide that you want the player to go faster than 2, you have to go back through EACH EVENT and change them to 3. Then what happens when you decide 3 is also to slow, and you go to change it to 4?

There are two solutions to this: One is to use a global variable 'speed', and just put that in each key event. You can then change speed and all of them are changed.

But what happens if your actor gets in an elevator, and can now only move up and down? How do you disable the keydown events for only left and right?


What's best is either to use a getkeystate() inside draw actor, or a simple variable 'dir' to hold the last arrowkey pressed in keydown. Then, you have access to all the variables from all the keydown events in one spot, in your draw actor.

You can then easily disable the left and right dirs while still allowing up and down in the elevator.


Now i don't mean to imply that the builtin ge events are not useful; quite the contrary. See, GE was built on this premise:

You can make games without any programming knowledge, or if you do have programming knowledge, you can use that too. The choice is yours. Now if you want a house, you can either buy one or build one.

If you build one, you can make it whatever you like it to be; but if you buy one, you get it how it already is. What this means in making games is, if you do not wish to learn to program, you can still make simple games, or you can buy a game from someone else. But if you want to design your own custom game of any complexity, you are going to have to learn to build it yourself.

I use mousebuttondown> events all the time, for all sorts of things. But at the same time, i control them heavily through scripting as well. If you simply click on the title screen to start the game, then click on buttons in game, you either have to disable the titlescreen>mousebuttondown event, or you have to destroy/move/move away from the title screen after clicking. And you can simply start a timer on titlescreen click and then destroy it without having any scripting knowledge whatsoever.

But if you want menus and difficulty settings and sound/graphic options screens, then you are going to have to learn to program.

People complained that you couldn't easily make a pause menu in ge, because PauseGameOn(); stops all events. But ask yourself, how does GE know which events to stop and which ones not to? Well, you gotta tell it!!! Some might suggest it should have a built-in pause menu option that operates outside of the normal game, and many other things like it, such as a text handler for dialoge, or auto-health meters.

I can't speak for everyone, and different people work best with different toolsets, but i can tell you, even in programs i've tried that had these builtin options, i rarely used them, because i am always doing something slightly different than what the creators intended. You want auto-health meters? what about auto-mana meters? what about a million other meters i might add? how many should the game creation software allow for? Unlimited? Well, with a canvas actor and some script, you can make all the health meters you want in ge.

And since its scripted, if you have many meters, you can automate the capture of the variables and the display of the variables as well. If they were built in, you'd have to go thru each one as a menu item and assign it this or that; while in script, you can simply make a loop that designates the position, variable and color of each meter. You can create a keypad of buttons with 10 lines of code, or with 70 zillion menu clicks/mouse drags. One requires you to learn and plan; the other requires you to do the same repetitive motions over and over. But wait...isn't doing repetitive actions exactly what computers are for? Why do them yourself?

My point is, if you have so many of these items that you need separate handlers for them, then you won't be able to manage them via menu options in the first place. You need to script them. 200 Rollerskates != 1 car. Not by a long shot. (Athough i would like for Ge to have a built in dialogue engine :D )

Regarding a pause menu option, the way its done traditionally is to control the main draw routine; and only draw (but dont' calculate or run any other functions) when the pause ==1; However, that requires you to have a completely scripted draw routine for all objects and functions in the game. Which basically means scripting from scratch, and not using a game creator at all! If that's what you want to do, there are tons of languages and editors and compilers to handle that. The concept of GE, on the other hand, is to allow you to make games without scripting everything from scratch. I'd rather have a game with no pause menu than a bunch of script i'll never finish because it's too long and complicated.

We all want it to be simple, yet flexible and also powerful. Any software you use is always some combination of those attributes. One might liken choosing a creation software to choosing a character in an rpg. What do you want, fighter, mage, healer, rogue? What options do you need the most?

I'm not saying that GE is perfect by any means, and everything in existence can use improvement (except for certain games made by nintendo). I'm just saying there are two sides to every coin, and every upside has a downside and vice versa. No game creator works perfectly just out of the box. Professional companies don't just compile a game and it works fine on every system; no, they have to constantly test, revise, and upgrade their products. It's a lot of work.

What I am saying is that GE has lived up to it's promise: Make games with no programming knowledge. Just don't expect them to standout from the rest, unless you learn to script them yourself. And if, after learning, GE still doesn't do what you want it to do, then move on to something else. Just be willing to pay the price, to make the trade-offs.

There are no free lunches.

If you are reading this from the 'view new posts' option in the forum, try reading the last post on page 3 of this thread too. They were both posted minutes from each other, and i realize the previous post will now not show up in the new posts option, because it will go directly to this page instead.
Last edited by DST on Thu Jun 17, 2010 5:16 am, edited 1 time in total.
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: Thoughts about data control

Postby Fuzzy » Sat Jun 12, 2010 1:58 pm

If you thing DST made up EAFP, he didnt. Its a real thing. Its a cool way to think.

Its actually the way he thinks too, and there are programming languages that cater to that type of thinking. Its why hes so creative. He works quickly and then goes back over his code fixing things up.

The opposite, which fits C more closely but is farther from human thinking is LBYL or look before you leap. In this case, thats what hes talking about. Explicitly test your assumptions(your variables) before you act. Make no assumptions about the state of keys or buttons. When you are finished, clean them up. Dont rely on some other event to do it for them because it might not come.

LBYL is more how I think, and I am not very prolific when it comes to software. I like to think things through very carefully and make the smallest, cleanest possible move. When DST, BeeAnt and I collaborate, we compliment each others thinking because we each have our own style. Bee is naturally a EAFP thinker too. Its the sort of thinking that comes natural to artists.

So what you are seeing is DST working with two styles of thinking at once. He has his native style (EAFP) and he uses LBYL to shape what he is doing.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Thoughts about data control

Postby Bee-Ant » Mon Jun 14, 2010 2:59 pm

What is EAFP???
I didn't read DST's post very well :P

Oh, let me share my new method in animations...
If you have cloned enemy with several type and the same animation pattern, for example "EnemyType1StopLeft", "EnemyType1StopRight", "EnemyType2StopRight", "EnemyType2StopLeft", etc...

Instead of doing this :
Code: Select all
//In this case walk==0 : stop, walk==1 : walk, right==0 : facing left, right==1 : facing right
if(type==1)
{
    if(right==0&&walk==0) //facing left
    {
        ChangeAnimation("Event Actor", "EnemyType1StopLeft", FORWARD);
    }
    if(right==1&&walk==0) //facing right
    {
        ChangeAnimation("Event Actor", "EnemyType1StopRight", FORWARD);
    }
}
if(type==2)
{
    if(right==0&&walk==0) //facing left
    {
        ChangeAnimation("Event Actor", "EnemyType2StopLeft", FORWARD);
    }
    if(right==1&&walk==0) //facing right
    {
        ChangeAnimation("Event Actor", "EnemyType2StopRight", FORWARD);
    }
}

You better do this :
-) Add this code on Global code :
Code: Select all
char TypeName[2][16]={"EnemyType1","EnemyType2"};
char State[2][16]={"Stop", "Walk"};
char Direction[2][16]={"Left","Right"};

-) And this is how to use it :
Code: Select all
char AnimationName[32];
sprintf(AnimationName,"%s%s%s",TypeName[type],State[walk],Direction[right]);
ChangeAnimation("Event Actor", AnimationName, FORWARD);

A lot cleaner right?
And whenever you want to add more Enemy type, you just need to edit the TypeName variable :
Code: Select all
char TypeName[4][16]={"EnemyType1","EnemyType2","EnemyType3","EnemyType4"};
//etc

You don't need to set any other thing... :D
User avatar
Bee-Ant
 
Posts: 3717
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 210 Give a positive score

Re: Thoughts about data control

Postby Fuzzy » Tue Jun 15, 2010 10:35 am

That looks really good Bee. Might I also suggest using global vars to track the number of names?
Code: Select all
int NumEnemies = 2;
char TypeName[NumEnemies][16]={"EnemyType1","EnemyType2"};

I also notice that you have a system for naming things, and that here you are limiting yourself to 16 character long names. Do you have any tips regarding names?
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Thoughts about data control

Postby Bee-Ant » Tue Jun 15, 2010 1:30 pm

Fuzzy wrote:That looks really good Bee. Might I also suggest using global vars to track the number of names?
Code: Select all
int NumEnemies = 2;
char TypeName[NumEnemies][16]={"EnemyType1","EnemyType2"};


Hmmm...I think GE won't allow that...
Might be like this :
Code: Select all
#define NumEnemies 2
char TypeName[NumEnemies][16]={"EnemyType1","EnemyType2"};

Fuzzy wrote:I also notice that you have a system for naming things, and that here you are limiting yourself to 16 character long names. Do you have any tips regarding names?

Do you need more than 16 letters for name?
User avatar
Bee-Ant
 
Posts: 3717
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 210 Give a positive score

Re: Thoughts about data control

Postby Fuzzy » Tue Jun 15, 2010 2:30 pm

Bee-Ant wrote:
Fuzzy wrote:I also notice that you have a system for naming things, and that here you are limiting yourself to 16 character long names. Do you have any tips regarding names?

Do you need more than 16 letters for name?


I'm not asking for help. I just mean that being consistent with names is important, but you want them short. At the same time they have to be descriptive. Thats data control too.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Thoughts about data control

Postby Bee-Ant » Tue Jun 15, 2010 6:41 pm

Fuzzy wrote:I'm not asking for help. I just mean that being consistent with names is important, but you want them short. At the same time they have to be descriptive. Thats data control too.

I didn't mean to ask either...
I was stating..."do you really need more than 16 letters for that kind of names?"
For me, I don't need it...
We're talking about name for state("stop", "walk"), direction("left", "right"), and character name ("Bee-Ant", "DST", "Fuzzy") right?
If we use more than 16 letters for them, I think it's just wasting memory since we use several arrays here :
Code: Select all
#define NameCount 10
#define NameLength 16
char State[NameCount][NameLength];
char Direction[NameCount][NameLength];
char CharacterName[NameCount][NameLength];

10x16x3=480
Look, we've already reserve 480 rooms on memory... (Oh well, I don't really know how variables take place on memory...but that's how my logic think about it)
Since my main focus is on the speed, I would reduce memory reservation as small as possible...
I may also cut the NameLength for State and Direction into half, but keep the CharacterName.
Being consistent or not it depends on how long the names commonly be... :D
I didn't limit myself, I just suppressed it to be the smallest possible size
User avatar
Bee-Ant
 
Posts: 3717
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 210 Give a positive score

Re: Thoughts about data control

Postby Fuzzy » Wed Jun 16, 2010 2:46 pm

Right, but there is a pattern there too. You have a minimal amount of information to express.

For example, "EnemyType2StopLeft" could be very short as "ET2SL" but it will make absolutely no sense in 6 months to a year. "EnTp2StLft" is just about as bad. Or if you are tired it can make very little sense. Its easier to make typing mistakes.

DST likes to work purely in numbers of course, so his is more like the "ET2SL". He naturally favours math.

So its important that each programmer work out a system and stick to it. That means all your games are going to have the same naming scheme. This shortens development time.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Thoughts about data control

Postby Bee-Ant » Wed Jun 16, 2010 6:06 pm

Fuzzy wrote:Right, but there is a pattern there too. You have a minimal amount of information to express.

For example, "EnemyType2StopLeft" could be very short as "ET2SL" but it will make absolutely no sense in 6 months to a year. "EnTp2StLft" is just about as bad. Or if you are tired it can make very little sense. Its easier to make typing mistakes.

DST likes to work purely in numbers of course, so his is more like the "ET2SL". He naturally favours math.

So its important that each programmer work out a system and stick to it. That means all your games are going to have the same naming scheme. This shortens development time.

Oh...about this thing...
I use their full word...
Doesn't mean to be ineffective, I just want to avoid the cross-code.
What's the difference between "EnemyType2StopLeft" and "EnemyType2SpecialLeft" if you shorten both to "ET2SL" ?
It's indeed simpler, but need an extra carefulness...

My system maybe a "one-for-all", so I use their full name. Here, let me show you how/why I use this...

- I use a library as the information source :
Code: Select all
#define total 10
char Names[total][16]=
{
    "WBR", "Bee-Ant", "Fuzzy", "DST", "Dreade",
    "OgreProgrammer", "KingOfEverything", "Regame", "Meta", "TowerDefense"
};

- Just call the index to get the animation name :
Code: Select all
sprintf(AnimationName,"%s%s%s",Names[index],State[walk],Direction[direct]);

In this case, I have to type all the animations name to have their full name as well. Hmmm, this is not really a problem for me.

- Just call the index to display the character's name on the screen :
Code: Select all
strcpy(EnemyName.text,Names[index]);

Well, if you shorten the name library... Bee-Ant into BA, Fuzzy into FZ, KingOfEverything into KOE in the first place, you would need an extra library to check what BA stands for, what FZ stands for, what KOE stands for...etc... Unless you want to display that shortened names to the player...I think it would just makes him confuse...

- Just call the index to display name on the dialog :
Code: Select all
sprintf(Dialog.text,"Hello %s, how do you do?",Names[index]);

Again, you would need an extra library to show the full name if you shortened them in the first place...

- Etc...
I would just call the index to get the name to access Timers, CreateActor, magic numbers, etc...

This is my pattern, oh well maybe not... I don't have any pattern?!
User avatar
Bee-Ant
 
Posts: 3717
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 210 Give a positive score

Re: Thoughts about data control

Postby DST » Thu Jun 17, 2010 3:28 am

Bee, your animation call method consists of 5% defines and 95% win. Good job!
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: Thoughts about data control

Postby Bee-Ant » Thu Jun 17, 2010 1:56 pm

DST wrote:Bee, your animation call method consists of 5% defines and 95% win. Good job!

Oh really???thanks :D
How did you calculate it anyway? :D
User avatar
Bee-Ant
 
Posts: 3717
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 210 Give a positive score

Re: Thoughts about data control

Postby Fuzzy » Thu Jun 17, 2010 2:58 pm

Bee-Ant wrote:My system maybe a "one-for-all", so I use their full name. Here, let me show you how/why I use this...


Yes, I would be inclined to use full names as well, but you know me, I am always looking for efficiency. This is one of those situations where there is no nice middle ground, but of course your system is already highly efficient.

This is thread is my favourite topic at GE.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Thoughts about data control

Postby Bee-Ant » Thu Jun 17, 2010 8:13 pm

Fuzzy wrote:Yes, I would be inclined to use full names as well, but you know me, I am always looking for efficiency. This is one of those situations where there is no nice middle ground

Hmmm, okay. Maybe we can just use the full name for Character's name, but shortened name for state, direction,etc since we don't show their values to the player.
Code: Select all
#define total 3
char Names[total][16]={"Bee-Ant", "DST", "Fuzzy"};
char State[3][1]={"S","W","J"}; //S=Stop; W=Walk; J=Jump;
char Direction[2][1]={"L","R"}; //L=Left; R=Right;

A nice enough middle ground I think... :mrgreen:
Oh, and let me guess...I think you would use data dict for the Names[total][16] :P
Fuzzy wrote:This is thread is my favourite topic at GE.

Nobody thinks hyper coder like you would love other topic beside data control :P
User avatar
Bee-Ant
 
Posts: 3717
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 210 Give a positive score

Re: Thoughts about data control

Postby Fuzzy » Fri Jun 18, 2010 6:57 am

Bee-Ant wrote:char State[3][1]={"S","W","J"}; //S=Stop; W=Walk; J=Jump;
char Direction[2][1]={"L","R"}; //L=Left; R=Right;[/code]


These dont need to be 2D arrays if you use it like this. As you have defined the array, it actually has 6 cells.


Also, I am thinking that oddly, you dont need to even have the arrays!

#define Direction[0] "L"
#define Direction[1] "R"

Then when you use it you can refer to an array that doesnt even exist. Haha!
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Thoughts about data control

Postby Bee-Ant » Fri Jun 18, 2010 7:55 am

Fuzzy wrote:#define Direction[0] "L"
#define Direction[1] "R"

Then when you use it you can refer to an array that doesnt even exist. Haha!

Arkggghhh...
Oh darn, you won :P

Oh wait...can you use them this way? :
Code: Select all
Direction[direction_var];

I'm away, so i cant test...
User avatar
Bee-Ant
 
Posts: 3717
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 210 Give a positive score

PreviousNext

Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest