Page 1 of 1

Purebasic - HTML5 game engine

Posted: Sun Feb 17, 2013 1:56 pm
by eddy
Hi,
Yesterday, I took a look at PhoneGap to port a HTML5 game on Android and Windows Phone.
Shortly after, I wondered if Purebasic can build a game coded in HTML5 & Javascript.

So I'm developping a wrapper for MelonJS framework.
I chose MelonJS engine because :
- it supports a cross-platform Tile Editor
- it supports tween FX, collision, parallax scrolling
- it supports MP3 & OGG
- free & open source

I encountered some difficulties:
- create a local web server coded in PB (lack of examples but for the moment I use EasyPHP as web server)
- using a web debugger (CHROME debugger for my test)
- There's no cross-platform audio format (the launcher will need to convert audio files into MP3 and OGG)

How it works:
1- PB compile and run a web launcher
2- The launcher generate the HTML/JS code based MelonJS code template
3- PB start a local web server
4- PB open the HTML page in localhost mode

Below the first test code:

Re: Purebasic - HTML5 game engine

Posted: Sun Feb 17, 2013 3:16 pm
by eddy

Code: Select all

; ***********************
; HTML5 GAME TEMPLATE
; ***********************
XIncludeFile "MelonJS.pbi"
DisableExplicit

If InitWebApplication()
   
   LevelBackground0=PreloadWebResource(#PB_Any,"area01_parallax/area01_bkg0.png","area01_bkg0")
   LevelBackground1=PreloadWebResource(#PB_Any,"area01_parallax/area01_bkg1.png","area01_bkg1")
   LevelTiles=PreloadWebResource(#PB_Any,"area01_tileset/area01_level_tiles.png","area01_level_tiles")
   LevelMap=PreloadWebResource(#PB_Any,"area01.tmx","area01")
   
   If OpenWebPage("Purebasic Game - HTML5 & MelonJS",RGB(169, 195, 249))
      If OpenWebScreen(640,480)
         BuildWebApplication()
      EndIf 
   EndIf 
EndIf
Image

Re: Purebasic - HTML5 game engine

Posted: Sun Feb 17, 2013 8:34 pm
by Kiffi
Sounds interesting! Looking forward to further informations. :-)

Greetings ... Kiffi

Re: Purebasic - HTML5 game engine

Posted: Sun Feb 17, 2013 10:16 pm
by eddy
I'll share the include file in Trick'n tips later. (or github)

It's interesting challenge :mrgreen: but it's really big.

Re: Purebasic - HTML5 game engine

Posted: Wed Feb 20, 2013 8:53 pm
by zxtunes.com
html5 slows and eats your battery! :evil:

Perhaps the situation will improve when it is implemented in hardware acceleration Canvas.

Re: Purebasic - HTML5 game engine

Posted: Wed Feb 20, 2013 11:08 pm
by eddy
It's true.
Only recent browsers support GPU acceleration.

Re: Purebasic - HTML5 game engine

Posted: Wed Feb 20, 2013 11:50 pm
by LuCiFeR[SD]
must admit, this is looking interesting Eddy :P