JR 01's Weekly Coding Challenge

Joints must be a movable object to attach to first object, the joint behavior also has a secret feature where you can joint non-movable, but only to the movable joint. So to make a bridge, you have a nonmovable object that joints to a bridge object. The bridge can joint to itself but you meed to make sure to not create an infinite loop. A good way is to send a number to the joint input, so the joint object can get that value from the start value extract option. After a set amount of bridge joints, you can joint to a nonmovable object to end the bridge.

Answer

image

First object:
image

Bridge Object:

3 Likes

Perfect Looping Sound

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

Share a screenshot on how you would handle on creating a perfect loop with sounds. In instances that music or sounds needs to loop without cutting off, you’ll notice that the loop checkbox isn’t sufficiant

A good example of music you should try to loop in the library is
music > loops > 12okt

image

5 Likes

spoiler @JR01

what if the game lags and the music and timer get out of sync?

4 Likes
Well for one,

music and timers are both their own things that run outside of game performance, so that wouldnt happen anyways.

Sounds running mp3 through its own player through the device, and timers are running on the device clock speed, so neither behaviors should desync if a game were to have performance issues.

And two, this is just for a challenges where you submit screenshots of code. These challenges aren’t performance based, or i would make them expression challenges.

2 Likes

but

spoilers

But the engine doesn’t know when the sound has loaded, so depending on the internet connection, the speed/time could vary. The Play output also doesn’t output when the sound loads successfully, unfortunately.

4 Likes
True but there is no way around that. But...

The sound behavior only allows playing one instance of sound per behavior so even if its starts late, the next trigger will reset the sound behavior and then be on sync.

If there was a way for the behavior to output when the sound has loaded, then there would just be an easy connection to make it loop without resets.

Bad internet connection causes delay in music for all games at really slow speeds. So it will not be considered in this challenge.

1 Like

Despite no attempts, I still will show the answer for searchability for users that are looking for it.
This one is really beginner but isn’t obvious when trying to figure it our for the first time. The Loop checkbox had a delay because the metadata in a mp3 prevents it from running seamlessly. For most music, this isn’t a problem but it is a workaround if you need seamless audio. A timer works outside of the game fps and uses the devices clock speed. So timers will always be able to loop the audio perfectly. With bad internet speeds, the audio may have a delay to start. There is no work around for that, but when the loop is activated, it will reset the sound and then loop perfectly. Sound behaviors does not play the same sound multiple times, it resets the sound for each sound behavior is the only instance for that one sound.

Answer

image

1 Like

Excuse me? May I ask an off-topic question?

How did you center that image?

Making Custom Gravity

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

Show the code how to change gravity in 4 directions in a platformer (up, down. left, Right). Also have your own run and jump code to move the player in those direction.

image

2 Likes
<div align = center>

image 
2 Likes

Wait, I didn’t know that it existed.

[I really wish flowlab had an option to just edit the actual “gravity” property of individual objects, rather than having to phenegal separate mass and force estimates for each object with a specific density…(applying forces in different directions on a player object is neat, but when you try to apply it to multiple objects with different sizes…things get very tough accuracy-wise). Also, it would be cool if we could know the units on the density, gravity, velocity, impulse, etc. since currently you just kind of have to do your best guess and check…]

3 Likes

True, but if we do get a gravity behavior it needs to have a “this object” toggle to be able to apply different gravity by object. I also want to argue that we need a rotatable forces like velocity so we can have different angles (like how x velocity doesn’t affect y force of the object).

3 Likes

I made this really quickly, but it works. :slight_smile:

Answer

Player Gravity Code;


Player Settings
image

Can I use that code for the gun composite in my game?

1 Like

Sure! I don’t mind if you use any of my code. :slight_smile:

Code Here
{"data":{"behavior":{"v":"2","nodes":[{"inputCount":0,"outputCount":1,"name":"Always","behaviorType":"logic.triggers.Always","x":-90,"y":-16,"group":"","id":"f1054a38d2c3f741"},{"inputCount":3,"outputCount":1,"name":"Object Variable","behaviorType":"logic.properties.CustomProperty","x":90,"y":-16,"group":"","id":"f1058ae92b09be49","tag":"Player Gravity:Number"},{"expression":"A*-1","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":2,"tag":"Reverse","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":270,"y":-16,"group":"","id":"f105edd60f818540","notes":"Reverse to negative.","n_o":1},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":90,"y":144,"group":"","id":"f107adeb4723de47","startVal":45,"tag":"Set Gravity","roundMode":1},{"inputCount":0,"outputCount":1,"name":"Once","behaviorType":"logic.triggers.Once","x":-90,"y":160,"group":"","id":"f107bd7d132d7243","resetOnLevelStart":false},{"inputCount":3,"outputCount":1,"name":"Object Variable","behaviorType":"logic.properties.CustomProperty","x":270,"y":144,"group":"","id":"f107f5ef4cb6c04b","tag":"Player Gravity:Number"},{"inputCount":3,"outputCount":3,"name":"Push Motor","behaviorType":"logic.components.Motor","x":450,"y":-16,"group":"","id":"f1086e139ae8ee42"}],"links":[{"input_id":"f1058ae92b09be49i1","output_id":"f1054a38d2c3f741o0"},{"input_id":"f1058ae92b09be49i1","output_id":"f1054a38d2c3f741o0"},{"input_id":"f105edd60f818540i0","output_id":"f1058ae92b09be49o0"},{"input_id":"f105edd60f818540i2","output_id":"f1058ae92b09be49o0"},{"input_id":"f105edd60f818540i0","output_id":"f1058ae92b09be49o0"},{"input_id":"f105edd60f818540i2","output_id":"f1058ae92b09be49o0"},{"input_id":"f1086e139ae8ee42i1","output_id":"f105edd60f818540o0"},{"input_id":"f107adeb4723de47i1","output_id":"f107bd7d132d7243o0"},{"input_id":"f107f5ef4cb6c04bi0","output_id":"f107adeb4723de47o0"},{"input_id":"f107adeb4723de47i1","output_id":"f107bd7d132d7243o0"},{"input_id":"f107f5ef4cb6c04bi0","output_id":"f107adeb4723de47o0"},{"input_id":"f1086e139ae8ee42i1","output_id":"f105edd60f818540o0"}]}}}

I don’t need that copy code because Idk how to copy it in my game :penguin:

1 Like

You can use the import button, and paste it in there. If you select code with the tool in the editor and copy it, it automatically copies it to your clipboard, then letting you import it into your game.

Thanks, I didn’t know that.

1 Like

This challenge was a bit more difficult than I exspected, so any custom gravity is good. If you try this challenge, just try to make a custom gravity and controls on the cieling.

But yes, to create custom gravity, you should remove effected by gravity on the object and use a motor to replace the Gravity effect. Then you can use Motor X and Y to create custom Gravity in any direction. The answer below will have a link on how I made 4 directional custom Gravity.

Simple Solution
Challenge Answer

Flowlab Game Creator - Custom Gravity