How would I go about creating a browser game?

If I have a template and know html what other code should I learn?

Page 1 of 1

11 Replies - 1333 Views - Last Post: 17 May 2010 - 04:56 PM Rate Topic: -----

#1 Guest_Travis Whitehead*


Reputation:

How would I go about creating a browser game?

Posted 15 May 2010 - 11:36 PM

I know how to use html and I have designed my own website (which I am quite proud of even though it's amateurish) for a text based browser game about the Warriors series by Erin Hunter. My website isn't online yet but I plan on getting a free host and buying a domain name. The game will essentially be a big Warriors roleplay, a giant fan fiction. I know quite a few of these have been done but I've tried most of them and they are all either built around forums or chatrooms and they are terribly disorganized where any user can post whatever they want whether it is or isn't relevant to the subject. I've also noticed that in these roleplays the creators make a separate thread or chatroom for each area of the camp/forest making it difficult to keep up with what's going on without checking every single thread/chatroom. That's why I decided I would make my own and top the other unsuccessful Warriors roleplays.

Here's what I need to know:
~What coding language should I use for something like this?
~Where can I find tutorials for something like this?
~How would I combine another code with html to pull it all together? (I've only semi-recently started designing websites and I haven't done anything like this so far...)
~How would I go about saving the data for players? (I plan on having everyone create an account for their character(s) so I would need to know how to store/access the data. Would I need to rent/buy a server?)
~How would I set up a messaging system on the site for players to interact? (In html I know how to insert forms but I don't know yet how to do anything with the information put into the forms. If anyone knows of any tutorials about this please link me to them.)

Here's what I can do:
~I've coded before. (Mostly in Lua, I know a decent amount of html, and I've read some C++.)
~I've taken two game design classes in the past. (Both fairly simplistic but I have general knowledge of coding and game design so I'm not hopeless.)
~I can create websites. This is fairly obvious as it's stated above but it does fall into this category.

Please push me in the right direction by linking me to any helpful tutorials and by providing any helpful information you've got. We all start somewhere right?

Is This A Good Question/Topic? 0

Replies To: How would I go about creating a browser game?

#2 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 942
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: How would I go about creating a browser game?

Posted 16 May 2010 - 06:12 AM

You might want to read this topic here on creating web based games. It is more geared to a mafia style game but the priciples are the same.

http://www.dreaminco...web-based-game/
Was This Post Helpful? 0
  • +
  • -

#3 Guest_Travis Whitehead*


Reputation:

Re: How would I go about creating a browser game?

Posted 16 May 2010 - 09:29 AM

Thanks, this looks like it will be really helpful. I have a question though. So would cron jobs be what you use to update your game? I was looking at the free web hosts that supported cron jobs but I found few.
Was This Post Helpful? 0

#4 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: How would I go about creating a browser game?

Posted 16 May 2010 - 01:07 PM

Quote

So would cron jobs be what you use to update your game?
It depends on how your game is implemented. Let's say you want an update (of something) every 5 minutes. You must either have a program running continuously, that keeps a timer. Every 5 minutes, the timer expires, and something is done. The other mechanism is to rely on the operating system (which is obviously always running). On NIX systems, there are cron jobs, and on Windows, it's the task scheduler. So at scheduled times, a program is run.

If you have really frequent updates, you want your long running process. You don't want to have the system running a process, and shutting it down, and starting it up again, and shutting it down, and ....

Usually the question comes up with PHP. So the way PHP is usually implemented is that you have a web browser making a request, the server handles that request by passing it over to PHP. PHP only runs in response to a request. For an analogy, imagine a store cashier, who is always sleeping unless a customer wants to buy something.

So, the only time you can have the cashier do something is when there's a customer who wants to buy something. No one says this is how you must design your game. But PHP is implemented like this. Hence, problems with doing anything other than quickly serving requests.
Was This Post Helpful? 1
  • +
  • -

#5 Whitellama  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 16-May 10

Re: How would I go about creating a browser game?

Posted 16 May 2010 - 01:58 PM

Thanks Oler1s that was really helpful. I like the simile of the cashier and PHP but I'm still not entirely sure I understand cron jobs. Would an example of a cron job be something like I wanted to add a feature to my site allowing players to be a badger so I would set up a cron job and schedule the update at midnight so the update application will run at midnight? Would my computer need to be on for this? Please clarify and thanks in advance.

(Oh yeah and if you didn't notice I made myself an account. ^_^)

EDIT:

Actually, I just figured out what a cron is from a site I found here.
So in this scenario I would use it for updates to my website, right? If I was in the same scenario stated above (where I wanted to update a new badger character feature at midnight)would my computer need to be on for that or is that something the web host handles?

This post has been edited by Whitellama: 16 May 2010 - 02:05 PM

Was This Post Helpful? 0
  • +
  • -

#6 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: How would I go about creating a browser game?

Posted 16 May 2010 - 03:09 PM

Quote

So in this scenario I would use it for updates to my website, right?
Fixed schedule updates, yes.

Quote

If I was in the same scenario stated above (where I wanted to update a new badger character feature at midnight)would my computer need to be on for that or is that something the web host handles?
Whichever computer is running the program needs to have the cron job or scheduler entry. If your computer has the updating program, your computer than needs to have the cron job, and needs to be on. Clearly, this is something that should be on a server, but you may not have a choice if you get some free webhost. Actually, low cost webhosts won't allow you to do this. But if your computer is the one that runs the job, then you need to ensure it is in on.

And how robust is your game? Will it fall apart, if for some reason, your computer isn't on (like you forgot)? Things to think about.
Was This Post Helpful? 0
  • +
  • -

#7 Whitellama  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 16-May 10

Re: How would I go about creating a browser game?

Posted 16 May 2010 - 08:09 PM

View PostOler1s, on 16 May 2010 - 02:09 PM, said:

Whichever computer is running the program needs to have the cron job or scheduler entry. If your computer has the updating program, your computer than needs to have the cron job, and needs to be on. Clearly, this is something that should be on a server, but you may not have a choice if you get some free webhost. Actually, low cost webhosts won't allow you to do this. But if your computer is the one that runs the job, then you need to ensure it is in on.
When you say "whichever computer is running the program" do you mean the update program? I've never really worked with web hosts, servers, MySQL databases, or cron jobs until recently (and I can't really call it working with them more like reading up about them.) Please clarify.

I've got another question too, what's the difference between a server and a web host? Would a server be something running from your computer rather than using a web host site? When you say server you're talking about a dedicated server right?

For the cron jobs I would just need a webhost that allows cron jobs right? I found a few of them that look like they might work. One of them is here. Do you think this would work? Is it a good enough bandwidth for what I'm doing?

I think it would be pretty helpful if someone just explained to me what role the servers/webhosts and the MySQL databases play in this whole thing. I think I understand cron jobs enough though so no need to explain that.

View PostOler1s, on 16 May 2010 - 02:09 PM, said:

And how robust is your game? Will it fall apart, if for some reason, your computer isn't on (like you forgot)? Things to think about.
I'm not entirely sure what you're saying here. Since my website isn't online and I haven't done much coding for the signup/login or the game yet it's not very far along. How would it fall apart if the computer went off? That may sound like a stupid question but like I said I'm not sure I understand how the servers and web hosts work together. Everyone has to start somewhere. Thanks in advance.

This post has been edited by Whitellama: 17 May 2010 - 07:36 AM

Was This Post Helpful? 0
  • +
  • -

#8 dsherohman  Icon User is offline

  • Perl Parson
  • member icon

Reputation: 226
  • View blog
  • Posts: 654
  • Joined: 29-March 09

Re: How would I go about creating a browser game?

Posted 17 May 2010 - 05:49 AM

View PostOler1s, on 16 May 2010 - 08:07 PM, said:

It depends on how your game is implemented. Let's say you want an update (of something) every 5 minutes. You must either have a program running continuously, that keeps a timer. Every 5 minutes, the timer expires, and something is done. The other mechanism is to rely on the operating system (which is obviously always running). On NIX systems, there are cron jobs, and on Windows, it's the task scheduler. So at scheduled times, a program is run.

There is a third option, and one which is well-suited to PHP: Lazy calculation.

In many (though not all) cases, the result of a periodic event doesn't matter until someone looks at it, so you can get away with just storing a timestamp for when it was last processed and then "catch up" whenever someone looks.

The classic example of this is regeneration (of health, mana, action points, whatever). You get injured and then you heal N hit points every 5 minutes. Setting up a timed process or cronjob to go around every 5 minutes, find everyone who's hurt, and add the healed HP back is generally kind of wasteful (as well as being ill-suited to typical PHP execution models). Most web games will instead keep a 'last healed at' timestamp and, each time a page showing your HP is loaded, check whether it's been more than 5 minutes since you last healed and, if so, do all accumulated healing (i.e., do health regen once if it's been 5 minutes, twice if it's been 10 minues, twelve times if it's been an hour, etc.) before displaying your health.

Of course, there are disadvantages to this method, such as not being able to email people or otherwise notify them as soon as they're fully healed. If the result needs to be known in real-time rather than deferred until the next time someone looks at it, then you do need to use cron or a long-running process to handle it.
Was This Post Helpful? 0
  • +
  • -

#9 Whitellama  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 16-May 10

Re: How would I go about creating a browser game?

Posted 17 May 2010 - 07:35 AM

Thanks dsherohman that's a good idea.

Remember guys, in my post before this one I've still got some unanswered questions...

This post has been edited by Whitellama: 17 May 2010 - 07:37 AM

Was This Post Helpful? 0
  • +
  • -

#10 Dannyboy997  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 64
  • View blog
  • Posts: 258
  • Joined: 17-April 09

Re: How would I go about creating a browser game?

Posted 17 May 2010 - 08:26 AM

For the server part of your questions:


A server is a computer that does only a specific task. A Web host is still a server but it's specific task is to either run a website or some sort of database system, etc..

What you need is a Web server, usually you wouldn't get a dedicated server because they cost to much. A usual free web host is a shared server with hundreds of people sharing it.

The best FREE one that I found was 000webhost

If you're willing to pay about $5 a month on a web server, than hostgatoris the right choice for you.

Both of these offer cron jobs, php, mysql, etc..


If you don't know how to store the users data, that's where MYSQL comes in.

MYSQL is a database system, that stores data. Using MYSQL with PHP is really easy.

Here is how a database is structured:

There are columns and rows.


The columns tell the system what is stored. EX: Username.

A row is the data that is stored. EX: John (for a Username)

This is how it would be structured:
-------------------------
ID | USERNAME | PASSWORD
-------------------------
1 | John | password
-------------------------


As you can see there is an ID, Username, and Password.

The purpose of an ID is so that every row is unique.

The Username is the users username, and same goes for the password.

This is how you would build your database.

But the rows and columns are in whats called a table, and a table is in a database.

You can have as many databases / tables / columns and rows as you want (depending on your host).

Free host (like 000webhost) limit on 1 database per account, and all sort of limits here and there.



If you search in google you'll find some tutorials on MYSQL and PHP.

LINKS: w3schools, Develop Php


You should use cron jobs for your game. It becomes really handy.

Hope this Helps!
Was This Post Helpful? 1
  • +
  • -

#11 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: How would I go about creating a browser game?

Posted 17 May 2010 - 09:31 AM

dsherohman said:

There is a third option, and one which is well-suited to PHP: Lazy calculation.
I should have mentioned this approach, but you covered it well. I should note one important issue you didn't bring up.

The update should be quick. This work is being done along with handling a request. It cannot add significant overhead. The work is being done when handling a request, and handling a request should happen as quickly as possible. So this janitorial update should not take a significant amount of time. Something like updating player turns is quickly done. Rank table updates are not (unless you make specific concessions).

Whitellama said:

When you say "whichever computer is running the program" do you mean the update program?
Yes.

Quote

I've got another question too, what's the difference between a server and a web host?
A server is a generic term. It means something that serves, or provides a service. That can be anything. A web host is specific. It's an entity (company, non-profit, your ISP, whatever), that runs web servers, and allows you to put websites on these servers.

Nothing says you must go to a webhost. You could certainly set up your own servers, and so on. Of course, you then need to be able to match technical expertise and hardware requirements (i.e. knowledge and money).

Quote

Would a server be something running from your computer rather than using a web host site?
No. A server indicates nothing about location. It's just the role it plays. A money lender indicates nothing about who is lending. Just the fact that the person is lending. The same applies.

Quote

When you say server you're talking about a dedicated server right?
I just mean providing a service. It can be implemented in any one of ways. Server just means playing that role. Doesn't matter who does it. Doesn't matter how it's done.

Quote

One of them is here. Do you think this would work? Is it a good enough bandwidth for what I'm doing?
Bandwidth shouldn't be relevant in handling cron jobs. There's no communication with the outside world. It's a purely internal update.

Quote

I think it would be pretty helpful if someone just explained to me what role the servers/webhosts and the MySQL databases play in this whole thing.
Scrap the notion of webhosts. Go back to a basic principle. You have someone with a browser going to a site (like example.com). So at example.com, there should be a computer. This computer should take that browser request, and give an appropriate response. That's all. Because the requests and response are using the HTTP protocol, we can say that example.com has an HTTP server or a web server.

Now consider your role as a developer. Every time a request comes in, you want your program (written in PHP) to handle that request. So the web server needs to be setup a certain way. Furthermore, you need a place to store data. Where could you store information? There's many ways to do this (file, memcached, etc.). But a really common way to store data is in databases. Let's take one database as an example. This is not true of all databases, just this particular database.

MySQL, which you probably are going to use, works like this. It's a separate program. Requests for data (or manipulating data come in). The program does its magic. Then it gives back a response. Notice how this sounds really similar to a web server. But because this server represents a MySQL database, we call it a database server. So your program uses a server to manage data.

A webhost is someone who just sets all of this up for you, for a price of course. You don't have to use a webhost. During development, you just have your own private setup to work on. You just need to download Apache, PHP, and MySQL and set them up. In my case, I have Apache, Python, and a number of more complex setups on my computer. Either way, my computer acts a server (providing different services, actually).

Quote

How would it fall apart if the computer went off?
I was just being hypothetical. You have a game that depends on a scheduled update. What happens if that update doesn't happen or is delayed? That's the hypothetical I was posing to you. You don't know the answer, but I hope you get the sense that it's an important issue to worry about. I just wanted to make you aware that there are things to worry about.
Was This Post Helpful? 0
  • +
  • -

#12 Whitellama  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 16-May 10

Re: How would I go about creating a browser game?

Posted 17 May 2010 - 04:56 PM

Thanks Oler1s and Dannyboy997. Both examples were helpful. The idea of a database being a table was really easy to understand too. I don't have anymore questions for now but I'll probably be back soon with more. Right now I'm going to go work on the login script and work on the MySQL database. (I'm using a tutorial here.)

This post has been edited by Whitellama: 17 May 2010 - 08:53 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1