Example - load maps from ext. file

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

Example - load maps from ext. file

Postby Eliminator » Mon Aug 04, 2008 7:55 pm

this example shows how to make a level loading from external file and custom levels.

-all maps are 8x5 (you can change it in the source code, global->vars.) world[x][y]
-maplist must be saved in "maps.txt" file.
-maximum 10 maps in maplist. you can change this value in the view->create actor->script editor.
for(i=0;i<10;i++) //<<==Change this
{
fscanf(maps,"%s\n",mapname[i]);
}


-Dummy map:
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,

0 - nothing
1 - wall
2 - guy*
3 - portal 2 the next level*
*-must be 1 on each level

-you can add a new level actors and objects in global->creator:
example:

if(world[i][j]==4)
{
CreateActor("wall2", "wall2", "(none)", "(none)", mapX, mapY, false);
{

of course, u must create an "wall2" actor with anim. name "wall2". and don't forget to add these
objects to global->Destroyer.


...and don't laugh about the hero name...
Attachments
dfx.jpg
DfX_src.zip
(214.03 KiB) Downloaded 572 times
Eliminator
 
Posts: 9
Joined: Sun Jul 27, 2008 11:37 am
Score: 4 Give a positive score

Re: Example - load maps from ext. file

Postby speckford123 » Tue Aug 05, 2008 12:48 pm

hey, nice work
i was thinking of making something like this but i guess you beat me to it
point for you :D
speckford123
 
Posts: 334
Joined: Fri May 05, 2006 6:33 pm
Score: 49 Give a positive score

Re: Example - load maps from ext. file

Postby moonmoon » Tue Aug 26, 2008 5:26 pm

good job. :lol:
moonmoon
 
Posts: 10
Joined: Sat Feb 16, 2008 2:16 pm
Score: 0 Give a positive score

Re: Example - load maps from ext. file

Postby Lexcondran » Mon Sep 01, 2008 6:23 pm

wow im confused and have no idea what to do Ploos theres no noises and you did do a good job but iguess im not experienced enough to make my own level this confuses me :D
http://www.mediafire.com/?e4zzycilztdm1qm =My RPG APP FILE V. 3.0 {7/15/2010}
http://www.mediafire.com/?tjjmmmkzyga =My editable demo of my Rpg for people V2.3
viewtopic.php?f=6&t=10247 =Link to my RPG's (4.0) Topic =]
User avatar
Lexcondran
 
Posts: 230
Joined: Thu Jul 31, 2008 6:09 pm
Location: Tucson, Arizona, USA
Score: 8 Give a positive score

Re: Example - load maps from ext. file

Postby Lexcondran » Sat Sep 06, 2008 8:57 am

i have figured this stuff out and made something cool but still im wondering how to make this random.
so i changed the sizes from the small ness to 50x50 level rooms. and im messed it up and the map name thing does not appear or any other words.
http://www.mediafire.com/?e4zzycilztdm1qm =My RPG APP FILE V. 3.0 {7/15/2010}
http://www.mediafire.com/?tjjmmmkzyga =My editable demo of my Rpg for people V2.3
viewtopic.php?f=6&t=10247 =Link to my RPG's (4.0) Topic =]
User avatar
Lexcondran
 
Posts: 230
Joined: Thu Jul 31, 2008 6:09 pm
Location: Tucson, Arizona, USA
Score: 8 Give a positive score

Re: Example - load maps from ext. file

Postby supa-tails » Sun Nov 02, 2008 3:12 am

COUNTER STRIKE FTW! XD Im about to test this.
................................................................................................ www.freewebs.com/thebiverse .....................................................................................




c'ya on the other side
User avatar
supa-tails
 
Posts: 269
Joined: Fri Jul 27, 2007 3:03 pm
Location: In an aliens tummy... Or in cumming Georgia USA
Score: 17 Give a positive score

Re: Example - load maps from ext. file

Postby jimmynewguy » Fri Feb 20, 2009 1:28 am

guess this is a bumb, oh well, but anyway
how do you actually make a map? i feel kind of stupid but like in the script editor what would i put it i wanted a map like idk
ex.

2,0,0,0,0,0,0,0,
1,1,1,1,1,1,0,0,
0,0,0,0,0,0,0,0,
1,0,1,1,1,1,1,0,
0,3,0,0,0,0,0,0,

what would i do to save that as like level_1 for example, make an array variable? :roll: im confuzled :lol:
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Example - load maps from ext. file

Postby 4erv' » Mon Feb 23, 2009 8:42 pm

Okay, two questions:
1. what this "%s\n" means in fscanf(maps,"%s\n",mapname[i]);?
2. what the function MapL(); do?
:D
Gold Basketball 2008 - the first basketball game made with game editor.

User avatar
4erv'
 
Posts: 188
Joined: Sat Jul 07, 2007 10:52 am
Location: in Recycle Bin
Score: 10 Give a positive score

Re: Example - load maps from ext. file

Postby skydereign » Tue Feb 24, 2009 1:46 am

1. what this "%s\n" means in fscanf(maps,"%s\n",mapname[i]);?
It is the 'rules' fscanf follows or looks for. %s scans a string until \n, which is a newline.

2. what the function MapL(); do?
It loads the map by creating the actors, from a file.
Code: Select all
void MapL()
{
FILE *map = fopen(curmap, "r"); // sets map to direct into the file
mapX=0; // sets the x and y to 0
mapY=0;

    for(i=0;i<sizeY;i++)   // nested for loop to obtain xy coordinates
    {
        for(j=0;j<sizeX;j++)
        {
            fscanf(map,"%d, ",&world[i][j]);  // scans into map file, looks for an int; signed decimal notation
            if(world[i][j]==1) // If that ij is 1, create actor 1
            {
                CreateActor("FON", "FON", "(none)", "(none)", mapX, mapY, false);
            }
            if(world[i][j]==2) // If that ij is 1, create actor 2
            {
                CreateActor("Dollfucker", "st3_25x60", "(none)", "(none)", mapX, mapY, false);
            }
            if(world[i][j]==3) // If that ij is 1, create actor 3
            {
                CreateActor("portal", "portal", "(none)", "(none)", mapX, mapY, false);
            }
            mapX+=40; // Then move mapX for placement
        }
    mapX=0;  // after all x for the row is done, reset x and increase y, and repeat
    mapY+=40;
    }
    sprintf(cDEBUG.text,"MAP:%s",curmap);  // prints the map name
fclose(map); // closes map
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Example - load maps from ext. file

Postby 4erv' » Tue Feb 24, 2009 7:26 pm

Thank you! :D
+1 point
Gold Basketball 2008 - the first basketball game made with game editor.

User avatar
4erv'
 
Posts: 188
Joined: Sat Jul 07, 2007 10:52 am
Location: in Recycle Bin
Score: 10 Give a positive score

Re: Example - load maps from ext. file

Postby Bee-Ant » Mon Jun 01, 2009 9:21 am

I love this demo and using the method for my current game.
But i have a problem with 3 digit number. I mean :
125,658,425,133,966,546,
546,872,111,105,613,525,
466,651,826,136,665,251,
646,883,852,564,369,964,
etc
I use 75x75 array. But GE always stopped working everytime i click GameMode.
Whats wrong?
Anyone who knows this stuff,may i have your email address?thanx :D

Bee
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: Example - load maps from ext. file

Postby skydereign » Mon Jun 01, 2009 9:32 am

3 digit numbers shouldn't be a problem, and I am assuming that your grid is 75x75, each place holds a three digit number. I can help you out, or just post a demo of it working for me. Are you trying just to hold ints? Or are you trying to save and load?
Last edited by skydereign on Sun Jul 12, 2009 5:12 am, edited 1 time in total.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Example - load maps from ext. file

Postby Bee-Ant » Mon Jun 01, 2009 10:25 am

Too complicated to explain..
I will just send you the demo, and check it yourself.
Thanx :D

Edit: i mean,GE stopped working when you exit from GameMode.
I can load the map,but ugly..
Im so sure i put the right code and array.
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: Example - load maps from ext. file

Postby Bee-Ant » Tue Jun 02, 2009 2:22 pm

I have tested the function so many times, and there's a problem when loading high arrays. I tried use 75x75 and put the same number for each i and j. Theres 1 blank spot at 12,0 and 1 error spot(something like in this spot doesnt recognize any animation changing),and there are 15 blank spots in the end of arrays. It should make total square background right?but it doesnt. When i use 50x50,there's only 1 error spot, but makes total square background.

So i assume that this function capable to handle at low arrays only. I think below 50.

I thought that i misscalculate my arrays. Because when i use 75x75 the background cropped at j=15.

Oh yah,anyone knows how to use pointer at this stuff?using high array such wasting memory...

Thanx.
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: Example - load maps from ext. file

Postby Bee-Ant » Tue Jun 02, 2009 5:48 pm

Ah, one more thing...
This function doesnt work on exported game.
I can use it on project mode only...
Hhh,i wonder why this happening...
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

Next

Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest