Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,672 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,170 people online right now. Registration is fast and FREE... Join Now!




Getting Started with a Text Based Game.

 
Reply to this topicStart new topic

Getting Started with a Text Based Game.

anow2
post 28 Jul, 2007 - 02:42 PM
Post #1


New D.I.C Head

*
Joined: 28 Jul, 2007
Posts: 10


My Contributions


I am looking at creating a Text based game, in PHP.
I just started learning PHP about 2 days ago, and I have so far, only created a Login/Register System, using MySQL.

I am not sure whether or not I am going to be tackling on this project by myself or with a friend of mine.

The game is going to be a Tycoon sortof game, where you build buildings, and can upgrade, etc. Closer to the road gives a bigger boost for more traffic. You could also vandalize other peoples property. (Bomb, Graffiti, etc.)

How would I go about starting my project?

Thanks,
-anow2
User is offlineProfile CardPM

Go to the top of the page

girasquid
post 28 Jul, 2007 - 10:10 PM
Post #2


Barbarbar

Group Icon
Joined: 3 Oct, 2006
Posts: 1,256



Thanked 14 times

Dream Kudos: 650
My Contributions


Writing your authentication system first seems like a good idea to me - it's generally the course I follow when I'm building something too.

Once you've gotten that part down, start with the simplest and least inter-linked part of the system. That might seem weird, but it works.

Let's say you have 2 options: letting players choose where to place a building, and letting players customize a building based on where it was placed. You'd probably want to work on the first segment first, and then work on the systems that required it afterwards.

That's the process I follow, though. Your mileage may vary.
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 29 Jul, 2007 - 03:50 PM
Post #3


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,062



Thanked 175 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


If you are really serious about this I would start by grabbing a pad and pencil and write down everything you want in the game and how things might interact with other objects. For instance you might want to define the building types, what kinds of buildings will you have? How much will they cost? Can they be upgraded? What type of people or what types of streets, how will the player make money etc.

It seems a bit boring, but thinking it all out and writing it down will make your programming easier. You will then clearly see what needs to be done before other steps by putting your ideas in a general outline of events (even a Gantt chart if you know what those are).

Once you have that done the coding part will be much easier and faster. You will stand a better chance of actually finishing it and getting it out there on the market for others to enjoy.

Oh and don't forget to put in a programming lab building to your game so that your players can have cool elite hacker like geeks into their city to solve the world's problems. wink2.gif

This post has been edited by Martyr2: 29 Jul, 2007 - 03:51 PM
User is offlineProfile CardPM

Go to the top of the page

NickyBoy
post 30 Jul, 2007 - 02:54 AM
Post #4


New D.I.C Head

*
Joined: 30 Jul, 2007
Posts: 1


My Contributions


Hello!
First of all I like announce you that i might do some mistakes in spelling. biggrin.gif
I'm learning PHP,MySql,Javascript,CSS and html.... And I wanna' make a browser game like anow2.
...but I have some questions.
1)Let's say my city have some resources and for example 1200 WOOD. And the villagers consume 60 wood/hour. How can I modify my database every second for all the players. It will take too long? Is there another way?
I have tried with php timer and... it dose'nt work.
2)I have read on other forums that the security is a big problem.
3)MySql is good enouth for suporting plenty of users?

10x,
NickyBoy
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 30 Jul, 2007 - 10:57 AM
Post #5


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,062



Thanked 175 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


QUOTE(NickyBoy @ 30 Jul, 2007 - 03:54 AM) *

Hello!
First of all I like announce you that i might do some mistakes in spelling. biggrin.gif
I'm learning PHP,MySql,Javascript,CSS and html.... And I wanna' make a browser game like anow2.
...but I have some questions.
1)Let's say my city have some resources and for example 1200 WOOD. And the villagers consume 60 wood/hour. How can I modify my database every second for all the players. It will take too long? Is there another way?
I have tried with php timer and... it dose'nt work.
2)I have read on other forums that the security is a big problem.
3)MySql is good enouth for suporting plenty of users?

10x,
NickyBoy


Yeah that is a bit of the tricky part but what is usually done is the setup of a what is known as a "cron job" (chronological job) on the server. It is a scheduled process which executes a script every so many seconds, minutes, hours, days etc.

For your example you would setup a script that calculates the rate of wood consumption (based on population, mills you have built etc) and then deduct that from their total. Now unlike desktop games where you could update every second or so, due to the work that may be involved to update hundreds and thousands of users this would be impractical. So what you would do is instead maybe set the schedule every 5 minutes or maybe every 30 minutes. If they are using 60 wood/hour, you may need to design the game so that your job runs every 30 minutes and subtracts 30 wood from the account.

This limitation is why you find many online games work on the idea of a "game day" where a game day may be an hour in real life. Their job will then run every hour and update gold, wood, stone, etc. I strongly recommend never setting up the scheduled job less than maybe 5 minutes because you will run into scalability issues later if your game becomes quite popular.

Below is a few links to an explanation of what cron jobs are (I am probably going to get yelled out by the *nix crowd for such simple sites but oh well). I hope they help push you into the right direction.

Cron job basics
Cron help site
Setting up crons (link to windows version as well)
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:06AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month