This Basic to Javascript converter, was originally written in Basic. Then the converter
converted itself  to Javascript
- boom! I'd be lying if I'd say there was no desperation
due to excessive debugging, but hey, that's what we do. 

Write your Basic program and have it running in the browser by a single click. Export
and save locally (copy paste to notepad for now) and feel free to publish your
creation. If you do so, please leave a link in the comments section!

This is an early version, sure some bugs are still lurking around. Stick with the Syntax!

Update Note:

Several new Versions uploaded, V8 solves some fatal bugs, hopefully all of them, but
esp. the one in "Export JS", and added some embedded examples.

Documentation:

A brief guide can be found in the embedded "cheat sheet". For more details you
should also download the BB2JS windows version (containing the sourcecode for the
Blitz3D compiler, that can be found here on itch.io). It contains some Docs, but keep
in mind that the "cheat sheet" contains the latest state and some of the restrictions
listed in the older Docs don't exist anymore, for instance one-line If Then's are now
allowed, as well as multiple commands on one line, when separated by ":".

To modd the current version, you should edit the runtime template
"my_ide_template.html" (eg. to add support for further commands), then use the
program "turn_template_into_include.bb" to convert this html file into the js file
"my_ide_template_include.js" that contains the template as an array of strings, so
BB2JS can assemble your program with the template to a working standalone html5
page..

StatusPrototype
CategoryTool
PlatformsHTML5
Rating
Rated 5.0 out of 5 stars
(3 total ratings)
AuthorjfkEO1010etc
Tags2D, basic, blitz3d, blitzbasic, gamedesign, html5, programming

Download

Download
bb2js_html5port_rel8dl.zip 373 kB

Development log

Comments

Log in with itch.io to leave a comment.

(+1)

In case you are interested in adding 3D features similar to Blitz3D, there is a wrapper for the library OpenB3D in JavaScript


https://github.com/angros47/OpenB3D-JS

Thanks!

(+1)

Here's a mod of the starfield example, allowing for speed control using the mouse.

; this is executed in the main loop:

If veteran=0

 veteran=1

 grapw=GraphicsWidth()

 graph=GraphicsHeight()

 grapw2=grapw/2

 graph2=graph/2

 For i=0 To nnn

  star_x#(i)=Rnd(0,grapw)

  star_y#(i)=Rnd(0,graph)

  star_speed#(i)=Rnd(1.001,1.01)

  star_col(i)=0

 Next

 calc_stars(nnn,1)

EndIf

Cls()

ms#=1.001+(MouseY()/graph)

calc_stars(nnn,ms)

draw_stars(nnn)


;----------------

;this is For Globals, Arrays, Media-Preloading And Functions

Global veteran=0

Global grapw=0

Global graph=0

Global grapw2=0

Global graph2=0

Global nnn=500

Dim star_x#(nnn)

Dim star_y#(nnn)

Dim star_x2#(nnn)

Dim star_y2#(nnn)

Dim star_speed#(nnn)

Dim star_col(nnn)

Function calc_stars(n,ms#)

 For i=0 To n

  star_x2#(i)=star_x#(i)

  star_y2#(i)=star_y#(i)

  star_x#(i)=star_x#(i)-grapw2

  star_y#(i)=star_y#(i)-graph2

  star_x#(i)=star_x#(i)*star_speed#(i)*ms

  star_y#(i)=star_y#(i)*star_speed#(i)*ms

  star_x#(i)=star_x#(i)+grapw2

  star_y#(i)=star_y#(i)+graph2

  star_col(i)=star_col(i)+20

  If star_col(i)>255

   star_col(i)=255

  EndIf

  If (star_x#(i)<-50) Or (star_x#(i)>(grapw+70)) Or (star_y#(i)<-50) Or (star_y#(i)>(graph+50))

   star_col(i)=0

   star_x#(i)=Rnd(0,grapw)

   star_y#(i)=Rnd(0,graph)

   star_x2#(i)=star_x#(i)

   star_y2#(i)=star_y#(i)

  EndIf

 Next

End Function

Function draw_stars(n)

 For i=0 To n

  x#=star_x#(i)

  y#=star_y#(i)

  x2#=star_x2#(i)

  y2#=star_y2#(i)

  Color(star_col(i),star_col(i),star_col(i))

  Line(x,y,x2,y2) ; here's also a bugfix btw

 Next

End Function

Nice. ๐Ÿ‘ Any progress integrating this with Copperlicht?

On another note, I'm going to try if I can strip out all display related stuff with a server code I'm working on, otherwise I'll just do it with full JS.

Currently busy with other things. Cheers, cya.

Just uploaded V8, that hopefullly fixes all the string replace issues still found in V7. Just one little "bug": When the tool has loaded, it shows the pong example, but the examples select menu shows "test". Also, to reload an example, you first need to load a diffrent one, as loading of examples is triggered by "onchange" in the selection menu.

The previously mentioned mysterious disappearance  of some tags seems to be solved. In some instances using JS string.replace for BB Replace() has caused mayhem. Now string.replaceAll() is used, which solved tons of initially weird issues.

Another pitfall are array indicies. If they are not full numbers, make sure to use Floor(index), js cannot use indicies like eg. 5.3, but requires 5.0, for example.

Also, this online version contains test1.png and test1.mp3, so you can test those. It's however a js restriction to mandate a user action prior playing a sound. For music etc. it is therefor advised to implement a startscreen mode, in which the user has to do a click or keyhit to start the game and the music.

In general you should make use of your browsers javascript error console, esp. if something is not working.

here's a starfield:


; this is executed in the main loop:
If veteran=0
 veteran=1
 grapw=GraphicsWidth()
 graph=GraphicsHeight()
 grapw2=grapw/2
 graph2=graph/2
 For i=0 To nnn
  star_x#(i)=Rnd(0,grapw)
  star_y#(i)=Rnd(0,graph)
  star_speed#(i)=Rnd(1.01,1.1)
  star_col(i)=0
 Next
 calc_stars(nnn)
EndIf

Cls()
calc_stars(nnn)
draw_stars(nnn)


;this is For Globals, Arrays, Media-Preloading And Functions
Global veteran=0
Global grapw=0
Global graph=0
Global grapw2=0
Global graph2=0
Global nnn=500
Dim star_x#(nnn)
Dim star_y#(nnn)
Dim star_x2#(nnn)
Dim star_y2#(nnn)
Dim star_speed#(nnn)
Dim star_col(nnn)

Function calc_stars(n)
 For i=0 To n
  star_x2#(i)=star_x#(i)
  star_y2#(i)=star_y#(i)
  star_x#(i)=star_x#(i)-grapw2
  star_y#(i)=star_y#(i)-graph2
  star_x#(i)=star_x#(i)*star_speed#(i)
  star_y#(i)=star_y#(i)*star_speed#(i)
  star_x#(i)=star_x#(i)+grapw2
  star_y#(i)=star_y#(i)+graph2
  star_col(i)=star_col(i)+20
  If star_col(i)>255
   star_col(i)=255
  EndIf
  If (star_x#(i)<-50) Or (star_x#(i)>(grapw+70)) Or (star_y#(i)<-50) Or (star_y#(i)>(graph+50))
   star_col(i)=0
   star_x#(i)=Rnd(0,grapw)
   star_y#(i)=Rnd(0,graph)
   star_x2#(i)=star_x#(i)
   star_y2#(i)=star_y#(i)
  EndIf
 Next
End Function
Function draw_stars(n)
 For i=0 To n
  x#=star_x#(i)
  y#=star_y#(i)
  x2#=star_x2#(i)
  y2#=star_y2#(i)
  Color(star_col(i),star_col(i),star_col(i))
  Line(star_x#(i),star_y#(i),star_x2#(i),star_y2#(i))
 Next
End Function

(+1)

Hello j,

Thanks for this...BASIC is fun for me and there are lots of old basic programs that may take on new HTML5 life thanks to projects like this.

I hope you continue to develop this! 

I could not get the starfield code to run. I got a dark screen but no stars.

I was able to do some Print statements and have some nostalgia!

A_R

Hey, thanks a lot for trying it out. About the starfield, did you copy the Globals section to the right side textarea and the mainloop section to the left side? I know It's a bit complicated, thinking about to add examples and save/load. The starfield should work. Yeah, Print, only unofficially supported, as it uses document.write() ontop of the canvas. You can also use Text(x,y,t$)

That said, I just spotted a bad bug and may upload a new version asap. In any case the project can be downloaded and may be debugged, expanded and modded by anybody. I think, most important is a stable set of simple functions, reducing javascript-typical excessive debugging time (from my POV anyway) to a minimum and allowing to actually concentrate on the game/project itself.

(+1)

You are correct I did not load the code correctly! It works good and is super fast.

My first computer language was BASIC so this is a lot of fun to mess with.

Thanks again and if you decide to declare it ready/released please add me to your list to notify.  I will add you to my Follow list.

I am interested in using it to generate some simple programs in JS to use in Tuesday JS visual novel builder....

thanks

A_R

Thanks, I appreciate it a lot if people actually use it. But I doubt it will ever be finished - there's always something that can be done better. Still, given the most game-breaking bugs are fixed, it can already be used. For instance I ported my "jack Airbourne" platformer with an older version (using the blitzbasic version of the converter back then). I just uploaded a new version that hopefully fixes previous export problems.

BTW thanks a lot (!) for your Rating.

(1 edit) (+1)

Update log:

Continuously debugging and uploaded several new versions. Some big bugs have been fixed with Array Brackets. If something didn't work, please try again.

Also, some strange disappearance of closing html tags after using js methods split() and join(), but only when they were on the same line as their opening tags, so for now I write these to a new line, which fixed the problem, but this mystery is yet to be solved.

Good news: ReadPixel, which doesn't work when the page runs locally from a file:// url, is now working when run on itch.io. I am assuming the same is true for CopyRect.