Browse Search Popular Register Upload Rules User list Login:
Search:
Disconnected Pico (FOR CODERS) (SHORT CODING LESSON SORTA)

Image:
screenshot of the scene

Author: AverageCoder

Group: Default

Filesize: 1.04 MB

Date added: 2024-06-14

Rating: 5

Downloads: 1337

Views: 208

Comments: 0

Ratings: 1

Times favored: 0

Made with: Algodoo v2.2.0b

Tags:

Scene tag

If you are on mobile, go away
If you are on pc, stay
If you are a advanced coder or you just want to understand how it works, you can look at the code and see how it functions

postStep snippet:

(e)=>{
anims := [_left, _down, _up, _right];
animsOffsets := [_leftOffsets, _downOffsets, _upOffsets, _rightOffsets]; <-- This line and the one above defines what animations and offsets will be used in the form of a list
waitTime := 0.4; <-- how long in seconds it takes for the animation to go back to idle
framerate := 12; <-- frames per second
keys.isdown("shift") && Keys.isDown("z") ? {
_intendedPos = app.mousePos
} : {};
_gamePlayMode ? { <-- If the _gamePlayMode variable is true, then execute everything in the first set of {} brackets
_playAnimOnce(anims(_currentAnimation), 12, animsOffsets(_currentAnimation), _timeWhen, sim.time);
Keys.isDown(_keybinds(0)) ? { <-- If the key that is down matches _keybinds(0) in which keybinds is the list [c,v,n,m], do the stuff in the first set of brackets
_1 ? {
_1 = false;
_timeWhen = sim.time;
_currentAnimation = 0
} : {};
_timeWhenLetgo = sim.time
} : {
_1 = true
};

} : {}
}

Lists can be very useful for things like this that would otherwise be too long

[1,0](_var)

instead of :

_var == 1 ? 1 : 0

both would return 1 if _var is equal to 1 and 0 if _var is not equal to 1
with larger if statements it can get very cluttered

The way that it works is that the number in the () brackets returns what correlates with it in the [] brackets
for example : [1,2](0) returns 1, [32,45,63](2) returns 63, [1](0) returns 1

The way that it is used for the post step code is very useful, I will use it for future projects

the [_left,_down,_up_right] are also all lists, and when one of them are chosen, it returns the list that the variable went to so I wouldnt have to code every one of them seperate for the _playAnimOnce code

speaking of it, it is a function

basic function code would be like

(variableIdk)=>{_idk = variableIdk}

this makes it so you could write something like :

_absolute := (number)=>{number >0 ? number * 1 : number * (-1)}

it would return the absolue value of the number inputted that would then always be positive
for example : _absolute(-1) returns 1 and _absolute(2) returns 2

I hope this helps people in the communtiry understand how Thyme code works
Please log in to rate this scene
edit
Similar scenes
Title: Lesson 002: Testing your skills
Rating: 5
Filesize: 17.83 kB
Downloads: 186
Comments: 3
Ratings: 1
Date added: 2016/02/08 18:48:33
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: RMR Season 1, Part 1.
Rating: 5
Filesize: 36.52 kB
Downloads: 136
Comments: 0
Ratings: 1
Date added: 2020/05/29 21:12:56
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: frustrating asl ngl. (for coders)
Rating: 5
Filesize: 104.97 kB
Downloads: 384
Comments: 4
Ratings: 1
Date added: 2024/10/19 07:21:14
Made with: Algodoo v2.2.0b
Rating: rated 5
download
Title: Expansion of gasses visualization
Rating: 5
Filesize: 70 kB
Downloads: 292
Comments: 0
Ratings: 1
Date added: 2014/11/17 04:26:20
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Brawl of Stupidity Ep 0
Rating: 5
Filesize: 2.54 MB
Downloads: 605
Comments: 0
Ratings: 1
Date added: 2016/03/24 05:05:47
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: springs lesson +bike
Rating: 5
Filesize: 221.98 kB
Downloads: 540
Comments: 0
Ratings: 1
Date added: 2009/11/30 15:52:11
Made with: Phun
Rating: rated 5
download