DeadlyAzn Posted March 28, 2012 Share Posted March 28, 2012 Is this possible? I have around 2 weeks for a computer science project and I want to do this in PHP. However, I have just started learning PHP, and since I'm so short on time I'm going to see if I can learn how to code this while learning basics of PHP. So basically, can anyone give me a simple and good way of starting this? I have no idea where to begin. I was thinking of doing rooms in a coordinate system with North, South, East, West buttons and a pick up item button and an attack button. So can you guys help? I would also like to know how to make buttons in HTML or anything that goes with Apache 2, I have no idea how that works. Right now I have PHP set up with Apache 2, so I can navigate to the file with the code in the browser and run the code. Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/ Share on other sites More sharing options...
DeadlyAzn Posted March 29, 2012 Author Share Posted March 29, 2012 Bump please, urgent help needed :'( Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332148 Share on other sites More sharing options...
scootstah Posted March 29, 2012 Share Posted March 29, 2012 Users should not "bump" topics that are still on the first page of the forums. If you bump' date=' you must provide additional information. If you resort to bumping, chances are your question needs to be re-thought and re-described (see Eric Raymond's "How To Ask Questions The Smart Way").[/quote'] We're not going to write it for you. Do you have a specific question or are you stuck on something in particular? Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332165 Share on other sites More sharing options...
DeadlyAzn Posted March 29, 2012 Author Share Posted March 29, 2012 Very good point. I am truly sorry. I meant, is there any way to create a system of coordinate points or rooms and access them and place things in them? Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332167 Share on other sites More sharing options...
KevinM1 Posted March 29, 2012 Share Posted March 29, 2012 Yes. We're not going to design it for you, however. That's beyond the scope of what we do here. What we do is provide help for specific problems that our members have at least made a token effort to address on their own. Do you have a PHP-specific question? Any code for us to see? Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332169 Share on other sites More sharing options...
smerny Posted March 29, 2012 Share Posted March 29, 2012 sort of just an idea that might work for what you are doing... could create a rooms db table with fields... if you want your building to be like 20x20 rooms, it could be pretty simple... could have a database with 400 rows for example... then you just kind of visualize that the northern row is 0-19, second would be 20-39, etc moving south 1 could be something like nextRoom = currentRoom + 20; moving north 1 could be something like nextRoom = currentRoom - 20; moving west 1 could be something like nextRoom = currentRoom - 1; moving east 1 could be something like nextRoom = currentRoom + 1; you could have fields within the rooms table (or bridged tables) that specify whether a room is accessible, or which sides its accessible from, or what items are in it, etc and obviously you'd have to check for edges.. like if a person is in room 0, 20, 30, etc.. they wouldn't be able to move west... this give you any idea on how you might want to start? Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332175 Share on other sites More sharing options...
DeadlyAzn Posted March 29, 2012 Author Share Posted March 29, 2012 Oh my god yes! Do you have any more information on these tables? Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332178 Share on other sites More sharing options...
Proletarian Posted March 29, 2012 Share Posted March 29, 2012 Or you could organize your database as "room references" where each row references a room file. That way you don't need coordinates and don't have to organize the rooms in a static field; i.e., you can build and connect rooms dynamically. Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332179 Share on other sites More sharing options...
smerny Posted March 29, 2012 Share Posted March 29, 2012 Do you have any more information on these tables? huh? mysql? not sure i understand the question Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332181 Share on other sites More sharing options...
DeadlyAzn Posted March 29, 2012 Author Share Posted March 29, 2012 Or you could organize your database as "room references" where each row references a room file. That way you don't need coordinates and don't have to organize the rooms in a static field; i.e., you can build and connect rooms dynamically. I'm confused. How do you do this? Do you have any more information on these tables? huh? mysql? not sure i understand the question How do I make db tables? Or what you mentioned? Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332185 Share on other sites More sharing options...
Proletarian Posted March 29, 2012 Share Posted March 29, 2012 You're probably going to want to learn how to use a database, like mysql. Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332191 Share on other sites More sharing options...
DeadlyAzn Posted March 29, 2012 Author Share Posted March 29, 2012 Oh man. How does that work? I was thinking about giving variables to every room and assigning values to them, and those variables would be items or people or bits of string that contain the story. For example, the "inspect" button would echo out "The surrounds are dim and gloomy." And the "take items" button would be "You take $string and $paper." And the attack button would check if the value of the npc in the area was 1 or 0, 1 for alive and 0 for dead, and would be like if $life = 1 then echo "You attack the dogs, and they run away." If 0, then "You don't see anyone to attack!". And if $life was still 1, then it would echo "You can't move in any direction, you are trapped here!". Also, do you guys have any idea on how you can have the player variable or something contain variables within itself? Like items, etc. Like, maybe contain $string, and the value of $string would be either "working" or "broken". Wow ok, this went really detailed, but its pretty specific, could you respond to these things? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332195 Share on other sites More sharing options...
DeadlyAzn Posted March 29, 2012 Author Share Posted March 29, 2012 Did I do something wrong? Hello? Is this not specific enough? Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332211 Share on other sites More sharing options...
smerny Posted March 29, 2012 Share Posted March 29, 2012 where you gonna get this data from? and store data? might want to research how to use php with mysql Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332213 Share on other sites More sharing options...
scootstah Posted March 29, 2012 Share Posted March 29, 2012 It sounds like you are trying to run a marathon before you can crawl. I think you need to take a step back, start learning the fundamentals of PHP, and then come back when you are ready. Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332310 Share on other sites More sharing options...
KevinM1 Posted March 29, 2012 Share Posted March 29, 2012 Exactly. Attempting to create something that works with this many moving parts (how should a room be represented? its items? its exits? player position?) when you don't know the bare bones basics of the language, and with a two week deadline, is just going to end in tears. Do something simple. Create a small guestbook or something that addresses the basics of form handling, database insertion/retrieval, and user registration/logins. Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332329 Share on other sites More sharing options...
DeadlyAzn Posted March 29, 2012 Author Share Posted March 29, 2012 Well right now I just want to know how to make a database or coordinate system. I have everything else read, I have a method of entering text and going to different files, right now I'm just very confused on how to do location. Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332354 Share on other sites More sharing options...
scootstah Posted March 30, 2012 Share Posted March 30, 2012 Sorry to be blunt but if you do not know how to create a database, you do not have the ability to do this. Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332532 Share on other sites More sharing options...
DeadlyAzn Posted March 30, 2012 Author Share Posted March 30, 2012 Alright so right now I'm just thinking about making 100 files, each name 1, 2, 3, 4, 5 etc and so forth, and giving each file code to move to which file depending on which action. This is lots of manual work but only way I can think of doing it. Also, is there some way I can check for what I entered in a text box and then run a code with an if statement depending on what word was inside it? Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332545 Share on other sites More sharing options...
smerny Posted March 30, 2012 Share Posted March 30, 2012 stop trying to do stuff right away... learn first... read through some php tutorials and stuff Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332553 Share on other sites More sharing options...
DeadlyAzn Posted March 30, 2012 Author Share Posted March 30, 2012 I told you, I already read through a lot of tutorials, i was thinking about doing an array to store items for the player. Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332557 Share on other sites More sharing options...
DeadlyAzn Posted March 30, 2012 Author Share Posted March 30, 2012 Can you please just help me figure out how to check for which words are entered? D: Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332561 Share on other sites More sharing options...
batwimp Posted March 30, 2012 Share Posted March 30, 2012 Did you actually follow along with the tutorials, or just read them? The reason I ask is, some of the questions you are asking are VERY basic and would easily have been covered in any number of beginning PHP tutorials. The gurus are here to help people along with specific tasks regarding PHP programming, but rarely (if ever) write code for someone. Usually it is understood that someone has done due diligence to find out as much as they can, try it out for themselves, and post their problem code here for everyone to look at. If you're saying that you have read through many tutorials and still don't understand the extreme basics, you may want to look into another programming language that more fits your thinking processes. I'm just thinking about making 100 files, each name 1, 2, 3, 4, 5 etc and so forth, and giving each file code to move to which file depending on which action. This is lots of manual work but only way I can think of doing it. This tells many of the regulars here that you don't understand the key components of PHP programming. It's a web-based language, and it goes hand-in-hand with databases (usually MySQL). Most tutorials on beginning PHP should eventually start including database implementation. I'm not an expert when it comes to databases (or PHP, for that matter), but I had to learn the database thing in order to make anything useful with PHP. The quote above also states that you probably don't know a whole lot about arrays, which is also a must-know thing in any programming language. (OK, you don't HAVE to know it, but most things won't be possible to program if you don't.) This is like walking into a garage and asking a mechanic how to start a car and adjust the seats, then casually asking him to rebuild the engine for you. OK. That being said, I will now step off my soapbox and give you some design advice (though I'm not going to teach you how to build database tables, implement a database, or build arrays; this would take WAY too long). I have built at least three of the types of game you want to make. I will tell you right now that you don't need to implement a database unless you want the player to be able to save their game mid-play. You can build everything you need with arrays, though it's not as fun. Technically, you could save player location and information in a flat file, but that's beyond the scope of my rant as well. Continued in the next post. Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332572 Share on other sites More sharing options...
batwimp Posted March 30, 2012 Share Posted March 30, 2012 Build a couple of multidimensional arrays (you can either hand-code them or pull the data from a database). One array is for locations on the map (I call them 'squares'), and another array for inventory (items). The first index of each array is a square number, so on a 10X10 grid, you would have 0 - 99 for square numbers. I actually print out a grid with the numbers in them, 0 - 99, upper-let to lower-right. So now every location has a number which is associated with the first index of the two-dimensional array. So $square[0][0] would refer to the upper-left-most square, and $square[99][0] would refer to the bottom-right-most square. The second dimension of the array is for meta information. I use [zero] for the square name ("City Hall"), [1] for the description ("You are standing in the center of City Hall. There is a pathway to the east and more of the city to the south"), [2],[3],[4],[5] are all used for North, South, East, and West, respectively. So $square[0][3] would be the square number you would get to if you went SOUTH of that square, so $square[0][3] = 10, and if the player went south, it would load up $square[10][0] (think of the squares on a 10X10 grid, starting at zero, the square to the south of square zero would be square 10. If you can't go that direction from a particular square, you just have zero as its index. So in the City Hall example, City Hall would be $square[0][2] = 0 (can't go north), $square[0][3] = 10 (you can go south, and it will take you to square 10), $square[0][4] = 1, $square[0][5] = 0 (can't go west either). Use this information as a starting point. If I have time in the future, I'll tell you how to implement the inventory and items array. But I'm going to assume, for now, that this information may be a little beyond where you are right now. Take heed of the others and DO (not just read) some more PHP tutorials. Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332578 Share on other sites More sharing options...
DeadlyAzn Posted March 30, 2012 Author Share Posted March 30, 2012 Thank you! I will carefully analyze your informatino since I don't understand it completely, and I'll do more tutorials now! Quote Link to comment https://forums.phpfreaks.com/topic/259906-making-a-text-adventure-in-php-very-basicbeginner/#findComment-1332587 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.