RetroBASIC

Retrogamecoding(.org) => BrowserBasic => Topic started by: SteveOW on June 30, 2013, 04:54:08 PM

Title: requests
Post by: SteveOW on June 30, 2013, 04:54:08 PM
@Guilect

I wonder is there any chance of getting two extra functions in the next release of BB:- strokeEllipse, fillEllipse?

= = = = =

Also do you think it would be possible to have a "goto" command (and associated label statement)?
 
I assumed that javascript doesnt have such capability but after reading the following link the picture isnt clear.
http://stackoverflow.com/questions/9751207/how-can-i-use-goto-in-javascript.

cheers, SteveOW.

EDIT:
Just realized a simple way to implement goto:
Basic:  Goto LabelOne          JS:   If (1==2) {   //...Goto LabelOne
Basic:  LabelOne:                JS:   }                //...LabelOne:
leave it to the programmer to avoid jumping across control structures.
Title: Re: requests goto and ellipse
Post by: Guilect on June 30, 2013, 11:08:20 PM
Not a big fan of 'goto'.
But if it can be easily implemented I could do it and users could choose to use it or not.

I do not get your JS example.
Quote
If (1==2) {   //...Goto LabelOne
}                //...LabelOne:

I can make a keyword 'Goto' in BB what what is its JS equivelant that BB outputs?

The ellipse request seems doable.

{EDIT}:
I have implemented the stroke and fill ellipses.
When used each on their own they work fine.
But, like the POLY draw function, when used together the stroked one gets a extra outline.
I will continue to look into that.
Title: Re: requests goto and ellipse
Post by: SteveOW on July 01, 2013, 10:04:41 AM
@Guilect

Re: GOTO...Sorry my illustration was a bit confusing. :-[
Code: [Select]
Basic:  Goto abc123         
Basic:  a line of code that I want to skip for now in order to see if that solves a particular bug
Basic:  a line of code that I want to skip for now in order to see if that solves a particular bug
Basic:  a line of code that I want to skip for now in order to see if that solves a particular bug
Basic:  abc123:               

Here is the minimal JS required to implement the goto effect
JS:   If (1==2) { 
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:   }           

JS code with additional endline comments which explain to another programmer how a goto is being implemented
JS:   If (1==2) {     //  this line acts as a goto abc123
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:  a line of code that I want to skip for now in order to see if that solves a particular bug
JS:   }   // this line acts like a basic "label abc123"

I would not expect the compiler to auto-generate the end-line comments.
I dont expect the compiler to check the validity/safeness of the use to which goto is put.
Compiler must recognize that a basic statement "goto abc123" can be replaced simply by "if(1==2)"  It can ignore the specifics of the label.
Compiler must recognize that a statement like "abc123:" is a label (as in VB6) and simply replace it by a "}"

My main reason for having goto's is I find it helps in bug hunting to quickly and clearly jump over blocks of code that may harbour the bug.
In JS one can use the block comment start & end structure: /* .... ... ... */
But in VB6 (AFAIK) there is  no such start & end block comment facility.
Same seems to apply for BB. (I think I might include the facility in Browzic).

Second reason for using goto = it helps explain to Level 1 novices how computers really work, using near-natural language terms.
Then Level 2 novices can be allowed to confuse themselves with goto spaghetti.
Then Level 3 novices will appreciate the benefits of structured programming. :)

cheers, SteveOW.

PS I would be very glad to have fillEllipse, I can live with the outlining "feature".


Title: Re: requests goto and ellipse
Post by: Cybermonkey on July 01, 2013, 10:28:33 AM
The only thing I can say is that I never ever needed GOTO the last 15 years. I only needed it on the Commodore64 but that BASIC had'nt advanced control structures.
Title: Request for "Open Hyperlink"
Post by: SteveOW on July 01, 2013, 10:34:19 AM
@Guilect
Please could you provide an Open Hyperlink function in next release of BB?
Here is some JS which opens a hyperlink in a new browser tab when supplied with a url as a string:-

   var page_URL //as string
   page_URL = "sow_FRED.html"
   window.open(page_URL,'_newtab');

Cheers, SteveOW.
Title: Re: requests goto and ellipse
Post by: SteveOW on July 01, 2013, 11:48:59 AM
@Cybermonkey

Sorry
I didnt mean to rattle anyone's cage by re-lighting the Goto Controversy
http://www.sonoma.edu/users/l/luvisi/goto/goto.pdf

I just found a solution published some time ago...
use "Come From" instead !!!
http://www.fortran.com/come_from.html ;)

cheers, SteveOW.
Title: Re: requests goto and ellipse
Post by: Guilect on July 01, 2013, 12:31:09 PM
@SteveOW

How about this.
Two suggestions.

First,  use the method you just descibed.
If you want to programatically not have a section of code run
you can using BB syntax do:

If (1=2) then
    code you want to skip
    code you want to skip
    code you want to skip
    code you want to skip
endif

Or secondly, what I do if I want to skip code is to comment it out.
Even if it is a large block of code it is no problem with the editor that comes with BB
as it has a block comment feature under the edit menu.
Title: Re: requests goto and ellipse
Post by: SteveOW on July 01, 2013, 01:42:33 PM
@Guilect,

Obviously I got no problem if you dont want to put GOTO & Labels into BB, its your baby.

Those two methods are obviously feasible workarounds.

[ramble]
Code: [Select]
For me Goto and Labels (as found in VB6) are useful and convenient.
Unlike those two methods my Goto & Labels stick out like sore thumbs in my code.
Which is exactly what I want them to do. 
They are like duct tape or temporary traffic signs.
They say "there is something unfinished here which needs attention at some time".
Whereas those two methods blend in with lots of my stable code.
I tend to use comments to de-activate fossil code which shows how the program used to do something.
I sometimes find it useful to keep such stuff hanging around for a few years.
Whereas my goto's & labels are often only in use for a few minutes until a bug has been cornered.
[/ramble]

cheers, SteveOW. :)

PS My PN.exe inserts !~ as comment instead of '.
maybe due to current scheme in PN being "Fortran 95" ?
Title: Re: requests goto and ellipse
Post by: Guilect on July 01, 2013, 03:08:41 PM
Quote
PS My PN.exe inserts !~ as comment instead of '.
maybe due to current scheme in PN being "Fortran 95" ?

I will look into the comment character insertion.

The lexer needs to be set to Fortran 95.
This is the built in lexer in the scintilla control.
It turns out that the fortran language is the closest to BB's regarding functions, for loops, and if-then statements.
Selecting Fortran allows the editor to (mostly) process BB code correctly for code folding of functions, if-thens, for-next loops, etc.
Title: Request for NO_CLEAR option
Post by: SteveOW on July 15, 2013, 11:05:06 AM
@Guilect
Am trying to port Tomaaz's javascript prog for Langtons Ant into BrowserBasic (see BB code below).
It works alright except that BB refreshes the screen on every repeat call to the OnDraw function.

I have tried writing the image to an array and repainting the image on every step of the loop.
But this makes the prog very slow (40 minutes instead of 1 minute to complete 12000 steps).

Would it be possible to provide an option in BB that prevents the clearing of the old canvas image?

Alternatively could there be a way for a BB programmer to manipulate an image in a buffer and then onevery step to rapidly "BitBlt" the image from the buffer to the screen/canvas?

cheers, SteveOW.

PS Maybe this Topic could be renamed "Requests"?

Code: [Select]
'... Global Vars

var PixelData[4] as array
var PixelDataLong as number
var steps as number
var x as number
var y as number
var Direction as number
var scaler as number

'... Initialisation
Function OnLoad()

scaler = 1
steps = 12000
x = 100*scaler
y = 100* scaler
Direction = 1

endfunction

'... Update

Function OnUpdate()
endfunction

'... Draw

Function OnDraw()

PixelDataLong = getPixel(x,y)

if PixelDataLong > 0 then '...black
setColor (0,0,0) '...white
setPixel(x,y)    '...paint pixel
''fillRect(x,y,1*scaler,1*scaler)

select Direction
case 1
Direction = 4
x=x+  scaler
break
case 2
Direction = 1
y=y+  scaler
break
case 3
Direction = 2
x=x-  scaler
break
case 4
Direction = 3
y=y-  scaler
break
endselect
else
setColor (255,255,255) '...black
setPixel(x,y)    '...paint pixel
''fillRect(x,y,1*scaler,1*scaler)

select Direction
case 1
Direction = 2
x=x-  scaler
break
case 2
Direction = 3
y=y-  scaler
break
case 3
Direction = 4
x=x+  scaler
break
case 4
Direction = 1
y=y+  scaler
break
endselect
endif
steps = steps-1

if steps= 0 then
msgbox("Finished")
endif

endfunction '...OnDraw()

Title: Re: requests
Post by: Guilect on July 15, 2013, 09:36:31 PM
Hi SteveOW,

I can allow the user to create a hidden canvas, draw to it, and then flip it to the main canvas.

Something like this (pseudo code):

var mycanvas as number
mycanvas = CreateCanvas()

func. OnUpdate()
    SetCanvas(mycanvas)
' draw your stuff to your canvas

endfunc.
   
func. OnDraw()
    setCanvas(mycanvas)
endfunc.
Title: Re: requests
Post by: SteveOW on July 16, 2013, 12:00:12 AM
@Guilect,
I can allow the user to create a hidden canvas, draw to it, and then flip it to the main canvas.
That sounds good.
But I dont understand your pseudo-code.
Maybe something like:-
Code: [Select]
Function Update()
   If UserChooses then ClearCanvas(MyCanvas)
   SetDrawCanvas(MyCanvas)
   draw stuff (to MyCanvas)
endFunction

Function Draw()
   CopyCanvas(MyCanvas, OutputCanvas)
   DisplayCanvas(OutputCanvas)
endFunction
Title: New request: Append input BB source code to output HTML file
Post by: SteveOW on August 24, 2013, 11:47:23 PM
@Guilect,

I think it could be useful for the HTML file outputted by the BB compiler to include (as a commented-out appendix) the BB source code which was originally input.

That way someone interested in examining or forking the source code could simply extract it from the HTML file.
This would save the provider having to post parallel html and BB files.

Of course some authors would prefer not to share their code and so this would be provided as an option for the author to select prior to compiling.

What do you think?
Title: Request: html <title> definition in BB
Post by: SteveOW on August 25, 2013, 12:02:32 AM
It would be nice for coder to have ability to specify the value of the html page title field from within a BB code statement
e.g. status = Define_Page_Title ("Peter's Page").
Thus the text appearing on the tab for a BB page could be short and simple rather than the default rambling filespec.

The required html code is simple:
<title>Peter's Page</title>
Title: Re: requests
Post by: Guilect on August 25, 2013, 04:41:39 PM
@SteveOW

Being able to set the title page makes sense.
I will see about getting it into the next release.

I know you would like to have the BB source output in the .html file.
Not sure how many other users (does BB have any other users besides you?) would make use of that.  By including the BB source in the html you have just doubled the size and download time of the file.  Will look into it.
Title: Re: requests
Post by: SteveOW on August 28, 2013, 02:03:02 PM
@SteveOW

Being able to set the title page makes sense.
I will see about getting it into the next release.

thanks. :)
Title: Re: requests
Post by: SteveOW on August 28, 2013, 02:24:48 PM

I know you would like to have the BB source output in the .html file.
Not sure how many other users (does BB have any other users besides you?) would make use of that. 
By including the BB source in the html you have just doubled the size and download time of the file. 
Will look into it.

thanks.
also would be cool if BB IDE could take as input such an html file containing BB code block..
 this would simplify file management during development.
sure i appreciate that target users might be confused by this so perhaps keep it as a deeply buried or secret option.
i am just being a lazy programmer i suppose so no pressure ;)
Title: Re: requests
Post by: Cybermonkey on August 31, 2013, 09:51:31 AM
Nice would be support for tiled map editor maps. I see that Tiled can export JSON files (http://www.mapeditor.org/).
Title: 3D graphics in BrowserBasic
Post by: SteveOW on September 01, 2013, 07:57:10 PM
@Guilect
Do you have any new thoughts or plans for 3D graphics in BrowserBasic?
I have dabbled with the Three.js (webGL-based) library (example http://www.zen226082.zen.co.uk/PONGO_FULL.html)
(I was very surprised that this runs very smoothly on my android tablet when using Firefox browser).
I am thinking of using it in my Browzic product.
But if something is coming along in BrowserBasic then I might not need to do it in Browzic.

@XXX
Does anyone else know of other 3D graphics libraries which might be suitable?
either in javascript or in something that could be translated into javascript +/- webGL?

cheers, SteveOW.
Title: Re: requests
Post by: Guilect on September 01, 2013, 09:12:29 PM
@SteveOW

I have no plans for 3D right now.
I would love to see them in your Browzic.
Title: Re: 3D graphics in browser
Post by: SteveOW on September 10, 2013, 08:20:37 PM
Just found this nice site:
http://www.physgl.org/
An in-browser, Lua/Basic-like coding window,
it produces simple 3D graphics and animations
based on three.js & javascript.



Title: Re: 3D graphics in BrowserBasic
Post by: bolbo on September 22, 2013, 12:29:01 PM

@XXX
Does anyone else know of other 3D graphics libraries which might be suitable?
either in javascript or in something that could be translated into javascript +/- webGL?


Turbulenz is said to have modules to be used separately
http://docs.turbulenz.com/game_engine_overview.html
You may want to research this other opensource projects :
http://shapesmith.net/
http://openjscad.org/
Title: Re: requests
Post by: SteveOW on September 23, 2013, 02:36:30 PM
@bolbo
Thanks. Turbulenz looks awesome but rather daunting for me (python, webservers, ++ are outside my comfort zone).
Shapesmith and OpenJSCad look interesting for making static 3D objects.
For now I'm ploughing ahead with exploring Three.js and trying to decide on the right mix of simplicity and flexibility to expose to a user of Browzic. 
Latest prototype is here:- http://www.zen226082.zen.co.uk/TRI_VP.html, works best in Chrome or Opera, (sadly not Firefox except on Android).
Title: Re: requests
Post by: Cybermonkey on September 27, 2013, 08:11:20 PM
A little bit offtopic but it's WebGL: http://madebyevan.com/webgl-water/
Runs smoothly on my Computer on Linux 64 bit with Chromium (Radeon HD 7770 proprietary driver).
Title: Re: requests
Post by: SteveOW on October 02, 2013, 05:24:19 AM
Very impressive but it demands a powerful machine.
Running on Chrome it crashes my 3 year old windows 7 laptop.
On Firefox it is a bit jerky.
Title: Re: requests
Post by: SteveOW on November 20, 2013, 07:53:00 PM
By popular demand (from the voices in my head)
a basic flight simulator with missiles
so you can shoot things.

just click the link to play:-
http://www.zen226082.zen.co.uk/TRI_VP.html

On my Windows7 PC the best browser is Chrome.
On my Android 4.01 tablet the best browser is Firefox.

Uses Javascript/webGL/Three.js.
Its not as fast as I hoped for. 
Best to open just one viewport at a time.


Title: Re: requests
Post by: Guilect on November 24, 2013, 09:14:28 PM
For me the demo ran a bit slow also.
Three.js is a nice interface to WebGL.
I bet it did not take long to understand Three.js and make the demo.
There are lots of people using Three.js.
Title: Re: requests
Post by: SteveOW on November 25, 2013, 12:38:07 PM
@Guilect thanks for the feedback.

For me the demo ran a bit slow also.
Yes I think that 1600 smoke sprites is too many.
Without them it is much, much faster.
There may be a better way of coding them.

Quote
Three.js is a nice interface to WebGL.
It can certainly produce some awesome effects and there are very few bugs.
There are lots of code examples out there e.g. http://stemkoski.github.io/Three.js/
An excellent intro is here:- http://math.hws.edu/eck/cs424/notes2013/15_Threejs_Intro.html

Quote
I bet it did not take long to understand Three.js and make the demo.
Actually it has taken me quite a lot of time to get Three.js to do what I want.
In fact I pretty much dont understand a lot of it.
I mostly just find other people's examples and hack them around until they work for me.

I still think it would be good to have a simple Basic wrapper (like BrowserBasic) to hide away the general horribleness (html, css, javascript, three.js, other js libraries).
Thats what Browzic will do if it ever happens.
Till then this demo will provide (to me) a useful platform for customizing from.

Quote
There are lots of people using Three.js.
Yup its got a lot of critical mass of users and developers and its free.
It can be used for 2D or 3D games, retro or modern.
I think it will be around for quite a while.