/**** * Classes ****/ // Blade class var Blade = Container.expand(function () { var self = Container.call(this); var bladeGraphics = self.attachAsset('blade', { anchorX: 0.5, anchorY: 0.5 }); self.updatePosition = function (x, y) { self.x = x; self.y = y; }; }); // Boss class var Boss = Container.expand(function () { var self = Container.call(this); var bossGraphics = self.attachAsset('boss', { anchorX: 0.5, anchorY: 0.5 }); // Initialize the Minesweeper game with interaction self.minesweeper = new Minesweeper(10, 10, 10, function (x, y) { // Callback function to handle cell opening // This can be expanded to include more interactive gameplay features console.log("Cell at (" + x + ", " + y + ") was opened."); }); self.isGameOver = false; self.update = function () { if (!self.isGameOver) { // Check if game is over if (self.minesweeper.isGameOver()) { self.isGameOver = true; // If player won, destroy boss if (self.minesweeper.isWin()) { self.destroy(); } } } }; }); // Assets will be automatically created based on usage in the code. // Fish class var Fish = Container.expand(function (type) { var self = Container.call(this); var fishGraphics = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 2 + 1; self.direction = Math.random() < 0.5 ? 1 : -1; self.hits = type === 'fish1' ? 1 : type === 'fish2' ? 5 : type === 'fish3' ? 1 : 1; // High score fish require more hits self.initialHits = self.hits; // Store the initial hits for each fish self.score = type === 'fish1' ? 10 : type === 'fish2' ? 50 : 10; // High score fish have higher score self.move = function () { self.x += self.speed * self.direction; if (self.x > 2048 || self.x < 0) { self.direction *= -1; } // Add a hit effect when a fish is hit if (self.hits < self.initialHits) { LK.effects.flashObject(self, 0xff0000, 1000); self.initialHits = self.hits; } }; }); // Minesweeper class var Minesweeper = Container.expand(function (width, height, mines, onCellOpen) { var self = Container.call(this); // Initialize the Minesweeper game self.grid = []; for (var i = 0; i < width; i++) { self.grid[i] = []; for (var j = 0; j < height; j++) { self.grid[i][j] = { isMine: false, isOpen: false }; } } // Randomly place mines for (var i = 0; i < mines; i++) { var x = Math.floor(Math.random() * width); var y = Math.floor(Math.random() * height); self.grid[x][y].isMine = true; } // Method to open a cell self.openCell = function (x, y) { if (self.grid[x][y].isOpen) { return; } self.grid[x][y].isOpen = true; // Invoke the callback function when a cell is opened if (onCellOpen) { onCellOpen(x, y); } if (self.grid[x][y].isMine) { self.isGameOver = true; } }; self.isGameOver = false; // Initialize game over state as false // Method to check if the game is over self.checkGameOver = function () { for (var i = 0; i < width; i++) { for (var j = 0; j < height; j++) { if (!self.grid[i][j].isOpen && !self.grid[i][j].isMine) { return false; } } } return true; }; // Method to check if the player has won self.isWin = function () { for (var i = 0; i < width; i++) { for (var j = 0; j < height; j++) { if (self.grid[i][j].isMine && !self.grid[i][j].isOpen) { return false; } } } return true; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x00008B // Dark blue background to represent deep sea }); /**** * Game Code ****/ var fishes = []; var blade; var score = 0; var scoreTxt = new Text2('Score: 0', { size: 150, fill: "#FFD700", stroke: '#000000', strokeThickness: 5, fontStyle: 'bold', fontFamily: 'Arial' }); LK.gui.top.addChild(scoreTxt); // Create fishes for (var i = 0; i < 100; i++) { var type = 'fish' + (i % 3 + 1); var fish = new Fish(type); fish.x = Math.random() * 2048; fish.y = Math.random() * 2732; fish.score = (i % 3 + 1) * 10; game.addChild(fish); fishes.push(fish); } // Create blade blade = new Blade(); game.addChild(blade); // Create boss var boss = new Boss(); boss.x = 2048 / 2; boss.y = 2732 / 2; boss.visible = false; // Initially, boss is not visible game.addChild(boss); // Handle touch move game.on('move', function (obj) { var pos = obj.event.getLocalPosition(game); blade.updatePosition(pos.x, pos.y); // Check for collisions with fishes fishes.forEach(function (fish, index) { if (blade.intersects(fish)) { fish.hits--; if (fish.hits <= 0) { // Increase score score += fish.score; scoreTxt.setText('Score: ' + score); // Make boss appear and start interaction every 500 score if (score % 500 === 0) { if (!boss.visible) { boss.visible = true; boss.x = 2048 / 2; boss.y = 2732 / 2; } // Start or resume Minesweeper game interaction boss.minesweeper.openCell(Math.floor(Math.random() * 10), Math.floor(Math.random() * 10)); } // Power-up player when score reaches 100 if (score >= 100) { // Show power-up selection screen var powerUpScreen = new Container({ backgroundColor: 0x000000, alpha: 0.8 }); var powerUpText = new Text2('Select a Power-Up!', { size: 100, fill: "#ffffff" }); powerUpText.anchor.set(0.5, 0.5); powerUpText.x = 2048 / 2; powerUpText.y = 2732 / 2; powerUpScreen.addChild(powerUpText); LK.gui.center.addChild(powerUpScreen); // Generate random power-up options var powerUps = ['Double Blade Size', 'Increase Speed', 'Extra Life']; var selectedPowerUp = powerUps[Math.floor(Math.random() * powerUps.length)]; // Listen for power-up selection powerUpScreen.on('down', function (obj) { // Remove power-up selection screen powerUpScreen.destroy(); // Resume the game LK.resumeGame(); // Apply selected power-up switch (selectedPowerUp) { case 'Double Blade Size': blade.width *= 2; // Double the size of the blade blade.height *= 2; break; case 'Increase Speed': // Increase blade speed blade.speed *= 2; break; case 'Extra Life': // Add extra life player.lives += 1; break; } score = 0; // Reset score scoreTxt.setText('Score: ' + score + ' ' + selectedPowerUp + '!'); }); } // Remove fish fish.destroy(); fishes.splice(index, 1); } else { // Show visual feedback for the hit LK.effects.flashObject(fish, 0xff0000, 1000); } } }); }); // Game tick LK.on('tick', function () { // Move fishes fishes.forEach(function (fish) { fish.move(); }); // Update boss if (boss.visible) { boss.update(); // Open a random cell in the Minesweeper game var x = Math.floor(Math.random() * 10); var y = Math.floor(Math.random() * 10); boss.minesweeper.openCell(x, y); } });
/****
* Classes
****/
// Blade class
var Blade = Container.expand(function () {
var self = Container.call(this);
var bladeGraphics = self.attachAsset('blade', {
anchorX: 0.5,
anchorY: 0.5
});
self.updatePosition = function (x, y) {
self.x = x;
self.y = y;
};
});
// Boss class
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('boss', {
anchorX: 0.5,
anchorY: 0.5
});
// Initialize the Minesweeper game with interaction
self.minesweeper = new Minesweeper(10, 10, 10, function (x, y) {
// Callback function to handle cell opening
// This can be expanded to include more interactive gameplay features
console.log("Cell at (" + x + ", " + y + ") was opened.");
});
self.isGameOver = false;
self.update = function () {
if (!self.isGameOver) {
// Check if game is over
if (self.minesweeper.isGameOver()) {
self.isGameOver = true;
// If player won, destroy boss
if (self.minesweeper.isWin()) {
self.destroy();
}
}
}
};
});
// Assets will be automatically created based on usage in the code.
// Fish class
var Fish = Container.expand(function (type) {
var self = Container.call(this);
var fishGraphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 2 + 1;
self.direction = Math.random() < 0.5 ? 1 : -1;
self.hits = type === 'fish1' ? 1 : type === 'fish2' ? 5 : type === 'fish3' ? 1 : 1; // High score fish require more hits
self.initialHits = self.hits; // Store the initial hits for each fish
self.score = type === 'fish1' ? 10 : type === 'fish2' ? 50 : 10; // High score fish have higher score
self.move = function () {
self.x += self.speed * self.direction;
if (self.x > 2048 || self.x < 0) {
self.direction *= -1;
}
// Add a hit effect when a fish is hit
if (self.hits < self.initialHits) {
LK.effects.flashObject(self, 0xff0000, 1000);
self.initialHits = self.hits;
}
};
});
// Minesweeper class
var Minesweeper = Container.expand(function (width, height, mines, onCellOpen) {
var self = Container.call(this);
// Initialize the Minesweeper game
self.grid = [];
for (var i = 0; i < width; i++) {
self.grid[i] = [];
for (var j = 0; j < height; j++) {
self.grid[i][j] = {
isMine: false,
isOpen: false
};
}
}
// Randomly place mines
for (var i = 0; i < mines; i++) {
var x = Math.floor(Math.random() * width);
var y = Math.floor(Math.random() * height);
self.grid[x][y].isMine = true;
}
// Method to open a cell
self.openCell = function (x, y) {
if (self.grid[x][y].isOpen) {
return;
}
self.grid[x][y].isOpen = true;
// Invoke the callback function when a cell is opened
if (onCellOpen) {
onCellOpen(x, y);
}
if (self.grid[x][y].isMine) {
self.isGameOver = true;
}
};
self.isGameOver = false; // Initialize game over state as false
// Method to check if the game is over
self.checkGameOver = function () {
for (var i = 0; i < width; i++) {
for (var j = 0; j < height; j++) {
if (!self.grid[i][j].isOpen && !self.grid[i][j].isMine) {
return false;
}
}
}
return true;
};
// Method to check if the player has won
self.isWin = function () {
for (var i = 0; i < width; i++) {
for (var j = 0; j < height; j++) {
if (self.grid[i][j].isMine && !self.grid[i][j].isOpen) {
return false;
}
}
}
return true;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x00008B // Dark blue background to represent deep sea
});
/****
* Game Code
****/
var fishes = [];
var blade;
var score = 0;
var scoreTxt = new Text2('Score: 0', {
size: 150,
fill: "#FFD700",
stroke: '#000000',
strokeThickness: 5,
fontStyle: 'bold',
fontFamily: 'Arial'
});
LK.gui.top.addChild(scoreTxt);
// Create fishes
for (var i = 0; i < 100; i++) {
var type = 'fish' + (i % 3 + 1);
var fish = new Fish(type);
fish.x = Math.random() * 2048;
fish.y = Math.random() * 2732;
fish.score = (i % 3 + 1) * 10;
game.addChild(fish);
fishes.push(fish);
}
// Create blade
blade = new Blade();
game.addChild(blade);
// Create boss
var boss = new Boss();
boss.x = 2048 / 2;
boss.y = 2732 / 2;
boss.visible = false; // Initially, boss is not visible
game.addChild(boss);
// Handle touch move
game.on('move', function (obj) {
var pos = obj.event.getLocalPosition(game);
blade.updatePosition(pos.x, pos.y);
// Check for collisions with fishes
fishes.forEach(function (fish, index) {
if (blade.intersects(fish)) {
fish.hits--;
if (fish.hits <= 0) {
// Increase score
score += fish.score;
scoreTxt.setText('Score: ' + score);
// Make boss appear and start interaction every 500 score
if (score % 500 === 0) {
if (!boss.visible) {
boss.visible = true;
boss.x = 2048 / 2;
boss.y = 2732 / 2;
}
// Start or resume Minesweeper game interaction
boss.minesweeper.openCell(Math.floor(Math.random() * 10), Math.floor(Math.random() * 10));
}
// Power-up player when score reaches 100
if (score >= 100) {
// Show power-up selection screen
var powerUpScreen = new Container({
backgroundColor: 0x000000,
alpha: 0.8
});
var powerUpText = new Text2('Select a Power-Up!', {
size: 100,
fill: "#ffffff"
});
powerUpText.anchor.set(0.5, 0.5);
powerUpText.x = 2048 / 2;
powerUpText.y = 2732 / 2;
powerUpScreen.addChild(powerUpText);
LK.gui.center.addChild(powerUpScreen);
// Generate random power-up options
var powerUps = ['Double Blade Size', 'Increase Speed', 'Extra Life'];
var selectedPowerUp = powerUps[Math.floor(Math.random() * powerUps.length)];
// Listen for power-up selection
powerUpScreen.on('down', function (obj) {
// Remove power-up selection screen
powerUpScreen.destroy();
// Resume the game
LK.resumeGame();
// Apply selected power-up
switch (selectedPowerUp) {
case 'Double Blade Size':
blade.width *= 2; // Double the size of the blade
blade.height *= 2;
break;
case 'Increase Speed':
// Increase blade speed
blade.speed *= 2;
break;
case 'Extra Life':
// Add extra life
player.lives += 1;
break;
}
score = 0; // Reset score
scoreTxt.setText('Score: ' + score + ' ' + selectedPowerUp + '!');
});
}
// Remove fish
fish.destroy();
fishes.splice(index, 1);
} else {
// Show visual feedback for the hit
LK.effects.flashObject(fish, 0xff0000, 1000);
}
}
});
});
// Game tick
LK.on('tick', function () {
// Move fishes
fishes.forEach(function (fish) {
fish.move();
});
// Update boss
if (boss.visible) {
boss.update();
// Open a random cell in the Minesweeper game
var x = Math.floor(Math.random() * 10);
var y = Math.floor(Math.random() * 10);
boss.minesweeper.openCell(x, y);
}
});
日本の包丁. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
忍者鰯. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
侍蛸. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
殿様鯨. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
爆弾クラーケン. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.