Purebasic - HTML5 game engine

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Purebasic - HTML5 game engine

Post 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:
Last edited by eddy on Sun Feb 17, 2013 8:56 pm, edited 5 times in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Purebasic - HTML5 game engine

Post 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
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
Kiffi
Addict
Addict
Posts: 1503
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Purebasic - HTML5 game engine

Post by Kiffi »

Sounds interesting! Looking forward to further informations. :-)

Greetings ... Kiffi
Hygge
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Purebasic - HTML5 game engine

Post 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.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
zxtunes.com
Enthusiast
Enthusiast
Posts: 375
Joined: Wed Apr 23, 2008 7:51 am
Location: Saint-Petersburg, Russia
Contact:

Re: Purebasic - HTML5 game engine

Post by zxtunes.com »

html5 slows and eats your battery! :evil:

Perhaps the situation will improve when it is implemented in hardware acceleration Canvas.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Purebasic - HTML5 game engine

Post by eddy »

It's true.
Only recent browsers support GPU acceleration.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: Purebasic - HTML5 game engine

Post by LuCiFeR[SD] »

must admit, this is looking interesting Eddy :P
Post Reply