Creating features in gamelab

I understand gamelab is quite limited and that may be because it is made solely for students to learn, but in case a game wants to be created. I’ve discovered many tricks to bypass limitations, and I certainly hope they don’t get patched.

Creating custom cursors
A lot of games struggle to do this, my best solution is to either use
cursor(GRAB), or to use noCursor() and to make a sprite follow the mouse

Buttons that work regardless of frameRate
function mousePressed(){} and function mouseReleased() {} work regardless of frameRate. The simplest way to make a button is:
var b = createSprite(200, 200, 50, 50);b.hold=false;b.clicked=function(){console.log(“i was clicked”)}
function mousePressed(){
b.hold = mouseIsOver(b)
}
function mouseReleased() {
if (mouseIsOver(b) and b.hold) b.clicked()
}

Making setKeyValue and getKeyValue more secure
In no ways does this make exploiting 100% protected, but when games use setKeyValue, they can be easily changed using the console. They key is to use a scope:
function s() {
function changeKey(key, val) {
if (key.substring(0, 4)===“abc”) setKeyValue(key, val); //combine with getUserId()
}
return {change:changeKey}
}
s = s()
s.change(“abcd”, “hello world”)

Making it so code.org doesn’t alert users of setKeyValue and getKeyValue
code.org alerts users when “setKeyValue” or “getKeyValue” is found inside the code, this means that even if it is placed within comments, users will still be alerted. The trick is to concatenate strings and get the function from the window variable:
var set = window[“set”+“KeyValue”]

Making custom thumbnails (and even animated ones)
Very hard to explain, but using inspect mode, and going to the network tab, there is a POST request going to studio.code.org/v3/channels/GAMEID, simply copy the request as CURL, go to terminal/command prompt, and edit thumbnail url to an image of a choice, or even a gif

Loading sounds
When a game loads for the first time, the sounds will take a while to play when they are first called, to bypass this, I used the option callback of playSound, and added stopSound
function loadSound(sound) {
playSound(sound, false, function(){
stopSound(sound)
})
}

3d objects
I discovered that code.org uses p5.js when doing some inspection. Many features are left out and that is a shame, however, one can use createCanvas(400, 400, WEBGL). 3d is kind of broken but one could use https://p5js.org/examples/3d-geometries.html

http requests (theoretical)
Http requests for me are entirely theoretical and I haven’t really made it working. It’s fustrating for me to constantly inspect network to see how setKeyValue works only to get nothing. Basically, what I imagine is playSound tries to request a sound from another domain, the request is received and that would make a webhook. The server could then edit setKeyValue and such. The client would then use getKeyValue to view the response, and then use eval() to run the code.

I’m planning to incorporate many of these tricks into a unique game to demonstrate that you can do far more than just make a breaker game.