Thoughts about data control

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

Re: Thoughts about data control

Postby schnellboot » Tue Feb 15, 2011 6:15 am

In computer science, an array type is a data type that is meant to describe a collection of elements (values or variables), each selected by one or more indices that can be computed at run time by the program. Such a collection is usually called an array variable, array value, or simply array.[1] By analogy with the mathematical concepts of vector and matrix, an array type with one or two indices is often called a vector type or matrix type, respectively.
Source: wikipedia
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Thoughts about data control

Postby lcl » Thu May 26, 2011 10:10 pm

Here's what I've been working on to get my data control as clear as possible.

I noticed that many users (including me) are having problems with creating levels and especially choosing how to make them, (multiple geds, using activation regions).

Both of these methods have some things that make them inefficient to use:

Multiple geds:
- Every ged needs to contain all the same actors and events and actions and changing even a small thing in the game will become very big work because all the geds have to be changed. And think about if the thing to be changed is massive..

Activation regions:
- The functionality of this method is not so good. I used activation regions with dimension55355 and it was hard to get it working. Some actors just disappeared from some activation regions and fixing it was really painful.

So, I have thought of other ways to create game levels and I ended up making a system that loads levels from text files.

I have succeeded to create a level according to the contents of a file which I wrote manually.
I am currently working on a level creator program that will be able to write a level into file.

The files' contents will be:

1. Level name (can contain many words, just must use '_' between them. The system will change '_''s to space).
2. Height of level (max count of tiles on vertical axis).
3. Width of level (max count of tiles on horizontal axis).
4. Tile height
5. Tile width
6. The actual data, numbers that represent the levels content.

There may come more things that need to be written in the file.
And the editor will automatically count the widths and heights.

The editor will be published with level loading code as soon as I get it done.

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

Re: Thoughts about data control

Postby Game A Gogo » Thu May 26, 2011 10:56 pm

Cool :D
if you ever need help to make your level editor and levels more advanced, I think I mastered file saving with fopen pretty well! I'm sure you looked at P4020
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Thoughts about data control

Postby lcl » Thu May 26, 2011 11:25 pm

Game A Gogo wrote:Cool :D
if you ever need help to make your level editor and levels more advanced, I think I mastered file saving with fopen pretty well! I'm sure you looked at P4020

Thanks! :)
I will ask you if I need help.

Oh, I forgot to say that I am trying to develop it so user friendly that anyone on the forum could use it for their games. The whole idea is to make it suitable for creating levels to anyones games, easily. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Thoughts about data control

Postby falcon3600games » Mon Aug 08, 2011 8:25 am

DST wrote:
Hblade wrote:Does anyone know if DST Is human? O.o. He's way to frakin smart lol.

Well, I'm smarter than your average bear, but that's only part of what being smart is.

Listening to other people and learning from them - that's what smart is!

Programming the computer to work for you - that's what smart is!

Never putting personal pride ahead of learning - that's what smart is!


These things are all really hard sometimes! the last one is probably the hardest!
(especially when you get old!).


It's random for me to post this, but DST, you seem like a top MF at this! :)
falcon3600games
 
Posts: 5
Joined: Wed Aug 03, 2011 4:04 am
Score: 1 Give a positive score

Re: Thoughts about data control

Postby DST » Fri Dec 16, 2011 9:16 pm

I mentioned using data arrays to create spreadshots in another thread. Here's the example:

Say you want a boss to fire this spread pattern:
spreadf.png


Simple create a data array of nine integers, as long as the total number of waves of the shot. In this case it's

Code: Select all
int fSpread[][]={{
0, 0, 0, 1, 0, 1, 0, 0, 0},{
0, 0, 1, 0, 1, 0, 1, 0, 0},{
0, 1, 0, 0, 1, 0, 0, 1, 0},{
0, 0, 0, 1, 0, 1, 0, 0, 0},{
0, 0, 0, 0, 1, 0, 0, 0, 0}};
int sWave=0;



Then write your firing loop, creating a shot at each position with a '1' in it.

Code: Select all
void fSpreadShot(){
int j; int x1;
for(j=0; j<9; j++){
if(fSpread[sWave][j]==1){
x1=j*24;
CreateActor(shot etc, x1, y);
}
} //end j Loop
sWave++;
if(sWave==5){
sWave=0;
}
} //end fSpreadShot


Run this script at a regular interval and boom! The boss will fire spreadshots. You can add sine/cos values to the x and y to allow for the boss to fire them in a specific direction.

At any time, you can run this script with a different data array to make different spreadshots. If you make a [][][] array, you can store all your spreadshots in a big list. You can even use the first array of each array [][][thisone] to store the other values for the script, such as the interval, the type of shot or shot speed, etc. and simply start the 'sWave' on 1.

For extra control, 'sWave' variable in reverse, and write the data arrays the other direction. This way, when you create your data arrays, they will appear geometrically the same as the spread pattern does onscreen, if you catch my drift.

int happyface[][]={{
1, 1, 1, 0, 0, 0, 1, 1, 1},{
1, 1, 0, 1, 1, 1, 0, 1, 1},{
1, 0, 1, 0, 1, 0, 1, 0, 1},{
1, 0, 1, 1, 1, 1, 1, 0, 1},{
1, 0, 1, 0, 1, 0, 1, 0, 1},{
1, 1, 0, 1, 0, 1, 0, 1, 1},{
1, 1, 1, 0, 0, 0, 1, 1, 1}};
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 » Tue Dec 27, 2011 12:39 am

I was inspired by DSTs function and I came up with something a little different. Here it is.
Code: Select all
int firingPattern = 0x15; // the binary pattern looks like 1010100000000000 - it is "21" in decimal.
int patternFire(int pattern)
{
    int result = 0; // start with no signal to fire
    int steps = 16; // pattern length in bits - we are using a 16 bit space.
    result = pattern & 0x1; // grab the parity bit
    if ((result == 1) {
        CreateActor(shot etc, parentX, parentY);
    }
    pattern = pattern >> 1; // consume the end bit - this is bitwise division by 2.
    pattern = pattern ^ result << (steps-1); // use the result bit to rebuild the pattern.
    return pattern;
}


It fires a 1D stream of shots endlessly with a pattern. You probably want to fire only every few draws, so use a timer.

If you want a 2D pattern, you can use an array of firingPatterns, and call the function on each one.
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 » Sun Apr 29, 2012 7:32 pm

Random code before I sleep...

I was thinking of storing string securely, because as you can see, saving them through saveVars() still left the string readable.
So here I came up with encoding idea.
Code: Select all
char *Encode(char str[64])
{
    int i,char1,char2,char3,char4;
    char tmp1[5],*tmp2=malloc(256);
    for(i=0;i<strlen(str);i++)
    {
        char1=(int)str[i]-10;
        char2=(int)str[i]+rand(20)-10;
        char3=(int)str[i]+rand(20)-10;
        char4=(int)str[i]+rand(20)-10;
        sprintf(tmp1,"%s%s%s%s",&char1,&char2,&char3,&char4);
        strcat(tmp2,tmp1);
    }
    return tmp2;
}

char *Decode(char str[256])
{
    int i,char1;
    char tmp1[2],*tmp2=malloc(64);
    for(i=0;i<strlen(str)/4;i++)
    {
        char1=(int)str[i*4]+10;
        sprintf(tmp1,"%s",&char1);
        strcat(tmp2,tmp1);
    }
    return tmp2;
}

The usage as follows:
(considering you have global var called password that's stored in data group)
Code: Select all
//to save data
strcpy(data,Encode("BeeIsHandsome"));
saveVars("data.sav","data");

//to load data
loadVars("data.sav","data");
strcpy(PassText.text,Decode(password));

To check whether the code is correct or not, run this code on a Text actor or something:
Code: Select all
strcpy(Password,"BeeIsHandsome");
sprintf(text,"Original: %s\nEncoded: %s\nDecoded: %s",Password,Encode(Password),Decode(Encode(Password)));

The key to encode is just get the ASCII code for each letter, subtract by 20, and add 3 more letters randomly.
You can mess with the pattern by changing the subtraction or randomness of the additional letters.

Useful for secure data exchanging or storing. Might be useful to deceive CheatEngine user too :P

I guess that's all.
Night...



*EDIT: tested, working now
Last edited by Bee-Ant on Mon Apr 30, 2012 5:12 am, edited 2 times in total.
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: Thoughts about data control

Postby SuperSonic » Sun Apr 29, 2012 9:34 pm

Dude, that's awsome! I really need to study this topic for other cool stuff like this :P
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Thoughts about data control

Postby Bee-Ant » Mon Apr 30, 2012 8:54 am

Here I am again...
I dunno whether someone already posted this or not, but here the function to convert decimal to binary and vice versa:
Code: Select all
char *DecToBin(int xx)
{
    int i,yy=xx,aa,bb,cc;
    char tmp1[2],tmp2[256],*tmp3=malloc(256);
    while(yy>=2)
    {
        aa=yy/2;
        bb=yy%2;
        sprintf(tmp1,"%i",bb);
        strcat(tmp2,tmp1);
        yy=aa;
    }
    if(yy<=1)
    {
        sprintf(tmp1,"%i",yy);
        strcat(tmp2,tmp1);
    }
    for(i=strlen(tmp2);i>0;i--)
    {
        cc=tmp2[i-1]-48;
        sprintf(tmp1,"%i",cc);
        strcat(tmp3,tmp1);
    }
    return tmp3;
}

int BinToDec(char str[256])
{
    int i,j,tmp,xx;
    double yy;
    for(i=0;i<strlen(str);i++)
    {
        j=strlen(str)-1-i;
        xx=(str[i]-48)*pow(2,j);
        yy+=xx;
    }
    tmp=yy;
    return tmp;
}


Usage:
Code: Select all
//Decimal to Binary
sprintf(text,"%s",DecToBin(89)); //you will get 1011001 output

//Binary to Decimal
sprintf(text,"%i",BinToDec("1011001")); //you will get 89 output


Please note that with the function above the binary is stored as string.
There are 2 ways If you want them as integer, first, simply use atoi():
Code: Select all
//Decimal to Binary
sprintf(text,"%i",atoi(DecToBin(89))); //you will get 1011001 output

Second, use this function instead:
Code: Select all
int DecToBin(int xx)
{
    int i,yy=xx,aa,bb,cc,tmp4;
    char tmp1[2],tmp2[256],tmp3[256];
    while(yy>=2)
    {
        aa=yy/2;
        bb=yy%2;
        sprintf(tmp1,"%i",bb);
        strcat(tmp2,tmp1);
        yy=aa;
    }
    if(yy<=1)
    {
        sprintf(tmp1,"%i",yy);
        strcat(tmp2,tmp1);
    }
    for(i=strlen(tmp2);i>0;i--)
    {
        cc=tmp2[i-1]-48;
        sprintf(tmp1,"%i",cc);
        strcat(tmp3,tmp1);
    }
    tmp4=atoi(tmp3);
    return tmp4;
}

Hopefully will be useful, enjoy :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: Thoughts about data control

Postby Sarmad786 » Sun Sep 02, 2018 7:09 pm

Hey Guys !!
I am developing a Space Shooter Game. So I needed to ask about the Boss's movement. Any ideas on how to create Boss movement like in the other Shoot em up Games.

Thanks in advance!! :)
Working on SpaceShooter :D
User avatar
Sarmad786
 
Posts: 12
Joined: Sat Sep 01, 2018 8:19 am
Score: 0 Give a positive score

Previous

Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest