BASIC

Author Topic: HTML5 / JavaScript ist starting to get useful  (Read 12079 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
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]

Offline Wampus

  • Prof. Inline
  • *****
  • Posts: 1004
    • View Profile
Re: HTML5 / JavaScript ist starting to get useful
« Reply #1 on: 2012-Nov-09 »
Can't wait to play with this. Go Gernot!  :good:

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2613
    • View Profile
Re: HTML5 / JavaScript ist starting to get useful
« Reply #2 on: 2012-Nov-09 »
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)

Offline Ruidesco

  • Mr. Polyvector
  • ***
  • Posts: 236
    • View Profile
Re: HTML5 / JavaScript ist starting to get useful
« Reply #3 on: 2012-Nov-09 »
It does work well in Firefox. :good:

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Re: HTML5 / JavaScript ist starting to get useful
« Reply #4 on: 2012-Nov-09 »
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.

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4186
    • View Profile
    • Portfolio
Re: HTML5 / JavaScript ist starting to get useful
« Reply #5 on: 2012-Nov-09 »
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: 

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
Re: HTML5 / JavaScript ist starting to get useful
« Reply #6 on: 2012-Nov-09 »
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.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3366
  • Integrated Brain
    • View Profile
Re: HTML5 / JavaScript ist starting to get useful
« Reply #7 on: 2012-Nov-09 »
Uhhhhu!!! This it´s very very nice!!!

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

Offline backslider

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 892
    • View Profile
Re: HTML5 / JavaScript ist starting to get useful
« Reply #8 on: 2012-Nov-12 »
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

  • Guest
Re: HTML5 / JavaScript ist starting to get useful
« Reply #9 on: 2012-Nov-12 »
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

  • Guest
Re: HTML5 / JavaScript ist starting to get useful
« Reply #10 on: 2012-Nov-12 »
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!
« Last Edit: 2012-Nov-12 by MrTAToad »

Offline Ruidesco

  • Mr. Polyvector
  • ***
  • Posts: 236
    • View Profile
Re: HTML5 / JavaScript ist starting to get useful
« Reply #11 on: 2012-Nov-12 »
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

  • Guest
Re: HTML5 / JavaScript ist starting to get useful
« Reply #12 on: 2012-Nov-12 »
It's no great loss not being able to use the current version of Internet Explorer

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3611
    • View Profile
    • Space Fractal
Re: HTML5 / JavaScript ist starting to get useful
« Reply #13 on: 2012-Nov-12 »
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....
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline D2O

  • Prof. Inline
  • *****
  • Posts: 1062
    • View Profile
    • http://www.deuteriumoxid.com
Re: HTML5 / JavaScript ist starting to get useful
« Reply #14 on: 2012-Nov-13 »
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