Animation: A Moment of Panic
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Animation: A Moment of Panic
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.
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.
Last edited by richmond62 on Sun May 22, 2022 7:18 pm, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
This is certainly a worthwhile port-of-call (especially if you cannot draw anything semi-decent like me):
https://craftpix.net/categorys/sprites/
-
https://craftpix.net/categorys/sprites/
-
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
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.
-
-
I really ought to get out more: but the chains cramp my style.
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.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
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.
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.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
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".
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".
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
This thread IS about animation, and that tends to involve movement.
In my stack, the RESET button uses . . set the loc.
In my stack, the RESET button uses . . set the loc.
Re: Animation: A Moment of Panic
You know what I mean!
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
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 . . .
Back with a vengeance (that means you, Klaus), and a thumping headache tomorrow . . .
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
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 . . .
the moveSpeed up well high?
Mind you, if the flaming DJ could turn the volume down
to about 20% round these parts . . .
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
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.
Last edited by richmond62 on Mon May 23, 2022 9:26 am, edited 2 times in total.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
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.
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.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
- Attachments
-
- FLIP SPRITE.livecode.zip
- Stack.
- (41.62 KiB) Downloaded 74 times
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Animation: A Moment of Panic
- Attachments
-
- TWIST and SHOUT.livecode.zip
- Stack.
- (43.53 KiB) Downloaded 71 times
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Animation: A Moment of Panic
Historical tidbit: sprite masking was implemented as a built-in engine feature for SuperCard 2.0 circa 1995 under the feature name of "filmstrips".
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn