Spectre Posted December 7, 2007 Share Posted December 7, 2007 Hi all, I'm trying to figure out a way to make a maze in PHP. Basically, a user would start at one of x entry places, and the maze would be navigated with 4 arrows (up, down, left, right) just simple text links'll do, and middle button/link for an action.... now I have in my mind the vision of the maze, with it being hard to navigate, with passages and drops in certain places using a rand or 12 lol. But I'm just trying to find out what may be the best way about it, I'm not an uber coder, I do bug fixes and code stuff for a few onlint text based games, but this is part of something i want t try but not sure where to begin and the logistics of it all, so any tips or ideas etc would be appreciated. Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 7, 2007 Share Posted December 7, 2007 Start simple then add to this: the simplest method to get started is have a table: User | Xrow | Yrow So example: 1 | 10 | 12 Now lets for now say limit X is 10 and limit Y is 15. What you do is 4 buttons in a form then do : If(isset($_POST['UP'])){ // query = X+1 If(isset($_POST['DOWN'])){ // query = X-1 If(isset($_POST['LEFT'])){ // query = Y-1 If(isset($_POST['RIGHT'])){ // query = Y+1 you get the idea then in a table make co-ords for dead ends: X | Y | recordid then do a simple if statement to check if user hits dead end firstly get users x and y and put them to $UserX and $UserY: //query *get user's X and Y another query: //query $check find row from dead ends table WHERE X=$UserX and Y=$UserY //if there is 1 row found then the user must have hit a dead end If(mysql_num_rows($check) == 1){ Die("you hit a dead end"); } Quote Link to comment Share on other sites More sharing options...
ikmyer Posted December 7, 2007 Share Posted December 7, 2007 how is the user going to visually see the maze... Images? It like a top view maze... or like the person would be "in" a corn maze Sounds interesting... interested to see what you come up with. Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 7, 2007 Share Posted December 7, 2007 how is the user going to visually see the maze... Images? It like a top view maze... or like the person would be "in" a corn maze Sounds interesting... interested to see what you come up with. That will get twice as complicated throwing images in .. i would start by plotting out the dead ends and general moving around the maze with a script first! Then apply the images once you got it fully working.. after all images are merely for eye candy.. Get the script to work first. Then worry about images second. Quote Link to comment Share on other sites More sharing options...
Spectre Posted December 18, 2007 Author Share Posted December 18, 2007 Thanks guys I've done a basic explore system before it's just trying to get it as a maze with certain randoms etc and features, to start off will be purely text based with the explore buttons and a on screen display of you are at "xx,yy" and any actions available if in the right place, it's just trying to get head around the dead end bits and rand starts etc was not working in my head lol, you know how it goes, works great in your head but then comes the logistics xD Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.