Maps without seperate files (GED included)

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

Maps without seperate files (GED included)

Postby Hblade » Sat Mar 31, 2012 11:40 pm

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 304 times


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


Enlarged for thumbnail and/or viewing:
screen_enlarged.png
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Maps without seperate files (GED included)

Postby JamesLeonardo32 » Wed Apr 04, 2012 1:44 pm

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 =)
JamesLeonardo32
 
Posts: 320
Joined: Wed Oct 13, 2010 4:57 pm
Score: 36 Give a positive score

Re: Maps without seperate files (GED included)

Postby Hblade » Wed Apr 04, 2012 3:18 pm

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.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Maps without seperate files (GED included)

Postby JamesLeonardo32 » Wed Apr 04, 2012 4:06 pm

Ah i see, good luck then! ;)
JamesLeonardo32
 
Posts: 320
Joined: Wed Oct 13, 2010 4:57 pm
Score: 36 Give a positive score

Re: Maps without seperate files (GED included)

Postby Hblade » Wed Apr 04, 2012 4:14 pm

Thanks. You should enter haha, it ends friday, so technically 3 days.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest

cron