HTML5 / JavaScript ist starting to get useful

Previous topic - Next topic

Kitty Hello

Howdy,

the HTML5 port is getting into shape. I found some bugs and have a working demo now. See attached file.
Next step is to pack the resources from the Media directory into the html and then compress the output with a gzip option. But it's all no big problem anymore I guess.

It's a bit slow on my Opera browser. Maybe it's Opera, maybe another bug. It's using WebGL, btw.

One tiny bitter pill is there to swallow, though. The structured programming of GLBasic will have to be changed for HTML5. There's no way to write code like:
Code (glbasic) Select

WHILE TRUE
   PRINT "X", 0,0
   SHOWSCREEN

for JavaScript. It would lock the browser and that would kill the script soon.

So, GLBasic (V11) already supports a new mechanism for this (cross platform, of course).
The key is the GLB_ON_LOOP sub, and the command SETLOOPSUB, that are new.

Here's the HTML5 example attached as code:
Code (glbasic) Select

LIMITFPS 60
STDOUT "In main game now\n"
GLOBAL stary%[]
DIM stary%[300]
FOREACH y IN stary[]
y = -RND(400)
NEXT

// SETLOOPSUB "GLB_ON_LOOP" // - GLBasic V11 calls this at the END of "main"

STDOUT "finishing the main loop now\n"


@SUB GLB_ON_LOOP: // this is called by the framework after the "main" init module
LOCAL spd% = 0, x% = 0
FOREACH y IN stary[]
spd = bAND(spd+1, 3)
INC y, spd+1
PRINT "*", x, y
IF y>400 THEN y=-32
INC x
NEXT

PRINT "Merry Christmas, HoHoHo", 32,(1+SIN(GETTIMERALL()/10.)) * 64+60

SHOWSCREEN

ENDSUB





[attachment deleted by admin]

Wampus

Can't wait to play with this. Go Gernot!  :good:

bigsofty

Very cool stuff!  :good: I had a wee look at the produced Javascript too... :O
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Ruidesco


spicypixel

What's the effective overhead in Kb for a HTML5 project? For example would a simple "Hello World!" have 300Kb core js code regardless, more? less?
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

erico

aaaalmost there :)
this should open up a new dimension, I wonder what people here have in mind for it.

Great work Gernot! :booze:
I will try and get Papai Noel to deliver you some this year.

Now, if I get this right, a home page could then be programed with GLB right?
Should work on almost every browser but IE, right?

Really great to hear advancements on this front.
Congrats! :good: 

Hemlos

Looks and works great! Cant wait to give it a shot!

I noticed the fullscreen doesnt scale up, but it does fill the screen with a black background.
Bing ChatGpt is pretty smart :O

mentalthink

Uhhhhu!!! This it´s very very nice!!!

In Firefox for me runs very fine!!! super-smooth and quick!!!

backslider

Wow!

This is really nice, Gernot!
I can't wait for a Web GLBasic Game! :)

Show the monkey who the boss is. (only a joke) :D

jestermon

WOW. Perfect under Firefox. Smooth and fast. I can see network analysis and management front-end programs with hundreds of bells and whistles. Can't wait for it.

MrTAToad

#10
It doesn't seem to like Internet Explorer 9 unfortunately - just get "Downloading" and an empty box - so it looks like all browsers except that are supported :)

It'll be interesting to see what sprites are like!

Ruidesco

IE doesn't support WebGL at all.
MS making friends yet again.

Well, to be honest you can install a plug-in for WebGL support. But it just doesn't support it natively like the rest of the world does.

MrTAToad

It's no great loss not being able to use the current version of Internet Explorer

spacefractal

Look like its a nice solution . I do allready something like that in Greedy Mouse, so I could adapt it very easy (that property in the java applets public void run() did the extract same thing and then its easier for me doing something similar). Howover the game mightbeen a tad too big for online use, but could been fun if its could been integrate that way for new platforms mightbeen....
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

D2O

FF          geht
Chrome geht aber kein Fullscreen
IE          geht nicht, leeres fenster
Opera   geht nicht, leeres fenster
Safarie  geht nicht, leeres fenster

Video: ~5mb
http://www.deuteriumoxid.com/glbasic/GLBHTML5.avi
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell