From a44db77003cf0cea02737fb3a3cd6ce56479e65e Mon Sep 17 00:00:00 2001 From: Davis Date: Mon, 31 Jan 2022 19:12:21 -0600 Subject: [PATCH 1/3] Update Liscense --- jumpD/assets/into1.txt | 14 ++++++++++++++ jumpD/js/ManagePhysics.js | 4 ++++ jumpD/js/Player.js | 27 +++++++++++++++++++++++---- jumpD/js/SceneMain.js | 1 + jumpD/js/intro.js | 5 +++++ jumpD/js/tileMap.js | 35 ++++++++++++++++++++++++++++++++--- 6 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 jumpD/assets/into1.txt create mode 100644 jumpD/js/intro.js diff --git a/jumpD/assets/into1.txt b/jumpD/assets/into1.txt new file mode 100644 index 0000000..664351f --- /dev/null +++ b/jumpD/assets/into1.txt @@ -0,0 +1,14 @@ +I have, in the past, been told +that there are things you can't do +once you grow older + +that in the "real world" +you can't play with your toys +first your blanket, your teddy bear +then your toys and books + +expectations are higher +people aren't kind and nice to others +the + +I decided diff --git a/jumpD/js/ManagePhysics.js b/jumpD/js/ManagePhysics.js index a741bd2..cf05c7c 100644 --- a/jumpD/js/ManagePhysics.js +++ b/jumpD/js/ManagePhysics.js @@ -8,4 +8,8 @@ function updatePhysics() { scene.player.updatePhysics(); scene.tilemap.updatePhysics(); +} +function cleanPhysics(){ + scene.tilemap.cleanPhysics(); + scene.player.cleanPhysics(); } \ No newline at end of file diff --git a/jumpD/js/Player.js b/jumpD/js/Player.js index 9ab779d..c66add7 100644 --- a/jumpD/js/Player.js +++ b/jumpD/js/Player.js @@ -8,6 +8,10 @@ class Player { frameHeight: 32 }); this.keys = makeKeys(['w', 'a', 's', 'd', 'j']); + var spaceBar = scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + this.keys.push(spaceBar); + this.keys.SPACE = spaceBar; + this.drag = 300; this.maxVelocityX = 180; @@ -30,20 +34,28 @@ class Player { const animation = animations[i]; console.log(player.anims.create(animation)); } - scene.input.keyboard.on("keyup", this.onKeyUp); + scene.input.keyboard.on("keyup", this.onKeyUp.bind(this)); } onKeyUp(event) { if (event.keyCode == Phaser.Input.Keyboard.KeyCodes.J) { - scene.tilemap.swapLayers(); + + this.swap = true; + } } + cleanPhysics(){ + this.swap = false; + } updatePhysics() { + var onFloor; if (player.body.onFloor()) { player.setDragX(this.drag); + onFloor = true; } else { + onFloor = false; player.setDragX(0); } let downKeys = getKeysDown(this.keys); @@ -55,6 +67,8 @@ class Player { for (var i in downKeys) { switch (downKeys[i]) { case keys.w: + case keys.SPACE: + console.log('Space down') up = true; break; case keys.a: @@ -67,16 +81,21 @@ class Player { break; } } + if (this.swap){ + scene.tilemap.swapLayers(); + } let cursors = this.cursors; if (cursors.left.isDown || left) { - player.setAccelerationX(-180); + let dragBonus = onFloor && player.body.velocity.x > 0 ? -this.drag : 0; + player.setAccelerationX(-180 + dragBonus); player.anims.play('walk', true); player.flipX = true; } else if (cursors.right.isDown || right) { - player.setAccelerationX(180); + let dragBonus = onFloor && player.body.velocity.x < 0 ? this.drag : 0; + player.setAccelerationX(180 + dragBonus); player.play('walk', true); player.flipX = false; diff --git a/jumpD/js/SceneMain.js b/jumpD/js/SceneMain.js index 956a367..5d7fa5c 100644 --- a/jumpD/js/SceneMain.js +++ b/jumpD/js/SceneMain.js @@ -24,6 +24,7 @@ class SceneMain extends Phaser.Scene { } update() { updatePhysics(); + cleanPhysics(); } } \ No newline at end of file diff --git a/jumpD/js/intro.js b/jumpD/js/intro.js new file mode 100644 index 0000000..8c13c15 --- /dev/null +++ b/jumpD/js/intro.js @@ -0,0 +1,5 @@ +class TextScreen extends Phaser.Scene{ + constructor(){ + + } +} \ No newline at end of file diff --git a/jumpD/js/tileMap.js b/jumpD/js/tileMap.js index 82a9ff3..ab08d91 100644 --- a/jumpD/js/tileMap.js +++ b/jumpD/js/tileMap.js @@ -37,16 +37,45 @@ class tilemap { let c1 = scene.physics.add.collider(this.Layer1, player); let c2 = scene.physics.add.collider(this.Layer2, player); c2.active = false; + /*let o1 = scene.physics.add.overlap(this.Layer1,player,function(bdy1,ci){ + if (ci && (ci.collideUp && ci.collideDown && ci.collideRight && ci.collideLeft)){ + this.Layer1.playerInzone = true; + } + }.bind(this)); + let o2 = scene.physics.add.overlap(this.Layer2,player, function(bdy1,ci){ + if (ci){ + //console.log(ci); + } + if (ci && (ci.collideUp && ci.collideDown && ci.collideRight && ci.collideLeft)){ + this.Layer1.playerInzone = true; + } + }.bind(this))*/ this.colliders = [c1, c2]; } + cleanPhysics(){ + for(var i in this.layers){ + this.layers[i].playerInzone = false; + } + } + isPlayerInZone(layer){ + let bounds = player.getBounds(); + let tiles = layer.getTilesWithinShape(bounds, {isNotEmpty: true}); + let overlap = scene.physics.overlapTiles(player,tiles); + return overlap; + } swapLayers() { + let currentCollider = this.colliders[this.activeLayer]; let currentLayer = this.layers[this.activeLayer]; - this.activeLayer = (this.activeLayer + 1) % 2; + let activeLayer = (this.activeLayer + 1) % 2; + + let newCollider = this.colliders[activeLayer]; + let newLayer = this.layers[activeLayer]; + + if (this.isPlayerInZone(newLayer)) return; - let newCollider = this.colliders[this.activeLayer]; - let newLayer = this.layers[this.activeLayer]; + this.activeLayer = activeLayer; currentCollider.active = false; newCollider.active = true; From e18b0d288f5e5944d5c3321d4dd44d015549d562 Mon Sep 17 00:00:00 2001 From: Davis Date: Sun, 20 Feb 2022 19:33:15 -0600 Subject: [PATCH 2/3] added intro text file --- jumpD/assets/into1.txt | 14 +++++++++++++- jumpD/assets/outro1.txt | 0 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 jumpD/assets/outro1.txt diff --git a/jumpD/assets/into1.txt b/jumpD/assets/into1.txt index 664351f..fc52804 100644 --- a/jumpD/assets/into1.txt +++ b/jumpD/assets/into1.txt @@ -11,4 +11,16 @@ expectations are higher people aren't kind and nice to others the -I decided +I decided not to visit this "real world" + +Care to Join Me? + +'Yes'/'No' + +'Yes' Welcome! + +'No' What will you do now? + +'Wait.'/'Goodbye' + +'Wait' Care to Join Me? \ No newline at end of file diff --git a/jumpD/assets/outro1.txt b/jumpD/assets/outro1.txt new file mode 100644 index 0000000..e69de29 From d4cf632c59533252672a404919840e4ddef4edb5 Mon Sep 17 00:00:00 2001 From: Davis Date: Fri, 18 Mar 2022 17:52:51 -0500 Subject: [PATCH 3/3] changed liscense --- jumpD/LISCENSE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jumpD/LISCENSE b/jumpD/LISCENSE index afc8c48..48bdac0 100644 --- a/jumpD/LISCENSE +++ b/jumpD/LISCENSE @@ -1,3 +1,5 @@ +--- +--- This Game is availible under the GNU-GPLv3.0 liscense with the following additional condition added to the liscense: if you modify the game you must tell others that the game was modified if you change the game so the gameplay is different (e.g. add levels, change mechanics),