added basic screenmanager class
This commit is contained in:
parent
771b7f7534
commit
bc25578c01
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
/target
|
||||
Cargo.lock
|
||||
/database/database.sqlite
|
||||
/database/database.sqlite
|
||||
/NEA_Screenshots
|
@ -12,6 +12,8 @@
|
||||
|
||||
<!-- Element Script Files -->
|
||||
<script src="./ui_elements/canvas.js"></script>
|
||||
<script src="./screens/screenmanager.js"></script>
|
||||
|
||||
<script src="./ui_elements/textbox.js"></script>
|
||||
<script src="./ui_elements/timer.js"></script>
|
||||
<script src="./ui_elements/button.js"></script>
|
||||
|
@ -1,6 +1,4 @@
|
||||
let canvas;
|
||||
let api;
|
||||
let textbox, timer, button;
|
||||
let canvas, api, screenManager;
|
||||
|
||||
function setup() {
|
||||
// Creating the canvas
|
||||
@ -10,27 +8,20 @@ function setup() {
|
||||
|
||||
frameRate(60);
|
||||
|
||||
textbox = new Textbox(400, 200, 700);
|
||||
timer = new Timer(0, 0, 100, 100, 0, true, '#000', true, '#000','#F3C969', 10, true);
|
||||
timer.start();
|
||||
api = new API();
|
||||
button = new Button(300, 300, 100, 50, 0, true, '#fff', false, '#000', '#666', 'button');
|
||||
screenManager = new ScreenManager();
|
||||
}
|
||||
|
||||
// this function is called once per frame and draws all other elements
|
||||
function draw() {
|
||||
background(200);
|
||||
textbox.draw();
|
||||
timer.tick();
|
||||
timer.draw();
|
||||
button.draw();
|
||||
button.isPressed();
|
||||
screenManager.draw();
|
||||
}
|
||||
|
||||
|
||||
// whenever a key is pressed this function is called
|
||||
function keyPressed() {
|
||||
textbox.letterTyped(key);
|
||||
screenManager.textbox.letterTyped(key);
|
||||
}
|
||||
|
||||
// This ensures that the canvas is always the correct size and at the center
|
||||
|
13
website/screens/screenmanager.js
Normal file
13
website/screens/screenmanager.js
Normal file
@ -0,0 +1,13 @@
|
||||
class ScreenManager {
|
||||
constructor() {
|
||||
this.textbox = new Textbox(400, 200, 700);
|
||||
this.timer = new Timer(0, 0, 100, 100, 0, true, '#000', true, '#000','#F3C969', 10, true);
|
||||
this.button = new Button(300, 300, 100, 50, 0, true, '#fff', false, '#000', '#666', 'button');
|
||||
}
|
||||
|
||||
draw() {
|
||||
this.textbox.draw();
|
||||
this.timer.draw();
|
||||
this.button.draw();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user