User prompt
Create a new cookie variant with a new image
User prompt
Make variant two slower than the others
User prompt
Make variant 1 faster than the others
User prompt
Make the two variants can appear separately
User prompt
Make them appear even less frequently
User prompt
Make obstacle variants appear less frequently
User prompt
Make each variant have a different image
User prompt
Create two obstacle variants
User prompt
Create a new cookie variant that gives more points and appears less frequently
User prompt
Make the new variant give 3 points and appear less frequently
User prompt
Make the new variant give 5 points and appear less frequently
User prompt
Create a cookie variant
User prompt
Create an image for the background
Initial prompt
Cookie eater
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Cookie class representing the cookies to be eaten var Cookie = Container.expand(function () { var self = Container.call(this); var cookieGraphics = self.attachAsset('cookie', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += 5; // Move cookies downwards }; }); // Obstacle class representing obstacles to dodge var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += 7; // Move obstacles downwards faster }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var background = game.addChild(LK.getAsset('background', { anchorX: 0.0, anchorY: 0.0 })); // Initialize arrays to keep track of cookies and obstacles var cookies = []; var obstacles = []; var score = 0; // Create a character to eat cookies var character = game.addChild(new Container()); var characterGraphics = character.attachAsset('character', { anchorX: 0.5, anchorY: 0.5 }); character.x = 2048 / 2; character.y = 2732 - 200; // Score display var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Handle touch events to move the character game.down = function (x, y, obj) { character.x = x; character.y = y; }; // Update game logic game.update = function () { // Spawn cookies and obstacles if (LK.ticks % 60 == 0) { var newCookie = new Cookie(); newCookie.x = Math.random() * 2048; newCookie.y = -50; cookies.push(newCookie); game.addChild(newCookie); var newObstacle = new Obstacle(); newObstacle.x = Math.random() * 2048; newObstacle.y = -50; obstacles.push(newObstacle); game.addChild(newObstacle); } // Update cookies and check for collisions for (var i = cookies.length - 1; i >= 0; i--) { var cookie = cookies[i]; cookie.update(); if (cookie.y > 2732) { cookie.destroy(); cookies.splice(i, 1); } else if (character.intersects(cookie)) { score++; scoreTxt.setText(score); cookie.destroy(); cookies.splice(i, 1); } } // Update obstacles and check for collisions for (var j = obstacles.length - 1; j >= 0; j--) { var obstacle = obstacles[j]; obstacle.update(); if (obstacle.y > 2732) { obstacle.destroy(); obstacles.splice(j, 1); } else if (character.intersects(obstacle)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } };
===================================================================
--- original.js
+++ change.js
@@ -1,104 +1,108 @@
-/****
+/****
* Classes
-****/
+****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Cookie class representing the cookies to be eaten
var Cookie = Container.expand(function () {
- var self = Container.call(this);
- var cookieGraphics = self.attachAsset('cookie', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.update = function () {
- self.y += 5; // Move cookies downwards
- };
+ var self = Container.call(this);
+ var cookieGraphics = self.attachAsset('cookie', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ self.y += 5; // Move cookies downwards
+ };
});
// Obstacle class representing obstacles to dodge
var Obstacle = Container.expand(function () {
- var self = Container.call(this);
- var obstacleGraphics = self.attachAsset('obstacle', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.update = function () {
- self.y += 7; // Move obstacles downwards faster
- };
+ var self = Container.call(this);
+ var obstacleGraphics = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ self.y += 7; // Move obstacles downwards faster
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
+****/
+var background = game.addChild(LK.getAsset('background', {
+ anchorX: 0.0,
+ anchorY: 0.0
+}));
// Initialize arrays to keep track of cookies and obstacles
var cookies = [];
var obstacles = [];
var score = 0;
// Create a character to eat cookies
var character = game.addChild(new Container());
var characterGraphics = character.attachAsset('character', {
- anchorX: 0.5,
- anchorY: 0.5
+ anchorX: 0.5,
+ anchorY: 0.5
});
character.x = 2048 / 2;
character.y = 2732 - 200;
// Score display
var scoreTxt = new Text2('0', {
- size: 150,
- fill: 0xFFFFFF
+ size: 150,
+ fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Handle touch events to move the character
game.down = function (x, y, obj) {
- character.x = x;
- character.y = y;
+ character.x = x;
+ character.y = y;
};
// Update game logic
game.update = function () {
- // Spawn cookies and obstacles
- if (LK.ticks % 60 == 0) {
- var newCookie = new Cookie();
- newCookie.x = Math.random() * 2048;
- newCookie.y = -50;
- cookies.push(newCookie);
- game.addChild(newCookie);
- var newObstacle = new Obstacle();
- newObstacle.x = Math.random() * 2048;
- newObstacle.y = -50;
- obstacles.push(newObstacle);
- game.addChild(newObstacle);
- }
- // Update cookies and check for collisions
- for (var i = cookies.length - 1; i >= 0; i--) {
- var cookie = cookies[i];
- cookie.update();
- if (cookie.y > 2732) {
- cookie.destroy();
- cookies.splice(i, 1);
- } else if (character.intersects(cookie)) {
- score++;
- scoreTxt.setText(score);
- cookie.destroy();
- cookies.splice(i, 1);
- }
- }
- // Update obstacles and check for collisions
- for (var j = obstacles.length - 1; j >= 0; j--) {
- var obstacle = obstacles[j];
- obstacle.update();
- if (obstacle.y > 2732) {
- obstacle.destroy();
- obstacles.splice(j, 1);
- } else if (character.intersects(obstacle)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- }
+ // Spawn cookies and obstacles
+ if (LK.ticks % 60 == 0) {
+ var newCookie = new Cookie();
+ newCookie.x = Math.random() * 2048;
+ newCookie.y = -50;
+ cookies.push(newCookie);
+ game.addChild(newCookie);
+ var newObstacle = new Obstacle();
+ newObstacle.x = Math.random() * 2048;
+ newObstacle.y = -50;
+ obstacles.push(newObstacle);
+ game.addChild(newObstacle);
+ }
+ // Update cookies and check for collisions
+ for (var i = cookies.length - 1; i >= 0; i--) {
+ var cookie = cookies[i];
+ cookie.update();
+ if (cookie.y > 2732) {
+ cookie.destroy();
+ cookies.splice(i, 1);
+ } else if (character.intersects(cookie)) {
+ score++;
+ scoreTxt.setText(score);
+ cookie.destroy();
+ cookies.splice(i, 1);
+ }
+ }
+ // Update obstacles and check for collisions
+ for (var j = obstacles.length - 1; j >= 0; j--) {
+ var obstacle = obstacles[j];
+ obstacle.update();
+ if (obstacle.y > 2732) {
+ obstacle.destroy();
+ obstacles.splice(j, 1);
+ } else if (character.intersects(obstacle)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ }
};
\ No newline at end of file
Rock. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Chocolate chip cookie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Person man running. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Golden cookie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
360-degree missile. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Mountain. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Rainbow cookie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows