bb2js update on the way
In the process of porting my Platformer "Jack Airbourne" to Javascript using my converter bb2js, I stumbled upon a bunch of difficulties, but I finally succeeded and got it running in the Browser. One major issue was the lack of pre-Initializiation of single Dimension Arrays (a thing Blitz does, but JS doesn't) that caused hours of confusion and debugging. So, until I have uploaded the new version of the converter, I strongly suggest, right after a Dim you initialize the Array manually, for instance:
Dim mylist%(100)
for i=0 to 100
mylist%(i)=0
next
Otherwise in JS the Array cells will contain "undefined" and will cause errors when you try to use it eg. as an index for an other Array. For 2-dimesional Arrays the converter does that already automaticly, but not so for single Dimension Arrays.
Further notice: I have found a great and extremly simple way in JS to wait for all Images to be loaded before starting the Game, that is, since all Images use the LoadImage() function, it was possible to create a HTML String containing <img> Tags for all Images, using inline Style to position them all at one Spot on the Page and make them invisible. Only after they have all loaded into the Page, the onload Event of the body HTML Element is triggered, which is the bb2js__myinit() Function. Note, using commands that are painting to the Canvas are only possible after the Page has fully loaded, so you have to put them into bb2js__myinit() (for instance DrawImage() ) if you need to use them before the Program runs the main Loop. Also found a way to substitute WaitKey(), and Ways to circumvent Javascript's denial of playing Sounds without prior User Action. Well, one Action is still required, that is the "Hit Space to start the Game" Action, after Loading is complete.
I will upload the updated Version of bb2js ASAP, as well as the JS Version of Jack Airbourne, hopefully playable right here in the Browser, along with a Blitzbasic Code that converts the Worldmap File of the Windows Version to the one JS uses. The JS Version of Jack Airbourne will most likely not contain the integrated Map Editor, at least for now.
Files
Get BB2JS v0.02-ish
BB2JS v0.02-ish
Convert BlitzBasic to Javascript HTML5 - debugged version 0.02
Status | Prototype |
Category | Tool |
Author | jfkEO1010etc |
Tags | basic, basic-to-js, blitz3d, blitzbasic, coding, games-design |
Leave a comment
Log in with itch.io to leave a comment.