Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Using GWT to go from Java to Java Script  (Read 3124 times)
0 Members and 1 Guest are viewing this topic.
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Posted 2011-10-03 00:53:15 »

I've recently been having a play with GWT. I've wanted to try it out for a while and Legends of Yore seems like a big enough project to really test it (if not for performance). So, after a short bit of hacking I've ported my engine on to the canvas/context stuff from GWT. Here's what came out:

http://www.legendsofyore.com/js

I'm pretty impressed with both performance and ease of use from GWT. I'm not sure if I'll go this way properly but it was certainly an interesting experiment. With all the hoo-hah about java in browsers at the moment it might give us another option.

Has anyone else tried this and got any results with more action based games - it looks to me like it'd be pretty possible.

Cheers,

Kev

Offline tberthel
« Reply #1 - Posted 2011-10-03 01:07:40 »

Yes.  Action games work now.  The performance depends on people having a new browser though.

You would be surprised how many people have 2 year old browsers that are still very slow for games.

Offline ra4king

JGO Kernel


Medals: 342
Projects: 2
Exp: 5 years


I'm the King!


« Reply #2 - Posted 2011-10-03 02:23:55 »

Oh wow! This runs beautifully on Chrome Dev!

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline JL235

JGO Coder


Medals: 10



« Reply #3 - Posted 2011-10-03 04:43:53 »

It runs very well in Firefox, but the screen is a little small.

If you increase the canvas size using CSS, but keep the width/height attributes, then it is scaled dynamically by the browser. This would allow you to make it fullscreen, but you would have to do this dynamically, so that the size ratio of the canvas is correct (perhaps with black bars filling in any empty space). You will also have to account for the scaling when getting the mouse location.

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #4 - Posted 2011-10-03 07:51:31 »

worked great for me
Offline Z-Man
« Reply #5 - Posted 2011-10-03 08:22:01 »

So that's what you were working on Wink Loads fine on my iPhone 4 I didn't play it any though. How long did it take you to get LoY from Java to GWT/JavaScript?

EDIT: Played around with it on my iPhone and the touch controls are a little wonky, but there's an iOS app so I assume the web version isn't targeted towards iOS.

Z Pointing
Offline theagentd
« Reply #6 - Posted 2011-10-03 09:35:10 »

Runs great on Chrome. I even zoomed in and played it fullscreen! Pixels the size of my thumb!
There does seem to be a "problem" with loot generation though... At level 7 I bought the treasure map from the farmer and found the treasure which contained 1000 gold and a level 73 Gold Ring. Uh... It has awesome stats, but I won't be able to use it for days of playing. >_>

Myomyomyo.
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #7 - Posted 2011-10-03 09:47:01 »

Yeah, it's sometimes a bit random, but thats ok - you can sell the ring for lots of cash Smiley

Kev

Offline gouessej
« Reply #8 - Posted 2011-10-03 10:14:16 »

Hi

It works fine on Firefox 3.6.13.

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #9 - Posted 2011-10-03 17:33:49 »

let me get this straight, would u need the JRE in order to run the game then? cause if not then this would be rather convenient....
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #10 - Posted 2011-10-03 17:38:46 »

Nope, no JRE.

Kev

Offline vyh

Senior Newbie





« Reply #11 - Posted 2011-10-03 17:54:05 »

Hi,
It work fine in Google Chrome 14.0.835.187 m
How long take porting Legends Of Yore(Engine/Game)?
Offline Gudradain
« Reply #12 - Posted 2011-10-03 22:05:31 »

Very impressive Kev!!

I think we should stop crying about the java plug in and applet and work toward using GWT. Will probably check it myself in a near future.
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #13 - Posted 2011-10-03 22:18:01 »

@vyh The game was unchanged. The engine took two evenings to port to it's current state.

Thanks for the feedback all Smiley

Kev

Offline quixote_arg

Junior Member


Projects: 1


Jengibre


« Reply #14 - Posted 2011-10-03 22:37:26 »

There's already a game framework that uses GWT for JS (among other target platforms), it's the one used by Rovio to make Angry Birds for the Chrome store, and aparently is being used by Three Rings as well (samskivert is a commiter): PlayN
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #15 - Posted 2011-10-03 22:44:21 »

Yep, it used to be called forplay - couldn't get it to work for legends tho.

Kev

Offline dezzroy

Senior Newbie


Exp: 10 years



« Reply #16 - Posted 2011-10-04 08:07:59 »

 Cheesy Very cute, Kev.

I did a project at work with GWT, CRUD app.. I was surprised you can do animations and stuff with GWT. It's pretty cool if you don't mind getting your hands dirty and testing a bunch of features.

How much of this is running client-side and how much server-side? I guess you just load media assets from the server in the beginning and the game basically runs totally client-side?
Offline zammbi

JGO Coder


Medals: 4



« Reply #17 - Posted 2011-10-04 09:39:48 »

Works fine in Chrome. Crashes in IE9 on startup:

Quote
SCRIPT5022: DOM Exception: INDEX_SIZE_ERR (1)
D82088EF1E55AEB3B6794A569DFCDE29.cache.html, line 1 character 1

Current project - Rename and Sort
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #18 - Posted 2011-10-04 11:17:54 »

It's all client side, just resource pre-load at the start.

IE9 is a worry tho.

Kev

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #19 - Posted 2011-10-04 11:20:29 »

It's all client side, just resource pre-load at the start.

IE9 is a worry tho.

Kev
You could always use Chrome Frame if IE really doesn't like it.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline ReBirth
« Reply #20 - Posted 2011-10-04 13:57:11 »

It took a very long time (more than 5mins) to create game. FF 3.6.14 WinXP ancient machine.
Does creating game have something to do with connection's speed? I thought all resources like images had been loaded at start.

Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #21 - Posted 2011-10-04 13:59:58 »

Nope, creating a game is just reading some XML files that are already in memory. Might have just been old machine with FF 3

Kev

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #22 - Posted 2011-10-04 18:26:53 »

hey, by the way registering does not owrk, my best guess is becasue ur using jboxes (if I remember that name correctly) whihc don't work in jscript I imagine
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #23 - Posted 2011-10-04 19:05:50 »

So, what's actually going on under the hood? Java source/bytecode cross-compiled to run on javascript, and java.applet.* emulated via JS canvas? Just how much of the standard java apis work and how much aren't available?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #24 - Posted 2011-10-04 19:54:26 »

Registering will work now.

I don't emulate java.applet - I use a custom API which is implement in java.applet for the applet version. I just reimplemented that API in GWT terms (same as for Android and iOS)

The standard SDK is hardly supported at all it's a bit of mess actually. I'm lucky(ish) that because I've been using XMLVM all along I use a very limited set of java anyway.

However, for me the JS route is mostly to get me to WebOS


Kev

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #25 - Posted 2011-10-05 16:25:04 »

Registering will work now.

I don't emulate java.applet - I use a custom API which is implement in java.applet for the applet version. I just reimplemented that API in GWT terms (same as for Android and iOS)

The standard SDK is hardly supported at all it's a bit of mess actually. I'm lucky(ish) that because I've been using XMLVM all along I use a very limited set of java anyway.

However, for me the JS route is mostly to get me to WebOS


Kev
Sorry, I mean "does GWT emulate applet" not whether you do.

So it sounds like GWT is an entirely different API then? And you 'just' reimplement the core Slick api on top of either Java2D or GWT? Does it give you access to WebGL at all?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #26 - Posted 2011-10-05 23:05:41 »

I'm not using Slick for this fwiw.

I haven't seen it exposive WebGL, that's not to say it doesn't. The 2D stuff I'm using gets acceleration anyway where possible.

Kev

Offline krasse
« Reply #27 - Posted 2011-10-06 13:39:41 »

I get that INDEX_SIZE_ERR stuff when I try to draw images that have a zero width or height in IE.
Might be something to check for maybe...

I was surprised to get my canvas project working in IE9 at all Smiley. You can check out my project here if you want to compare something. It doesn't use GWT, it is pure javascript.

Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #28 - Posted 2011-10-06 13:45:25 »

Got music and sounds working now.

Cheers,

Kev

Offline xinaesthetic

Senior Member


Medals: 1



« Reply #29 - Posted 2011-10-13 14:19:33 »

Hi,

Works great in Chrome, I got a little hooked...

I take it that being mobile-friendly is one of your goals with this, so I tried it out on my phone (Moto Defy), and while it works (which is cool) there are a couple of problems.  All of these only apply to the phone.

One is that every tap causes the whole canvas element to be momentarily selected, so you see a translucent orange rectangle over the whole game...
The first time I ran it it seemed to be stuck on loading, although I looked at the phone again a little later and it was done.  I tried it on a different browser and the loading showed steady progress and happened fairly quickly, I seem to remember it not handling going down to dungeon well at some point, but I just gave it another go and it seems ok.
Actually, it seems to just become unresponsive fairly randomly... so that's not good.
I tried to enable music and it didn't work.

FWIW, the first browser I tried was Miren & the next Boat; AFAIK they are both just different GUIs on the same Android Webkit engine, not sure.
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36

Riven (45 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!