• Advertisement
Sign in to follow this  

Making a game map viewer class thingy

This topic is 4376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been working on an online game and have just recently conquered the network portion of it. My next step was to work on the actual game 'map' the character would be wandering around in. Now I know this part is normally fairly easy, and is well-documented, but I wanted to get some actual developer feedback before I started. Here are the game/design parameters: 1. It's a C# Windows forms app, and the map would most likely be placed/displayed on a panel control. 2. I'm looking for a standard grid-style game map, so I'll be using a 2-dimensional array, probably 100x100, that displays somewhere around 15x15 or 20x20 grid spaces at one time. 3. I'd like to track units within the grid spaces as well, mostly to keep track of different movement rates between different characters. For example, one char may have a movement rate of '30' while his opponent has one of '15', so one char is moving twice as fast as the other. I'd prefer to use actual units to show this by having a char move 30 or 15 units per second (or whatever unit of time) and move grid spaces based on that. My current thinking is that 30 units is roughly the space covered by an average person who takes two steps. 4. I'd like the map to center its display on the current played character (the char of the guy who loads up the client). So each client will see different views of the map. (Not hard, just thought I'd bring it up along with everything else) 5. The map is actually an arena where two fighters are in combat, so I'd like to add obstructions as well, things can block arrows/spells/ranged attacks, or force people to go around them. 6. Although I'd be happier with an isometric view, a very basic top-down view is just fine. Graphics are secondary at this point to demonstrating actual game-play. That's all I can think of at the moment. I'm not exactly looking for HOW to do this, mostly just things I need to be aware of, or tips/suggestions from people who have done this before, especially on Windows Forms apps. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Ok, trying this again. :)



I'm having issues with tracking the user in relation to the array that holds the tiles. I picture the viewer itself (which is a panel control in C#) as just showing a portion of the overall map, and I'd like to be able to redraw the map with the user at the center. So when I click on the map viewer (panel) I capture the mouse coordinates, and I'd like to find an easy way to translate those coordinates to the underlying array location. Once I have the array loc, I can probably use it to get the array loc of the top left corner, and redraw the map from there. At least that's what I'm thinking of doing conceptually. I'm having trouble turning it into code.

I DO have it working as just a map in and of itself, though. I can click on the map and my little player-image 'walks' to that location using a timer. So basically what I'm trying to do is expand the map beyond the boundaries of the panel and have it recenter.

Any ideas or thoughts on this?

Share this post


Link to post
Share on other sites
I only know how to do this with a top down view, not isometric:
Store the position of the player in world coordinates, for example measured in pixels.
From this and the view size, you can determine the "world window", the range of the world you have to draw (a rectangle with its dimensions measured in pixels).
Then you can determine which tiles to draw by taking the pixel coordinates of the rectangle's top left and bottom right vertices divided (not modulo, sorry) by your tile width/height.
Now you have the array coordinates for the corners, and you can draw the tiles. You'll need to displace them so that the top-left pixel drawn corresponds to the top-left corner of the "world window".

I'd also suggest adopting some sort of naming convention, so you can always tell whether a variable refers to world-coordinates in pixels, world-coordinates in tiles, screen-coordinates in pixels or something else. This will prevent lots of confusion.

[Edited by - Barius on January 26, 2006 3:12:00 AM]

Share this post


Link to post
Share on other sites
Thanks for the tip.

Yeah, I'd prefer isometric at some point, but top-down is just fine for now. I've just been having a problem solving the problem in my head before I start coding aimlessly, and that's why I was hoping to hear from other people who have done this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement