From b7ec93026f3515b9ad70dc41bfbb5f77c618831d Mon Sep 17 00:00:00 2001 From: cbennet Date: Wed, 9 Oct 2019 15:52:47 -0400 Subject: [PATCH 1/2] start on ground --- public/bundle.js | 6 ++++-- public/pixiBasic.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index d573acaa..f2fa2edf 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -44580,8 +44580,9 @@ bgPic.tilePosition.y = 0; app.stage.addChild(bgPic); function resetPaw() { + paw.anchor.set(1); paw.x = app.screen.width / 2; - paw.y = app.screen.height / 2; + paw.y = app.screen.height; paw.vx = 0; paw.vy = 0; paw.height = 60; @@ -44591,8 +44592,9 @@ function resetPaw() { } function resetDog() { + dog.anchor.set(1); dog.x = app.screen.width / 2; - dog.y = app.screen.height / 2; + dog.y = app.screen.height; dog.vx = 0; dog.vy = 0; dog.height = 60; diff --git a/public/pixiBasic.js b/public/pixiBasic.js index 7b8d72bf..a6fd4ea3 100644 --- a/public/pixiBasic.js +++ b/public/pixiBasic.js @@ -36,8 +36,9 @@ bgPic.tilePosition.y = 0; app.stage.addChild(bgPic); function resetPaw() { + paw.anchor.set(1); paw.x = app.screen.width / 2; - paw.y = app.screen.height / 2; + paw.y = app.screen.height; paw.vx = 0; paw.vy = 0; paw.height = 60; @@ -47,8 +48,9 @@ function resetPaw() { } function resetDog() { + dog.anchor.set(1); dog.x = app.screen.width / 2; - dog.y = app.screen.height / 2; + dog.y = app.screen.height; dog.vx = 0; dog.vy = 0; dog.height = 60; From a6816497f7564ddb14f63e4766bcbe7f86feea73 Mon Sep 17 00:00:00 2001 From: Nkalish Date: Wed, 9 Oct 2019 17:16:13 -0400 Subject: [PATCH 2/2] fixed jumping --- public/bundle.js | 15 ++++++++++----- public/pixiBasic.js | 14 +++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index f2fa2edf..8b711999 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -44539,6 +44539,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; var app = new PIXI.Application({ backgroundColor: 0x00FFFF }); +var hasTouchedGround = false; var loader = new PIXI.Loader(); document.getElementById("pixi").appendChild(app.view); var paw = PIXI.Sprite.from('images/cat.png'); @@ -44580,9 +44581,9 @@ bgPic.tilePosition.y = 0; app.stage.addChild(bgPic); function resetPaw() { - paw.anchor.set(1); + hasTouchedGround = false; paw.x = app.screen.width / 2; - paw.y = app.screen.height; + paw.y = app.screen.height / 2; paw.vx = 0; paw.vy = 0; paw.height = 60; @@ -44592,9 +44593,9 @@ function resetPaw() { } function resetDog() { - dog.anchor.set(1); + hasTouchedGround = false; dog.x = app.screen.width / 2; - dog.y = app.screen.height; + dog.y = app.screen.height / 2; dog.vx = 0; dog.vy = 0; dog.height = 60; @@ -44697,9 +44698,13 @@ app.ticker.add(function (delta) { addTurtle(); } + if (activeChar.y === app.screen.height - 62) { + hasTouchedGround = true; + } + turtle.x += turtle.vx; - if (up.isDown && count < 45 && fallDone) { + if (up.isDown && count < 45 && fallDone && hasTouchedGround) { activeChar.vy = -2; count++; } else { diff --git a/public/pixiBasic.js b/public/pixiBasic.js index a6fd4ea3..eb33d563 100644 --- a/public/pixiBasic.js +++ b/public/pixiBasic.js @@ -2,6 +2,7 @@ import * as PIXI from 'pixi.js'; //init basics let app = new PIXI.Application({ backgroundColor: 0x00FFFF}); +let hasTouchedGround = false; const loader = new PIXI.Loader(); document.getElementById("pixi").appendChild(app.view); let paw = PIXI.Sprite.from('images/cat.png'); @@ -36,9 +37,9 @@ bgPic.tilePosition.y = 0; app.stage.addChild(bgPic); function resetPaw() { - paw.anchor.set(1); + hasTouchedGround = false; paw.x = app.screen.width / 2; - paw.y = app.screen.height; + paw.y = app.screen.height / 2; paw.vx = 0; paw.vy = 0; paw.height = 60; @@ -48,9 +49,9 @@ function resetPaw() { } function resetDog() { - dog.anchor.set(1); + hasTouchedGround = false; dog.x = app.screen.width / 2; - dog.y = app.screen.height; + dog.y = app.screen.height / 2; dog.vx = 0; dog.vy = 0; dog.height = 60; @@ -149,8 +150,11 @@ app.ticker.add(function(delta) { if(time % 8 === 0){ addTurtle(); } + if (activeChar.y === app.screen.height - 62) { + hasTouchedGround = true; + } turtle.x += turtle.vx; - if (up.isDown && count < 45 && fallDone) { + if (up.isDown && count < 45 && fallDone && hasTouchedGround) { activeChar.vy = -2; count++; } else {