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.velocity = 0; self.jump = function () { this.velocity = -this.jumpForce; }; self.update = function () { this.y += this.velocity; this.velocity += 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); var platforms = []; var ground = self.createAsset('ground', 'Ground', 0, 1); ground.y = 2732; var player = self.addChild(new Player()); player.x = 2048 / 2; player.y = ground.y - player.height; 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(); 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(); } } }); stage.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); if (player.intersects(pos)) { player.jump(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -26,11 +26,13 @@
});
var Game = Container.expand(function () {
var self = Container.call(this);
var platforms = [];
+ var ground = self.createAsset('ground', 'Ground', 0, 1);
+ ground.y = 2732;
var player = self.addChild(new Player());
player.x = 2048 / 2;
- player.y = 2732 / 2;
+ player.y = ground.y - player.height;
for (var i = 0; i < 5; i++) {
var platform = new Platform();
platform.x = Math.random() * 2048;
platform.y = i * (2732 / 5);
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.