Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: Ingame Mini Map

(115 views • 8 replies)

This topic is 1 page long.

<< < > >>
None

pancake0Dean

Reply To Post Reply & Quote

Posted at: 7/19/08 02:43 PM

pancake0Dean LIGHT LEVEL 05

Sign-Up: 04/17/05

Posts: 196

Ahoy!

So during beta testing my game I received a bunch of requests for a mini map (a la GTA). At first I ignored the requests because I have close to no idea as my first attempt at one went horribley wrong. Anywhoo I've realised it would come in quiet handy. I've searched about a bit and found nothing terrebley helpful. Anyone care to explain to me how to make one?

My overall map is 1748 by 1472 if that helps?

Help :)


None

pancake0Dean

Reply To Post Reply & Quote

Posted at: 7/19/08 02:44 PM

pancake0Dean LIGHT LEVEL 05

Sign-Up: 04/17/05

Posts: 196

Ignore the spelling mistakes and nonsenselessness. =D


None

DawnOfDusk

Reply To Post Reply & Quote

Posted at: 7/19/08 03:19 PM

DawnOfDusk LIGHT LEVEL 11

Sign-Up: 02/22/08

Posts: 1,100

ok well then just scale down the map to a certain ratio, redraw a loose representation of the overworld map, and by using the same numbers as the ratio, plug in an equation to make the mini map move also.

Say, your map was 12x9 k? (just picture)

then you mini map could be something like 4:3.
And to make your mini map move, you would do something along the lines of...

//After alot of shit

if(Key.isDown(w/e)){
character._x += _root.speed.
Minimap._x += (1/3)*_root.speed.
}

That should help get you started.


None

pancake0Dean

Reply To Post Reply & Quote

Posted at: 7/19/08 06:34 PM

pancake0Dean LIGHT LEVEL 05

Sign-Up: 04/17/05

Posts: 196

Still not quite got it. I think it's because I'm shit at maths.


None

gankro

Reply To Post Reply & Quote

Posted at: 7/19/08 07:07 PM

gankro EVIL LEVEL 11

Sign-Up: 09/16/06

Posts: 1,136

be more specific, there are many styles of mini maps, do you want an entire map visible at once or just a portion at a time? if it's the portion then it is simple as using a mask and changing it's coordinates at a scaled rate as the real maps I.E:

if your mini map = 1/10 the size of the real map, it will move 1/10 as fast as it.

My Coding Portfolio (updated frequently)
If you stay in bed for long enough it will be socially acceptable to go to bed again

BBS Signature

None

Wurmy

Reply To Post Reply & Quote

Posted at: 7/19/08 07:26 PM

Wurmy EVIL LEVEL 23

Sign-Up: 06/20/06

Posts: 1,840

Here's what I would do for a perfectly accurate minimap.

Lets say you have a map that is 10 units by 10 units (what the units are doesn't matter, this is an example). You have a minimap that is 1 unit by 1 unit.

So the minimap is 1 tenth the size of the real map. What you do next is get the position of the player relative to the map (the 10 by 10 map)

Then divide the x by 10, and the y by 10. Those are your relative coordinates to use in the minimap!

hai guyz

BBS Signature

None

ssjskipp

Reply To Post Reply & Quote

Posted at: 7/19/08 08:47 PM

ssjskipp LIGHT LEVEL 14

Sign-Up: 10/16/03

Posts: 714

Easiest thing to do:

Bismapdata.draw();

Useful. Hint: Scaling matrix.

AS3:

//Create minimap BMD
var minimap:BitmapData = new BitmapData(200, 200, true, 0);
//Create the holder
var bmp:Bitmap = new Bitmap(minimap);
//Attach it
stage.addChild(bmp);
//If you have a level MC (some display object containing JUST terrain), replace stage
//Make sure you don't include the minimap itself in the draw (hence it attaching to stage, not root)
//You'll have to do more translating + scaling with the matrix to make it fit right if 0,0 isn't top left
var target = root;

function renderMap() {
	//Set scales
	sX = minimap.width/target.width;
	sY = minimap.height/target.height;
	//Preserve square-minimap scaling
	sX = sX > sY ? sY : sX;
	sY = sY > sX ? sX : sY;
	//Create draw matrix
	var scale:Matrix = new Matrix();
	//Scale matrix
	scale.scale(sX, sY);
	//Clear minimap + fill with a transparent color (makes it easier to see edges of minimap)
	minimap.fillRect(minimap.rect, 0x33000000);
	//Draw new minimap, using scale values
	minimap.draw(target, scale);
}
//Set an interval to re-render minimap every 30ms (= to 30fps, 1fps = 1000ms/f, 30fps = 30ms/f)
setInterval(renderMap, 30);

"Give a man a match, and he'll be warm for a minute, but set him on fire, and he'll be warm for the rest of his life."


None

DawnOfDusk

Reply To Post Reply & Quote

Posted at: 7/19/08 09:14 PM

DawnOfDusk LIGHT LEVEL 11

Sign-Up: 02/22/08

Posts: 1,100

At 7/19/08 08:47 PM, ssjskipp wrote: Easiest thing to do:

How was that easy? lmao. Good Stuff, anywho.

I love how my idea is the same as everyone elses except for yours, but urs is good.
Good stuff.


None

ssjskipp

Reply To Post Reply & Quote

Posted at: 7/19/08 09:32 PM

ssjskipp LIGHT LEVEL 14

Sign-Up: 10/16/03

Posts: 714

It's easy because it clones the EXACT map -- I mean, yeah, if you don't know bitmap data and such, it's a little tough, but I mean -- I typed that into here, then quickly tested + formatted, then copied back in like, 2 minutes.

Also, it requires 0 work except for copy + paste (you don't need to re-draw a map). And if you were clever, you can write an edge finding script, and turn ANY map into edges-only (removes terrain and stuff). For that, convolution filter!

"Give a man a match, and he'll be warm for a minute, but set him on fire, and he'll be warm for the rest of his life."


All times are Eastern Daylight Time (GMT -4) | Current Time: 04:23 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!