Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [GM][TAW]Minimap
HeroOfHyla
post Jun 15 2009, 10:56 PM
Post #1


Twirling towards freedom
Group Icon

Group: +Gold Member
Posts: 2,791
Type: Scripter
RM Skill: Advanced




Minimap
This tutorial will teach the use of views in Game Maker by creating a minimap for the TopDownShooter demo.

Main TAW Topic: http://www.rpgrevolution.com/forums/index....showtopic=31232

Game maker can support multiple "views" at once time on the screen. Each view can display any part of the room, on any part of the screen. This tutorial will examine how views work, and provide some handy tips.

I'm assuming you have downloaded my TopDownShooter demo already. I'm going to be working off of that, so I don't have to type in a new movement script/etc for this.

The first step is the easiest: Setting up the 2 views in the room. Open up the room editor, and you'll see a tab called "views." The first thing you need to do is mark the check box that enables the use of views. Now make sure "View 0" is highlighted on the list. The default setting should work for now, except that you need to check the box that says "Visible when room starts."

Click on "View 1." Make this one visible when the room starts, too. We want the same positioning for the view in the room, but we want it to be smaller on the actual screen. I found that a good size was W= 160, H= 120. You can position it wherever you want in the room with the X and Y. I left mine at 0,0.

Run the game, and you'll see a smaller version of the room on top of the larger version. That is actually all you need to do for the most basic of minimaps, but let's spruce it up a bit! It's a bit hard to tell what's what at that scale, so why don't we make it draw colored rectangles on the minimap instead of full sprites? To do this, you're going to have to go into every object, and add a "draw" event. Let's start with objBlock:
CODE
{
    if (view_current = 0)
    {
        draw_sprite(sprite_index,image_index,x,y);
    }
    else
    {
        draw_set_color(c_black);
        draw_rectangle(x,y,x+31,y+31,0);
    }
}

What this does is check what view is being drawn, and draw the proper thing. If it's drawing view 0 (the main room) it draws the proper sprite. If not, it draws a black square instead. Go ahead and stick something like this in the draw event for objEnemy and objChara, except with different colors. I used c_red for the enemy and c_lime (light green) for the character.

For objDeadEnemy, I decided to immediately remove the picture from the minimap, instead of having it remain while the corpse stayed. So I copied the code into the draw event, but I got rid of the "else" section.

objController already has a draw event that's used to draw the health bar. However, it needs to be moved over because of the placement of the minimap. Here's the new code I used:
CODE
{
    if (view_current = 0)
    {        
    
        background_index[0] = -1;
        draw_healthbar(530,10,630,30,health,c_black,c_red,c_Lime,0,1,1);
    }
    else
    {
        background_index[0] = bgFloorTile;
    }
}


I also added another thing in this script. I decided I didnt want the floor pattern on the minimap, so I set the index of the background to -1 for the minimap view. But wait! The code for the 2 background settings are in the wrong spots! Well, that's because the background's depth is higher than the objController's depth. It's drawn first, so it shows up before the controller has a chance to change the background. You have to preplan for the next time draw events occur.

That should do it! Give it a test run. If you want to be ambitious, play around with having the view follow an object on the screen.



Demo: http://www.mediafire.com/download.php?lygzzw3jd00


__________________________
Asexual - Arizonan - Atheist
I've got a gmail account and a yahoo mail account under this name, if you need to contact me.
You can find me on facebook too. facebook.com/heroofhyla . If you send me a friend request, tell me who you are so I don't get confused.

PlagueRPG SITE IS WORKING! (if you see "test page," hit ctrl+f5)
Latest update: New battle system demo, April 19, 2010

http://heroofhyla.deviantart.com/ ----- http://heroofhyla.livejournal.com/ ----- http://thatonecomic.smackjeeves.com
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 10:47 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker