/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// Class for Letter Tiles
var LetterTile = Container.expand(function () {
var self = Container.call(this);
self.letter = '';
var tileGraphics = self.attachAsset('tile', {
anchorX: 0.5,
anchorY: 0.5
});
var letterText = new Text2(self.letter, {
size: 100,
fill: "#ffffff"
});
letterText.anchor.set(0.5, 0.5);
self.addChild(letterText);
self.setLetter = function (letter) {
self.letter = letter;
letterText.setText(letter);
};
self.down = function (x, y, obj) {
if (game.selectedTile) {
game.selectedTile.deselect();
}
game.selectedTile = self;
self.select();
};
self.select = function () {
tileGraphics.tint = 0xff0000; // Highlight selected tile
};
self.deselect = function () {
tileGraphics.tint = 0xffffff; // Remove highlight
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize variables
game.selectedTile = null;
game.letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
game.tiles = [];
game.word = '';
game.score = 0;
// Create letter tiles
for (var i = 0; i < game.letters.length; i++) {
var tile = new LetterTile();
tile.setLetter(game.letters[i]);
tile.x = 200 + i * 150;
tile.y = 200;
game.tiles.push(tile);
game.addChild(tile);
}
// Create word display
var wordDisplay = new Text2(game.word, {
size: 100,
fill: "#ffffff"
});
wordDisplay.anchor.set(0.5, 0.5);
wordDisplay.x = 2048 / 2;
wordDisplay.y = 500;
game.addChild(wordDisplay);
// Create score display
var scoreDisplay = new Text2('Score: ' + game.score, {
size: 100,
fill: "#ffffff"
});
scoreDisplay.anchor.set(0.5, 0.5);
scoreDisplay.x = 2048 / 2;
scoreDisplay.y = 100;
game.addChild(scoreDisplay);
// Event listener for game area
game.down = function (x, y, obj) {
if (game.selectedTile) {
game.word += game.selectedTile.letter;
wordDisplay.setText(game.word);
game.selectedTile.deselect();
game.selectedTile = null;
}
};
// Function to check if the word is valid
function isValidWord(word) {
// Placeholder for word validation logic
return word.length > 2; // Example: word must be longer than 2 letters
}
// Function to submit the word
function submitWord() {
if (isValidWord(game.word)) {
game.score += game.word.length;
scoreDisplay.setText('Score: ' + game.score);
game.word = '';
wordDisplay.setText(game.word);
} else {
// Flash screen red for invalid word
LK.effects.flashScreen(0xff0000, 500);
}
}
// Create submit button
var submitButton = new Text2('Submit', {
size: 100,
fill: "#ffffff"
});
submitButton.anchor.set(0.5, 0.5);
submitButton.x = 2048 / 2;
submitButton.y = 700;
game.addChild(submitButton);
submitButton.down = function (x, y, obj) {
submitWord();
};
// Update function
game.update = function () {
// Game update logic
};
A smooth, clean, blank and empty scrabble tile for a game.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A clean, warm and welcoming classroom in a school, facing the blackboard.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A small golden star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.