Welcome to the forum, AlbertEinlime!
AlbertEinlime:
So every red or green block takes its own frame to execute? Do other things continue to execute before the next frame is called, or does every “thread” pause?
Is there more documentation for this type of thing? “What is hopscotch doing and when?” type stuff?
There is some more information on that part here (though it relates more to the runtime of individual blocks and not in relation to When containers)
How Hopscotch works right now
This post is in response to some folks on the forum who wanted more details about how Hopscotch works. The following is somewhat technical but should be understandable by a determined 14-year-old who is interested in coding.
Note: we reserve the right to update this in later versions of the player for various reasons. As of today, November 25, 2019, it is accurate to the best of my knowleddge
The code
The Hopscotch player is written in javascript , a language for…
For the When containers, the idea in theory is that each is simultaneously checking whether its condition is met and running the code inside — though in practice, there is an order of execution which tries to replicate that
ThinBuffalo made some pretty helpful diagrams here which go through execution order for Whens. (This is from an older post which I think was a draft, and unfortunately the archive/deprecated category is restricted to trust level 2 and above, but I have quoted parts of the post)
https://forum.gethopscotch.com/t/tbsrs-hopscotch-coding-topic/25409/966?u=t1_hopscotch
Definitions:
Rule - “When” Blocks. The code inside executes when the rule evaluates to true
Trait - Properties of an object, e.g., x position
, rotation
, and speed
.
Original Object - The objects found on the Editor’s stage.
Global Variable - Variables found under iPhone/iPad. Can be referenced anywhere.
Object Variable - Variables founds under Objects. Every object maintains its own, unique value. Object variables of original objects can be referenced anywhere by selecting the appropriate object reference. Object variables of clones can only be referenced by (self).
The app is written in Objective C, the player (both in app & the web player) uses JavaScript, specifically pixiJS , and server side they use Ruby on Rails.
nothing instantaneous. nothing simultaneous
order matters
Discuss lag. from too many rules/blocks (clones), from collision rules (need to update figures to show when collision checking occurs?), from unoptimized code
Notes on Collision Rules:
Unlike variables that can be changed intra-frame, Collision rules evaluate only based on the object states at beginning of the frame
Collisions rules do not fire on the very 1st frame, even if objects are touching on the Stage
3 Likes