User prompt
move shape on the back, in terms of visibility order
User prompt
Text should be on top of the shape in terms of visibility order
User prompt
Text should be on the top of the shape
User prompt
Increase the size of the Shape, and move the text inside a shape
User prompt
remove the kite shape from everywhere in the code
User prompt
remove heptagon
User prompt
add the shapes, to array
User prompt
use different - different background image assets for buttons
User prompt
Both buttons background should be different
User prompt
Add a background for the both the buttons
User prompt
Button are not visible.
User prompt
Add Two Big buttons at the bottom of the screen, first is true and second is false
Initial prompt
ShapyBrain
===================================================================
--- original.js
+++ change.js
@@ -1,56 +1,56 @@
-/****
+/****
* Classes
-****/
+****/
//<Assets used in the game will automatically appear here>
// Shape class to represent the shapes in the game
var Shape = Container.expand(function () {
- var self = Container.call(this);
- self.shapeType = null;
- self.shapeGraphics = null;
- self.setShape = function (type) {
- self.shapeType = type;
- if (self.shapeGraphics) {
- self.removeChild(self.shapeGraphics);
- }
- self.shapeGraphics = self.attachAsset(type, {
- anchorX: 0.5,
- anchorY: 0.5
- });
- };
+ var self = Container.call(this);
+ self.shapeType = null;
+ self.shapeGraphics = null;
+ self.setShape = function (type) {
+ self.shapeType = type;
+ if (self.shapeGraphics) {
+ self.removeChild(self.shapeGraphics);
+ }
+ self.shapeGraphics = self.attachAsset(type, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ };
});
// Text class to represent the shape names in the game
var ShapeText = Container.expand(function () {
- var self = Container.call(this);
- self.text = new Text2('', {
- size: 100,
- fill: "#ffffff"
- });
- self.text.anchor.set(0.5, 0.5);
- self.addChild(self.text);
- self.setText = function (text) {
- self.text.setText(text);
- };
+ var self = Container.call(this);
+ self.text = new Text2('', {
+ size: 100,
+ fill: "#ffffff"
+ });
+ self.text.anchor.set(0.5, 0.5);
+ self.addChild(self.text);
+ self.setText = function (text) {
+ self.text.setText(text);
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
+****/
// Initialize variables
var shapes = ['circle', 'square', 'triangle'];
var currentShape = null;
var currentShapeText = null;
var score = 0;
var scoreTxt = new Text2('Score: 0', {
- size: 100,
- fill: "#ffffff"
+ size: 100,
+ fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create shape and text objects
@@ -63,57 +63,57 @@
shapeText.y = 2732 / 2;
game.addChild(shapeText);
// Function to update the shape and text
function updateShapeAndText() {
- var randomShape = shapes[Math.floor(Math.random() * shapes.length)];
- var randomText = shapes[Math.floor(Math.random() * shapes.length)];
- shape.setShape(randomShape);
- shapeText.setText(randomText);
- currentShape = randomShape;
- currentShapeText = randomText;
+ var randomShape = shapes[Math.floor(Math.random() * shapes.length)];
+ var randomText = shapes[Math.floor(Math.random() * shapes.length)];
+ shape.setShape(randomShape);
+ shapeText.setText(randomText);
+ currentShape = randomShape;
+ currentShapeText = randomText;
}
// Function to handle True button press
function handleTruePress() {
- if (currentShape === currentShapeText) {
- score++;
- } else {
- score--;
- }
- scoreTxt.setText('Score: ' + score);
- updateShapeAndText();
+ if (currentShape === currentShapeText) {
+ score++;
+ } else {
+ score--;
+ }
+ scoreTxt.setText('Score: ' + score);
+ updateShapeAndText();
}
// Function to handle False button press
function handleFalsePress() {
- if (currentShape !== currentShapeText) {
- score++;
- } else {
- score--;
- }
- scoreTxt.setText('Score: ' + score);
- updateShapeAndText();
+ if (currentShape !== currentShapeText) {
+ score++;
+ } else {
+ score--;
+ }
+ scoreTxt.setText('Score: ' + score);
+ updateShapeAndText();
}
// Create True and False buttons
var trueButton = new Text2('True', {
- size: 100,
- fill: "#00ff00"
+ size: 200,
+ fill: "#00ff00"
});
trueButton.anchor.set(0.5, 0.5);
-trueButton.x = 2048 / 3;
-trueButton.y = 2732 * 2 / 3;
+trueButton.x = 2048 / 4;
+trueButton.y = 2732 * 3 / 4;
LK.gui.bottom.addChild(trueButton);
var falseButton = new Text2('False', {
- size: 100,
- fill: "#ff0000"
+ size: 200,
+ fill: "#ff0000"
});
falseButton.anchor.set(0.5, 0.5);
-falseButton.x = 2048 * 2 / 3;
-falseButton.y = 2732 * 2 / 3;
+falseButton.x = 2048 * 3 / 4;
+falseButton.y = 2732 * 3 / 4;
LK.gui.bottom.addChild(falseButton);
// Add event listeners for buttons
trueButton.down = function (x, y, obj) {
- handleTruePress();
+ handleTruePress();
};
falseButton.down = function (x, y, obj) {
- handleFalsePress();
+ handleFalsePress();
};
// Initialize the game with the first shape and text
updateShapeAndText();
\ No newline at end of file