User prompt
Don’t set jump force on move
User prompt
Increase jump power by 2x
User prompt
Increase jump power by 30%
User prompt
Decrease the jump power by a factor of 100
User prompt
Decrease the power of jumps by a factor of 100
User prompt
Jump force should be calculated based on the office from the initial touch point when releasing
User prompt
Have both x and y velocity for the player
User prompt
Make jumping based on dragging back and releasing, like a spring. You should be able to start dragging from anywhere on the screen
User prompt
Don’t start moving until I jump the first time
User prompt
The ground should move down along with the platforms
User prompt
Add a ground to the game that the player initially stands on
User prompt
Progress game
Initial prompt
Jumping game
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) {
var dx = this.x - x;
var dy = this.y - y;
this.jumpForceX = dx / 100;
this.jumpForceY = dy / 100;
};
self.update = function () {
this.x += this.velocityX;
this.y += this.velocityY;
this.velocityY += this.gravity;
if (this.y > 2732) {
this.y = 2732;
this.velocity = 0;
}
};
});
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 / 100;
player.velocityY = -player.jumpForceY / 100;
dragStart = null;
}
});
stage.on('move', function (obj) {
if (dragStart) {
var pos = obj.event.getLocalPosition(self);
player.setJumpForce(dragStart.x, dragStart.y);
}
});
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();
if (firstJump) {
ground.move();
for (var i = 0; i < platforms.length; i++) {
platforms[i].move();
if (platforms[i].y > 2732) {
platforms[i].y = 0;
platforms[i].x = Math.random() * 2048;
}
if (player.intersects(platforms[i]) && player.velocity > 0) {
player.jump();
}
}
}
});
var dragStart = null;
stage.on('down', function (obj) {
dragStart = obj.event.getLocalPosition(self);
});
});
===================================================================
--- original.js
+++ change.js
@@ -7,10 +7,10 @@
self.velocityY = 0;
self.setJumpForce = function (x, y) {
var dx = this.x - x;
var dy = this.y - y;
- this.jumpForceX = dx;
- this.jumpForceY = dy;
+ this.jumpForceX = dx / 100;
+ this.jumpForceY = dy / 100;
};
self.update = function () {
this.x += this.velocityX;
this.y += this.velocityY;
@@ -34,10 +34,10 @@
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;
+ player.velocityX = -player.jumpForceX / 100;
+ player.velocityY = -player.jumpForceY / 100;
dragStart = null;
}
});
stage.on('move', function (obj) {
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.