|
@@ -0,0 +1,67 @@
|
|
|
|
|
+"use strict";
|
|
|
|
|
+
|
|
|
|
|
+const FPS = 24;
|
|
|
|
|
+
|
|
|
|
|
+function setup() {
|
|
|
|
|
+ // Create the canvas.
|
|
|
|
|
+ createCanvas(500, 500);
|
|
|
|
|
+ frameRate(FPS);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function draw() {
|
|
|
|
|
+ // Clear the background.
|
|
|
|
|
+ background(255);
|
|
|
|
|
+
|
|
|
|
|
+ // Get input.
|
|
|
|
|
+ getInput();
|
|
|
|
|
+
|
|
|
|
|
+ // Check for interactions.
|
|
|
|
|
+ update();
|
|
|
|
|
+
|
|
|
|
|
+ // Draw the characters.
|
|
|
|
|
+ drawCharacters();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function getInput() {
|
|
|
|
|
+ // Check to see if a key is pressed.
|
|
|
|
|
+ if (keyIsPressed) {
|
|
|
|
|
+ // Check for the arrow keys.
|
|
|
|
|
+ // Left Arrow Key.
|
|
|
|
|
+ if (keyIsDown(LEFT_ARROW)) {
|
|
|
|
|
+ console.log('Left Arrow');
|
|
|
|
|
+ }
|
|
|
|
|
+ // Right Arrow Key.
|
|
|
|
|
+ else if (keyIsDown(RIGHT_ARROW)) {
|
|
|
|
|
+ console.log('Right Arrow');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Up Arrow Key.
|
|
|
|
|
+ if (keyIsDown(UP_ARROW)) {
|
|
|
|
|
+ console.log('Up Arrow');
|
|
|
|
|
+ }
|
|
|
|
|
+ // Down Arrow Key.
|
|
|
|
|
+ else if (keyIsDown(DOWN_ARROW)) {
|
|
|
|
|
+ console.log('Down Arrow');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function keyPressed() {
|
|
|
|
|
+ // Space Bar.
|
|
|
|
|
+ if (keyCode == 32) {
|
|
|
|
|
+ console.log('Space Bar');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // X Key.
|
|
|
|
|
+ if (keyCode == 88) {
|
|
|
|
|
+ console.log('X Key');
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function update() {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function drawCharacters() {
|
|
|
|
|
+
|
|
|
|
|
+}
|