bukwus Posted February 27, 2011 Share Posted February 27, 2011 Hi I'm attempting to learn more advanced PHP, such as OOP and the integration of XML, by making a browser-based version of the old Richard Garfield card game "Netrunner". I have a few years experience with pretty basic (bordering on intermediate) PHP. I've done some very basic coding for the game with PHP forms and I've researched some OOP (classes, objects, methods, etc.) but I'm not finding the beginner tutorials that I need. Everything I find has terminology and code that is beyond me. Does anyone have any book or website suggestions for me? I've tried the PHP online manual, but even that throws in advanced stuff all over the place. My goal is to better learn how to use PHP (because I've already put time into it) to create browser based games. Many thanks, Andy Link to comment https://forums.phpfreaks.com/topic/229073-making-a-game-learning-by-doing/ Share on other sites More sharing options...
MattDunbar Posted February 27, 2011 Share Posted February 27, 2011 Make sure that you fully comprehend what OOP is first. Don't look for OOP tutorials specific to PHP, look for a definition or explanation of OOP not specific to any programming language. This works: http://en.wikipedia.org/wiki/Object-oriented_programming Now, learn the terms (read the ones that you aren't familiar with): http://en.wikipedia.org/wiki/List_of_object-oriented_programming_terms After doing all that, you should be ready for a php-specific tutorial. Link to comment https://forums.phpfreaks.com/topic/229073-making-a-game-learning-by-doing/#findComment-1180578 Share on other sites More sharing options...
BugsyV5 Posted February 28, 2011 Share Posted February 28, 2011 OOP really isn't that hard. It's all about classes and functions, and than referencing to it in another file. Link to comment https://forums.phpfreaks.com/topic/229073-making-a-game-learning-by-doing/#findComment-1180631 Share on other sites More sharing options...
bukwus Posted March 1, 2011 Author Share Posted March 1, 2011 Thanks guys. Here's what I've been playing around with just to get to know OOP a little better. I created a PHP file that allows you to create a visible table for each time you click on the "Create Table" button. It works fine, but I want to know if I should be putting more of this code inside the CLASS. Here's the code: <?php session_start(); class myClass { public $html = '<table width="50%" border="1"> <tr> <td width="50%" border="1"> Cell 1 </td> <td width="50%" border="1"> Cell 2 </td> </tr> </table>'; } if ((!isset($_POST['reset'])) && (!isset($_POST['createTable']))) { $_SESSION['tableCount'] = 0; } if (isset($_POST['reset'])) { $_SESSION['tableCount'] = 0; unset ($_POST['reset']); } if (isset($_POST['createTable'])) { $_SESSION['tableCount'] = $_SESSION['tableCount'] + 1; unset ($_POST['createTable']); } if ($_SESSION['tableCount'] > 0) { for ($i = 1; $i <= $_SESSION['tableCount']; $i++) { $obj[$i] = new myClass; echo $obj[$i] -> html; } } ?> <form action="class_lib2.php" method="post"> <p><input type="submit" name="createTable" value="Create Table" /></p> <p><input type="submit" name="reset" value="Reset" /></p> </form> <?php echo $_SESSION['tableCount']; ?> Any suggestions are welcome. Thanks... Link to comment https://forums.phpfreaks.com/topic/229073-making-a-game-learning-by-doing/#findComment-1181401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.