Author Topic: Best design choices?  (Read 1551 times)

Offline vizion

  • Level 7
  • *
  • Posts: 32
  • Reputation: +1/-0
    • View Profile
    • Riddle Contest of Dooooom
Best design choices?
« on: September 26, 2007, 10:07:25 PM »
Hello,

I've decided to start writing a game just for the fun of it and to learn more PHP. I just can't learn by coding something I don't like. Anyway, I'm not a complete n00b. I've already created an online puzzle contest in PHP and MySQL with most of the code written from scratch. I've been looking at the source code for a bunch of different games like Dragon Knight, Legend of the Green Dragon, phpRPG, etc. I now have a good idea of where to start but I still need some opinions on these questions:

1) Just about all of these games are coded in PHP 4 and MySQL 4. I learned PHP 5 and MySQL 5. I've already learned that a huge difference between MySQL 4/5 is that MySQL 5 won't accept empty default  NOT NULL fields. What are the differences I should be looking for from PHP 4 to 5? I don't want to use an idea from one of these old games and have it be the "wrong" way to do things in PHP 5.

2) Is it better to set up a template system or to just each script have its own HTML? Which is faster? What are the advantages and disadvantages of each style?

3) Is it worth using a lot of object-oriented PHP? Will it just make things needlessly complicated. I'm really interested in building the game for speed.

4) I'm planning to add an AJAX chat system. Is there anything else that AJAX might be useful for? I'm going for simplicity. There will be images and not just text but simplicity is still the key for me. I'm not looking to create anything like Nowhere Else and Beyond. For reference, I'm a grizzled 2+ year veteran of Kingdom of Loathing and that's the level of simplicity I'm looking for from the interface.

That's it. Any help you guys can provide would be appreciated.

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Best design choices?
« Reply #1 on: September 27, 2007, 03:45:45 AM »
2. A complete templating system isn't needed I think, just a simple header and footer template. The advantage of this is that you only have to edit one or two pages to change the layout. If you add the HTML on each page, you'd need to go through every single page to change the layout of the game.

3. Object-oriented is your own choice I guess. I don't know what impact it has on the speed of the site, but if you think you can do it ,and you want to write the game in OO, then go for it :)

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Best design choices?
« Reply #2 on: September 27, 2007, 11:09:13 AM »
1. Try to use PHP no lower than 4.3, I would go for 5 if possible, it might be slightly tiny bit faster in some cases :) As for MySQL 3 is OK, but use 4 if possible (there is one useful function that 3.x does not have). "MySQL 5 won't accept empty default  NOT NULL fields." that's probably not true, my old script works on 3,4 and 5 without any problems.

2. own HTML

3. No

4. You don't need it. Maybe for registration process to check if the name is already used.


My personal advice: Do not listen to people whose games have less than 100 players, your script will break down once you reach higher traffic volume, and/or your purse will break down to pay for the server that can handle it. Go for the simpliest and fastest solution.

Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Re: Best design choices?
« Reply #3 on: September 27, 2007, 11:47:40 AM »
@Chris, like that last advice :)

For templates, I always use a header.php and a footer.php as a minimum.

I would agree with Chris, use php 4.3.11 at least, php5 would be the best since that will one day be the standard I guess. 

I don't think mySQL matters a whole lot.  From what I have seen v3 is ok.  If you are going to export from v3 to v4 you will need to import to v4 with v3 compatibility.  All the scripts I have ran seem fine on v3,4 or 5.

Using OOP doesn't necessarily make things faster.  It makes things more complicated to me only because I didn't learn php that way.  This is your choice.

Pretty much the same thing that everyone else has said.  Best advice is to have a plan and stick to it.  Make notes and have a flowchart or a design laid out on paper.  Decide what things that are going to be included in your first release and stick to that plan.  Otherwise you keep adding things as you go and you get caught up in this endless design/coding phase that goes on forever and eventually you lose interest in the project and stop working on it.

Offline RangerSheck

  • Level 9
  • *
  • Posts: 45
  • Reputation: +3/-0
    • View Profile
    • Aethora, the Browser-Based Tactical RPG
Re: Best design choices?
« Reply #4 on: September 27, 2007, 01:51:36 PM »
My personal advice: Do not listen to people whose games have less than 100 players, your script will break down once you reach higher traffic volume, and/or your purse will break down to pay for the server that can handle it. Go for the simpliest and fastest solution.

Well, this wouldn't be a proper forum without some disagreement :)

Personally, I love OOP. The act of programming in OOP is more enjoyable to me, and that's what the deciding factor is for me. I used PHP and didn't do any OOP for 6 or 7 years, until I started getting into Java and Python, which introduced me to the beauty of OOP. Unfortunately, PHP is not the best language for OOP, so it can be painful. For the last couple of year most of my web development has been with Ruby on Rails (and a little python). OOP can make your code easier to work with if you know what you're doing. It can make your code a lot more clean and agile and it makes a complex design much easier to digest.

As far as Ajax goes, be careful not to pursue it just for it's coolness factor alone. However, if you use it the right way, it can be very nice. It can make the end user experience smoother and reduce the load on your server.

Chris has some valid points if money and/or performance is a concern. He runs a well-established game with a lot more traffic than I get. I got 42k pageviews in the past week, not including ajax requests (and there's a ton of ajax in my game); I'm right around 100 players active each day. My server is holding (for now) but I know it probably could not support the amount of traffic Chris gets now without adding more hardware.

I just feel that developing my game with those restraints wouldn't be worth my time. I get enough enjoyment out of it that I don't mind losing a little money to hosting costs. I also use my skills elsewhere, in other non-game applications. In these cases, flexibility and speed of development are more important than hosting costs. You may consider, is this game you want to build just purely for your own entertainment? Are you trying to learn web development (or programming in general) for purposes outside making a game? In the case that you plan to grow this way professionally, embracing new technologies and methodologies is highly beneficial.

Offline vizion

  • Level 7
  • *
  • Posts: 32
  • Reputation: +1/-0
    • View Profile
    • Riddle Contest of Dooooom
Re: Best design choices?
« Reply #5 on: September 27, 2007, 07:05:37 PM »
"MySQL 5 won't accept empty default  NOT NULL fields." that's probably not true, my old script works on 3,4 and 5 without any problems.

It's true. Your script probably gives those fields values when it runs. In MySQL it's ok to leave the default empty when you create your table but not ok to leave that field empty when a record is entered. In MySQL 4 you can leave the default empty and the field empty when entering a record. I ran into this problem when installing Legend of the Green Dragon. When creating an account the game doesn't fill in a lot of the fields which creates errors and stops execution. Switching those fields to NULL fixed the problem. There's documentation somewhere but I can't find it. You can try it out if you want though.

Anyway, I will be using PHP 5 and MySQL 5. I was just wondering about the differences between PHP 4 and 5. Is there something in PHP 4 that is done differently and better in PHP 5 that I should look out for?

Also, what do you mean by my script will break down with a lot of users? How do I prevent that. I seriously doubt that my game will beat the odds and become popular but I'd still like to code to be as strong as possible. This is just for fun and learning for me. I don't want to take shortcuts and produce halfass code. My real job is in medicine so programming is a hobby for me.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Best design choices?
« Reply #6 on: September 29, 2007, 07:40:55 AM »
You are worrying about nothing. I have installed 50 games that use 15 databases (mysql 3, 4.0, 4.1, 5) and 5 servers (php 4.1, 4.3, 5.0, 5.1). During this I have encountered only 3 compatibility issues, none of which was serious. If you are making just one copy of the game installed on one machine only, just forget, you will easily accomodate on the fly.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal