2022-09-29 15:11:33 +01:00
|
|
|
let canvas;
|
2022-09-29 19:40:57 +01:00
|
|
|
let textbox, timer;
|
2022-09-29 16:22:48 +01:00
|
|
|
|
2022-09-29 15:11:33 +01:00
|
|
|
function setup() {
|
|
|
|
// Creating the canvas
|
|
|
|
canvas = new Canvas();
|
|
|
|
canvas.resize();
|
|
|
|
canvas.center();
|
2022-09-29 16:22:48 +01:00
|
|
|
|
2022-09-29 19:40:57 +01:00
|
|
|
frameRate(60);
|
|
|
|
|
2022-09-29 19:11:20 +01:00
|
|
|
textbox = new Textbox(400, 200, 700);
|
2022-10-03 10:02:55 +01:00
|
|
|
timer = new Timer(100,100,100,100,0,true,0,false,0,0,30,true);
|
2022-09-29 19:40:57 +01:00
|
|
|
timer.start();
|
2022-09-29 15:11:33 +01:00
|
|
|
}
|
|
|
|
|
2022-10-03 10:02:55 +01:00
|
|
|
// this function is called once per frame and draws all other elements
|
2022-09-29 15:11:33 +01:00
|
|
|
function draw() {
|
|
|
|
background(255,100,100);
|
2022-09-29 19:11:20 +01:00
|
|
|
textbox.draw();
|
2022-09-29 19:40:57 +01:00
|
|
|
timer.tick();
|
|
|
|
timer.draw();
|
2022-09-29 19:11:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// whenever a key is pressed this function is called
|
|
|
|
function keyPressed() {
|
|
|
|
textbox.letterTyped(key);
|
2022-09-29 12:12:55 +01:00
|
|
|
}
|
|
|
|
|
2022-10-03 10:02:55 +01:00
|
|
|
// This ensures that the canvas is always the correct size and at the center
|
|
|
|
// of the screen, p5 calls windowResized whenever the browser size is changed.
|
2022-09-29 15:11:33 +01:00
|
|
|
function windowResized() {
|
|
|
|
canvas.resize();
|
|
|
|
canvas.center();
|
2022-09-29 12:12:55 +01:00
|
|
|
}
|