User prompt
Add a text to the center of the screen saying drag and release to jump
User prompt
Use impact for score and add a dropshadow
User prompt
Add a score to the game
User prompt
Increment game speed with .5
User prompt
Increase game speed each time player jumps
User prompt
Remove the game speed from player update
User prompt
When adding platform speed to platforms also add game speed
User prompt
When adding platform speed to player y also add game speed
User prompt
Add game speed to player y as well
User prompt
Only add 5 platforms
User prompt
Set background alpha to .5
User prompt
when adding platform speed also add gamespeed
User prompt
When adding platfomSpeed also add gameSpeed
User prompt
Add a new variable called game speed to games class
User prompt
don't set width and hight of background element
User prompt
Add background element to game
User prompt
Make the platform hit-test element have alpha 0
User prompt
Attach the player after platforms are attached
User prompt
use the platform hit test element for intersection testing rather than the platform itself
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'player.hitTestAsset.height')' in this line: 'if (player.intersects(platforms[i].hitTestAsset) && !player.jumping && player.y + player.hitTestAsset.height / 2 < platforms[i].y) {' Line Number: 91
User prompt
Also use the hittestasset for player.y calculation
User prompt
Rather than intersecting with platform, intersect with the platform hittestasset
User prompt
make hit-test asset a property of the platform class
User prompt
Add a hit-test asset inside the platform class that is expoed
User prompt
set to maxMagnitude to 1000
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 vectorMagnitude = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); var maxMagnitude = 1000; if (vectorMagnitude > maxMagnitude) { x = x / vectorMagnitude * maxMagnitude; y = y / vectorMagnitude * maxMagnitude; } this.jumpForceX = x / 12.5; this.jumpForceY = y / 12.5; }; self.jumping = false; self.onPlatform = false; 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.y > 2732) { LK.showGameOver(); } 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; this.onPlatform = false; } }; }); var Platform = Container.expand(function () { var self = Container.call(this); var platformGraphics = self.createAsset('platform', 'Platform', .5, .5); self.hitTestAsset = self.createAsset('hitTest', 'Hit Test Asset', .5, .5); }); var Game = Container.expand(function () { var self = Container.call(this); stage.on('up', function (obj) { if (dragStart && player.onPlatform) { 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 platformSpeed = 0; var player = self.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - player.height; var firstJump = false; for (var i = 0; i < 6; i++) { var platform = new Platform(); if (i == 0) { platform.x = player.x; platform.y = player.y + player.height; } else { platform.x = Math.random() * 2048; platform.y = i * (2732 / 6); } platforms.push(platform); self.addChild(platform); } LK.on('tick', function () { player.update(); if (player.y < 2732 / 2) { platformSpeed = Math.min(platformSpeed + 0.1, 5); } else { platformSpeed = Math.max(platformSpeed - 0.1, 0); } for (var i = 0; i < platforms.length; i++) { platforms[i].y += platformSpeed; } player.y += platformSpeed; for (var i = 0; i < platforms.length; i++) { if (player.intersects(platforms[i]) && !player.jumping && player.y + player.height / 2 < platforms[i].y) { player.y = platforms[i].y - player.height / 2 - platforms[i].height / 2; player.velocityY = 0; player.velocityX *= 0.8; player.onPlatform = true; } else if (platforms[i].y - platforms[i].height > 2732) { platforms[i].y = -platforms[i].height; platforms[i].x = Math.random() * 2048; } } }); var dragStart = null; stage.on('down', function (obj) { dragStart = obj.event.getLocalPosition(self); }); });
===================================================================
--- original.js
+++ change.js
@@ -39,9 +39,9 @@
});
var Platform = Container.expand(function () {
var self = Container.call(this);
var platformGraphics = self.createAsset('platform', 'Platform', .5, .5);
- var hitTestAsset = self.createAsset('hitTest', 'Hit Test Asset', .5, .5);
+ self.hitTestAsset = self.createAsset('hitTest', 'Hit Test Asset', .5, .5);
});
var Game = Container.expand(function () {
var self = Container.call(this);
stage.on('up', 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.