Skip to content

Commit

Permalink
letsgoo
Browse files Browse the repository at this point in the history
  • Loading branch information
Skparab1 committed Aug 17, 2022
1 parent 7f9fde5 commit 65771c2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
55 changes: 55 additions & 0 deletions canvas-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2615,6 +2615,61 @@ const sleep = ms => new Promise(res => setTimeout(res, ms));
})();
// ok thats it for the main loop

function keyed(k){
if (!started){
counter = 0;
}

const ctx = canvas.getContext('2d');

let actkey = k;
let filterletters = 'QWERTYUIOPASDFGHJKLZXCVBNM';
//console.log('pressed'+actkey);

// starter
if (!startwaiter && (closedintro) && actkey != 'ArrowRight' && actkey != 'D'){
startwaiter = true;
startspeed = speed;
console.log('put speed as',speed);
capturedspeed = false;
started = true;
counter = 0;
let z = document.getElementById('display');
z.textContent = 'Start';
fpslst = [];
lastfps = Date.now();
speed = basespeed;
// no starting thing
//yd = -speed;
}

// beayboard shortcuts
if (lost && actkey == 'P' && closedintro){
location.reload();
}
if (lost && actkey == "L" && closedintro){
window.location.href = 'https://skparab1.github.io/pacman/leaderboard/leaderboard.html';
}

// we only need 1 waiter
if (actkey == 'ArrowLeft' || actkey == 'A'){
waiter = 'left';
keylog = keylog + 'l' + String(elapsedtime).substring(0,10)+',';
}
if (actkey == 'ArrowRight' || actkey == 'D'){
waiter = 'right';
keylog = keylog + 'r' + String(elapsedtime).substring(0,10)+',';
}
if (actkey == 'ArrowUp' || actkey == 'W'){
waiter = 'up';
keylog = keylog + 'u' + String(elapsedtime).substring(0,10)+',';
}
if (actkey == 'ArrowDown' || actkey == 'S'){
waiter = 'down';
keylog = keylog + 'd' + String(elapsedtime).substring(0,10)+',';
}
}

// keypress processing
(async () => {
window.addEventListener("keydown", function(event) {
Expand Down
4 changes: 4 additions & 0 deletions html-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,24 @@ function starteverything(){
function left() {
waiter = 'left';
starteverything();
keyed("A");
}

function up() {
waiter = 'up';
starteverything();
keyed("W");
}

function down() {
waiter = 'down';
starteverything();
keyed("S")
}

function right() {
waiter = 'right';
keyed("D");
}

function changemode(){
Expand Down

0 comments on commit 65771c2

Please sign in to comment.