User prompt
when you start game, block is random color
User prompt
if block is filled to 30. use Game over screen
User prompt
after block touched ground, spawn another block falling but change color randomly
User prompt
when block touched ground, dont use game over screen
User prompt
after block is in the ground, spawn another one and make it fall faster
User prompt
make the background color purple
Initial prompt
Block Stacker Go!
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Block class representing each block in the game var Block = Container.expand(function () { var self = Container.call(this); var blockGraphics = self.attachAsset('block', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Blocks do not have any specific update logic for now }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x800080 //Init game with purple background }); /**** * Game Code ****/ // Initialize variables var blocks = []; var currentBlock = null; var stackHeight = 0; var gameSpeed = 1; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Function to create a new block function createBlock() { var block = new Block(); block.x = 2048 / 2; block.y = 100; blocks.push(block); game.addChild(block); currentBlock = block; } // Function to handle block placement function placeBlock() { if (currentBlock) { currentBlock.y = 2732 - stackHeight * 100 - 50; stackHeight++; score++; scoreTxt.setText(score); currentBlock = null; createBlock(); gameSpeed += 0.1; } } // Initialize the first block createBlock(); // Event listener for touch down game.down = function (x, y, obj) { placeBlock(); }; // Update function called every game tick game.update = function () { if (currentBlock) { currentBlock.y += gameSpeed; if (currentBlock.y > 2732) { // Game over logic LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } };
===================================================================
--- original.js
+++ change.js
@@ -1,76 +1,76 @@
-/****
+/****
* Classes
-****/
+****/
//<Assets used in the game will automatically appear here>
// Block class representing each block in the game
var Block = Container.expand(function () {
- var self = Container.call(this);
- var blockGraphics = self.attachAsset('block', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.update = function () {
- // Blocks do not have any specific update logic for now
- };
+ var self = Container.call(this);
+ var blockGraphics = self.attachAsset('block', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ // Blocks do not have any specific update logic for now
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x800080 //Init game with purple background
});
-/****
+/****
* Game Code
-****/
+****/
// Initialize variables
var blocks = [];
var currentBlock = null;
var stackHeight = 0;
var gameSpeed = 1;
var score = 0;
var scoreTxt = new Text2('0', {
- size: 150,
- fill: "#ffffff"
+ size: 150,
+ fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Function to create a new block
function createBlock() {
- var block = new Block();
- block.x = 2048 / 2;
- block.y = 100;
- blocks.push(block);
- game.addChild(block);
- currentBlock = block;
+ var block = new Block();
+ block.x = 2048 / 2;
+ block.y = 100;
+ blocks.push(block);
+ game.addChild(block);
+ currentBlock = block;
}
// Function to handle block placement
function placeBlock() {
- if (currentBlock) {
- currentBlock.y = 2732 - stackHeight * 100 - 50;
- stackHeight++;
- score++;
- scoreTxt.setText(score);
- currentBlock = null;
- createBlock();
- gameSpeed += 0.1;
- }
+ if (currentBlock) {
+ currentBlock.y = 2732 - stackHeight * 100 - 50;
+ stackHeight++;
+ score++;
+ scoreTxt.setText(score);
+ currentBlock = null;
+ createBlock();
+ gameSpeed += 0.1;
+ }
}
// Initialize the first block
createBlock();
// Event listener for touch down
game.down = function (x, y, obj) {
- placeBlock();
+ placeBlock();
};
// Update function called every game tick
game.update = function () {
- if (currentBlock) {
- currentBlock.y += gameSpeed;
- if (currentBlock.y > 2732) {
- // Game over logic
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- }
+ if (currentBlock) {
+ currentBlock.y += gameSpeed;
+ if (currentBlock.y > 2732) {
+ // Game over logic
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ }
};
\ No newline at end of file