Sign in to follow this  
rferk

How to code/design an area map for a first-person-view point-and-click game

Recommended Posts

My question is about how best to set up / code an area map for a first-person-view point-and-click adventure game (think Myst). I am working in python, but python-specific answers are not necessary - it's more about the general game/code design.

 

A bit of background first:

 

I am not a programmer, nor a game developer, and only a casual gamer. And yet...somehow I've gotten into a bit of coding with Python. It started simply, as a way to help automate GIS tasks for work. But the book I read to learn Python involved learning by making simple "games" (like hangman, blackjack, and such). Somehow, while watching my hubby play his RPG games, or playing myself, I found myself constantly thinking about how it was implemented in the background, and thought: wouldn't it be cool to do something like that.

 

Now obviously I'm aware of the fact that such a task would be WAYYY beyond me, but I thought it might be good to at least learn better OOP skills by making a (much more simplistic) game. Something more than just a card game.

 

I started out thinking that I would do an IF-like text-adventure game, but soon decided to try out pygame and make it more graphic. At the moment, my intent is for a (simple and small) point-and-click adventure like I remember playing as a kid. Because I don't think I'm ready yet for animating character sprites moving across a screen, I hope to do a first-person-view game like Myst and Riven (minus the animation). Thus, a given "room" or "location" would be a single image, and the user would navigate to a new "room" or "location" (and thus see a new image) by clicking on a right or left or forward arrow, etc.

 

I've got the basic GUI set up, and tested navigating from one room object to another successfully. But now I'm realizing that I'm not quite sure how to code in the full "map" of the area, with information about which "room" objects are adjacent to which (and in which direction). Ideally, I wouldn't have it hard-coded in.

 

At first I was thinking that I could use a simple array somehow the way one might make a tile map, and that I could organize the map in an external file like a csv, with each cell referencing a "location" object, then load it in to a "map" object. But I'm a bit stumped with the implementation. Is this actually the correct approach? How would I deal with "rooms" above or below another room? Is it better for adjacent room information to be coded in with each room, or to look for the reference to the room object in the map object, then use the map object to check for adjacency? Am I overly complicating things?

 

Any and all help is welcome, and I'm sorry if this is a "stupid" question with an "obvious" answer - I tried some searching first but was mostly finding tile-map stuff.

 

Thanks!

 

Share this post


Link to post
Share on other sites

Hi,

 

I'm far from being an expert, probably about the same level as you to be honest, but there is probably no real "correct approach". There may be approaches that fit what you are trying to do well, and approaches that may not fit it well.

 

You may want to think about XML as a way to store your level data, where you would store attributes about the room, some of which could be the exits/entrances, i.e.:

<room ID="1">
   <exits>
      <exit Dir="North" ID="2" />
      <exit Dir="East" ID="3" />
   </exits>
</room>

So the "Dir" attribute would be the direction of the exit in the room, and the "ID" attribute would be the ID of the room that the exit leads to...

 

I did come across this article here, which sums it up more eloquently than I ever could:

http://blogs.msdn.com/b/dowens/archive/2007/04/16/loading-map-data-from-xml.aspx

 

So after that you would have to read the XML file and store it in some kind of linked list or array (probably better if it's tiled) of Room objects to then use, as not all rooms will have exits in each direction.

 

Hope this helps in some way!

Share this post


Link to post
Share on other sites
Here's the magic of a game like Myst: you don't actually need to have locations that correspond to real spots on a map!
 
Instead, all you need to store is adjacency. Like ArrTaffer said, just keep track of each "location" (room, area, whatever you want to call it) and a list of areas on the screen you can click to get to other locations. I did this for a point-and-click RPG many years ago, and it works great.

The trick is in the visuals. Instead of relying on the game to convey that "Room A" is through the "Red Door" from "Room B", you just make it visual. Draw an imaginary rectangle around the Red Door on the screen in Room A's picture, and when the player clicks inside that rectangle, you load up Room B. The player will infer all kinds of physical spaces that don't even really exist. You can even do things like have "impossible rooms" that are bigger on the inside than the outside, and so on.

Since you're in Python, I'd suggest a simple dictionary. The key is the ID of the room you're in, and the value is a list of rectangles on the screen as well as where they "connect" to. Then you can load this from a simple text file pretty easily.

For clarification, I'd describe an area like this in text:

Room A
1
0,0,100,100,Room B
"Room A" is the name of the location (just one line of text, can be anything). 1 is the number of "exits" or "connections." Then there's the rectangle, and its "connection point", and you're done!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this