Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

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.