Game Programming and Development Tools

Java browser-based game thread 2.0 – jestermax

jestermax

Member

Posts: 1064
From: Ontario, Canada
Registered: 06-21-2006
Hey, does anyone have any good resources for making browser based games? I have a couple years of java experience under my belt but i haven't done much in the way of browser embedded programs.
I've used the GTGE game engine with java which is a blast but outside of that i've done very little game dev with it.
luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
Well, if you are referring to applets, its not that different than a normal application. The main differences code wise are :

There is no public static void main(String [] arg) method (at least your not forced to have one)
Your 'main' class must inherit from the applet class.

you can not save files (with the exception of cookies)
you can not go full screen
and some other security restrictions that I can't remember right now.

Although since you already have a few years o Java under your belt, I am probably answering the wrong question =D

------------------
"Do not condemn others for their ignorance, use it against them."
Scott E. Roeben

Realm Master

Member

Posts: 1971
From: USA
Registered: 05-15-2005
Holy crap!!! I was JUST learning the EXACT SAME THING in my java class!

Holy crap!!! Crap!!

Holy!!!

Holy crap!!!

dang, thats some coinidence. You need to inherit from the applet class, you don't have a main you have a init (spell check) and....

yeah, thats about all i know now...

I know I havea way to go...

------------------
yeah, im a little crazy

Blessed are those who suffer for doing what is right.
The kingdom of heaven belongs to them.-Matthew 5:10

PM ME YOUR DESCRIPTION OF ME! ILL PUT IT HERE!

Here's all the comments!

P.S. I HATE 640x480!!!!!!

jestermax

Member

Posts: 1064
From: Ontario, Canada
Registered: 06-21-2006
I know about applets (i will admit that i forgot about them when i asked this question, lol ) but i'm unsure as to their capabilities. When i took my java courses i learned the syntax and then i went into the hardcore stuff like datastructures and object oriented design. So i didn't actually learn ANYTHING about applets .

-Are the 2D/3D libraries half decent for applets? I wasn't very impressed with the java graphics stuff last time i tried but i didn't exactly go indepth.
-Can you add server support? aka, can i make a multiplayer game with it? (dumb question i know, but is there a lot involved?)
-Can you easily add keyboard/mouse input? (yes, another dumb question, i know you can but is there insane work involved?)

I'm a hardcore C++ programmer now as of a few months ago (i've spent every day since then coding C++) but i would be willing to use java if it meant i could make some stylin' browser stuff.

steveth45

Member

Posts: 536
From: Eugene, OR, USA
Registered: 08-10-2005
This page has tons of demo Java applet games that you can play and download the source for: http://www.homepages.hetnet.nl/~brianpostma/java.html . There's probably plenty in these source files to get you started. I did a simple Java applet "game" about 8 years ago as a freshman at the University for a class. It was my first OO language experience. I just knew C and BASIC at that point. It was a breeze. There is built in API functionality for loading bitmaps and drawing them to the window. You can get keyboard input and mouse clicks. You can get mouse movement as long as the mouse is over the applet. That was easy enough with Java 1.0... I'm sure the API has improved since then.

------------------
+---------+
|steveth45|
+---------+

luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
as far as graphics and GUI go, they are identical to what you would use for a real application, all the applet knows is that it has a rectangle of a certain width and height, and with the exception of no full screen porting from a true app to applet consists mostly of changing the public static void main(string [] args) method into a thread that inherits from the applet class (this is of course a bit of a simplification, but my point is that an applet is almost identical to an app in source code)

------------------
I reject your reality and substitute my own!

ArchAngel

Member

Posts: 3450
From: SV, CA, USA
Registered: 01-29-2002
well, Applets are designed for in-browser use, and you can use images and make animations, etc.

however, since it is java, it will run slower, so a more graphically "intense" program will be less feasible

------------------
"Patience, my good citizen, patience. It's bad enough to rob a man of his dream"
-Sydney Carton, Tale of Two Cities
Soterion Studios

luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
True, true.

But I have seen Full 3d software rendered applets (although a bit small) before; eg Scared at 'www.brackeen.com'

------------------
I reject your reality and substitute my own!

jestermax

Member

Posts: 1064
From: Ontario, Canada
Registered: 06-21-2006
oh boy...:S my friend and recently group member for a massive project has come up with the idea of making an applet MMORPG-style game. Ironically he hasn't been reading this posting and came up with the same idea as me, lol.

Anyways, i think to accomplish this we're going to use GTGE (the amazing java game engine i've been going on about). I know there's an existing applet MMORPG called Runescape or something like that that does rather well.
Can anyone direct me to some articles on useful topics like the networking aspect of this (client/server stuff) or database/servlet apps stuff (logging in users and saving game data)?

As much as i like java i'm beginning to no like the idea of using it, lol

HanClinto

Administrator

Posts: 1828
From: Indiana
Registered: 10-11-2004
I'm really intrigued by the possibility of making a Javascript in-browser game with something like Ajax. I don't like Applets because they never seem to work in my browser, but simple javascript like flyovers and whatnot always works -- can someone make a game using Javascript without it being in an applet? And using xml post requests, one could also in theory make a multiplayer game. Does anyone know where I would go to learn about this sort of thing?

Thanks!

--clint

jestermax

Member

Posts: 1064
From: Ontario, Canada
Registered: 06-21-2006
you and your newfangled gadgets
SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
Another great choice is to use g-java. The GameMaker-->Java converter. I believe it will convert all of the drag & drop commands from a GameMaker 6.1 file. There are several examples on-line of converted games into applets.

This may be a BIG help in understanding how to build a Java game. Although I have not used it yet myself, so I do not know how clear or easy the Java code is to read.

The registered version ($20) of GameMaker has multiplayer capability, but I am not sure if this code will actually get converted. If not, you can always use GameMaker as a start to get your Java code. Then integrate in some other API for the multiplayer aspect.

HanClinto, I don't think Javascript needs to be in an applet. Javascript is completely separate from Java. As long as you use the HTML 'script' tag with 'javascript', you can use Javascript in your HTML files. Or something like that. I don't totally remember off the top of my head. In any case, Javascript can be be run inside a plain HTML file. Or, perhaps you were asking something completely different.

HanClinto

Administrator

Posts: 1828
From: Indiana
Registered: 10-11-2004
quote:
Originally posted by SSquared:
HanClinto, I don't think Javascript needs to be in an applet. Javascript is completely separate from Java. As long as you use the HTML 'script' tag with 'javascript', you can use Javascript in your HTML files. Or something like that. I don't totally remember off the top of my head. In any case, Javascript can be be run inside a plain HTML file. Or, perhaps you were asking something completely different.

No, that's along the lines of what I was asking. I guess I'm wondering if there is enough functionality within Javascript to make a multiplayer game without it being a Java applet.

Thanks!

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
I see where you are going. I wouldn't think you can make a multi-player game with Javascript alone. It's an extremely limited scripting language. But I suppose with POST requests you can make a turn-based game.

With my EXTREMELY eensy, teensy knowledge of AJAX, it still doesn't seem like you can create any type of real-time MP game, but it may suit well for a turn-based game. You can request an update from the server and your screen will then update with the latest moves. Card games may work well for this.

jestermax

Member

Posts: 1064
From: Ontario, Canada
Registered: 06-21-2006
i'll give it to the .NET framework, they have a lot of very nice libraries and examples. Theres pre-made examples of SO many cool applications (i'm actually using part of one for a contract i've been working on).
I wish java had that sort of deal. Maybe it does and i've just never heard of it, but it just doesn't seem like theres many PROFESSIONAL examples for applications out there. I know theres several open source projects but a lot of them aren't that well done .
SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
quote:
Originally posted by jestermax:
i'll give it to the .NET framework, they have a lot of very nice libraries and examples.

So true. I pretty much stick to CodeProject (http://www.codeproject.com), but there are plenty more sites out there. One of these days I'll get around to writing some articles.

I'm sure there are similar sites for Java, but it's kind of funny. I never really thought about it until after reading your post. Most of my Java searching is related to understanding topics/concepts as opposed to my C# searching which is centered around how to actually DO something. Does that make sense? Kind of like finding out what a radio is, how it works, and maybe even what parts are used to make it (my Java searches) versus how do I actually build a radio (my C# searches)?

HanClinto

Administrator

Posts: 1828
From: Indiana
Registered: 10-11-2004
Thanks for the reply, SSquared! I know almost nothing about Java (I only know OOP concepts about it, no coding), so your knowledge is really helpful to me.

The turn-based thing might be all that I would need -- I'm envisioning doing an in-browser isometric walk-around game (sortof like an RPG except with only inventory -- no stats). I'm picturing a static bitmap for the background, then putting in all the players and items with individual items that can move around with normal Javascript animation. Players wouldn't need to see exactly when other players move, just that they moved. Lag of 3-5 seconds to see others players move would be fine -- I don't picture players being able to block each other from moving around, though maybe, I'm not sure.

I did some looking around, and I *really* like Cross-browser -- it's a large collection of Javascript routines that are designed to be maximally compatible with different browsers -- that's very cool to me. There are some great functions for animations, and this Inner Solar System example gives me a lot of encouragement that what I want to do might be feasible. There's a project called DutchPIPE that is doing a lot of the in-browser chat stuff that I want to do -- basically I just want to add isometric walking-around to DutchPIPE and that will be 90% of the game that I want right there. I just wonder if that would push Javascript too far to try and do that.

Thanks for all of your input on this -- I'm interested in knowing what you think about all of this.

Cheers!

In Christ,
clint

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
That solar system example is niiiiice.

Do you mean Java or JavaScript? JavaScript has absolutely nothing to do with Java and is rather improperly named. I know some stuff regarding JavaScript but not too much. I have done simple tasks like input validation, maybe pop up some message, I can't remember what else. I actually had NO IDEA how powerful JavaScript has grown. I really liked some of what I saw on that Cross-browser link. I will look at it more from home.

Java, on the other hand, I am much more familiar.

It sure seems you can accomplish what you want. Basically, you want some cross-browser technology that is not Java, C#, C++ based? DutchPIPE looks promising. I actually saw you on-line when I went there. You logged off and back on with a different avatar. :-) What type of technology does it use? How does it communicate? Again, I may check this out sometime from home.

HanClinto

Administrator

Posts: 1828
From: Indiana
Registered: 10-11-2004
quote:
Originally posted by SSquared:
Do you mean Java or JavaScript? JavaScript has absolutely nothing to do with Java and is rather improperly named.

Ah, right -- sorry. Yes, I mean Javascript.

quote:
Originally posted by SSquared:
It sure seems you can accomplish what you want. Basically, you want some cross-browser technology that is not Java, C#, C++ based? DutchPIPE looks promising. I actually saw you on-line when I went there.

Hah, yeah. I was on there and talked with the developer for quite a while -- he's a really nice guy. We were talking about adding an isometric front-end to it so that people could walk around and see each other walk around. You may be interested in seeing a super-simple ultra-cheesy example I did last night as a proof of concept:
Super-Simple Ultra-Cheesy Isometric Game Concept Thingy

DutchPIPE uses AJAX to do its communication with the server, and polls for new data every 2 seconds (though this is configurable). So I'm thinking that just as avatar changes and chat requests are sent, so x/y updates could be sent and displayed similarly to how my isometric concept thing works. When a player is moving, it will give him a walking graphic appropriate to his direction, when a player is stationary it will give him a static standing graphic.

Whaddya' think?

My next step is to get my own install of DutchPIPE up and running so that I can mess around with this stuff.

Cheers!

--clint

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
Looks like a great start. Let me know when you can add more people. I'd love to test it out.
buddboy

Member

Posts: 2220
From: New Albany, Indiana, U.S.
Registered: 10-08-2004
pretty cool... i'd test it out too. if you want me to.

------------------
WARNING:

RADIOACTIVE IE AHEAD!
--------------------
#include <spazz.h>

int name()
{
char name['B','u','d','d','B','o''y']

HanClinto

Administrator

Posts: 1828
From: Indiana
Registered: 10-11-2004
Well, it's not multiplayer yet, but I spent a couple hours learning DutchPIPE better and a little more time learning more about isometric game math, and have another demo that looks very similar to the previous one, but I think it's gotten enough improvement to warrant another post. Note how it now displays the isometric x/y coordinates in the upper-left corner, and there's a cursor that follows your mouse around. (please note that these demos only work in FireFox for now, I'll be making it work for IE soon enough)
http://includingjudas.com/clint/vbk/IsoTest4/IsoTest.html

Just thought y'all might like to see a little progress.

I've got too many irons in the fire right now, so I'm not sure how much time I'll put into this over the next few months, but I think this is something that I would like to continue working on as time goes by.

Cheers!

--clint

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
Quite intriguing. Sorry you won't have time for more research.

I don't quite understand the Y-coordinate. It does not seem to increment/decrement when I think it should.

HanClinto

Administrator

Posts: 1828
From: Indiana
Registered: 10-11-2004
Hey SSquared!

Does this picture clear anything up?

Basically, the x direction proceeds from the upper-left corner and proceeds down to the lower-right corner. The y direction proceeds from the upper-right corner and proceeds down to the lower-left corner. Since I don't know how high/wide my isometric map is for this game, I decided to not try and define limits but rather to define the tile at the upper-left corner of the screen as being at (0,0), and then moving from there. This means that the line of tiles moving down-right from the upper-left is going to be at y=0, and only x will increase. If you move closer to the upper-right of the screen, y will decrease (even going negative), and if you go to the lower-left, y will increase (going positive after crossing that center line).

It took me a looong time to figure all of this stuff out, even though if you look at the source Javascript, the functions to convert between isometric/pixels aren't that compicated. It just took me a while to understand and write is all.

Here is another great isometric tutorial that I found helpful.

I'm not saying I won't continue to find time to work on this, but Progress21 and other projects still have priority over this one. Still, this is a fun diversion and one that I think has a lot of potential for building a great Christian community site.

Cheers!

--clint

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
Thanks. That clears it up. I believe I had the numbers all shifted counter-clockwise by 1, making X/Y the complete opposite of how you have them. I should have realized my mistake.
CoolJ

Member

Posts: 354
From: ny
Registered: 07-11-2004
I stumbled upon this guys website a couple of weeks ago, he created a pretty good pacman clone using only javascript. He also has a doc explaining how to make your own javascript game.
http://www.masswerk.at/games_set.htm

I like his browser based linux like OS written completely in javascript too..he's good!

Jari

Member

Posts: 1471
From: Helsinki, Finland
Registered: 03-11-2005
Sorry for not reading this thread in detail so I might say something that is said already but I just wanted to say that javascript is indeed worth to try for a browser game. I have been learning and doing some browser game development with javascript and php. I made a simple text based adventure game in MUD style where you could move between areas by clicking links and buy/sell items to an NPC. Then I made a base for a board game which basically allows you to move piece from A to B. So it's definitely a good solution for those kind of games. There is also a open source project called phpRPG which is a turn based browser rpg engine that allows displaying a simple map.

By the way Clint, that isometric walking example of yours amazed me! If I understand correctly it uses ajax.

What comes to java and games, have you tried this 2D sprite/game engine?


------------------
2Co 7:10 For godly sorrow worketh repentance to salvation not to be repented of: but the sorrow of the world worketh death.

[VoHW] (Help needed) [Blog] - Truedisciple (mp3)

[This message has been edited by jari (edited July 12, 2006).]

HanClinto

Administrator

Posts: 1828
From: Indiana
Registered: 10-11-2004
CoolJ:
Wow! That link is great, thanks! That guy is very very good - I think his resources will be very helpful to me.

Jari:
That's great that you were doing some MUD work in JavaScript/PHP! That's exactly what I'm working on with this browser-based game.
"If I understand correctly it uses ajax."
You're close -- eventually it *will* use Ajax. At this point, it's offline and doesn't communicate anything with the server. Everything I've been doing on that isometric test has just been to build a simple framework that I could then interface with DutchPIPE (which is an Ajax MUD-type engine). My graphical engine is going just fine -- it's really simple, there's not much to it. So my next steps are to learn DutchPIPE better (it has an *excellent* manual btw), and to port my graphical example to a better library. Currently it uses the excellent X Library from Cross-Browser.com, but sadly that is LGPL and DutchPIPE is MIT/BSD. They're not incompatible, but I would like other people to be able to use my isometric thing, so I'm going to try to stay MIT/BSD. I think I'm going to try and use the Yahoo UI Library -- a very excellent library that's BSD, very featureful and is license-compatible.

So those are my two next steps. I really see the potential for building a great community site with these tools -- imagine opening up a website and all of the sudden you're brought into a game with almost no waiting, no signups, no plugin installations, no proxy/firewall reconfigurations, etc. Just boom -- suddenly you're chatting with dozens of other people from all over the world, in an expansive, flexible (yet simple) game environment. I really want to build a Christian community site with this. And then there will be minigames on there (much like your scripture-quizzing game, Jari) where people can get points and prizes and things, we can advertise for various ministries and give points and prizes for doing quests regarding them (such as filling out questionaires that can be answered by exploring their website, etc), and even giving out special items for participating in real-world activities such as Bible Bowl tournaments.

I think it has great potential - even moreso than Mite or Bible Dave or many of the other projects that I've got on my plate right now. That's why I'm cramming this project into my already oh-so-full schedule, because I think it could *really* go somewhere.

This wasn't my idea, but rather the idea of young friend of mine (he's 12) -- he and his parents enjoy playing Disney's Virtual Magic Kingdom, which is a wonderful game except that it's pure Disney marketing and doesn't promote many good things that it could promote.

Maybe that gives you all a little bit of the idea that I'm envisioning here.

Cheers!

--clint

[This message has been edited by HanClinto (edited July 12, 2006).]

HanClinto

Administrator

Posts: 1828
From: Indiana
Registered: 10-11-2004
Okay, I guess I've officially hijacked this thread now. Jestermax, I hope you don't mind.

So I did a fair bit of work on the web-based isometric game example. Now the pirate's sprite changes, and there is some rudimentary path-finding so that the pirate will walk from square to square as he goes to his destination.

Also, it's fixed so that it works cross-browser in IE and Firefox now (though I'm having issues with some older versions of Firefox, the latest one works just fine).

Here's version 9!

The next (quite large) step is to integrate this into DutchPIPE to make it truly multiplayer. Not sure when I'll get that done, but I'm hoping I can do it somewhat soon. No promises though.

As always, would love to hear your feedback.

Thanks!

--clint

Jari

Member

Posts: 1471
From: Helsinki, Finland
Registered: 03-11-2005
Works in firefox 1.5, well done Clint.

------------------
2Co 7:10 For godly sorrow worketh repentance to salvation not to be repented of: but the sorrow of the world worketh death.

[VoHW] (Help needed) [Blog] - Truedisciple (mp3)

HanClinto

Administrator

Posts: 1828
From: Indiana
Registered: 10-11-2004
Thanks, Jari -- very glad to hear it.
buddboy

Member

Posts: 2220
From: New Albany, Indiana, U.S.
Registered: 10-08-2004
pretty cool Han... i like it.

------------------
WARNING:

RADIOACTIVE IE AHEAD!
--------------------
#include <spazz.h>

int name()
{
char name['B','u','d','d','B','o''y']