School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

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




Creating Browser Game:

 

Creating Browser Game:, Ambitious Programmer Willing to Work.

Sonastylol

15 Oct, 2008 - 03:45 AM
Post #1

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 149


My Contributions
Hey guys,

Before I ask my question, understand that I know MySQL and PHP, and can manipulate data in a database, as well as handle all account and user information/variables(stats), and other features I may need.

I used to play a game called Virtopia, hosted on Petz.Pokemonvillage.com
I am linking an image of the game. EDIT: Image Size Increased.
IPB Image

Basically, the game allows you to create a character of a certain type, move around in a field by clicking directional arrows which would relocate your position on the field (and refresh the JAVA Applet. I THINK this is a java applet game, but I played it when I was 12-13 (I'm 21 now).

No matter where you were on that particular map, you could click the buildings to enter them -- shops, arenas, bank, etc. The map was made up of tiles I believe, with buildings placed all over them. Moving your character up down left right or however would KEEP you on this map, just move you from an enemy, unless you were on the edge of the map--in which case you would be brought to the next "zone".

How can I go about making a game in a java applet that was embedded into the website that can talk to a database?

I wouldnt mind making 1 circle character, one square building, and learning slowly while the character is in a white field.


Some things I understand:
-Positions are stored as X,Y coordinates in the database.
-Every time the Java applet reloads, which would be from clicking a direction button, entering a building, or clicking to attack an enemy (which also randomly spawned in the zones with an X,Y coordinate, your character's (new) position would be retrieved from the database and loaded on the screen.
-All stat/attribute changes are simple formulas that get stored through an Insert/Update MySQL query through PHP(unless Java can do this too).


Where do I get started? I am eager to start learning how to do this databse connectivity Java stuff.

I know 3 years of college Java, decently proficient in MySQL and PHP.

Another Game Screen
IPB Image

This post has been edited by Sonastylol: 15 Oct, 2008 - 03:49 AM

User is offlineProfile CardPM
+Quote Post


Sonastylol

RE: Creating Browser Game:

15 Oct, 2008 - 03:52 AM
Post #2

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 149


My Contributions
I don't know why those images aren't showing up. Here are the URLS:
I put lots of effort into this topic, hopefully you can take a second to check out the images! biggrin.gif If there is a problem with these links, right click and press COPY URL from my images in my first post -- those images hosted on Imageshack.us

IMG1-Showing Interface:

http://petz.pokemonvillage.com/showpic.asp...092;sshot10.jpg

IMG2-Different Zone:

http://petz.pokemonvillage.com/showpic.asp...#092;sshot5.jpg

This post has been edited by Sonastylol: 15 Oct, 2008 - 03:53 AM
User is offlineProfile CardPM
+Quote Post

Sonastylol

RE: Creating Browser Game:

16 Oct, 2008 - 09:40 AM
Post #3

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 149


My Contributions
Bump. Took me a lot of time to type this all up, and its an interesting subject I'm sure others would like to learn as well.
User is offlineProfile CardPM
+Quote Post

girasquid

RE: Creating Browser Game:

16 Oct, 2008 - 09:51 AM
Post #4

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,628



Thanked: 53 times
Dream Kudos: 825
My Contributions
Typically, you'll get an initial flurry of responses because your post has no replies - once it has replies, it tends to 'drop off the radar' - so bumping it won't do you any good.
User is offlineProfile CardPM
+Quote Post

Sonastylol

RE: Creating Browser Game:

16 Oct, 2008 - 09:53 AM
Post #5

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 149


My Contributions
QUOTE(girasquid @ 16 Oct, 2008 - 10:51 AM) *

Typically, you'll get an initial flurry of responses because your post has no replies - once it has replies, it tends to 'drop off the radar' - so bumping it won't do you any good.


Right.. and I never got my "initial flurry of responses" and it already dropped off the radar.

So...bumping it was in good order.

User is offlineProfile CardPM
+Quote Post

Sonastylol

RE: Creating Browser Game:

4 Nov, 2008 - 11:55 AM
Post #6

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 149


My Contributions

Its been a long time and I never got any help on this. If you have some time to read my topic and help me out, I'd appreciate it! I need to know where to start.

I know PHP/MySQL, but im not sure how this game saved and moved your avatar across a 2d image map (and had monsters spawn on it as well).

Was this javascript? Where can I learn how to make a game that uses this map spawning system. Like I said in my first post, I think it would store your coordinates on the map (like map name and anywhere between (0-100, 0-100) (x,y)).

Thanks for your help. I would love to start!

Here is a large image of the game!

http://petz.pokemonvillage.com/showpic.asp...092;sshot10.jpg


This post has been edited by Sonastylol: 4 Nov, 2008 - 11:57 AM
User is offlineProfile CardPM
+Quote Post

modi123_1

RE: Creating Browser Game:

5 Nov, 2008 - 11:10 AM
Post #7

Suiter #2
Group Icon

Joined: 12 Jun, 2008
Posts: 1,760



Thanked: 72 times
Dream Kudos: 150
My Contributions
QUOTE(Sonastylol @ 15 Oct, 2008 - 05:45 AM) *

Hey guys,

Before I ask my question, understand that I know MySQL and PHP, and can manipulate data in a database, as well as handle all account and user information/variables(stats), and other features I may need.

I used to play a game called Virtopia, hosted on Petz.Pokemonvillage.com
I am linking an image of the game. EDIT: Image Size Increased.
IPB Image

Basically, the game allows you to create a character of a certain type, move around in a field by clicking directional arrows which would relocate your position on the field (and refresh the JAVA Applet. I THINK this is a java applet game, but I played it when I was 12-13 (I'm 21 now).

No matter where you were on that particular map, you could click the buildings to enter them -- shops, arenas, bank, etc. The map was made up of tiles I believe, with buildings placed all over them. Moving your character up down left right or however would KEEP you on this map, just move you from an enemy, unless you were on the edge of the map--in which case you would be brought to the next "zone".

How can I go about making a game in a java applet that was embedded into the website that can talk to a database?

I wouldnt mind making 1 circle character, one square building, and learning slowly while the character is in a white field.


Some things I understand:
-Positions are stored as X,Y coordinates in the database.
-Every time the Java applet reloads, which would be from clicking a direction button, entering a building, or clicking to attack an enemy (which also randomly spawned in the zones with an X,Y coordinate, your character's (new) position would be retrieved from the database and loaded on the screen.
-All stat/attribute changes are simple formulas that get stored through an Insert/Update MySQL query through PHP(unless Java can do this too).


Where do I get started? I am eager to start learning how to do this databse connectivity Java stuff.

I know 3 years of college Java, decently proficient in MySQL and PHP.

Another Game Screen
IPB Image




This all is covered in any basic 2-d tiled game tutorial. Yes there are some language specific things that you will have to translate (programming languages that is), but it's all out there.

http://www.google.com/search?hl=en&q=2...mp;aq=f&oq=

Regarding talking to a database.. wow.. okay.. I am not sure if you realize but a regular java app connecting to a database is no different than a java video game connecting to a database.

http://www.google.com/search?hl=en&q=j...base+connection

You will need:
1. a place that hosts java applets.
2. has a database you can connect to. (I guess Mysql in your case).

I would google those for you as well, but that might ruin my flow here. Find a webspot that does that and you are off and running.

Regarding your interacting with the database - that is all handled in the java code. No php needed. The webpage hosting the app should do pretty much nothing besides host it.. there is no need for it to connect to the database. I'll stress that again - the java code will have to handle the connection to the database.

In short - any 2d tiled game tutorial will help you. I spottted the grip of Java based ones. Java will handle the database connections and interactions. Throw PHP out of that loop. Java will handle the applet refresh (not the whole page) and do all the image transfers.

QUOTE(Sonastylol @ 15 Oct, 2008 - 05:52 AM) *

I don't know why those images aren't showing up. Here are the URLS:
I put lots of effort into this topic, hopefully you can take a second to check out the images! biggrin.gif If there is a problem with these links, right click and press COPY URL from my images in my first post -- those images hosted on Imageshack.us

IMG1-Showing Interface:

http://petz.pokemonvillage.com/showpic.asp...092;sshot10.jpg

IMG2-Different Zone:

http://petz.pokemonvillage.com/showpic.asp...#092;sshot5.jpg


Please tell me a post on the internet wasn't "lots of effort" for you. If so I weap for the younger generations. (You can thank my work's mercs for that nerve you just hit on. )
QUOTE(Sonastylol @ 16 Oct, 2008 - 11:40 AM) *

Bump. Took me a lot of time to type this all up, and its an interesting subject I'm sure others would like to learn as well.


Now this is where things turn south. I'll supress the desire to yell "four minutes is a long time?". Much like most things on the internet - regardless of the time spent writing it doesn't mean it has value.

QUOTE(Sonastylol @ 16 Oct, 2008 - 11:53 AM) *

QUOTE(girasquid @ 16 Oct, 2008 - 10:51 AM) *

Typically, you'll get an initial flurry of responses because your post has no replies - once it has replies, it tends to 'drop off the radar' - so bumping it won't do you any good.


Right.. and I never got my "initial flurry of responses" and it already dropped off the radar.

So...bumping it was in good order.


You had 119 views... it clearly wasn't off the radar nor off the first page.

QUOTE(Sonastylol @ 4 Nov, 2008 - 01:55 PM) *

Its been a long time and I never got any help on this. If you have some time to read my topic and help me out, I'd appreciate it! I need to know where to start.

I know PHP/MySQL, but im not sure how this game saved and moved your avatar across a 2d image map (and had monsters spawn on it as well).

Was this javascript? Where can I learn how to make a game that uses this map spawning system. Like I said in my first post, I think it would store your coordinates on the map (like map name and anywhere between (0-100, 0-100) (x,y)).

Thanks for your help. I would love to start!

Here is a large image of the game!

http://petz.pokemonvillage.com/showpic.asp...092;sshot10.jpg


*sigh* such the emo response. My help above should be sufficient.

Answering your line by line:

You start with java and mysql.

PHP is not needed.

The game data is saved to the database via JAva.

The character movement is a character drawn on top of the background tile. Any 2-d tiled game tutorial can explain that. Keyboard events in java are well documented.

Monsters spawn from the code. The is probably a set timer that goes off which spawns them.

This was not java script - just java.

You learn how to make it via a 2-d tile tutorial.

The coordinates are an x,y point in memory. It's a variable in the java code you write ot make the game. Pretty basic stuff.

When it saves the data sure.. it probably saves your information.. the map name.. and your location on that map.



I am a wee bit tired of self entitlement today (you can thank my mercs at work for that one). Don't complain about it being snippy nor snotty. Just be happy someone told you something. This thread better not turn into a 'givez meh da codez' request either. I give it about five hours of actual work to get it done... that's including the research on java/mysql connections, java keyboard commands, and basic java 2-d tile drawing techniques.

Happy coding. I would be interested in seeing what you get done.

Oh, and one minor after thought - make this a single player NOT ONLINE proof of concept first. While I was refering to what you will need to make a mockup of this game I had no intention of you actually doing that complicated part first. Make the game a local game first.. then worry about it getting on line.

This post has been edited by modi123_1: 5 Nov, 2008 - 11:16 AM
User is offlineProfile CardPM
+Quote Post

Sonastylol

RE: Creating Browser Game:

5 Nov, 2008 - 04:37 PM
Post #8

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 149


My Contributions
modi123_1, that was a diesel post. Probably THE most diesel post I have ever seen. That was like a reply on 'roids. blink.gif I applaud you good sir, how could I EVER yell at you for being snotty! tongue.gif


I have a few questions to clarify and comments before I get started.
If you could find the time, it would be fantastic if you could confirm or deny these questions/comments.

1) You mentioned needing to find a web host that can support SQL databases. I already have a host that wonderfully supports my other database projects, and I would consider myself decently proficient in PHP and SQL (although I won't need PHP unless I plan to display some character info on the website), so I shouldn't have many problems here.

2) I have been instructed to learn about JAVA Applet 2d Tile Gaming and JAVA's ability to connect to my database. I will definitely check it out, and this is a direction I can definitely take with the game, although the game was not originally 2d tile-based -- I can make it my own.

3) [[Probably the most important]] You mention near the end that it is important to get this game working in a single-player perspective before worrying about getting it multi-player.
--I assumed you mean this includes saving the character and loading his position back into the game world, without worrying about displaying other people.

Is this the direction I want to go with the game? I was, I guess wrongfully-so, under the impression that unless a game is designed to be online and display 2+ characters' movement from the start, that it would be impossible to turn a single-game multi-player.


If you could address these statements for me, you would become even more-so appreciated in my eyes! Thank you so much
P.S - by effort I mean I didn't just randomly blab my thoughts into a topic in 1 min. or less, I meant I was posting carefully and really thinking about every thing I typed onto the screen. Doesn't matter much anyway, but you are right, it didn't take much "effort"! biggrin.gif

This post has been edited by Sonastylol: 5 Nov, 2008 - 04:38 PM
User is offlineProfile CardPM
+Quote Post

modi123_1

RE: Creating Browser Game:

5 Nov, 2008 - 05:57 PM
Post #9

Suiter #2
Group Icon

Joined: 12 Jun, 2008
Posts: 1,760



Thanked: 72 times
Dream Kudos: 150
My Contributions
QUOTE(Sonastylol @ 5 Nov, 2008 - 06:37 PM) *

modi123_1, that was a diesel post. Probably THE most diesel post I have ever seen. That was like a reply on 'roids. blink.gif I applaud you good sir, how could I EVER yell at you for being snotty! tongue.gif


Okay then. I had to hit up urban dictionary for that term.

QUOTE(Sonastylol @ 5 Nov, 2008 - 06:37 PM) *

I have a few questions to clarify and comments before I get started.
If you could find the time, it would be fantastic if you could confirm or deny these questions/comments.


Will do.

QUOTE(Sonastylol @ 5 Nov, 2008 - 06:37 PM) *

1) You mentioned needing to find a web host that can support SQL databases. I already have a host that wonderfully supports my other database projects, and I would consider myself decently proficient in PHP and SQL (although I won't need PHP unless I plan to display some character info on the website), so I shouldn't have many problems here.


Sounds good. As an aside, the character info can easily be show in java on a 'dashboard' view of the game or so.

QUOTE(Sonastylol @ 5 Nov, 2008 - 06:37 PM) *

2) I have been instructed to learn about JAVA Applet 2d Tile Gaming and JAVA's ability to connect to my database. I will definitely check it out, and this is a direction I can definitely take with the game, although the game was not originally 2d tile-based -- I can make it my own.


The images you shown looked awfully 2-d tile based.

QUOTE(Sonastylol @ 5 Nov, 2008 - 06:37 PM) *

3) [[Probably the most important]] You mention near the end that it is important to get this game working in a single-player perspective before worrying about getting it multi-player.
--I assumed you mean this includes saving the character and loading his position back into the game world, without worrying about displaying other people.


Saving the data yes. That should be high on the list. Character dispaly and movment.. also up there. Showing it to someone else's computer while you are moving the character on yours - low prio.

QUOTE(Sonastylol @ 5 Nov, 2008 - 06:37 PM) *

Is this the direction I want to go with the game? I was, I guess wrongfully-so, under the impression that unless a game is designed to be online and display 2+ characters' movement from the start, that it would be impossible to turn a single-game multi-player.


Yes that is the direction you want to go. Clearly you want to keep the multiplayer aspect in mind while you are writing it, but I have no idea what your programming background consists of (aside from what you mentioned). Code can always be reshuffled, recompartmentalized, and reworked. I have done this a few times myself. I got the proof of concept working on a single player and then translate that (since I built everything in objects) to a multiplayer fairly quickly.

Who ever told you that turning a single player game into a multiplayer game is impossible should be slapped. How do you think all the old school games did that? Doom was never meant to be a multiplayer game up front (well not the direct thrust of the game). That was just gravy on an awesome pile of brown demon corpses.

QUOTE(Sonastylol @ 5 Nov, 2008 - 06:37 PM) *

If you could address these statements for me, you would become even more-so appreciated in my eyes! Thank you so much
P.S - by effort I mean I didn't just randomly blab my thoughts into a topic in 1 min. or less, I meant I was posting carefully and really thinking about every thing I typed onto the screen. Doesn't matter much anyway, but you are right, it didn't take much "effort"! biggrin.gif


Have at it..
User is offlineProfile CardPM
+Quote Post

Sonastylol

RE: Creating Browser Game:

5 Nov, 2008 - 06:26 PM
Post #10

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 149


My Contributions
Awesome, Thanks!

Just to clarify, that wasn't supposed to look "2d tile-based". It is actually one solid image drawn in paint really fast to test out image maps. I created one image and put links on each building that ended with ?loc=1, ?loc=2, ?loc=3 to see if I could infact use image maps in the design of the game in order to communicate with the database through php where the players location is. That part seemed to work.


The hardest part for me is trying to grasp if it is possible to "spawn" images OVER an image map when a page loads. If I could load monsters onto the screen like that, I could bypass the whole real-time java movement altogether -- which would help immensely since I don't know java and having to learn all about java and applets would set me back a long time. I'd rather get really good at a few languages then keep relearning the basics of new ones sad.gif


whatsthat.gif On another forum I asked this same question, and my response was
QUOTE
You'd need to use a database to store where all the monsters are and such, then use a graphics package (most likely GD) to create the image on the fly, or just have a bunch of images you tile.


Would you be able to decipher that message? I'm not sure what that acronym stands for, but he seems to think that it is infact possible to have images get created over another image.

---I could also run some kind of code that checks the database for monster spawns (off a cron-job on each map) which will (when browser is refreshed) show a spawned enemy on the screen. If you are idle and someone else just returned from the item screen or whatever and sees the monster on his screen and attacks and kills it -- too late for you. Its gone now until the next spawn.
QUOTE
do you think this is possible, modi?


***EDIT**
After reading my post -- i realize I just blab a lot and never get my point across.

TL;DR
If it is possible to somehow have an image get displayed to the screen ON TOP OF another image -- I can wrap that up in a PHP if statement and only have the image display based on some check in the database. That is my ultimate goal.

This post has been edited by Sonastylol: 5 Nov, 2008 - 06:31 PM
User is offlineProfile CardPM
+Quote Post

nycynik

RE: Creating Browser Game:

6 Nov, 2008 - 06:55 AM
Post #11

New D.I.C Head
*

Joined: 4 Nov, 2008
Posts: 12


My Contributions
QUOTE(Sonastylol @ 5 Nov, 2008 - 06:26 PM) *

The hardest part for me is trying to grasp if it is possible to "spawn" images OVER an image map when a page loads. If I could load monsters onto the screen like that, I could bypass the whole real-time java movement altogether -- which would help immensely since I don't know java and having to learn all about java and applets would set me back a long time. I'd rather get really good at a few languages then keep relearning the basics of new ones sad.gif


Image maps are virtual templates drawn over an image to indicate hot spots that are clickable. If you wanted a very simple game that you click on the house and you go in, or you click towards the edge and it goes to the next map, that might work. But it would not be easy to include walking using an image map, i mean you cant base your whole game on an image map.


QUOTE(Sonastylol @ 5 Nov, 2008 - 06:26 PM) *

whatsthat.gif On another forum I asked this same question, and my response was
QUOTE
You'd need to use a database to store where all the monsters are and such, then use a graphics package (most likely GD) to create the image on the fly, or just have a bunch of images you tile.


Would you be able to decipher that message? I'm not sure what that acronym stands for, but he seems to think that it is infact possible to have images get created over another image.



The image you see on the web page, is the image, there is no 'painting' going on, by that I mean that the browser displays the static image that it is told to, and thats it, it stops. You must use javascript if you want the browser to load another image without refreshing the whole page, and that image could come from a continuously refreshing game world image on the server.

This would be one way to handle the picture on the page, but it means that you need a way to make the server create a new image each time you ask for it, or you need the server to keep refreshing an image on it's own.

This is just a background howerver. By that I mean, how would you find out that a monster hit the player? The server could tell, because its drawing the world, but how would the web page find out?



In short, if your skipping the java applet, and trying to keep things simple, I think this could work for you. It will get you to the point where you will have a online game that:

1) Allows players to log in and play
2) Has some multi player action (you will be able to see others on the map)

To start out, if you were to ask me, i would say, begin by finding a way to make the world display, i think you said you have something for that built alread? So now just make it refresh. A javascript that refreshes the image from the server on a timer will do that.

-Step 1: You make a PHP page that can return a image response, based on the world picture in the database. This means, look at the data in the database and determine what to show. Something like this "worlddraw.php" and that will use something like GD to draw the world, using the x/y location of the current player. You can have that info in the session, or you can have that info in the url. The url would be something like "worlddraw.php?playerx=5&playery=5". If you put it in the url, then you can keep refreshing w/o having to redraw the page. So this PHP page, that returns an image, will basicly be taking that x/y location and looking in the DB to determine where the player is, and then what things are on the map around the player, then it draws them, and returns the image.

- Step 2: create another html/php page with a javascript that constantly refreshes the image on a timer.

- Step 3: you post a url, and we check it out smile.gif Haha, actually the next step is to think about movement, that is how we would move around as players.

GLHF

-Edited to make clear.

This post has been edited by nycynik: 6 Nov, 2008 - 07:02 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 04:03AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month