10 months ago

all this code

[article]

FOR JUST COLOR DETECTION AND KEY DECTION IN PENGUIN MOD GFEUWGFUAIS

and it doesnt work

[i used chat gpt and corrected it multiple times]


// color-and-keys-extension.js

(function (Scratch) {

'use strict';

class ColorAndKeyExtension {

getInfo() {

return {

id: 'colorAndKeyExtension_v2',

name: 'Color & Key Detector (v2)',

blocks: [

{

opcode: 'getColorUnderSprite',

blockType: Scratch.BlockType.REPORTER,

text: 'color under sprite'

},

{

opcode: 'getColorUnderSpriteAt',

blockType: Scratch.BlockType.REPORTER,

text: 'color under sprite at x: [X] y: [Y]',

arguments: {

X: { type: Scratch.ArgumentType.NUMBER, defaultValue: 0 },

Y: { type: Scratch.ArgumentType.NUMBER, defaultValue: 0 }

}

},

{

opcode: 'isKeyPressed',

blockType: Scratch.BlockType.BOOLEAN,

text: 'key [KEY] pressed?',

arguments: {

KEY: { type: Scratch.ArgumentType.STRING, defaultValue: 'space' }

}

},

{

opcode: 'keysPressedList',

blockType: Scratch.BlockType.REPORTER,

text: 'keys currently pressed'

}

]

};

}

_rgbToHex(r, g, b) {

const toHex = v => ('0' + Math.max(0, Math.min(255, Math.round(v))).toString(16)).slice(-2);

return '#' + toHex(r) + toHex(g) + toHex(b);

}

_getColorAtTarget(target, offsetX = 0, offsetY = 0) {

const vm = Scratch.vm;

const renderer = vm && vm.renderer;

const runtime = vm && vm.runtime;

if (!renderer || !runtime || !target) return '#000000';

const stageW = runtime.constructor.STAGE_WIDTH || 480;

const stageH = runtime.constructor.STAGE_HEIGHT || 360;

const xScratch = (target.x || 0) + Number(offsetX || 0);

const yScratch = (target.y || 0) + Number(offsetY || 0);

// Scratch→pick coords: (0,0) is center

const pickX = Math.round(xScratch + stageW / 2);

const pickY = Math.round(-yScratch + stageH / 2);

let pickResult;

try {

pickResult = renderer.pick(pickX, pickY, null, null);

} catch (e) {

return '#000000';

}

if (!pickResult) return '#000000';

let r, g, b;

if (Array.isArray(pickResult)) {

[ , r, g, b ] = pickResult;

} else if (typeof pickResult === 'object') {

({ r, g, b } = pickResult);

}

if (typeof r !== 'number') return '#000000';

return this._rgbToHex(r, g, b);

}

getColorUnderSprite(args, util) {

return this._getColorAtTarget(util.target, 0, 0);

}

getColorUnderSpriteAt(args, util) {

return this._getColorAtTarget(util.target, Number(args.X), Number(args.Y));

}

isKeyPressed(args) {

const key = String(args.KEY || '').toLowerCase();

const kbd = Scratch.vm.runtime.ioDevices.keyboard;

return kbd && kbd.getKeyIsDown(key);

}

keysPressedList() {

const kbd = Scratch.vm.runtime.ioDevices.keyboard;

if (!kbd || !kbd.getKeyIsDown) return '';

const keys = [];

for (le



0 comments

Loading...

Next up

this flower shop is delivering 120 aqua's a minute

whos buying so manyu flowers- /j

[random gif i made for no reason

me: tries to code

me: searches a gif

realises its opened at the aqua page

now i wanna look at those gifs too long dangit lol

love this random gif i stumbled upon

lmao

ok ill stop now these are just funny

This post keeps appearing

When I click it is gone

https://gamejolt.com/p/super-mario-2d-world-dx-heaven-wish-sprit…

Well imma go now lol cyall

well yea this is cheating but i still dunno what im doing since there is no grid so lol lemme try this for once

thats one of the worest descriptions ever lol

LIKE HOW IS THAT A DEMON

it has no horns

its not pure evil

it has no dmeon tail

its not one of the demon colors

the only correct thing is her having a red bow on her head and being pixelart

i still dont ge tthis gif lol

https://www.youtube.com/watch?v=qZf9OCkU6EA&list=RDqZf9OCkU6EA&s…

they couldve just used to dance that looked more like jevil and jevilfied it

but ig dubble spinning is funny too

OH THATS WHY ITS HARD TO RECREATE, IMPOSSIBLE NOTES

well illl recreate it whit smal notes and then make a normal ver ig lol