diff --git a/public/bundle.js b/public/bundle.js index d573acaa..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,6 +44581,7 @@ bgPic.tilePosition.y = 0; app.stage.addChild(bgPic); function resetPaw() { + hasTouchedGround = false; paw.x = app.screen.width / 2; paw.y = app.screen.height / 2; paw.vx = 0; @@ -44591,6 +44593,7 @@ function resetPaw() { } function resetDog() { + hasTouchedGround = false; dog.x = app.screen.width / 2; dog.y = app.screen.height / 2; dog.vx = 0; @@ -44695,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 7b8d72bf..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,6 +37,7 @@ bgPic.tilePosition.y = 0; app.stage.addChild(bgPic); function resetPaw() { + hasTouchedGround = false; paw.x = app.screen.width / 2; paw.y = app.screen.height / 2; paw.vx = 0; @@ -47,6 +49,7 @@ function resetPaw() { } function resetDog() { + hasTouchedGround = false; dog.x = app.screen.width / 2; dog.y = app.screen.height / 2; dog.vx = 0; @@ -147,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 {