User prompt
Only allow the player to snap to a platform if the center of the player is above the top of the platform
User prompt
Add a platform that the player initially stands on
User prompt
Fix Bug: 'ReferenceError: Can't find variable: ground' in this line: 'ground.move();' Line Number: 71
User prompt
Remove the ground from the game
User prompt
Inside the intersection check in tick, multiply player.velocityX with .8
User prompt
Inside the intersection check in tick, multiply player.velocityY with .8
User prompt
In tick method, after setting velocityY multiply velocityX with .8
User prompt
In the tick method multiply velocity y with .8 after setting velocity x
User prompt
Increase intertia by 5x if the player is standing on a platform
User prompt
Set player friction to .98 and also apply it to y movement
User prompt
Set player friction to .95
User prompt
Add friction to the player movement
User prompt
Player should bounce off edges
User prompt
Player should stand on platforms if not jumping
User prompt
Make the jumping check be larger or equal to 0
User prompt
Don’t call player jump inside tick
User prompt
Don’t test for first jump in tick
User prompt
Don’t move platforms on every tick
User prompt
Player should be able to jump up trough platforms but if the player is currently falling down he should be able to stand on platforms
User prompt
Reverse the velocities when applying jumping forve
User prompt
Increase jumping power with 4x
User prompt
Reverse the speedx and speedy that jumping applies to the player
User prompt
Decrease jump force by /50
User prompt
Just use x and y directly when setting jump force
User prompt
Don’t factor in position of the player in set jump force
var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.createAsset('player', 'Player character', .5, .5); self.gravity = 1; self.jumpForce = 20; self.velocityX = 0; self.velocityY = 0; self.setJumpForce = function (x, y) { this.jumpForceX = x / 12.5; this.jumpForceY = y / 12.5; }; self.jumping = false; self.update = function () { this.x += this.velocityX; this.y += this.velocityY; this.velocityY += this.gravity; if (this.jumping) { this.velocityX *= 0.98; this.velocityY *= 0.98; } else { this.velocityX *= 0.98 * 5; this.velocityY *= 0.98 * 5; } if (this.y > 2732) { this.y = 2732; this.velocityY = 0; } if (this.x < 0 || this.x > 2048) { this.velocityX *= -1; } if (this.velocityY >= 0) { this.jumping = false; } else if (this.velocityY < 0) { this.jumping = true; } }; }); var Platform = Container.expand(function () { var self = Container.call(this); var platformGraphics = self.createAsset('platform', 'Platform', .5, .5); self.speed = 5; self.move = function () { this.y += this.speed; }; }); var Game = Container.expand(function () { var self = Container.call(this); stage.on('up', function (obj) { if (dragStart) { var pos = obj.event.getLocalPosition(self); player.setJumpForce(dragStart.x - pos.x, dragStart.y - pos.y); player.velocityX = player.jumpForceX; player.velocityY = player.jumpForceY; dragStart = null; } }); stage.on('move', function (obj) { if (dragStart) { var pos = obj.event.getLocalPosition(self); } }); var platforms = []; var ground = self.createAsset('ground', 'Ground', 0, 1); ground.y = 2732; ground.speed = 5; ground.move = function () { this.y += this.speed; if (this.y > 2732) { this.y = 0; } }; var player = self.addChild(new Player()); player.x = 2048 / 2; player.y = ground.y - player.height; var firstJump = false; for (var i = 0; i < 5; i++) { var platform = new Platform(); platform.x = Math.random() * 2048; platform.y = i * (2732 / 5); platforms.push(platform); self.addChild(platform); } LK.on('tick', function () { player.update(); ground.move(); for (var i = 0; i < platforms.length; i++) { if (player.intersects(platforms[i]) && !player.jumping) { player.y = platforms[i].y - player.height; player.velocityY = 0; } } }); var dragStart = null; stage.on('down', function (obj) { dragStart = obj.event.getLocalPosition(self); }); });
===================================================================
--- original.js
+++ change.js
@@ -13,10 +13,15 @@
self.update = function () {
this.x += this.velocityX;
this.y += this.velocityY;
this.velocityY += this.gravity;
- this.velocityX *= 0.98;
- this.velocityY *= 0.98;
+ if (this.jumping) {
+ this.velocityX *= 0.98;
+ this.velocityY *= 0.98;
+ } else {
+ this.velocityX *= 0.98 * 5;
+ this.velocityY *= 0.98 * 5;
+ }
if (this.y > 2732) {
this.y = 2732;
this.velocityY = 0;
}
Single cartoon frog sitting. Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single Cartoon lillypad seen edge on. No flower Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cozy cartoon swamp background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.