Page 1 of 3
Animation: A Moment of Panic
Posted: Sat May 21, 2022 8:48 pm
by richmond62
I got "all hot and sweaty" today when I came across something called
sprite masking, which has to
do with the way
sprite images pass each other:
https://www.reddit.com/r/Unity3D/commen ... on_top_of/
When I realised that
LiveCode is so fantastic that there is no need to even consider that:
-
-
https://www.dropbox.com/s/a7skk4wyujf8j ... e.zip?dl=0
-
Use the 'A', 'D', 'J' and 'L' keys to move the 2 monsters.

Re: Animation: A Moment of Panic
Posted: Sun May 22, 2022 8:13 am
by richmond62
This is certainly a worthwhile port-of-call (especially if you cannot draw anything semi-decent like me):
https://craftpix.net/categorys/sprites/
-
Re: Animation: A Moment of Panic
Posted: Sun May 22, 2022 8:21 am
by richmond62
The reason I panicked was threefold:
1. I had never heard of sprite masks before.
-
-
2. I had forgotten I was not programming for the BBC Micro.
3. I had forgotten about
LAYERS in
LiveCode.
Code: Select all
on rawKeyDown RD
switch RD
case 97
set the layer of grc "mRIGHT" to top
put item 1 of the loc of grc "mRIGHT" into RLR
put item 2 of the loc of grc "mRIGHT" into RUD
subtract 20 from RLR
move grc "mRIGHT" to RLR,RUD
add 1 to fld "RR"
if fld "RR" > 17 then
put 0 into fld "RR"
end if
put fld "RR" into RX
set the backGroundPattern of grc "mRIGHT" to the ID of img ("Minotaur_01_Walking_" & RX & ".png")
break
case 100
set the layer of grc "mRIGHT" to top
put item 1 of the loc of grc "mRIGHT" into RLR
put item 2 of the loc of grc "mRIGHT" into RUD
add 20 to RLR
move grc "mRIGHT" to RLR,RUD
add 1 to fld "RR"
if fld "RR" > 17 then
put 0 into fld "RR"
end if
put fld "RR" into RX
set the backGroundPattern of grc "mRIGHT" to the ID of img ("Minotaur_01_Walking_" & RX & ".png")
break
case 106
set the layer of grc "mLEFT" to top
put item 1 of the loc of grc "mLEFT" into LLR
put item 2 of the loc of grc "mLEFT" into LUD
subtract 20 from LLR
move grc "mLEFT" to LLR,LUD
add 1 to fld "LL"
if fld "LL" > 17 then
put 0 into fld "LL"
end if
put fld "LL" into LX
set the backGroundPattern of grc "mLEFT" to the ID of img ("Minotaur_03_Walking_" & LX & ".png")
break
case 108
set the layer of grc "mLEFT" to top
put item 1 of the loc of grc "mLEFT" into LLR
put item 2 of the loc of grc "mLEFT" into LUD
add 20 to LLR
move grc "mLEFT" to LLR,LUD
add 1 to fld "LL"
if fld "LL" > 17 then
put 0 into fld "LL"
end if
put fld "LL" into LX
set the backGroundPattern of grc "mLEFT" to the ID of img ("Minotaur_03_Walking_" & LX & ".png")
break
end switch
end rawKeyDown
-
-
I really ought to get out more: but the chains cramp my style.

Re: Animation: A Moment of Panic
Posted: Sun May 22, 2022 12:17 pm
by richmond62
Oo-er:
https://docs.unity3d.com/Manual/class-SpriteMask.html
All very complicated indeed when, in LiveCode all one needs are a bunch of PNG or GIF images.
Re: Animation: A Moment of Panic
Posted: Sun May 22, 2022 12:25 pm
by richmond62
UNITY:
-

- SpriteMask3.png (27.38 KiB) Viewed 5495 times
-
LiveCode:
-
Re: Animation: A Moment of Panic
Posted: Sun May 22, 2022 1:02 pm
by Klaus
Richmond,
some time ago you admitted that I had finally been able to convince you to use "mouseup" instead of "mousedown".
Maybe I can also convince you to use "set the loc of xy to x,y"*** instead of "move xyz to x,y", what you ALWAYS use?
That will make everything much more "snappier"!
Try it here in your "Sprite Fight" example.
***Of course only where you do not need an animation-like "move".
Re: Animation: A Moment of Panic
Posted: Sun May 22, 2022 1:20 pm
by richmond62
This thread IS about animation, and that tends to involve movement.
In my stack, the RESET button uses . . set the loc.

Re: Animation: A Moment of Panic
Posted: Sun May 22, 2022 1:30 pm
by Klaus
You know what I mean!
Re: Animation: A Moment of Panic
Posted: Sun May 22, 2022 7:07 pm
by richmond62
Bloody Hell, mandatory attendance at an enormous piss-up for one my ex-pupils because she has finished high school (sit on your arse and you'll fall out the top oneday), no obvious method of escape.
Back with a vengeance (that means you, Klaus), and a thumping headache tomorrow . . .

Re: Animation: A Moment of Panic
Posted: Sun May 22, 2022 7:26 pm
by richmond62
Wait a moment . . . why not just rack
the moveSpeed up well high?
Mind you, if the flaming DJ could turn the volume down
to about 20% round these parts . . .
Re: Animation: A Moment of Panic
Posted: Mon May 23, 2022 9:15 am
by richmond62
-
The
ONLY significant difference between this stack and the previous one is that it employs
on
rawkeyUp instead of
rawKeyDown.
https://www.dropbox.com/s/ch9nnqcerx9n7 ... e.zip?dl=0
What that does entail is that each movement is
discrete, while in the first stack, by keeping one of
the control keys down the
move signal was sent repeatedly.
Generally, when teaching children how to make goofy games I suggest they use rawKeyUp rather than rawKeyDown
just so there is not the 'horrible' problem of
backGroundPattern animation happening in graphic rectangles AFTER movement of those graphic rectangles has taken place.
Re: Animation: A Moment of Panic
Posted: Mon May 23, 2022 9:23 am
by richmond62
Klaus, I understand your criticism of using move rather than set to be because,
using move in a rawKeyDown script means that, on keeping a key down,
movement proceeds in jerks, while, by using set that will not happen.
HOWEVER, and it is a 'HOWEVER' that has to be considered:
This stack was NOT conceived of as a way of reproducing Tom-&-Jerry like smooth animation, it was
conceived of as:
1. An illustration how, by using
set the layer of something to top
one did not have to get 'all hot and sweaty' about sprite masking in LiveCode.
2. How this might be implemented in a side-scrolling game.
Re: Animation: A Moment of Panic
Posted: Mon May 23, 2022 1:28 pm
by richmond62
Re: Animation: A Moment of Panic
Posted: Mon May 23, 2022 2:00 pm
by richmond62
Re: Animation: A Moment of Panic
Posted: Mon May 23, 2022 6:20 pm
by FourthWorld
Historical tidbit: sprite masking was implemented as a built-in engine feature for SuperCard 2.0 circa 1995 under the feature name of "filmstrips".