Page 1 of 1

Maps without seperate files (GED included)

PostPosted: Sat Mar 31, 2012 11:40 pm
by Hblade
Hi everyone, I created a simple way to manage maps, and how big the maps are based on your view's width and height. If you want just the raw code, here it is:
Code: Select all
//Map Functions
void setMapSize(int minX, int minY, int maxX, int maxY) //Set the limits of the view's X and Y
{
    view.x=min(view.width*maxX, max(view.x, view.width*minX)); //limit X based on screens(note 1)
    view.y=min(view.height*maxY, max(view.y, view.height*minY)); //limit Y based on screens(note 1)
}
void setMap(int mapnum, int startx, int starty) //Set the map index, to tell what map you are on
{
    map=mapnum; //Set the map
    x=startx; //start X (exact X and Y)
    y=starty; //Start y (Exact X and Y)
}


How to use:
Create a switch to determine what map your on, now it's as simple as limiting the view using this code
Code: Select all
setMapSize(minX, minY, maxX, maxY);

minX is how many screens the view can reach torwards the left (starting with 0, by default the views X and Y is 0 in the demo)
maxX is how many screens it can go to the right (Again, starting from 0).
same with miny and maxy, but minY is how much the screen to go UP, (In the demos case, -1 because it can only go up 1 screen, and the - represents up, unless your map is more complex and starts at 5, then if you wanted it to go up only 1 screen, you'd say 4 instead of -1 because your Y is already 5, and 5-1 is 4 :P)

Here's an example:
Code: Select all
switch(map)
{
    case 0:
    setMapSize(0, -1, 5, 0);
    break;
    case 1:
    setMapSize(6, 0, 10, 0);
    break;
    case 2:
    setMapSize(11, -2, 11, 0);
    break;
    case 3:
    setMapSize(12, 0, 12, 0);
    break;
}


Demo:
gb_game.zip
(22.03 KiB) Downloaded 303 times


Screenshot:
Screenshot-Game Editor.png
Screenshot-Game Editor.png (3.15 KiB) Viewed 2817 times


Enlarged for thumbnail and/or viewing:
screen_enlarged.png

Re: Maps without seperate files (GED included)

PostPosted: Wed Apr 04, 2012 1:44 pm
by JamesLeonardo32
So this was the game you mentioned that was inspired by mine. Cool.

I tried to add a player, but things got a lil complicated! Interesting use of parallax scrolling =)

Re: Maps without seperate files (GED included)

PostPosted: Wed Apr 04, 2012 3:18 pm
by Hblade
lol thanks but nah this wasn't the game xD The game I am making, it has 4 stages, you can select them, and a checkmark with a circle pops up when you beat it, and its similar to megaman only without the boss powerups, I only have 2 days left to complete it for the contest.

Re: Maps without seperate files (GED included)

PostPosted: Wed Apr 04, 2012 4:06 pm
by JamesLeonardo32
Ah i see, good luck then! ;)

Re: Maps without seperate files (GED included)

PostPosted: Wed Apr 04, 2012 4:14 pm
by Hblade
Thanks. You should enter haha, it ends friday, so technically 3 days.