Game utilities #2521
rileybot9000-design
started this conversation in
Ideas
Game utilities
#2521
Replies: 1 comment 3 replies
-
|
Yes it very much is a nice utility as the performance is probably better than using custom functions. Is there a official extension file or not? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Here is the code: class GameUtilities {
getInfo() {
return {
id: 'gameutilities',
name: 'Game Utilities',
color1: '#4C97FF',
color2: '#3373CC',
blocks: [
{
opcode: 'distanceTo',
blockType: Scratch.BlockType.REPORTER,
text: 'distance from x1 [x1] y1 [y1] to x2 [x2] y2 [y2]',
arguments: {
x1: { type: Scratch.ArgumentType.NUMBER },
y1: { type: Scratch.ArgumentType.NUMBER },
x2: { type: Scratch.ArgumentType.NUMBER },
y2: { type: Scratch.ArgumentType.NUMBER }
}
},
{
opcode: 'angleTo',
blockType: Scratch.BlockType.REPORTER,
text: 'angle from x1 [x1] y1 [y1] to x2 [x2] y2 [y2]',
arguments: {
x1: { type: Scratch.ArgumentType.NUMBER },
y1: { type: Scratch.ArgumentType.NUMBER },
x2: { type: Scratch.ArgumentType.NUMBER },
y2: { type: Scratch.ArgumentType.NUMBER }
}
},
{
opcode: 'clamp',
blockType: Scratch.BlockType.REPORTER,
text: 'clamp [value] between [min] and [max]',
arguments: {
value: { type: Scratch.ArgumentType.NUMBER },
min: { type: Scratch.ArgumentType.NUMBER },
max: { type: Scratch.ArgumentType.NUMBER }
}
},
{
opcode: 'lerp',
blockType: Scratch.BlockType.REPORTER,
text: 'lerp [a] to [b] by [t]',
arguments: {
a: { type: Scratch.ArgumentType.NUMBER },
b: { type: Scratch.ArgumentType.NUMBER },
t: { type: Scratch.ArgumentType.NUMBER }
}
},
{
opcode: 'distanceToSprite',
blockType: Scratch.BlockType.REPORTER,
text: 'distance to sprite [NAME]',
arguments: {
NAME: { type: Scratch.ArgumentType.STRING, menu: 'sprites' }
}
}
],
menus: {
sprites: {
acceptReporters: true,
items: '_getSprites'
}
}
};
}
}
Scratch.extensions.register(new GameUtilities());
Has these blocks: clamp, lerp, and other blocks, they could be useful for game making/editing.
Beta Was this translation helpful? Give feedback.
All reactions