User prompt
Move the score tab to the middle top of the screen
User prompt
make the game slightly wider
User prompt
add a golden sausage explosion to the golden sausage for when it is hit
User prompt
make it so that sausages explode when they touch the hero
User prompt
The golden sausage chould add 10 points to the score instead of 1
User prompt
Fix Bug: 'TypeError: this.scale is undefined' in or related to this line: 'Bullet.prototype.originalWidth = Bullet.prototype.width;' Line Number: 65
User prompt
Change the power-up so that it makes the bullets bigger for 10 seconds instead of shooting 3 bullets a a time
User prompt
Fix Bug: 'TypeError: bullets[i].move is not a function' in or related to this line: 'bullets[i].move();' Line Number: 155
User prompt
create a new golden sausage that has a 1 in a 100 chance of appearing. When hit, it gives a temporary power-up to the hero. The power-up makes it so that the hero shoots 3 bullets a a time for 10 seconds.
User prompt
Fullt Delete sausage bits from the code as they cause bugs
User prompt
Make it so that sausage bits disappear after hitting a sausage
User prompt
Once created, the sausage bits should move straight in a random direction, until they hit a sausage or the borders of the game
User prompt
Each hit sausage should create 4 bits. Also, the bits should be sent in random directions. When the bits hit the border of the game, they disappear
User prompt
make it so that when a sausage is hit, it launches 4 small sausage bits in random directions. When the bits hit a sausage, it explodes as if it was hit by a bullet.
User prompt
make the hero move faster
User prompt
make it so that sausages explode when hit
User prompt
make the score visible in the up right corner
User prompt
add a score in the upright corner so that each destroyed sausage gives 1 point
User prompt
Fix Bug: 'TypeError: window.addEventListener is not a function' in or related to this line: 'window.addEventListener('keydown', function (event) {' Line Number: 72
User prompt
make it so that we can move the hero using the keyboard's directional arrows
User prompt
Make it so that we can move the hero to the right and the left
User prompt
Make it so that we can see the background image
User prompt
add a background which represents a kitchen's ground
Initial prompt
Sausage Hunter
/**** * Classes ****/ var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.moveLeft = function () { self.x = Math.max(self.width / 2, self.x - self.speed); }; self.moveRight = function () { self.x = Math.min(2048 - self.width / 2, self.x + self.speed); }; self.shoot = function () { var bullet = new Bullet(); bullet.x = self.x; bullet.y = self.y - self.height / 2; game.addChild(bullet); return bullet; }; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -10; self.move = function () { self.y += self.speed; }; }); var Sausage = Container.expand(function () { var self = Container.call(this); var sausageGraphics = self.attachAsset('sausage', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.move = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundImage: 'kitchenBackground' }); /**** * Game Code ****/ var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 150; var bullets = []; var sausages = []; game.on('down', function (obj) { var touchPos = obj.event.getLocalPosition(game); if (touchPos.x < 2048 / 2) { hero.moveLeft(); } else { hero.moveRight(); } bullets.push(hero.shoot()); }); LK.on('tick', function () { // Move bullets for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].move(); if (bullets[i].y < 0) { bullets[i].destroy(); bullets.splice(i, 1); } } // Move sausages for (var j = sausages.length - 1; j >= 0; j--) { sausages[j].move(); if (sausages[j].y > 2732) { sausages[j].destroy(); sausages.splice(j, 1); } } // Check for collisions for (var b = bullets.length - 1; b >= 0; b--) { for (var s = sausages.length - 1; s >= 0; s--) { if (bullets[b] && sausages[s] && bullets[b].intersects(sausages[s])) { bullets[b].destroy(); bullets.splice(b, 1); sausages[s].destroy(); sausages.splice(s, 1); break; } } } // Spawn sausages if (LK.ticks % 120 == 0) { var newSausage = new Sausage(); newSausage.x = Math.random() * (2048 - newSausage.width) + newSausage.width / 2; newSausage.y = -newSausage.height / 2; sausages.push(newSausage); game.addChild(newSausage); } });
===================================================================
--- original.js
+++ change.js
@@ -1,109 +1,109 @@
-/****
+/****
* Classes
****/
var Hero = Container.expand(function () {
- var self = Container.call(this);
- var heroGraphics = self.attachAsset('hero', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.moveLeft = function () {
- self.x = Math.max(self.width / 2, self.x - self.speed);
- };
- self.moveRight = function () {
- self.x = Math.min(2048 - self.width / 2, self.x + self.speed);
- };
- self.shoot = function () {
- var bullet = new Bullet();
- bullet.x = self.x;
- bullet.y = self.y - self.height / 2;
- game.addChild(bullet);
- return bullet;
- };
+ var self = Container.call(this);
+ var heroGraphics = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.moveLeft = function () {
+ self.x = Math.max(self.width / 2, self.x - self.speed);
+ };
+ self.moveRight = function () {
+ self.x = Math.min(2048 - self.width / 2, self.x + self.speed);
+ };
+ self.shoot = function () {
+ var bullet = new Bullet();
+ bullet.x = self.x;
+ bullet.y = self.y - self.height / 2;
+ game.addChild(bullet);
+ return bullet;
+ };
});
var Bullet = Container.expand(function () {
- var self = Container.call(this);
- var bulletGraphics = self.attachAsset('bullet', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = -10;
- self.move = function () {
- self.y += self.speed;
- };
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('bullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -10;
+ self.move = function () {
+ self.y += self.speed;
+ };
});
var Sausage = Container.expand(function () {
- var self = Container.call(this);
- var sausageGraphics = self.attachAsset('sausage', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 2;
- self.move = function () {
- self.y += self.speed;
- };
+ var self = Container.call(this);
+ var sausageGraphics = self.attachAsset('sausage', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 2;
+ self.move = function () {
+ self.y += self.speed;
+ };
});
-/****
+/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundImage: 'kitchenBackground'
});
-/****
+/****
* Game Code
****/
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 150;
var bullets = [];
var sausages = [];
game.on('down', function (obj) {
- var touchPos = obj.event.getLocalPosition(game);
- if (touchPos.x < 2048 / 2) {
- hero.moveLeft();
- } else {
- hero.moveRight();
- }
- bullets.push(hero.shoot());
+ var touchPos = obj.event.getLocalPosition(game);
+ if (touchPos.x < 2048 / 2) {
+ hero.moveLeft();
+ } else {
+ hero.moveRight();
+ }
+ bullets.push(hero.shoot());
});
LK.on('tick', function () {
- // Move bullets
- for (var i = bullets.length - 1; i >= 0; i--) {
- bullets[i].move();
- if (bullets[i].y < 0) {
- bullets[i].destroy();
- bullets.splice(i, 1);
- }
- }
- // Move sausages
- for (var j = sausages.length - 1; j >= 0; j--) {
- sausages[j].move();
- if (sausages[j].y > 2732) {
- sausages[j].destroy();
- sausages.splice(j, 1);
- }
- }
- // Check for collisions
- for (var b = bullets.length - 1; b >= 0; b--) {
- for (var s = sausages.length - 1; s >= 0; s--) {
- if (bullets[b] && sausages[s] && bullets[b].intersects(sausages[s])) {
- bullets[b].destroy();
- bullets.splice(b, 1);
- sausages[s].destroy();
- sausages.splice(s, 1);
- break;
- }
- }
- }
- // Spawn sausages
- if (LK.ticks % 120 == 0) {
- var newSausage = new Sausage();
- newSausage.x = Math.random() * (2048 - newSausage.width) + newSausage.width / 2;
- newSausage.y = -newSausage.height / 2;
- sausages.push(newSausage);
- game.addChild(newSausage);
- }
+ // Move bullets
+ for (var i = bullets.length - 1; i >= 0; i--) {
+ bullets[i].move();
+ if (bullets[i].y < 0) {
+ bullets[i].destroy();
+ bullets.splice(i, 1);
+ }
+ }
+ // Move sausages
+ for (var j = sausages.length - 1; j >= 0; j--) {
+ sausages[j].move();
+ if (sausages[j].y > 2732) {
+ sausages[j].destroy();
+ sausages.splice(j, 1);
+ }
+ }
+ // Check for collisions
+ for (var b = bullets.length - 1; b >= 0; b--) {
+ for (var s = sausages.length - 1; s >= 0; s--) {
+ if (bullets[b] && sausages[s] && bullets[b].intersects(sausages[s])) {
+ bullets[b].destroy();
+ bullets.splice(b, 1);
+ sausages[s].destroy();
+ sausages.splice(s, 1);
+ break;
+ }
+ }
+ }
+ // Spawn sausages
+ if (LK.ticks % 120 == 0) {
+ var newSausage = new Sausage();
+ newSausage.x = Math.random() * (2048 - newSausage.width) + newSausage.width / 2;
+ newSausage.y = -newSausage.height / 2;
+ sausages.push(newSausage);
+ game.addChild(newSausage);
+ }
});
\ No newline at end of file
A crook sausage. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A heroic potato. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A background which represents a kitchen's ground. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A bullet shaped potato. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An exploding sausage. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A gold sausage. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An angry-looking onion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An onion exploding like a bomb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A carp which looks dumb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An ice cube. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.