2022-11-25 14:49:05 +00:00
|
|
|
/**
|
|
|
|
* @file This files is the root of the website.
|
|
|
|
* @author Arlo Filley
|
|
|
|
*/
|
|
|
|
|
2022-11-28 11:04:49 +00:00
|
|
|
// these are all of the globally accessible variables that are
|
|
|
|
// needed for the site to run correctly
|
2022-11-11 19:54:52 +00:00
|
|
|
let canvas, api, screenManager, user;
|
2022-09-29 16:22:48 +01:00
|
|
|
|
2022-11-25 14:49:05 +00:00
|
|
|
/**
|
|
|
|
* loads the any assets before the setup function
|
|
|
|
* this allows p5.js to acess these assets including: sprites,
|
|
|
|
* fonts, etc
|
|
|
|
*/
|
2022-11-17 11:48:12 +00:00
|
|
|
function preload() {
|
|
|
|
roboto = loadFont('./assets/fonts/RobotoMono-Medium.ttf');
|
|
|
|
}
|
|
|
|
|
2022-11-25 14:49:05 +00:00
|
|
|
/**
|
|
|
|
* defines variables and sets up the p5.js canvas
|
|
|
|
* ready to be drawn with using the draw() function
|
|
|
|
*/
|
2022-09-29 15:11:33 +01:00
|
|
|
function setup() {
|
|
|
|
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-11-11 19:54:52 +00:00
|
|
|
user = new User();
|
2022-12-01 14:41:14 +00:00
|
|
|
screenManager.setScreen(new StartScreen());
|
2022-11-11 19:54:52 +00:00
|
|
|
|
2023-09-05 08:52:28 +01:00
|
|
|
api.login(null, null, true);
|
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-11-25 14:49:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* called once per frame. draws all other elements onto the canvas
|
|
|
|
* mostly will just call the screenManager.draw() method to make
|
|
|
|
* sure that the correct screen is being drawn
|
|
|
|
*/
|
2022-09-29 15:11:33 +01:00
|
|
|
function draw() {
|
2022-12-01 14:41:14 +00:00
|
|
|
background(user.colorScheme.background);
|
2022-10-10 14:05:09 +01:00
|
|
|
screenManager.draw();
|
2022-09-29 19:11:20 +01:00
|
|
|
}
|
|
|
|
|
2022-11-25 14:49:05 +00:00
|
|
|
/**
|
|
|
|
* called whenever a key is pressed, the variable key contains the
|
|
|
|
* key that the user last pressed
|
|
|
|
*/
|
2022-09-29 19:11:20 +01:00
|
|
|
function keyPressed() {
|
2022-11-11 13:04:13 +00:00
|
|
|
screenManager.letterTyped(key);
|
2022-09-29 12:12:55 +01:00
|
|
|
}
|
|
|
|
|
2022-11-25 14:49:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* called whenever the user resizes the window. Uses methods from the canvas wrapper class
|
|
|
|
* to resize and center the canvas such that it displays correctly
|
|
|
|
*/
|
2022-09-29 15:11:33 +01:00
|
|
|
function windowResized() {
|
|
|
|
canvas.resize();
|
|
|
|
canvas.center();
|
2022-09-29 12:12:55 +01:00
|
|
|
}
|