Page 1 of 1

The idea behind a game with navigation...

Posted: Fri Jul 11, 2003 4:17 am
by Drachlen
One thing i have thought about, is a php rpg type game... And of course, you have to be able to move your character around using some sort or north east south west system. The thing that im bringing up, is the idea behind all the different areas on a map. What im curious about is the method of achieving such goals as to giving each area or location or whatever you want to call it a unique and easily modifyable design(ex: 1,4(x,y) would be the entrance to a dungeon).. Would you add a row to your table for each location? 1,1 1,2 1,3 ETC, or is there an easier way of doing it? Has anyone ever done something like this, if so, what method did you use? I'm not sure if this belongs in advanced, but i figured id put it here because it is about a method, although its not as advanced as other posts here....

Posted: Fri Jul 11, 2003 10:36 am
by nielsene
I think it would depend on the game's needs and the database used.

Do you care about grid cells or only about rooms? Do all rooms/grid cells have at most four exits along the cardinal directions?

Grid based approaches, often end up using a triple-indexed array:
$grid["x"]["y"]["Dir"]=True/False (if you can go that direction from the current location) This allows very quick looksup for walls, etc. This method will commonly be supplemented by a $rooms list that associated given grid ranges with a room, used for placing objects,monsters, events, etc... Or you can just add fields to the grid if you need higher granularity for placing items.

Room-based approaches tend to be more of a linked list structure.
Something like $rooms["Room Index"]["East"]= 0 or new room reached
Method just places items/events directly like $rooms["Roome Index"]["Event"]=$event;

Regrading how to store it in a database. Well normally the map file for the whole game or a sub region will be loaded into memory and often isn't queried against in a database sense, so storing it a simple file is more common. However, if I really wanted to store it in a datatabase I suspect I would end up creating a user defined type in the database (that holds grid/room contents) and have a row for every grid/room that includes the exists.

But then again I haven't done any game programming in about 15 years and all my projects were relatively small, so these approaches may not make sense for a larger system.

Posted: Fri Jul 11, 2003 12:43 pm
by ayron
i used a 3-dimensional referencing system for an adventure game i wrote 15 years ago in atari basic, so you have up and down as well as eight directions.

i also toyed at the time with a fourth reference for "room" alterations but never got around to implementing it, although i didn't think at the time it would be particularly efficient...

Posted: Thu Jul 17, 2003 12:26 am
by Gen-ik
The best thing to do In my opion is to site down with a pen and notepad and work out how everything is going to work before you start on the coding side of things.

I used to work for a video game development company (acclaim) and every game is down on paper before it is programmed.

I'm in the middle of building an RPG at the moment with Flash and PHP... which is multi-player and real-time, and the MySQL database I'm using is an essential part of the whole thing.

I guess it all boils down to what you want the game to do.. or want the player to do in the game.

Posted: Mon Jul 21, 2003 3:39 am
by Gleeb
Here's a far better way to do it than your typical 'grid'...

References ;)

Lets say I'm in room 1250, and I want to go north. I hit north, and it looks at all exits for one called north. It then looks up the room number for the exit north, and puts me in room 1256.

That is... unless you plan to use graphics and a map...

Posted: Mon Jul 21, 2003 7:23 am
by Gen-ik
[quote="Gleeb"]Here's a far better way to do it than your typical 'grid'...

References ;)

Lets say I'm in room 1250, and I want to go north. I hit north, and it looks at all exits for one called north. It then looks up the room number for the exit north, and puts me in room 1256.quote]

To need grids.. or some sort of x,y,z reference system.

Doing what was suggested above by Gleeb would work if you just wanted rooms, and didn't want any movement within the room, didn't want any objects in the room, and didn't want any enemies etc in the room.

Unless of course you are planning just to make one of those ancient text-based type RPG games.. "You're in a room facing north. There is a monster"... "Hit monster with stick" ... "Monster cries" ... "Hit monster with stick again" ... "Monster rips your head off" ... "Game Over"

Posted: Mon Jul 21, 2003 7:26 am
by twigletmac
Totally OT:
Gen-ik wrote:Unless of course you are planning just to make one of those ancient text-based type RPG games.. "You're in a room facing north. There is a monster"... "Hit monster with stick" ... "Monster cries" ... "Hit monster with stick again" ... "Monster rips your head off" ... "Game Over"
:lol: I used to play one of those but it had a graphical interface as well so you could see where you were going and there were lots of x's and #'s to represent monsters.

Mac

Posted: Mon Jul 21, 2003 10:50 am
by Gen-ik
haha that's cool :D

I'm actually in the middle of creating one as a sort of retro-mixed-with-modern-technology idea. Basically it's a retro RPG but multiple-players can be in the same 'world' and the actions of each player directly effect the 'world' of the other players.

You can also meet, chat, and 'see' the other players as your going along.. should be interesting.

Let me know if you want to have a go once it's up and running and you can help out with the beta-testing :)

Posted: Mon Jul 21, 2003 10:02 pm
by Drachlen
Well i was thinking having a table called world... 2 main fields would be X and Y... I was also thinking i could have 4 fields in it called N E S W, setting them at 0 if you cant go that direction, 1 if you can. Then using 4 ifs to check if you can go a direction. This would only be used in certain areas like inside of a tavern or something like that. And so you cant fall off the world, it checks if the X or Y is 0 or whatever is the edge, and disables that direction. So if you wanted to go north:

Code: Select all

<?php
if($fetch[N] == "1"){
echo "<a href=?x=" . ($fetch['X']) . "&y=" . ($fetch['Y']+1) . ">Go north.<br></a>";
}else{
echo "You cannot go north.<br>";
}
?>
And just to prevent people from cheating and typing in the exact coordinates of the location, each time it would make sure the previous X and Y was 1 box away.. But that could end up being alot of rows, and alot of constant database usage.. I've already got a working movement system, i put together a few zones(areas, coordinates, whatever) and it seemed to be working fine, but with more than 1 person could it be a bad solution?

Posted: Tue Jul 22, 2003 12:28 am
by Denzo
maybe make some classes and and put all your rooms in a db. then do something like go north Y+1 and you got 0,1 if that coordinates dont exists in the db then you cant go north etc.

and just check if it isnt way from the users current position. then the cheaters cant try.

Posted: Tue Jul 29, 2003 3:39 am
by warfleet
I wrote warfleet.com it has a map engine that was written to render on the client using javascript and its VERY VERY fast. (if you register and go to a map screen and view html source you will see what I mean. The engine could easily be adapted to an RPG (I have tried to see b4 if ppl were intrested) I am thinking of making my game open source -- but I spent like 3 years writing it - and I guess I am only human cos I don't have a real reason to do so at the mo. I am probably driving some puritans nuts when I say that. Though maybe not :-)

praps you can IM me or mail me (I am new to this forum) since I have a lot of experience in these matters now. Many many hours banging my head anyhow! I could praps post you privately my route finding algorithms.

PS: I know I am new here on this forum- but I am not BSing you at all

Posted: Tue Jul 29, 2003 8:41 am
by qartis
Hey, that's a pretty nice game :)

IE6 only? That's.. 40% of web traffic? From what I saw of your game, Mozilla can do all that and more, with just different syntax. Consider making that your next improvement: port it to mozilla, opera, netscrape, and I'll be happy :)