Skip to content

Commit 8f2e326

Browse files
committed
Bug Fixes, Framerate Fixes
1 parent 7d2be6a commit 8f2e326

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

games/GMTK Jam/app.js

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const states = {
103103
}
104104

105105
const phys = {
106+
bThresh: 2,
106107
bounce: 0.4,
107108
shake: 64
108109
}
@@ -131,7 +132,7 @@ const menu = {
131132
fontSize: 192,
132133
letterSpacing: -16,
133134
})),
134-
options: new PIXI.Text("Start [A]\t\t\t\tControls [S]\t\t\t\tAbout [D]", textStyle),
135+
options: new PIXI.Text("Start []\t\t\t\tControls []\t\t\t\tAbout []", textStyle),
135136
info: new PIXI.Text("", textStyle)
136137
}
137138

@@ -209,15 +210,15 @@ allocation.ladyLuck.y = app.view.height * 0.65;
209210
allocation.ladyLuck.anchor = { x: 0.5, y: 0.5 };
210211
allocationScreen.addChild(allocation.ladyLuck);
211212

212-
const directions = new PIXI.Text("Test your luck in the next round... [W]", textStyle)
213+
const directions = new PIXI.Text("Test your luck in the next round... []", textStyle)
213214
directions.x = app.view.width * 0.5;
214215
directions.y = app.view.height * 0.9;
215216
directions.anchor = { x: 0.5, y: 0.5 };
216217
directions.visible = false;
217218
allocationScreen.addChild(directions);
218219

219220
// Scene stuff
220-
const gameOver = new PIXI.Text("Looks like that's the end of your lucky break... [W]", new PIXI.TextStyle({
221+
const gameOver = new PIXI.Text("Looks like that's the end of your lucky break... []", new PIXI.TextStyle({
221222
align: "center",
222223
wordWrap: true,
223224
wordWrapWidth: 1200,
@@ -278,7 +279,7 @@ app.ticker.add((deltaTime) => {
278279

279280
bg.tint = bgTint[0];
280281

281-
if (PIXI.input.getKeyFired("a")) {
282+
if (PIXI.input.getKeyFired("arrowleft")) {
282283
menu.info.text = "";
283284
states.start = true;
284285
states.menu = false;
@@ -296,15 +297,9 @@ app.ticker.add((deltaTime) => {
296297
states.score = 0;
297298

298299
newRolls = [3, 3, 3, 3];
299-
300-
player.x = app.view.width * 0.5;
301-
player.y = app.view.height;
302-
player.anchor = { x: 0.5, y: 1.0 };
303-
player.vec = { x: 0, y: 0 };
304-
player.allowJump = true;
305-
} else if (PIXI.input.getKeyFired("s")) {
306-
menu.info.text = "Fullscreen [F]\n\nJump [W]\tLeft [A]\tDrop [S]\tRight [D]\n\nDodge or destroy Lady Luck's falling dice. Getting hit by one will lower your health by the number shown, but jumping on top of it will heal you by that same amount, and net you some extra points based on the risk! Take a chance and roll the dice!";
307-
} else if (PIXI.input.getKeyFired("d")) {
300+
} else if (PIXI.input.getKeyFired("arrowdown")) {
301+
menu.info.text = "Fullscreen [F]\n\nJump [↑]\tLeft [←]\tDrop [↓]\tRight [→]\n\nDodge or destroy Lady Luck's falling dice. Getting hit by one will lower your health by the number shown, but jumping on top of it will heal you by that same amount, and net you some extra points based on the risk! Take a chance and roll the dice!";
302+
} else if (PIXI.input.getKeyFired("arrowright")) {
308303
menu.info.text = 'You play as a die, fed up with Lady Luck telling you what to do, but trying to break away is easier said than done.\n\nThis game was made for the GMTK Game Jam 2022, with the theme "Roll of the Dice." The role of artist, programmer, and game designer were all filled by Cooper Ott.';
309304
}
310305
} else {
@@ -355,12 +350,12 @@ app.ticker.add((deltaTime) => {
355350
rollSprite.forEach((danger) => {
356351
if (danger.roll) {
357352
danger.vec.y += deltaTime;
358-
danger.y += danger.vec.y;
353+
danger.y += danger.vec.y * deltaTime;
359354
if (danger.y >= app.view.height) {
360355
danger.y = app.view.height;
361356
danger.vec.y *= -phys.bounce;
362357
danger.vec.x = danger.vec.x * phys.bounce + (Math.random() - 0.5) * danger.vec.y;
363-
if (danger.vec.y < -1) {
358+
if (danger.vec.y < -2) {
364359
danger.facing = rand(1, 6);
365360
danger.texture = diceImg[danger.facing];
366361
danger.tint = dangerTint[7 - danger.facing];
@@ -375,7 +370,7 @@ app.ticker.add((deltaTime) => {
375370
danger.x = app.view.width - danger.width * 0.5;
376371
danger.vec.x *= -phys.bounce;
377372
}
378-
if (Math.abs(danger.vec.y) < 0.25 && danger.y == app.view.height) {
373+
if (Math.abs(danger.vec.y) < phys.bThresh && danger.y == app.view.height) {
379374
newRolls[danger.slot] = danger.facing;
380375
danger.x = (danger.slot + 1) * 0.2 * app.view.width;
381376
danger.y = 0.3 * app.view.height;
@@ -387,9 +382,9 @@ app.ticker.add((deltaTime) => {
387382
});
388383

389384
if (newRolls.length == 4) {
390-
directions.text = "Test your luck in round " + (states.level + 1) + "... [W]"
385+
directions.text = "Test your luck in round " + (states.level + 1) + "... []"
391386
directions.visible = true;
392-
if (PIXI.input.getKeyFired("w")) {
387+
if (PIXI.input.getKeyFired("arrowup")) {
393388
states.level++;
394389
states.dangerCount = states.level * 10 + 10;
395390
states.allocation = false;
@@ -413,6 +408,12 @@ app.ticker.add((deltaTime) => {
413408
scene.removeChild(danger);
414409
dangerSet.delete(danger);
415410
});
411+
412+
player.x = app.view.width * 0.5;
413+
player.y = app.view.height;
414+
player.anchor = { x: 0.5, y: 1.0 };
415+
player.vec = { x: 0, y: 0 };
416+
player.allowJump = true;
416417
}
417418
}
418419

@@ -427,19 +428,19 @@ app.ticker.add((deltaTime) => {
427428

428429
if (states.life > 0) { // X velocity
429430
player.vec.x *= 1 - (0.2 * player.allowJump);
430-
player.vec.x += (states.speedMult * states.speed * player.allowJump * (PIXI.input.getKeyDown("d") - PIXI.input.getKeyDown("a")));
431+
player.vec.x += (states.speedMult * states.speed * player.allowJump * (PIXI.input.getKeyDown("arrowright") - PIXI.input.getKeyDown("arrowleft")));
431432
player.vec.x = clamp(player.vec.x, (states.speed + 2) * -states.speedMult, (states.speed + 2) * states.speedMult);
432433

433434
// Y velocity
434-
player.vec.y += 2 * PIXI.input.getKeyDown("s");
435-
if (player.allowJump && PIXI.input.getKeyFired("w")) {
435+
player.vec.y += (2 * PIXI.input.getKeyDown("arrowdown")) * deltaTime;
436+
if (player.allowJump && PIXI.input.getKeyFired("arrowup")) {
436437
sound.bounce[rand(1, 2)].play();
437438
player.allowJump = false;
438439
player.vec.y = -14 - states.jump * states.jumpMult;
439440
}
440441
} else {
441442
gameOver.visible = true;
442-
if (PIXI.input.getKeyFired("w")) {
443+
if (PIXI.input.getKeyFired("arrowup")) {
443444
states.menu = true;
444445
gameOver.visible = false;
445446
}
@@ -456,7 +457,7 @@ app.ticker.add((deltaTime) => {
456457
}
457458
player.x = (player.x + 0.5) ^ 0;
458459
// Player Y position
459-
player.vec.y += 1 + (player.vec.y > 0);
460+
player.vec.y += (1 + (player.vec.y > 0)) * deltaTime;
460461
player.y += player.vec.y * deltaTime;
461462
if (player.y >= app.view.height) {
462463
if (!player.allowJump) sound.bounce[rand(0, 2)].play();
@@ -467,7 +468,7 @@ app.ticker.add((deltaTime) => {
467468

468469
// Dangers
469470
dangerSet.forEach((danger) => {
470-
danger.vec.y++;
471+
danger.vec.y += deltaTime;
471472
danger.y += danger.vec.y * deltaTime;
472473
if (danger.y >= app.view.height) {
473474
danger.y = app.view.height;
@@ -508,7 +509,7 @@ app.ticker.add((deltaTime) => {
508509
danger.y -= player.height;
509510
}
510511
sound.hit[rand(0, 2)].play();
511-
} else if (Math.abs(danger.vec.y) < 0.25 && danger.y == app.view.height) {
512+
} else if (Math.abs(danger.vec.y) < phys.bThresh && danger.y == app.view.height) {
512513
if (states.life > 0) {
513514
states.score += danger.facing;
514515
states.dangerCount--;
@@ -541,7 +542,7 @@ app.ticker.add((deltaTime) => {
541542
scene.addChild(newDanger);
542543
dangerSet.add(newDanger);
543544
} else {
544-
states.dangerSpawnBoost += 0.00003 * (states.danger + states.level * 3);
545+
states.dangerSpawnBoost += 0.00003 * (states.danger + states.level * 3) * deltaTime;
545546
}
546547

547548
if (states.dangerCount <= 0) {

0 commit comments

Comments
 (0)