Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: truee is not defined' in this line: 'if (truee) {' Line Number: 98
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: floorTile.anchor is not a function' in this line: 'floorTile.anchor(0, 0);' Line Number: 109
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
center align instructions text
Code edit (1 edits merged)
Please save this source code
User prompt
add game instructions text: "Tap to move and throw snowballs at the evil snowmen"
User prompt
if player collides with snowmanenemy game over
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: player is not defined' in this line: 'var dx = player.x - self.x;' Line Number: 75
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: player is not defined' in this line: 'var dx = player.x - self.x;' Line Number: 75
User prompt
Fix Bug: 'ReferenceError: player is not defined' in this line: 'var dx = player.x - self.x;' Line Number: 75
Code edit (4 edits merged)
Please save this source code
User prompt
rename enemy class to SnowManEnemy
User prompt
create a snowman subclass of enemy
Code edit (5 edits merged)
Please save this source code
User prompt
on tap anywhere, increase player velocity towards the clicked position
Code edit (1 edits merged)
Please save this source code
User prompt
hide playbutton when pressed
User prompt
create a playbutton and call playButonPressed when it's pressed
Code edit (2 edits merged)
Please save this source code
var Snowflake = Container.expand(function () { var self = Container.call(this); var snowflakeGraphics = self.createAsset('snowflake', 'Snowflake', .5, .5); snowflakeGraphics.width = 10; snowflakeGraphics.height = 10; self.speed = Math.random() * 4 + 2; self.move = function () { self.y += self.speed; self.x += Math.sin(self.y / 100) * 5; if (self.y > 2800) { self.y = -10; } }; }); var FloorTile = Container.expand(function () { var self = Container.call(this); var floorTileGraphics = self.createAsset('floorTile', 'Floor Tile', .5, .5); floorTileGraphics.width = 200; floorTileGraphics.height = 200; }); var IceBlock = Container.expand(function () { var self = Container.call(this); var iceBlockGraphics = self.createAsset('iceBlock', 'Ice Block', .5, .5); }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.createAsset('player', 'Player character', .5, .5); self.velocity = { x: 0, y: 0 }; self.shoot = function () {}; self.move = function () { self.x += self.velocity.x; self.y += self.velocity.y; self.velocity.x *= 0.95; self.velocity.y *= 0.95; }; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('bullet', 'Bullet', .5, .5); self.direction = { x: 0, y: 0 }; self.speed = 10; self.move = function () { self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; }; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy', 'Enemy character', .5, .5); self.move = function () {}; }); var Game = Container.expand(function () { var self = Container.call(this); var iceBlocks = []; var blockSize = 200; var worldWidth = blockSize * 11; var worldHeight = blockSize * 15; console.log('Game world size:', worldWidth, 'x', worldHeight); console.log('LK.stageContainer.height:', LK.stageContainer.height); for (var i = 0; i < worldWidth / blockSize; i++) { for (var j = 0; j < worldHeight / blockSize; j++) { if (i === 0 || i === worldWidth / blockSize - 1 || j === 0 || j === worldHeight / blockSize - 1) { var iceBlock = new IceBlock(); iceBlock.x = i * blockSize; iceBlock.y = j * blockSize; self.addChild(iceBlock); } else { var floorTile = new FloorTile(); floorTile.x = i * blockSize; floorTile.y = j * blockSize; self.addChild(floorTile); } } } var player = self.addChild(new Player()); var playButton = self.createAsset('playButton', 'Play Button', .5, .5); playButton.x = worldWidth / 2; playButton.y = worldHeight / 2; playButton.scale = 3; playButton.on('down', function () { playButton.visible = false; LK.emit('playButtonPressed'); }); var bullets = []; var enemies = []; var enemySpawnInterval; var bulletInterval; LK.on('playButtonPressed', function () { enemySpawnInterval = LK.setInterval(function () { var enemy = new Enemy(); enemy.x = Math.random() * worldWidth; enemy.y = Math.random() * worldHeight; enemies.push(enemy); self.addChild(enemy); }, 2000); bulletInterval = LK.setInterval(function () { var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; var pos = { x: 0, y: 0 }; var dx = pos.x - player.x; var dy = pos.y - player.y; var magnitude = Math.sqrt(dx * dx + dy * dy); bullet.direction.x = dx / magnitude; bullet.direction.y = dy / magnitude; bullets.push(bullet); self.addChild(bullet); }, 2000); }); var snowflakes = []; for (var i = 0; i < 10; i++) { var snowflake = new Snowflake(); snowflake.x = Math.random() * 1800; snowflake.y = Math.random() * LK.stageContainer.height; snowflakes.push(snowflake); self.addChild(snowflake); } player.x = 330; player.y = 300; LK.on('tick', function () { player.move(); for (var i = 0; i < bullets.length; i++) { bullets[i].move(); if (bullets[i].x < 0 || bullets[i].x > worldWidth || bullets[i].y < 0 || bullets[i].y > worldHeight) { bullets[i].destroy(); bullets.splice(i, 1); continue; } for (var j = 0; j < enemies.length; j++) { if (bullets[i].intersects(enemies[j])) { enemies[j].destroy(); enemies.splice(j, 1); break; } } } for (var i = 0; i < enemies.length; i++) { enemies[i].move(); } for (var i = 0; i < snowflakes.length; i++) { snowflakes[i].move(); } }); stage.on('down', function (obj) { if (false) { var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; var pos = obj.event.getLocalPosition(self); var dx = pos.x - player.x; var dy = pos.y - player.y; var magnitude = Math.sqrt(dx * dx + dy * dy); bullet.direction.x = dx / magnitude; bullet.direction.y = dy / magnitude; bullets.push(bullet); self.addChild(bullet); player.x -= bullet.direction.x * 10; player.y -= bullet.direction.y * 10; var recoilFrames = 10; LK.on('tick', function recoilTick() { if (recoilFrames-- <= 0) { return; } player.x += bullet.direction.x; player.y += bullet.direction.y; }); } }); LK.setInterval(function () { var pos = LK.stageContainer.getMousePosition(); console.log('Mouse position:', pos.x, pos.y); }, 2000); });
===================================================================
--- original.js
+++ change.js
@@ -79,10 +79,11 @@
}
}
var player = self.addChild(new Player());
var playButton = self.createAsset('playButton', 'Play Button', .5, .5);
- playButton.x = LK.stageContainer.width / 2;
- playButton.y = LK.stageContainer.height / 2;
+ playButton.x = worldWidth / 2;
+ playButton.y = worldHeight / 2;
+ playButton.scale = 3;
playButton.on('down', function () {
playButton.visible = false;
LK.emit('playButtonPressed');
});
a penguin engineer Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
rectangular ice wall section, top down view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
ice floor texture tile top down view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
one cartoony snowball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white dot. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
button with arrow key pointing left. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a large round playbutton Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoony evil snowman character Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
icy treasure chest Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A snowcovered christmas tree decorated with snowballs.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.