Skip to content

Commit

Permalink
angular velocity
Browse files Browse the repository at this point in the history
  • Loading branch information
jwklong committed Nov 23, 2024
1 parent 2b69bd8 commit 3ed2eba
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions src/extensions/jwPsychic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ class Extension {
filter: [TargetType.SPRITE],
...Vector.Block
},
{
opcode: 'setVel',
text: 'set velocity to [VECTOR]',
blockType: BlockType.COMMAND,
arguments: {
VECTOR: Vector.Argument
},
filter: [TargetType.SPRITE]
},
{
opcode: 'getVel',
text: 'velocity',
disableMonitor: true,
filter: [TargetType.SPRITE],
...Vector.Block
},
{
opcode: 'setRot',
text: 'set rotation to [ANGLE]',
Expand All @@ -119,20 +135,23 @@ class Extension {
filter: [TargetType.SPRITE]
},
{
opcode: 'setVel',
text: 'set velocity to [VECTOR]',
opcode: 'setAngVel',
text: 'set angular velocity to [ANGLE]',
blockType: BlockType.COMMAND,
arguments: {
VECTOR: Vector.Argument
ANGLE: {
type: ArgumentType.ANGLE,
defaultValue: 0
}
},
filter: [TargetType.SPRITE]
},
{
opcode: 'getVel',
text: 'velocity',
opcode: 'getAngVel',
text: 'angular velocity',
blockType: BlockType.REPORTER,
disableMonitor: true,
filter: [TargetType.SPRITE],
...Vector.Block
filter: [TargetType.SPRITE]
}
],
menus: {
Expand Down Expand Up @@ -321,6 +340,18 @@ class Extension {
if (!body) return new Vector.Type(0, 0)
return this.matterToVector(body.velocity)
}

setAngVel({ANGLE}, util) {
let body = this.bodies[util.target.id]
if (!body) return
Matter.Body.setAngularVelocity(body, Cast.toNumber(ANGLE))
}

getAngVel({}, util) {
let body = this.bodies[util.target.id]
if (!body) return 0
return body.angularVelocity
}
}

module.exports = Extension

0 comments on commit 3ed2eba

Please sign in to comment.