Skip to content

Instantly share code, notes, and snippets.

@thacuber2a03
Last active August 4, 2021 16:00
Show Gist options
  • Select an option

  • Save thacuber2a03/9537312764c68a429f6d99bb1557bc28 to your computer and use it in GitHub Desktop.

Select an option

Save thacuber2a03/9537312764c68a429f6d99bb1557bc28 to your computer and use it in GitHub Desktop.
SCRIPT-8
//title:Button Class
init = state => {
state.pressed = false;
}
update = (state, input, elapsed) => {
if (input.a) {
state.pressed = true;
} else {
state.pressed = false;
}
}
draw = state => {
clear();
let pressed = state.pressed;
let button = new TextButton("test", 0, 0, 0, 5);
let button2 = new TextButton("test", 0, 7, 0, 5);
button.display(pressed);
button2.display(!pressed);
}
class TextButton {
constructor(text, x, y, c, c2, k) {
this.text = text
this.x = x
this.y = y
this.c = c
this.c2 = c2
this.k = k
this.a = false
}
display(a) {
if (!a) {
print(this.x, this.y+1, this.text, this.c2)
print(this.x, this.y, this.text, this.c)
} else {
print(this.x, this.y+1, this.text, this.c)
}
}
}
{
"iframeVersion": "0.1.280",
"lines": [
43,
0,
0,
0,
0,
0,
0,
0
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment