JR 01's Weekly Coding Challenge

Remembering Destroyed objects

April 19th, 2024
Difficulty: Challenging
(Calendar & Rules)

Share a screenshot of how to program an object to remember that it was destroyed when returning to the level. In this instance, it needs to work without the save behavior because you want it to reset every game session. There are 2 ways to do this technically, but one is much easier than the other.

Example: There is a hallway level where you destoryed enemies, you go to a room level and then back to the hallway level. The enemies re-appeard, how would you prevent them from re-appearing?

*Edit: If you didn’t destory them, they should reappear in the level. And the objects themselves need to remember if they have been destroyed.

image

2 Likes

Heres my answer!

Answer Here


image

Nope but you are close though, you don’t want the enemies to follow you if you don’t destory them.

2 Likes
Answer
Don't view the answer without trying yourself



Though the below was my original thought. I was thinking of a case were Huckleberry wanted to do this same thing for candles being on/off, but they weren’t removed from the level (just didn’t play their animation).
This is the 2nd solution JR01 mentioned

1 Like

What if I used a save behavior and then have it reset everytime the player starts a new game session?
Or do I just not use a save completely?

My answer

Enemy Object:


Enemy Keep Object:


Game:
Flowlab Game Creator - JR01 Weekly Coding Challenge

1 Like

That global would only work for a single enemy in the level.
If you had multiple of the same enemy, it would not delete any or delete all enemies in a level at once.
The case should resolve if you didn’t remove all the enemies in a level and when returning to a level.

2 Likes

Yeah I realized that like a few minutes after posting that. I’ll try to fix it tomorrow.

So there are 2 ways do this, one of which is a lot more complex than the other. I’ll share the answer to both here, but @CodeAlpaca got both answers right as well.

The simple method is setting the object to “Keep on level restart”. This means anything done done with or in this object is kept even if you restart or come back to the level.

Simple Answer

image

The complex answer will need to extract the objects ID, and save it in a global list. A global will keep the value between levels but reset when the game is reloaded. So when starting a level, you can check the global list to see if the destoryed ID is there and re-destroy the object when starting level over again.

Complex Answer
2 Likes

Strange, I never knew that’s what “Keep on level restart” meant lol.
I really like this topic, it’s helping me learn the parts of Flowlab I didn’t know about yet!

2 Likes

Spinning Coin with Size

April 22th, 2024
Difficulty: Beginner
(Calendar & Rules)

Share a screenshot of how you would spin an coin sprite without animations. Use the size behavior to make it look like it is spinning. A good example of this look is Paper Mario.

image

1 Like
My Answer.

image
This was rather easy.


Game link:
Flowlab Game Creator - JR01 Weekly Coding Challenge

1 Like

This one is fun

Answer

I also have an animation for the back/front of the coin


Flowlab Game Creator - Coin Flip Example

2 Likes
Answer

{"data":{"behavior":{"v":"2","nodes":[{"inputCount":0,"outputCount":1,"name":"Once","behaviorType":"logic.triggers.Once","x":-360,"y":208,"group":"0876df518b2eeb44","id":"087e1f6a2197634f","resetOnLevelStart":false},{"inputCount":6,"outputCount":2,"name":"Ease","behaviorType":"logic.logic.Ease2","x":-180,"y":208,"group":"0876df518b2eeb44","id":"087e1f6b3717f84e","duration":0.8,"from":100,"to":2,"easeFunc":"Quadratic","easeType":2,"smartRot":false},{"inputCount":3,"outputCount":3,"name":"Size","behaviorType":"logic.properties.Scale","x":0,"y":208,"group":"0876df518b2eeb44","id":"087e1f6b62eee74d"},{"inputCount":2,"outputCount":2,"name":"Toggle","behaviorType":"logic.logic.FlipFlop","x":0,"y":320,"group":"0876df518b2eeb44","id":"087e1f6b26a68248","loop":true,"initialState":0}],"links":[{"input_id":"087e1f6b3717f84ei3","output_id":"087e1f6a2197634fo0"},{"input_id":"087e1f6b3717f84ei3","output_id":"087e1f6a2197634fo0"},{"input_id":"087e1f6b3717f84ei3","output_id":"087e1f6b26a68248o0"},{"input_id":"087e1f6b3717f84ei4","output_id":"087e1f6b26a68248o1"},{"input_id":"087e1f6b62eee74di1","output_id":"087e1f6b3717f84eo0"},{"input_id":"087e1f6b26a68248i0","output_id":"087e1f6b3717f84eo1"},{"input_id":"087e1f6b26a68248i1","output_id":"087e1f6b3717f84eo1"},{"input_id":"087e1f6b62eee74di1","output_id":"087e1f6b3717f84eo0"},{"input_id":"087e1f6b26a68248i0","output_id":"087e1f6b3717f84eo1"},{"input_id":"087e1f6b26a68248i1","output_id":"087e1f6b3717f84eo1"},{"input_id":"087e1f6b3717f84ei3","output_id":"087e1f6b26a68248o0"},{"input_id":"087e1f6b3717f84ei4","output_id":"087e1f6b26a68248o1"}]}}}

I prefer seeing a portion of the sprite still, which is why I keep it at 2 as the minimum size. Also just avoids any issues that Flowlab occasionally have with sprites at 0 size. Other ease settings are fine, I just prefer this one because it feels like it shows the front slightly longer than Linear or something else would.

Though this isn’t perfect, it still just looks more like squashing then stretching the sprite. So I’d swap the sprite once it’s finished to sell the effect more, or make the sprite slightly darker as it gets smaller. Didn’t add it though as it’s not a required part of the challenge.

1 Like

m yeah I forgot about leaving some portion of the sprite lol

it neets thickness

1 Like

I made this a while ago…

Code Here

image

It is just easier to list the code, instead of four screenshots.

`"

data":{"behavior":{"v":"2","nodes":[{"inputCount":4,"outputCount":0,"name":"Flip+","behaviorType":"logic.NodeGroup","x":450,"y":48,"id":"76633c63292d4948","isMenuItem":false},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":-32,"group":"76633c63292d4948","id":"76633c655a822843","portId":"76633c63292d4948i0","tag":"Toggle","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":48,"group":"76633c63292d4948","id":"76633c6562bd8a4c","portId":"76633c63292d4948i1","tag":"Flip","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":128,"group":"76633c63292d4948","id":"76633c66e712cb45","portId":"76633c63292d4948i2","tag":"Back","dataType":2},{"inputCount":6,"outputCount":2,"name":"Ease","behaviorType":"logic.logic.Ease2","x":180,"y":32,"group":"76633c6c1fddf942","id":"76633c6752119a42","duration":0.1,"from":100,"to":0,"easeFunc":"Quadratic","easeType":0,"smartRot":false},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":0,"y":128,"group":"76633c6c1fddf942","id":"76633c68a59cc846","portId":"76633c6c1fddf942i0","tag":"Flip","dataType":2},{"inputCount":6,"outputCount":2,"name":"Ease","behaviorType":"logic.logic.Ease2","x":360,"y":32,"group":"76633c6c1fddf942","id":"76633c680196d544","duration":0.1,"from":0,"to":100,"easeFunc":"Quadratic","easeType":0,"smartRot":false},{"inputCount":3,"outputCount":3,"name":"Size","behaviorType":"logic.properties.Scale","x":450,"y":-112,"group":"76633c6c1fddf942","id":"76633c6a445b5243"},{"inputCount":3,"outputCount":3,"name":"Flip","behaviorType":"logic.properties.Flip","x":630,"y":176,"group":"76633c6c1fddf942","id":"76633c6a623f9346","spriteOnly":false},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":0,"y":208,"group":"76633c6c1fddf942","id":"76633c6b74c9fa4f","portId":"76633c6c1fddf942i1","tag":"Back","dataType":2},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":360,"y":160,"group":"76633c6c1fddf942","id":"76633c6b61ea0547","_startVal":0,"dataType":2},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":360,"y":256,"group":"76633c6c1fddf942","id":"76633c6bc9f2084b","_startVal":0,"dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":0,"y":-48,"group":"76633c6c1fddf942","id":"76633c6b76a9b24f","portId":"76633c6c1fddf942i2","tag":"Time","dataType":2},{"inputCount":3,"outputCount":0,"name":"Flip Ease","behaviorType":"logic.NodeGroup","x":270,"y":32,"group":"76633c63292d4948","id":"76633c6c1fddf942","isMenuItem":false},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":-32,"group":"76633c6eca14c943","id":"76633c6c539c9847","portId":"76633c6eca14c943i0","tag":"In1","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":112,"group":"76633c6eca14c943","id":"76633c6c349b5241","portId":"76633c6eca14c943i1","tag":"In2","dataType":2},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":180,"y":-48,"group":"76633c6eca14c943","id":"76633c6c8d180e4a","_startVal":1,"dataType":2},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":180,"y":96,"group":"76633c6eca14c943","id":"76633c6cdbe7ab4b","_startVal":0,"dataType":2},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":450,"y":-48,"group":"76633c6eca14c943","id":"76633c6d04cf624f","portId":"76633c6eca14c943o0","tag":"Out1","dataType":2},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":450,"y":112,"group":"76633c6eca14c943","id":"76633c6d81b65645","portId":"76633c6eca14c943o1","tag":"Out2","dataType":2},{"inputCount":2,"outputCount":2,"name":"Close Gate","behaviorType":"logic.NodeGroup","x":90,"y":80,"group":"76633c63292d4948","id":"76633c6eca14c943","isMenuItem":false},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":90,"y":176,"group":"76633c63292d4948","id":"76633c6eb645084a","portId":"76633c63292d4948i3","tag":"Time","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":-32,"group":"76633c6f611cbf45","id":"76633c6e8dda6b47","portId":"76633c6f611cbf45i0","tag":"In","dataType":2},{"inputCount":2,"outputCount":2,"name":"Toggle","behaviorType":"logic.logic.FlipFlop","x":90,"y":-32,"group":"76633c6f611cbf45","id":"76633c6fe1657545","notes":"I have no idea why I did this. :)","n_o":1,"loop":true,"initialState":0},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":270,"y":-48,"group":"76633c6f611cbf45","id":"76633c6f8e5d9d42","portId":"76633c6f611cbf45o0","tag":"Flip","dataType":2},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":270,"y":32,"group":"76633c6f611cbf45","id":"76633c6fa457214e","portId":"76633c6f611cbf45o1","tag":"Back","dataType":2},{"inputCount":1,"outputCount":2,"name":"Toggle Gate","behaviorType":"logic.NodeGroup","x":90,"y":0,"group":"76633c63292d4948","id":"76633c6f611cbf45","isMenuItem":false}],"links":[{"input_id":"76633c6f611cbf45i0","output_id":"76633c655a822843o0"},{"input_id":"76633c6eca14c943i0","output_id":"76633c6562bd8a4co0"},{"input_id":"76633c6eca14c943i1","output_id":"76633c66e712cb45o0"},{"input_id":"76633c6a445b5243i1","output_id":"76633c6752119a42o0"},{"input_id":"76633c680196d544i3","output_id":"76633c6752119a42o1"},{"input_id":"76633c6b61ea0547i2","output_id":"76633c6752119a42o1"},{"input_id":"76633c6bc9f2084bi2","output_id":"76633c6752119a42o1"},{"input_id":"76633c6752119a42i3","output_id":"76633c68a59cc846o0"},{"input_id":"76633c6b61ea0547i1","output_id":"76633c68a59cc846o0"},{"input_id":"76633c6bc9f2084bi0","output_id":"76633c68a59cc846o0"},{"input_id":"76633c6a445b5243i1","output_id":"76633c680196d544o0"},{"input_id":"76633c6752119a42i3","output_id":"76633c6b74c9fa4fo0"},{"input_id":"76633c6b61ea0547i0","output_id":"76633c6b74c9fa4fo0"},{"input_id":"76633c6bc9f2084bi1","output_id":"76633c6b74c9fa4fo0"},{"input_id":"76633c6b61ea0547i0","output_id":"76633c6b61ea0547o0"},{"input_id":"76633c6a623f9346i0","output_id":"76633c6b61ea0547o0"},{"input_id":"76633c6a623f9346i1","output_id":"76633c6bc9f2084bo0"},{"input_id":"76633c6bc9f2084bi0","output_id":"76633c6bc9f2084bo0"},{"input_id":"76633c6752119a42i0","output_id":"76633c6b76a9b24fo0"},{"input_id":"76633c680196d544i0","output_id":"76633c6b76a9b24fo0"},{"input_id":"76633c6c8d180e4ai2","output_id":"76633c6c539c9847o0"},{"input_id":"76633c6cdbe7ab4bi1","output_id":"76633c6c539c9847o0"},{"input_id":"76633c6c8d180e4ai1","output_id":"76633c6c349b5241o0"},{"input_id":"76633c6cdbe7ab4bi2","output_id":"76633c6c349b5241o0"},{"input_id":"76633c6c8d180e4ai0","output_id":"76633c6c8d180e4ao0"},{"input_id":"76633c6d04cf624fi0","output_id":"76633c6c8d180e4ao0"},{"input_id":"76633c6cdbe7ab4bi0","output_id":"76633c6cdbe7ab4bo0"},{"input_id":"76633c6d81b65645i0","output_id":"76633c6cdbe7ab4bo0"},{"input_id":"76633c6c1fddf942i0","output_id":"76633c6eca14c943o0"},{"input_id":"76633c6c1fddf942i1","output_id":"76633c6eca14c943o1"},{"input_id":"76633c6c1fddf942i2","output_id":"76633c6eb645084ao0"},{"input_id":"76633c6fe1657545i0","output_id":"76633c6e8dda6b47o0"},{"input_id":"76633c6fe1657545i1","output_id":"76633c6e8dda6b47o0"},{"input_id":"76633c6f8e5d9d42i0","output_id":"76633c6fe1657545o0"},{"input_id":"76633c6fa457214ei0","output_id":"76633c6fe1657545o1"},{"input_id":"76633c6c1fddf942i0","output_id":"76633c6f611cbf45o0"},{"input_id":"76633c6c1fddf942i1","output_id":"76633c6f611cbf45o1"}]}}}
[/

Spawning Rain with random.

April 24th, 2024
Difficulty: Intermediate
(Calendar & Rules)

Share a screenshot of how you would spawn rain from the top of the level. It should be randomly spawned from the top of the level and disapear when it hits the ground.

image

2 Likes

It’s been a busy week for me, here’s the answer for Monday.
I’ll post the answer for Wednesday later today and start Today’s challenge.

Monday's Answer

image

2 Likes

Spawning Rain

Answer

image

1 Like

Counting with Proximity

April 26th, 2024
Difficulty: Challenging
(Calendar & Rules)

Share a screenshot of how to count the number of objects selected with proximity. This can be coins, enemies, or items. Make a version of code that uses once to count the objects, and then another version with always that shows a live count in the proximity.

image

2 Likes