RetroBASIC

Retrogamecoding(.org) => BrowserBasic => Topic started by: Guilect on July 27, 2013, 07:50:26 PM

Title: New version released; v0.6
Post by: Guilect on July 27, 2013, 07:50:26 PM
New version released. v0.6
Saturday, July 27, 2013

fixed Chrome browser not opening correctly from the editor.
added getFPS   note: it is internally locked to run at 60 fps.
Fixed bug in draw positions of ellipses.
added Atan2 syntax in addition to the existing Atn2.
added some physics commands.
added ability of the editor to go to error line by clicking on the error message in       the output window.
added abilty to have types in types.
added ability to to declare and assign a value to numeric and string variables
      e.g.  var x as number = 55
added ability to have an external JS function return multiple values
    Type TPoint
var x as number
var y as number
EndType
var point as TPoint
point = GetPosition()
        'returns point.x and point.y
Changed the way that file names are look at so that file names with a
2 character extension e.g. .bb should work.
added CreateCanvas, setCanvas, and getCanvas commands (for example see ex_paint.txt)
added a preview hotkey for the Opera Browser
F8 - Runs the HTML page in Opera.
F9 - Starts the BrowserBasic WiFi Server
F10 - Launches help file.


Download Here (http://pewtersoftware.com/browserbasic/browserbasic.zip)
Title: Re: New version released; v0.6
Post by: SteveOW on August 14, 2013, 04:07:00 PM
@Guilect,

Looks like a nice set of new features in v0.6.
Tried the ex_paint example which uses the new canvas stuff and it works well.
Hope to have some time soon to get into the other stuff.
Title: Re: New version released; v0.6 - Bug when calling user defined function
Post by: SteveOW on August 16, 2013, 01:25:42 AM
Hi Guilect,

I found a bug in BB v0.6, when compiling my POND txt file (attached) it gives this message:-
Error.  Line: 516 ---- Function Call - Undeclared function: SOW_Zap_pea_at_MousePos.
When I comment out calls to this function the v0.6 compiler reports that the next user-defined function is undefined.

The same POND txt file compiles OK using BB v0.5.

When I test v0.6 with a small simple txt file (attached) it compiles OK.

cheers, SteveOW.
Title: Re: New version released; v0.6
Post by: Guilect on August 16, 2013, 01:47:15 PM
I'll look into it.
Title: Re: New version released; v0.6
Post by: Guilect on August 16, 2013, 11:20:05 PM
Fixed.

There is an array in BB that stores variable and function names.
After adding all the physics functions there was not so much room left for user variable and function names.
I have increased the size of that array.

v0.61
Download here (http://pewtersoftware.com/browserbasic/browserbasic.zip)
Title: Re: New version released; v0.6
Post by: SteveOW on August 16, 2013, 11:53:26 PM
@Guilect

Many thanks, that fixed my problem. 
I had just run into the same thing using BB version 0.5.
Will the BB compiler now report an error if at some time in the future that array runs out of space?
Title: Re: New version released; v0.6
Post by: Guilect on August 17, 2013, 01:30:23 PM
I will see about putting that in the next release.
Title: Touchscreen in BrowserBasic
Post by: SteveOW on August 18, 2013, 09:32:18 AM
@Guilect

Could you possibly make and post a simple BrowserBasic app that demonstrates basic Touchscreen capabilities?

I dont yet have a touch-enabled device and I dont want to waste money buying something unsuitable.  I have been trying out various devices in my nearest tech shop (12 miles away).  I have realized there is a lot of variation in capabilities when it comes to running html/javascript apps with touch. Touchscreen laptops are the best performers.  Personally I find anything with a screen size under 10 inches is awkward to use for control by touch.  Low end devices (£100) are painfully slow.  For me the best touchpad I have seen so far is the Samsung Galaxy Note 10.1 inch which has a little pen (which is just great for my fumbly fingers) but at £350 it is rather expensive and its html/javascript performance is only moderate.

I am trying to make my POND app respond to touch but the 24 mile round trip between coding and testing is going to make development rather slow!

cheers, SteveOW.
Title: Re: New version released; v0.6
Post by: Guilect on August 18, 2013, 05:16:59 PM
@SteveOW

Example at:

http://retrogamecoding.org/board/index.php?topic=203.0 (http://retrogamecoding.org/board/index.php?topic=203.0)
Title: Re: New version released; v0.6
Post by: Cybermonkey on August 21, 2013, 02:58:43 PM
By the way, is BrowserBasic made with GLBasic?  :o
Title: Re: New version released; v0.6
Post by: Guilect on August 21, 2013, 10:00:47 PM
@Cybermonkey

Yes it is.
Did you recognize the icon?
Title: Re: New version released; v0.6
Post by: SteveOW on August 22, 2013, 12:06:33 AM
@Guilect

FYI the attached code causes the BB compiler to get stuck in a loop.
I have to kill the process in Windows Task Manager.

cheers, SteveOW.

PS During the recent  forum outage I could not find a way to contact you (I wanted a copy of the touchscreen code).
BrowserBasic website has no contact details and Brutus2D was not accepting new users.
Is there a regular forum elsewhere that you visit where contact could be made in such a case?
Title: Re: New version released; v0.6
Post by: Guilect on August 22, 2013, 12:45:15 AM
@SteveOW

What attached code   ;)

This is the only place I hang out.
If this site was to go away, I would put something up at the BrowserBasic home page.
But, Cybermonkey has things humming along again.

Title: Re: New version released; v0.6
Post by: SteveOW on August 22, 2013, 08:17:46 AM
What attached code   ;)

Doh! :-[
And now I have modified the file and cannot reproduce the error.
Double Doh! :-[ :-[

Ill get back to you if I encounter it again.
cheers, SteveOW.


Title: Re: New version released; v0.6
Post by: SteveOW on August 22, 2013, 08:21:16 AM
This is the only place I hang out.
If this site was to go away, I would put something up at the BrowserBasic home page.
But, Cybermonkey has things humming along again.

Thanks.
Title: Re: New version released; v0.6
Post by: SteveOW on August 22, 2013, 08:56:05 AM
added ability to have an external JS function return multiple values

@Guilect
Please can you elaborate or provide example? e.g. how do I declare external function within BB code?

Also is it possible for  user to code a subroutine/function which changes values of multiple input parameters, e.g.
Code: [Select]
var gA as number =1
var gB as number =2
var gC as number =3

call subTenner (gA,gB,gC)

msgbox(gA + "," + gB + "," + gC)

'=================================

function subTenner (A as number,B as number,C as number)

A = A*10
B = B*10
C = C*10

return A,B,C

endfunction

cheers, SteveOW.

PS Thanks for all the goodies in this new release :D
Title: Re: New version released; v0.6
Post by: Cybermonkey on August 22, 2013, 10:18:41 AM
@Cybermonkey

Yes it is.
Did you recognize the icon?
Yep, so maybe we can keep our fingers crossed for a Linux version one day?
Title: Re: New version released; v0.6
Post by: SteveOW on August 22, 2013, 11:02:26 AM
Yep, so maybe we can keep our fingers crossed for a Linux version one day?

IMO the ideal compiler for BB would be written in BB and runnable (offline if desired) in any standard web browser.
And therefore runnable on any device (windows, linux, android, macOS,...) that supports a standard browser.

It (browser-based compilation) is on my roadmap for Browzic.

cheers, SteveOW.

Title: Re: New version released; v0.6
Post by: Guilect on August 22, 2013, 11:07:46 PM
@ SteveOW

When I mentioned external functions it was in reference to the known external libraries that BB uses such as Box2dWeb.js
On the todo list is to allow users to define external functions and use their own external JavaScript files.

Quote
Also is it possible for  user to code a subroutine/function which changes values of multiple input parameters
I think what you are asking for here is to send in variables by reference rather than by value.  Am I correct.  If so, JavaScript has no means to send primitive variables by reference to a function.  However, objects are sent by reference.  That means Types.  Having a Type as a function input parameter will be available in the next release.

@Cybermonkey

I used RedHat for a very short time a lifetime ago.
So I remember little about *nix.
Here is a build I did for linux.
If you have the time I would appreciate you seeing if it works.
It is just the compiler.  You will need to use some editor and pass the filename of the BB code to this.  The compiler will then spit out an .html file of the same name.

linux version here (http://www.pewtersoftware.com/browserbasic/browserbasic.linux)
Title: Re: New version released; v0.6
Post by: Cybermonkey on August 23, 2013, 11:40:17 AM
Thanks a lot. I will give it a try at the weekend.
Title: Re: New version released; v0.6
Post by: bolbo on August 23, 2013, 01:00:25 PM

IMO the ideal compiler for BB would be written in BB and runnable (offline if desired) in any standard web browser.
And therefore runnable on any device (windows, linux, android, macOS,...) that supports a standard browser.

It (browser-based compilation) is on my roadmap for Browzic.

Something like this ?
http://www.kevs3d.co.uk/dev/scratchpad/
Title: Re: New version released; v0.6
Post by: bolbo on August 23, 2013, 01:42:27 PM
Guilect, I thought that you might be interested in reading this recent discussion :
http://www.html5gamedevs.com/topic/686-to-box2d-or-not/#entry3619
They talk about performances of different physics engines on mobile devices,  Turbulenz engine and Chipmunk-JS seem to work well unlike  Box2D.
Thanks
 
Title: Re: New version released; v0.6
Post by: Guilect on August 23, 2013, 03:23:50 PM
Hi bolbo,

Thanks for the links.
While the idea being  able to program from any device sounds great, the practicality of it is not.
Who would want to try to code a program on their phone?
Being able to run your code on your phone is great.
Being able to use a full keyboard, a good editor, and saving and loading files from a hard drive is better.
Saving files from different browsers, on different OSes, on different platforms is a big pain.
Security restrictions do not allow access to a local hard drive from the browser.

I looked at a bunch of options for physics. 
One of the most important things that was required was the ability to take the API of the physics engine and make it fit into BASIC syntax.  The other choices for physics engines seemed too javascript-like to port over.
Box2d is slow on mobile devices today.  But, these mobile devices will get faster.
If you need more speed for a mobile device I would also recommend, like they did in the article, that you just code a few small routines to simulate the physics behavior that you want.
Title: Re: New version released; v0.6
Post by: bolbo on August 23, 2013, 04:46:37 PM
Guilect, thanks for sharing your design decisions with us. It is not my intention to put pressure, just to notice that Box2d does not work well on mobile devices currently (nor in many desktop pcs apparently). Besides, Turbulenz's physics engine is said to mirror Box2D's APIs so you may want to consider supporting it in the future if Box2D keeps being slow in quite a few cases.   
Title: Re: New version released; v0.6
Post by: SteveOW on August 24, 2013, 11:43:23 AM

IMO the ideal compiler for BB would be written in BB and runnable (offline if desired) in any standard web browser.
And therefore runnable on any device (windows, linux, android, macOS,...) that supports a standard browser.

It (browser-based compilation) is on my roadmap for Browzic.

Something like this ?
http://www.kevs3d.co.uk/dev/scratchpad/
@ Bolbo,

Yes indeed I am thinking of something like that but with the user seeing Browzic code instead of Javascript.
I have not seen this particular app before, I have seen several others which as I recall are based on something called CodeMirror.
The idea is that a user can program inside the browser without the need to access a remote server.

It is not easy for browser based apps to exchange data with the local hard drive but it can be done.

One way is using cookies but this is a bit crude.

Another way which I have recently come across is by using the HTML5 Local Store facility but I presently am a bit vague on this.

Another way is by the user cutting and pasting text or data into and out of html form fields (from and to text files opened by the user on the desktop).
(I demo this technique in my Pond and PongGoneWrong demos (http://www.zen226082.zen.co.uk/ 
This is rather crude of course.

Another way is by use of image files with the user selecting hard-disk files for the browser to read and write to and the browser (somehow) coding and encoding between meaningful data format and image data format.
Title: Re: New version released; v0.6
Post by: SteveOW on August 24, 2013, 12:00:41 PM
@ SteveOW

When I mentioned external functions it was in reference to the known external libraries that BB uses such as Box2dWeb.js
On the todo list is to allow users to define external functions and use their own external JavaScript files.

Quote
Also is it possible for  user to code a subroutine/function which changes values of multiple input parameters
I think what you are asking for here is to send in variables by reference rather than by value.  Am I correct.  If so, JavaScript has no means to send primitive variables by reference to a function.  However, objects are sent by reference.  That means Types.  Having a Type as a function input parameter will be available in the next release.

Re:external functions ...ah  I see, thanks.

Re:function input parameters...yes "by reference rather than by value" is effectively what I mean. 
I didnt realize that JS doesnt handle this. 
Forcing use of typed objects might be a bit harsh on a novice programmer?
I can see a way of doing it in javascript using global variables which could be invented by the BB compiler at compile time.
Not elegant but it could be hidden from the BB user. Probably would hobble performance if over-used.
Title: Re: New version released; v0.6
Post by: SteveOW on August 24, 2013, 12:19:59 PM
Who would want to try to code a program on their phone?
Do you remember programmable hand-held calculators with their one-line displays?
I think if a phone can run a spreadsheet then it could also let you write off-the-cuff programs.
In my line of work having a pocket device that you can program geometric and iterative algorithms on is quite nice to have.

I certainly want to be able to program on my tablet.
I realize not many other serious programmers might want to.
But with schoolkids increasingly using tablets these days I think it is a great way to get kids into programming.
I'd like to see Browzic one day having one front end similar to the MIT Scratch tool allowing novices to start with iconic/sprite-based animation programming and then move on if they desire to monolithic line-by-line textual code.

Title: Re: New version released; v0.6
Post by: Cybermonkey on August 25, 2013, 04:42:50 PM
@Cybermonkey

I used RedHat for a very short time a lifetime ago.
So I remember little about *nix.
Here is a build I did for linux.
If you have the time I would appreciate you seeing if it works.
It is just the compiler.  You will need to use some editor and pass the filename of the BB code to this.  The compiler will then spit out an .html file of the same name.
Ok, I tried it. From what I can say all examples compile correctly. Only the physics example does not work. It compiles but the scenery comes up for some ms and then there is a grey background. But this is the same with Windows. Tested with Firefox and Chrome. Maybe I did anything wrong?
Title: Re: New version released; v0.6
Post by: Guilect on August 25, 2013, 07:12:02 PM
Quote
physics example does not work
That would be because I forgot to include an image file in the release.
I will update the release download package.
But, if you want, just download the attached image and place it in the 'examples\img' folder.

Thanks for testing it by the way.
I will try to produce a linux version as well from now on.
Title: Re: New version released; v0.6
Post by: Cybermonkey on August 25, 2013, 08:13:06 PM
Yep, that was it. Now it works! If I have a bit free time I'll try to port one of my simple games to BrowserBasic.
(Just uploaded the first book on CreateSpace - not written by me but as a publisher - so time is rare at the moment.)
Title: Re: New version released; v0.6
Post by: SteveOW on August 28, 2013, 02:40:11 PM
I will try to produce a linux version as well from now on.

would that work on Android.?(please excuse my ignorance)
Title: Re: New version released; v0.6
Post by: Guilect on August 28, 2013, 09:43:58 PM
I am not aware of any linux ports to the AndroidOS.
Most applications that run on Android are programmed with the Java SDK and combined with the Android SDk to produce and .apk file which can then be run.
Title: Re: New version released; v0.6
Post by: ScriptBasic on August 29, 2013, 06:59:24 PM
Android Linux supports both native C/C++/... development or the mainstream Java VM.
Title: Re: New version released; v0.6
Post by: SteveOW on August 30, 2013, 07:43:44 AM
I read that GL Basic runs on Android.
Maybe GL Basic on Android can create a BB compiler executable which also runs on Android?
But I dont know what IDE could be used on Android in place of Geany or ProgrammersNotepad to do the actual edit and compile of BrowserBasic code.
Title: Re: New version released; v0.6
Post by: Mopz on August 30, 2013, 09:03:33 AM
Many of the cross platform solutions for game programming today are "simple programs" that open a webview that runs a html5/js game. Putting something together that transform BB code with some assets into an apk for android would probably not be impossible. If one would like to upload and sell games on Google Play, I mean.
Title: Re: New version released; v0.6
Post by: SteveOW on August 30, 2013, 11:40:58 AM
@Mopz

As developer of Browzic my target user is Joe who wants to program an app in one kind of Basic, with one kind of IDE and produce one kind (HTML5/JS) of executable or "runnable" which can be accessed by many different users/players thru many kinds of web-browsers (which all comply with a common global standard).

I had not thought of Joe wanting to sell his games.
If so I would prefer to give Joe some way of "copy-locking" an HTML5/JS game to prevent copying and then sell it from wherever.
 
One of way of "copy-locking" is to rely on the honesty of the purchaser.
I dont know much about any other way.
Maybe a BB-to-APK transformation, plus GooglePlay store, like you describe, would be the way to go.
 
Title: Re: New version released; v0.6
Post by: Cybermonkey on August 30, 2013, 11:57:16 AM
There's also the other way: making out of a BB game a desktop application. It's really easy using node webkit: https://github.com/rogerwang/node-webkit
Updates are made regularly maybe because
Quote
It's created and developed in the Intel Open Source Technology Center.

(I really need to take the time to code in BrowserBasic soon...)
Title: Re: New version released; v0.6
Post by: SteveOW on August 30, 2013, 12:19:53 PM
There's also the other way: making out of a BB game a desktop application. It's really easy using node webkit:

I see that
Quote
You can write native apps in HTML and Javascript with node-webkit.

Interesting but I am not entirely sure why you would want to do this when you can simply run BB-produced html file in a browser.
Maybe it gives better performance?
Maybe it lets you make an exe which cannot easilly be reversed engineered?


But it doesnt (currently) seem to support Android OS.
Also, by dropping out of the browser some functionality might be lost?
Title: Re: New version released; v0.6
Post by: Mopz on August 30, 2013, 05:37:17 PM
@Mopz

As developer of Browzic my target user is Joe who wants to program an app in one kind of Basic, with one kind of IDE and produce one kind (HTML5/JS) of executable or "runnable" which can be accessed by many different users/players thru many kinds of web-browsers (which all comply with a common global standard).

I had not thought of Joe wanting to sell his games.
If so I would prefer to give Joe some way of "copy-locking" an HTML5/JS game to prevent copying and then sell it from wherever.
 
One of way of "copy-locking" is to rely on the honesty of the purchaser.
I dont know much about any other way.
Maybe a BB-to-APK transformation, plus GooglePlay store, like you describe, would be the way to go.
 

Not even an imaginary "Joe" would appreciate his work being copied and sold.

Or maybe I'm just old and sick of the gaming industries :)
Title: BrowserBasic Local WebServer
Post by: SteveOW on September 23, 2013, 06:56:41 PM
@Guilect
Some time ago I tried setting up the BrowserBasic Wireless WebServer (as described in the manual).
It worked.
It serves html files to my android tablet.
Great. :D

Recently found that (on a PC) Chrome and Opera wont let me access locally-stored files the way that Firefox does. :(
There is a way to reconfigure Chrome (with a special command line switch) but it is said to be risky if you use the same session to view other web sites (they can use it to get stuff from your PC).
The recommended option is to install and run your own local web server.
I trawled the internet and found lots of advice but it all looked a bit fiddly and high maintenance.
Then I thought, I wonder if BB wireless web server is visible on the same PC.
It is! :D :D

This seems too good to be true.

Dumb question: Is my browser accessing the local webserver thru internal PC communications or is it getting it from the wireless signal?


Title: Re: New version released; v0.6
Post by: Guilect on September 24, 2013, 11:38:47 AM
@ScriptBasic
Thanks for the information regarding Android Linux.

@SteveOW
Quote
Is my browser accessing the local webserver thru internal PC communications or is it getting it from the wireless signal?
I believe it is from the wireless.
Title: BrowserBasic webserver
Post by: SteveOW on January 26, 2014, 07:46:25 PM
@Guilect

I want to run a local webserver that can serve files to a browser running on the same local machine (in my case a Windows7 PC) but without wireless broadacsting.

When I disable my PC's wireless hardware device the BrowserBasic webserver continues serving files OK.

It would be nice to have the option to run it but without broadcasting wireless, e.g. by passing a parameter when launching the .exe from a .bat file.

Can you suggest how I might go about doing this?
I have looked into setting up local webservers but so far havent found anything simple.

====== EDIT ================

Got Apache installed and running on my Win7 PC and serving files OK.
It doesnt do wireless.  It was a bit fiddly to install.
Whereas the BrowserBasic server installation seemed to just be a matter of downloading the .exe.
I am intrigued to know how it works and how it was made.  Does it use IIS I wonder?





Title: Re: New version released; v0.6
Post by: Guilect on February 08, 2014, 12:16:39 AM
Hi SteveOW,

The program just uses sockets.
It opens a TCP socket.
Binds the socket to port 80.
Then listens for incoming connections on port 80.
When your browser attempts to connect to the IP address,
it defaults to port 80.
The programs accepts the connection.
Then any HTTP requests are processed by the program.
Well not too many HTTP commands are supported, but GET is one of them.
(e.g. GET /index.html)
The program processes the GET command and checks to see if the file requested exists.
If it does exist, then file is streamed out the socket.

It is a very simple web server, it can not do ASP or CGI or anything along those lines.
Nor are many HTTP commands implemented.  It can not POST, there are no cookies.  Only the minimum to spit out an HTML 5 game file.
Title: Re: New version released; v0.6
Post by: SteveOW on February 08, 2014, 05:55:26 PM
@Guilect,

Many thanks for the details.

Prompted me to code my very own web server
(using VB6, Winsock and tips I found here:http://www.vb6.us/source-code/very-basic-web-server-test). 
It took less than 30 minutes. 
I never realized it would be so easy. :)