The Daily Click ::. Forums ::. Klik Coding Help ::. Best way to go about a grid map.
 

Post Reply  Post Oekaki 
 

Posted By Message

eyeangle



Registered
  12/06/2003
Points
  1683
20th June, 2007 at 21:08:11 -

Hi, I have the grid map.
- The whole screen res. is 800x600.
- The grid I'm making it 10x10.
- So that's 100 levels each 80x60 pixels big.

My aim is to have a black screen with white grid-lines and when you beat a level that grid gets coloured in with that part of the map.
I don't exactly know how to go about doing it and I don't want 100 different levels just for 1 map with each grid box coloured in seperately. Also some levels are scrolling so they take up 2 grib blocks or even 8 so as soon as you enter that level and press [Enter] you can see all the levels coloured in that you've completed.
I don't really care whether or not the map shows where you are because that will already be obvious.

Example:

Image

Thanks for the help.

 
theonecardgame.com

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
20th June, 2007 at 22:47:08 -

I think there are a probably many ways of doing it, but here's the first idea that springs to my mind (hopefully you're using MMF)...

1.) Create a background object 800x600, with the complete map (like if every level had been completed).

2.) Create an overlay object 800x600, with just the white lines and a *nearly* black background (absolute black is transparent). Set debug mode on.

3.) For each level, store an x and y coordinate for the corresponding grid cell (in an .ini or array - preferably the one that you store the levels in). For example, the highest 2x2 cell in your example picture would have coordinates 3,2.

4.) When you want to make a cell visible, you use the fill function in the overlay. For the x and y, you lookup the coordinates from the .ini or array, and multiply the x by 80 and the y by 60 (the cell dimensions). You might have to add 2 because of the white lines. Set the color to 0,0,0 (black) which will make the cell transparent, revealing that part of the background image beneath.


If you don't use MMF, then I'd again use a background object containing the full map. I'd then store the topleft, topright, bottomleft, and bottomright coordinates of each cell (again in an .ini or array). I'd then have 100 black active objects (slowdown isn't an issue because nothing much will be happening on a simple map screen), and one large active object with just the white lines. When you complete a level, it would look up the 4 coordinates and destroy all the active objects inside.

That was all reasonably clear?
Like I said, I'm sure there are other ways, but this is one way you don't have to bother making 100 individual 80x60 images at least.

btw; is this going to be for "Strike-Down 4" per chance?



Image Edited by the Author.

 
n/a

eyeangle



Registered
  12/06/2003
Points
  1683
20th June, 2007 at 23:15:00 -

Thanks Sketchy, your infomation worked a treat, and yes I am using MMF and yes it is for SD4.

And I'm using 256 colour so there's no problem for slowness, just in case.

Also another question, how do I get back to the level I was just on in the same spot with the same baddies killed after going to the map level???

Image Edited by the Author.

 
theonecardgame.com

eyeangle



Registered
  12/06/2003
Points
  1683
21st June, 2007 at 01:49:45 -

I'm still confused. I've never used inis or arrays before so as you can imagine I have no idea.

"2.) Create an overlay object 800x600, with just the white lines and a *nearly* black background (absolute black is transparent). Set debug mode on."

- How do you set debug mode on and what does it do?

"3.) For each level, store an x and y coordinate for the corresponding grid cell (in an .ini or array - preferably the one that you store the levels in). For example, the highest 2x2 cell in your example picture would have coordinates 3,2."

- How do you store an x and y in an ini or array? -I need to read an article about these two objects. Where are these articles? How does another level read an ini, do you have to put the same one in every level?

"4.) When you want to make a cell visible, you use the fill function in the overlay. For the x and y, you lookup the coordinates from the .ini or array, and multiply the x by 80 and the y by 60 (the cell dimensions). You might have to add 2 because of the white lines. Set the color to 0,0,0 (black) which will make the cell transparent, revealing that part of the background image beneath. "

- Where's the fill function in what overlay, what is an overlay, is it a backdrop??? How do you look up the x and y coordinates in an ini or array?

I know how to make a color change to another color but I don't know how to tell it where in the picture to change.

Best of luck explaining it to me, how did everyone else figure this stuff out for themselves???

 
theonecardgame.com

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
21st June, 2007 at 09:04:29 -

First of all, the overlay object (overlay/overlay redux/active overlay) is an extension which you will need to download if you don't already have it. It's somewhat like a background object with the exception that you can draw on it.
Initially, overlay objects are hidden. Setting debug mode on just makes it visible.

Ini files and arrays are data storage objets. An ini is just a simple text file really, with a kind of tree structure (can't really explain without a demonstration). Arrays are grids of data - kind of like an invisible excel datasheet.

Do some searches on here (the old clickteam forum archive) to find info;
http://www.clickteam.com/CTforum/wwwthreads.php3?Cat=&C=2

Also, the .pdf manual in your MMF folder is a lot more thorough than the normal help.
For keping all the baddies where they were when you show the map screen, you either have to save and reload the positions, speeds, etc of every active object, or just show the map screen as a sub app (easier).

Anyways, I'll see if I can't knock something together example-wise.

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
21st June, 2007 at 12:33:22 -

If you don't like the overlay object, then just use a grid of black active objects, and store the visibility state of each square in a two-dimensional array.

Arrays are not hard to understand. They simply provide a grid of variables, which can easily be accessed per index number. Think of an array as a table, used to store numbers (or strings). Just insert an array object to the game and check out its actions and conditions.

 
n/a

eyeangle



Registered
  12/06/2003
Points
  1683
21st June, 2007 at 18:59:22 -

Thanks Sketchy, I'll be sure to mention your name in the credits.

I'm going to go with showing the map screen as a sub app. It seems more logical that way.

Image Edited by the Author.

 
theonecardgame.com

Deleted User
21st June, 2007 at 19:01:22 -

Go to the object's properties in the frame editor and turn on transparency at 0,0,0.

 

eyeangle



Registered
  12/06/2003
Points
  1683
21st June, 2007 at 19:20:18 -

Okay I've got the Overlay Redux Object and the Array working now.

I did encounter a few problems:
- It can only read one coordinate at a time. For example if you are on level 3. Which is grid 2,5. Only that cell will be coloured in and not the two levels before it- cells 1,5 and 2,5. How do we get all levels from when you started to where you are on the map coloured in?

- Also, this is more of a suggestion. I supposed the problem above wont happen if the map is an extra app. becasue the cells will get coloured in as you go along. But does this mean the map app. has to be open at all times? Which I don't really want.

Image Edited by the Author.

 
theonecardgame.com

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
21st June, 2007 at 21:06:30 -

You can use the array to store all the info about the levels. For example;

You use the X coordinate to specify the level #.
You use the Y coordinate to specify the item of that levels data (x_coord, y_coord, completed?)

so,
when you complete level 6 for example, you use the function "write value to XY". You would use x=6 (the level#), y=3 (1=x, 2=y, 3=completed?). The value you would write would be 1 (0=has NOT been completed, 1=has been completed).

Now, when you want to show the map screen, you can open up a subapp with it in, and go through every level, checking the array to see if it has been completed (a sub application is another extension in case you weren't aware, not literally a whole other MMF application). Are you going to be allowing the player to save their game mid-level? If so, you needn't bother with the subapp - try to figure out how to save/load the level now (then you can save -> goto map -> load again).

Out of interest, did you get the overlay to go transparent at all? I'm certain it should, but when I came to trying to make an example for you it didn't seem to work in either MMF1 or MMF2, and I can't find a property or function anywhere to set the transparent colour. I'll see if I can find another overlay version...



 
n/a

eyeangle



Registered
  12/06/2003
Points
  1683
21st June, 2007 at 21:43:54 -

Yeah, you have to going into the Overlay Object Settings (double click the picture), and under Drawing Mode set it to Transparent Mode.

Yeah you will be able to save game mid level.

Image Edited by the Author.

 
theonecardgame.com

eyeangle



Registered
  12/06/2003
Points
  1683
22nd June, 2007 at 00:50:46 -

When I go "Write value to XY" it says before asking for the X and Y index, "Enter Value to Write"

What does this mean?

 
theonecardgame.com

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
22nd June, 2007 at 05:56:56 -

It asks what value you want the array at index (X,Y) to be. It means the same as "set value" if that's more clear for you.

 
This space is for rent

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
22nd June, 2007 at 07:30:54 -

I had an old version of overlay (I recently reinstalled MMF). I just put the OverlayRedux extension on and it's working fine.

EDIT:

ok, it's probably buggy as hell, but here's the example;

http://www.angelfire.com/mech/banshee/MapExample.zip (copy & paste as always)

anyways, hope it helps because it took me quite a bit longer than i'd anticipated. hope it's not too patronizing either - i commented pretty much every line, however obvious.

if you use a subapp, you can more or less ignore the first frame for now.



Image Edited by the Author.

 
n/a

eyeangle



Registered
  12/06/2003
Points
  1683
22nd June, 2007 at 22:10:18 -

Thanks Sketchy. I've been looking through to see how it all works and it's great, taught me a thing or to about inis, and the rest. However it is not showing me the levels when I go to the map screen, I think I might be having troubles with the overlay redux extention as well. What do I do? Or am I just simply not using the program the right way?

I mean I beat a level, type in 5, and go Map and it goes to the map but it's all just black.

 
theonecardgame.com
   

Post Reply



 



Advertisement

Worth A Click