Friday, April 30, 2021

Adaptation

 My work for toay: adapting a 2d array shuffle algorithm from

java to lua...


So far:



                                                             *     *     *

The [3][2] spot now shows 13:



                                                                        *     *     *







Thursday, April 29, 2021

Next_Step

 Now have the image appearing as tiles: one of each and no

doubles. Just need to integrate a shuffle!




                                                              *     *     *


It's a start! Not a real pro shuffle, but my homie concoction gives

something to play with:






Wednesday, April 28, 2021

Puzzling

 Been thinking it would be a waste to let that playable grid on match5

not be recycled into something more general Like making a puzzle with

a difficult image...


Now having the image appear. The actual grid is still in match3 mode🤨




*     *     *

There are know algorithms for shuffling members of an array:





The array in the code is version two of Fisher-Yates. The original version

dates from 1938 and was conceived not for computers. The more recent one

has linear time complexity: it is economical in time used. the video below

illustrates it.

With reference to the code: we are picking randomly form unchosen elements

from number in the series to 2 and swapping the picked one with the last one

of our current lot. It stops when the last remaining two have been swapped and

the new arrayis delivered...



Sunday, April 25, 2021

Boom!

 Been trying to use the knife code: a daunting experience.

It works as an extension to lus, but the particuliarities of

love2d make things difficult:





                                                      *     *     *

On top of things, this morning. Am now running The timer in the load

function (where things are only called once !?). With a little ingenuity - and

more Timers - should be able to get a scene going...



*     *     *
Turns out fine with everything on the same Timer.








Friday, April 23, 2021

Documentation

 Found the documentation on knife:

https://github.com/airstruck/knife


                                *     *     *

Amazing vid:


Vaccination_Push

 

Morning picture that put a smile on my face:

It is from La Presse.


Long a liberal newspaper, they are now registered as a non-profit (2018) but

continue to run on a non-aligned stance. They are totally digital.


As for vaccination, the US has yet to approve the AstraZeneca and have been

forwarding their stash to Canada, which has been a Godsend for our lagging

vaccination effort. Many Thanks.

Thursday, April 22, 2021

E_Day

 


Below, with initial opacity at .5:






Wednesday, April 21, 2021

Tweening

 Been playing with the notion of timers, which become important

in interpolation programs. One can have objects advance at different

rates with love2d as is, but if we become in interested in when they stop,

then one needs fancier code. Enter libraries, such as knife.


The term for game interpolation is tweening. Another term to know is easing,

having objects accelerate on departure and decelerate at arrival. One tweens

to ease...


Tweens1 was done with the love timer; Tweens2 with that from knife and shows

opacity coming in at different rates!


I've got it down to three birds, but still having trouble with the random position

version. Problem is, if love does two random oprations within one second of each

other, it will be using the same random seed, and to birds will be on the same y position.


Been thinking of running a problem with pi in between...😗





Tuesday, April 20, 2021

Overtake

 Looking at the translate command, used inside of love.draw().

It does just that: move the coordinates, and just once. Below, the 

result. Yellow is placed off-screen but translate brings it back...



In contrast, the update function, called every time the screen is redrawn.

Below, green overtakes yellow...






Monday, April 19, 2021

Twenty-six

 The brick wall, in Tiles1.lua, is not continuous. Been

revisiting the algorithm from Bird that scrolled the background:








The original background image is 1984 x 288. The screnn dimensions

requested are 800 x 600. By the terms of the algorithm, the image will

be drawn progressively from off-screen to the left until the offset reaches

800. This will then start all over. At a speed of 30 pixels per second, this should

take 26.6 seconds...







For the algorithm itself. What is initially drawn  is the image at 0, 0. On

redraw(dt) it is the value for the image minus that of bscroll. If we look

at what that is, it is scroll(initially 0) plus (0 * dt) ie an increaing value, that

of the scroll, The modulo operator is always at 0 because - up to 800 - the

denominator is larger than the numerator. the remainder is the scroll. At 800, 

the division value is 1, with remainder 0. This is where the image flips back to

HELLO! and the cycle begins again...




Sunday, April 18, 2021

Exemplary

 So, working as an exemplary student, I notice the menu in

the masterfile for Mario. One begins with tiles0, inVisual Studio

code.





There is a utility fonction to make quads, but no real spritesheet to speak of.

Just a lonely 32x16 piece of tiling whose right half is clear.





The utility function creates a spritesheet on orders form main.

And here main wants a map 20x20.

So what happens: one gets an empty background and a set of tiles to specification.

Below, the x-values will be, while y < 5, draw the Sky, set at 2, hence transparent.

Then, go to town and draw some tiles ie 1.






And there we are: 5 double rows of transparency and the rest, tiles...Modifiable at will!


*     *     *

*     *     *

Moving on to Tiles.1, one needs to change the code for the random 

background. Love2d currently codes for color not to 255 colors, the

RGB requirement. It rather expects a decimal value for that. The

default with no specifications will give that.



It's a fun exercise; one then gets a new background everytime one runs it.

The breakthrough, though, comes from the ability to advance the tiles - with the arrow
 
keys -  giving the impression of game mouvement. Recall that the scene is redrawn

in deltatime within love.draw().





                                        









Zelda

 I had promised to myself I would rest from these gaming

classes I have been slaving on. Couldn't stay away: started listening

to the Mario lecture, which I am planning to approfondir in every detail,

this time. Japanese video games really changed the whole environment

when they came along in the 1980s. 


An interesting aside, Le Monde is curently running a piece on the musical theme

from the Legend of Zelda . It is a recognizable icon, but has run through many

variations as the game has evolved. Legend will be the next lecture!! Below:



Saturday, April 17, 2021

Funeral Music

 Music at 1:14:13

https://youtu.be/mCY4b6GGkb4

Harsh

 The Sun UK - a British tabloid - has rebuked Prime Minister Trudeau

for his claim that Britain might be facing a Third Wave of the pandemic. 

Well, Ontario certainly is, clocking in at some 5000 new cases per day.and

a strained hospital system, the majority of these cases being the so-called

British variant. What's different about Britain itself: the vaccination rate.

Over half the British population has received a first dose, and that is making

a difference to the point where pubs have been allowed to  re-open.


Canada has been off to the races in buying vaccines, but not in receiving them

or vaccinating people effectively. Here in Quebec, vaccination is on with

no appointment vaccination for those willing to receive the AstraZeneca

vaccine. We have a high overall death rate because so many elderly people 

succombed in the first phase, but vaccine roll-out by age group seems to be 

working in calming caseloads for now.


Personally, I am lying low although vaccinated with the Pfizer. Just reading

yesterday that it might not be as effective against certain variants, and the makers

predict we will need a third jab and perhaps yearly vaccination thereafter, 

I go out for necessary shopping, and am grateful the Shopping Mall is

accessible.


We are a long way from a decent perspertive on what this pandemic has been

all about...



https://coronavirus.data.gov.uk/details/vaccinations

                                                                


*     *     *

On the clotting problem:


Friday, April 16, 2021

Understanding

 Moving on: I re-instated my score code, with an arrangement

for shiny tiles (in PlayState)


In Board.lua, inserted code - which I lifted outright - for 

including the whole row or column. What I couldn't see for

myself was that one can do a 'for... do' loop assigning a series

of y or x values. Now I understand!




                                                           *     *     *

The last part of the assignment struck me as truly Herculean: only allowing

a swap between tiles if it results in a match. Otherwise, reset the board. Just

found the code that does this on a Github. It's actually quite clever: from

Board.lua,  have every tile check left, right, top, bottom for a possible match 

by actually making the match; then reversing the match and returning true. 

If the whole eventually returns false to PlayState, re-set the board.


Now that's programming!


https://github.com/learyjk/Match-3