2022-11-11 19:54:52 +00:00
|
|
|
let canvas, api, screenManager, user;
|
2022-09-29 16:22:48 +01:00
|
|
|
|
2022-11-17 11:48:12 +00:00
|
|
|
function preload() {
|
|
|
|
roboto = loadFont('./assets/fonts/RobotoMono-Medium.ttf');
|
|
|
|
}
|
|
|
|
|
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-10-05 14:10:32 +01:00
|
|
|
api = new API();
|
2022-10-10 14:05:09 +01:00
|
|
|
screenManager = new ScreenManager();
|
2022-10-11 09:45:40 +01:00
|
|
|
screenManager.setScreen(new StartScreen());
|
2022-11-11 19:54:52 +00:00
|
|
|
user = new User();
|
|
|
|
|
|
|
|
// will log the user in if there details are in local storage
|
|
|
|
api.login();
|
2022-11-18 12:27:54 +00:00
|
|
|
api.getTest();
|
2022-11-17 11:48:12 +00:00
|
|
|
textFont(roboto);
|
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() {
|
2022-10-10 14:05:09 +01:00
|
|
|
screenManager.draw();
|
2022-09-29 19:11:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// whenever a key is pressed this function is called
|
|
|
|
function keyPressed() {
|
2022-11-11 13:04:13 +00:00
|
|
|
screenManager.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
|
|
|
}
|