Re: First pas2js public release

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Ingemar Ragnemalm

An update on my tests with pas2js:

I have overcome most problems now and am quite a bit happier with what I
see - and what I did see before was good!

Reimar Grabowski asked for interactivity. Done!

Myself, I wanted to reduce the amount of information, like file
references in the HTML file, because, yes, it does matter! And I wanted
to load sounds, and of course I, too, wanted interactivity! Done! Adding
missing methods, interfacing to more APIs (like audio), no problem! It
was surprisingly easy.

Here is an updated version of the Santa animation:

http://ragnemalm.se/images/santa/santa2.html

and here is an (almost) fully working snake game:

http://ragnemalm.se/images/santa/snake/snake.html

I really enjoyed making these! My code gets more and more comfortable,
there is no problem hiding the JS libraries. Will I do that in the long
run? Well, I don't know but doing that can help me making the code portable.

I also made some minor additions to Lightweight IDE, so now I edit,
compile and run directly from the IDE. "Run" passes the HTML to a web
browser.

I have implemented a different way to run animations, but still don't
know if it flickers on other platforms. On my Mac, there is no flicker
at all.

For gaming and similar purposes, all I miss now is the ability to save
scores on file. For a wider range of applications, I want the ability to
download data to my local drive. I havn't considered the case of
communicating directly with some server.

For being a preliminary "0." version, pas2js works wonderfully well!

/Ingemar


Den 2017-12-24 kl. 12:00, skrev Ingemar Ragnemalm:

> Den 2017-12-22 kl. 12:00, skrev Michael Van Canneyt:
>> On Wed, 20 Dec 2017, Reimar Grabowski wrote:
>>
>>> On Wed, 20 Dec 2017 15:14:50 +0100
>>> Ingemar Ragnemalm<[hidden email]>  wrote:
>>>
>>> But I don't see anything wrong with putting them in the HTML. For more flexibility you could create the HTML via a template engine or something but I would only load them from JS if there is a good reason to do so.
> One reason is to collect information in one place. Making HTML load it
> gives me two steps to the file instead of one. More chances to do it wrong.
>
>>> While you are updating your code you can remove the two dependencies on bootstrap (as they are not satisfied anyway and I think the whole fpReport dir is superflous) and perhaps do something about the flickering of the text (although this may be a little bit too much asked).
> Ah. They just remained from an example I worked from.
>
> Text flicker is most likely caused by not double buffering. I need to
> generate an image off-screen. Nothing strange with that, just one more
> thing to figure out in the JS environment.
>
>>>> It feels really nice to have my first Pascal web application running!
>>> Not dissing you or your work or pas2js but I fail to see the web application part. There is no communication between client and server. Actually there is no server side code at all and there is no interactivity. In my book this is a static page, but perhaps I miss something.
> There is no interactivity, and no client-server communication, but this is my *first*, my "proof of concept" for the platform, like Hello World but with some more features (animation, random numbers, graphics elements). Doing *something* with it myself, showing myself the potential, making a kind of "thanks" for it and a Christmas greeting atthe same time. Interactivity is the next step, and the ability to save data somewhere.
>
>> That is one of the points of pas2js. To allow you to program the browser.
>>
>> There is no need for a server. You can make e.g. a chess application that runs
>> 100% in the browser, using a single HTML file. You can embed the JS and
>> images in the HTML itself, and thus your HTML file is the 'executable'.
>>
>> See the browser as a desktop. Your program runs in that desktop.
>> If need be, this program can contact a server - the classical
>> client/server model, using HTTP as the protocol - but this is by no means a necessity.
>>
>> In that sense, the demo demonstrates this. The server is just there for you
>> to be able to download the "program"...
> Exactly. I get a cross-platform solution with no installations, in a way
> that users are increasingly used to. And I can write it in FPC, which I
> am a lot more happy with than a rubbish language like JavaScript! For me
> it opens a lot of possibilities!
>
> But let me get back to my current problems. I can accept loading images
> through HTML for now, but how can I load and play sounds? There is an
> "Audio" API in JavaScript but it seems that pas2js doesn't support it,
> it can't find play(). I have searched web.pas and a few others for it.
> Where do I start to fix that?
>
> /Ingemar

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Michael Van Canneyt


On Sun, 7 Jan 2018, Ingemar Ragnemalm wrote:

>
> An update on my tests with pas2js:
>
> I have overcome most problems now and am quite a bit happier with what I
> see - and what I did see before was good!
>
> Reimar Grabowski asked for interactivity. Done!
>
> Myself, I wanted to reduce the amount of information, like file
> references in the HTML file, because, yes, it does matter! And I wanted
> to load sounds, and of course I, too, wanted interactivity! Done! Adding
> missing methods, interfacing to more APIs (like audio), no problem! It
> was surprisingly easy.
>
> Here is an updated version of the Santa animation:
>
> http://ragnemalm.se/images/santa/santa2.html
>
> and here is an (almost) fully working snake game:
>
> http://ragnemalm.se/images/santa/snake/snake.html

Nice :)

>
> I really enjoyed making these! My code gets more and more comfortable,
> there is no problem hiding the JS libraries. Will I do that in the long
> run? Well, I don't know but doing that can help me making the code portable.
>
> I also made some minor additions to Lightweight IDE, so now I edit,
> compile and run directly from the IDE. "Run" passes the HTML to a web
> browser.

Lazarus already has this too.

>
> I have implemented a different way to run animations, but still don't
> know if it flickers on other platforms. On my Mac, there is no flicker
> at all.
>
> For gaming and similar purposes, all I miss now is the ability to save
> scores on file. For a wider range of applications, I want the ability to
> download data to my local drive. I havn't considered the case of
> communicating directly with some server.
>
> For being a preliminary "0." version, pas2js works wonderfully well!

Yes, the codebase that compiles with it is very large.

We're hoping to have it self-compiling someday.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Sandro Cumerlato
In reply to this post by Ingemar Ragnemalm
Awesame work! :-)

areas for improvement:

in santa2
- loop Jingle Bells.mp3 for an infinite pleasure ;-)
- play boing.mp3 multiple times in case of multiple keyboard hits.

in snake:



On 7 January 2018 at 15:03, Ingemar Ragnemalm <[hidden email]> wrote:

An update on my tests with pas2js:

I have overcome most problems now and am quite a bit happier with what I see - and what I did see before was good!

Reimar Grabowski asked for interactivity. Done!

Myself, I wanted to reduce the amount of information, like file references in the HTML file, because, yes, it does matter! And I wanted to load sounds, and of course I, too, wanted interactivity! Done! Adding missing methods, interfacing to more APIs (like audio), no problem! It was surprisingly easy.

Here is an updated version of the Santa animation:

http://ragnemalm.se/images/santa/santa2.html

and here is an (almost) fully working snake game:

http://ragnemalm.se/images/santa/snake/snake.html

I really enjoyed making these! My code gets more and more comfortable, there is no problem hiding the JS libraries. Will I do that in the long run? Well, I don't know but doing that can help me making the code portable.

I also made some minor additions to Lightweight IDE, so now I edit, compile and run directly from the IDE. "Run" passes the HTML to a web browser.

I have implemented a different way to run animations, but still don't know if it flickers on other platforms. On my Mac, there is no flicker at all.

For gaming and similar purposes, all I miss now is the ability to save scores on file. For a wider range of applications, I want the ability to download data to my local drive. I havn't considered the case of communicating directly with some server.

For being a preliminary "0." version, pas2js works wonderfully well!

/Ingemar


Den 2017-12-24 kl. 12:00, skrev Ingemar Ragnemalm:
Den 2017-12-22 kl. 12:00, skrev Michael Van Canneyt:
On Wed, 20 Dec 2017, Reimar Grabowski wrote:

On Wed, 20 Dec 2017 15:14:50 +0100
Ingemar Ragnemalm<[hidden email]>  wrote:

But I don't see anything wrong with putting them in the HTML. For more flexibility you could create the HTML via a template engine or something but I would only load them from JS if there is a good reason to do so.
One reason is to collect information in one place. Making HTML load it
gives me two steps to the file instead of one. More chances to do it wrong.

While you are updating your code you can remove the two dependencies on bootstrap (as they are not satisfied anyway and I think the whole fpReport dir is superflous) and perhaps do something about the flickering of the text (although this may be a little bit too much asked).
Ah. They just remained from an example I worked from.

Text flicker is most likely caused by not double buffering. I need to
generate an image off-screen. Nothing strange with that, just one more
thing to figure out in the JS environment.

It feels really nice to have my first Pascal web application running!
Not dissing you or your work or pas2js but I fail to see the web application part. There is no communication between client and server. Actually there is no server side code at all and there is no interactivity. In my book this is a static page, but perhaps I miss something.
There is no interactivity, and no client-server communication, but this is my *first*, my "proof of concept" for the platform, like Hello World but with some more features (animation, random numbers, graphics elements). Doing *something* with it myself, showing myself the potential, making a kind of "thanks" for it and a Christmas greeting atthe same time. Interactivity is the next step, and the ability to save data somewhere.

That is one of the points of pas2js. To allow you to program the browser.

There is no need for a server. You can make e.g. a chess application that runs
100% in the browser, using a single HTML file. You can embed the JS and
images in the HTML itself, and thus your HTML file is the 'executable'.

See the browser as a desktop. Your program runs in that desktop.
If need be, this program can contact a server - the classical
client/server model, using HTTP as the protocol - but this is by no means a necessity.

In that sense, the demo demonstrates this. The server is just there for you
to be able to download the "program"...
Exactly. I get a cross-platform solution with no installations, in a way
that users are increasingly used to. And I can write it in FPC, which I
am a lot more happy with than a rubbish language like JavaScript! For me
it opens a lot of possibilities!

But let me get back to my current problems. I can accept loading images
through HTML for now, but how can I load and play sounds? There is an
"Audio" API in JavaScript but it seems that pas2js doesn't support it,
it can't find play(). I have searched web.pas and a few others for it.
Where do I start to fix that?

/Ingemar

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: First pas2js public release

Free Pascal - General mailing list
In reply to this post by Ingemar Ragnemalm
On 07.01.2018 15:03, Ingemar Ragnemalm wrote:
> and here is an (almost) fully working snake game:
>
> http://ragnemalm.se/images/santa/snake/snake.html
>

Perhaps you should write somewhere how the snake is controlled. I
personally am used to using all four cursor keys to control the snake's
movement based on the global coordinate system instead of only left and
right from the local coordinate system on the snake. So I was quite
confused at first as I used "Up", but the snake didn't move there... ^^'

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal