Slider3 game

Anything QL Software or Programming Related.
stevepoole
Aurora
Posts: 889
Joined: Mon Nov 24, 2014 2:03 pm

Slider3 game

Post by stevepoole »

Hi All,

Just been converting some more QL games to Javascript, to work on any PCs. (Tactile interfaces not yet mastered.... but ok with PC keyboard entries.)

This one is the old game where you have to slide letters around a grid to reform a well known saying, using the arrow keys.

"IfAtFirstYouDoNotSucceedTryTryAgain". You get a count of the number of moves taken to reconfigure the randomised text.

Unzip, and LRUN the .bas file or click on the slider3.html file to exec it. (The .bas file compiles ok with 2ko of data space.)

The .bas code is very short, but the .html code is much longer, as I am only just learning the ropes !

Next job is to try a tactile screen version... for tablets and smartphones too.

Regards,
Steve.
slider3.zip
(2.52 KiB) Downloaded 139 times
slider3_bas.zip
(1.26 KiB) Downloaded 127 times


stevepoole
Aurora
Posts: 889
Joined: Mon Nov 24, 2014 2:03 pm

Re: Slider3 game

Post by stevepoole »

Hi Folks,

Here is the slider version which will run on any device with a tactile screen.

Conversion from keyboard to buttons proved quite easy.

Many thanks again to Per, for having directed me to a good tutorial site !

When unzipped, ensure that the file is called 'tactile.html'. If not, use your rename option to modify the file name. Then just click on it....

Regards,

Steve.
tactile.zip
(2.42 KiB) Downloaded 107 times


User avatar
bwinkel67
QL Wafer Drive
Posts: 1520
Joined: Thu Oct 03, 2019 2:09 am

Re: Slider3 game

Post by bwinkel67 »

That's a very fun game!


User avatar
Cristian
QL Wafer Drive
Posts: 1024
Joined: Mon Feb 16, 2015 1:40 pm
Location: Veneto

Re: Slider3 game

Post by Cristian »

Thank you Steve!


Derek_Stewart
Font of All Knowledge
Posts: 4684
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Slider3 game

Post by Derek_Stewart »

Hi Steve,

Coukd the tiles be selected by the mouse?

I have programmed in Javascript, so there would be a learning to get your level. I will have at look at W3Schools to see how hard it is...


Regards,

Derek
stevepoole
Aurora
Posts: 889
Joined: Mon Nov 24, 2014 2:03 pm

Re: Slider3 game

Post by stevepoole »

Hi Derek,

I am a newcomer to JavaScript, and it took me more than a week to get this far....

There was a tutorial example of how to use the mouse 'arrow' buttons, which helped me a lot.

But accessing 'tiles' is beyond my knowledge at present : (I haven't found out which JS keywords need to be searched for yet).

At present I am trying to find out how to use 'Matrix arrays' in JavaScript. These are easy to use in S*Basic, but in JS you need the 'R' language extensions it seems !

The Slider3 SuperBasic version uses 2D array accessing, but in JS I had to resort to splitting and splicing strings instead... quite acrobatic.

More complex games will require a great feal of matrix manipulation, whereas I chose 'slider3' as it only has one moving tile at a time.

Work in progress.
Steve.


EmmBee
Trump Card
Posts: 245
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Slider3 game

Post by EmmBee »

Hi Steve,

Would be interesting to write an SBASIC program to solve it.
Once a sequence of moves is found, they could be displayed
with a one-second interval between each.

How could finding such a sequence of moves be found?
Perhaps a heuristic could be made from how far each letter is
from its finishing position. Then choosing the best score obtained.

EmmBee


stevepoole
Aurora
Posts: 889
Joined: Mon Nov 24, 2014 2:03 pm

Re: Slider3 game

Post by stevepoole »

Hi EmmBee,

If I am not mistaken, Dilwyn did such a program some years ago.

I chose the 'slider' S*Basic progam to trancode into JavaScript, as it was short enough for my limited understanding of the latter to deal with.

The recoding is quite straightforward to achieve, but JavaScript keyboard and tactile screen handling is a bit daunting, at least to begin with.

The advantage of S*Basic is that it is easy to write prototypes with. But JavaScript runs on any device, with no need for emulators... once you have finalised code.

I hope forum members will profit from comparing the code written in the two languages, especially for younger programmers. ( I use NotePad++ to compare.)

All the Best,
Steve.


Derek_Stewart
Font of All Knowledge
Posts: 4684
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Slider3 game

Post by Derek_Stewart »

Hi,

A more interesting idea, would be if S*Basic could be directly interpreted into Javascript. So that all the QL based programming skills could be used to produce a good QL based programme and also have a Javascript version.

Maybe Dilwyn's start could be used to exapand the idea, but I could not find this on the QL Homepage.


Regards,

Derek
stevepoole
Aurora
Posts: 889
Joined: Mon Nov 24, 2014 2:03 pm

Re: Slider3 game

Post by stevepoole »

Hi Derek,

Automatic transcoding from QL Basic to JavaScript would require first fully mastering the latter, which will take some more time yet !


One project done successfully involved transcoding from QL Basic to C++ :
First, QL programs had to be made '128ko capable', then Turbo compatible, then CFIXed-ready for C68, then SB keywords had to be written in 'C'..... Ooof !


JavaScript is somewhat similar to C++ in some respects, except the user interfacing, which is all new ground to be dealt with. So although there is a possible 'C++' route to follow, it is probably easier to transcode all by hand at present to save valuable time...

The first task is to write JavaScript functions to replace SB keywords, and in this respect, work is progressing, albeit slowly.

My next trancoded program will involve finding out how to implement JavaScript 'matrix 2D arrays', done easily in SB via DIM grid(x,y) !

So I am digging out my old QL programs to see which are suitable for the increasing difficulties as I progress along the JavaScript learning curve....

Steve.


Post Reply