User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting '13.66')' in or related to this line: 'self.grid[x][y] = obj;' Line Number: 37
User prompt
add a grid and discrete movement for the mouse
User prompt
Add a maze and collision
User prompt
Lerp mouse position to input position
User prompt
Pero mouse position to touch position when input is detected
User prompt
Mouse moves to touch position only when touch input is detracted
User prompt
Make it a stealth game, add patrolling cats
Initial prompt
Cheese chase
/**** * Classes ****/ // Cheese class var Cheese = Container.expand(function () { var self = Container.call(this); var cheeseGraphics = self.attachAsset('cheese', { anchorX: 0.5, anchorY: 0.5 }); }); // Hole class var Hole = Container.expand(function () { var self = Container.call(this); var holeGraphics = self.attachAsset('hole', { anchorX: 0.5, anchorY: 0.5 }); }); // Assets will be automatically created based on usage in the code. // Mouse class var Mouse = Container.expand(function () { var self = Container.call(this); var mouseGraphics = self.attachAsset('mouse', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.move = function (direction) { if (direction === 'left') self.x -= self.speed; if (direction === 'right') self.x += self.speed; if (direction === 'up') self.y -= self.speed; if (direction === 'down') self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xF4D03F // Init game with a cheese-like background color }); /**** * Game Code ****/ var mouse = game.addChild(new Mouse()); mouse.x = 100; mouse.y = 2732 / 2; var cheese = game.addChild(new Cheese()); cheese.x = 2048 / 2; cheese.y = 2732 / 2; var hole = game.addChild(new Hole()); hole.x = 2048 - 100; hole.y = 2732 / 2; var dragNode = null; function handleMove(obj) { var event = obj.event; var pos = event.getLocalPosition(game); if (dragNode) { dragNode.x = pos.x; dragNode.y = pos.y; } if (mouse.intersects(cheese)) { // Mouse got the cheese, move cheese to mouse position cheese.x = mouse.x; cheese.y = mouse.y; } if (cheese.intersects(hole)) { // Cheese delivered to the hole, show game win LK.effects.flashScreen(0x00FF00, 1000); LK.showGameOver(); } } game.on('down', function (obj) { dragNode = mouse; handleMove(obj); }); game.on('move', handleMove); game.on('up', function (obj) { dragNode = null; }); LK.on('tick', function () { // Game logic to be executed each tick });
/****
* Classes
****/
// Cheese class
var Cheese = Container.expand(function () {
var self = Container.call(this);
var cheeseGraphics = self.attachAsset('cheese', {
anchorX: 0.5,
anchorY: 0.5
});
});
// Hole class
var Hole = Container.expand(function () {
var self = Container.call(this);
var holeGraphics = self.attachAsset('hole', {
anchorX: 0.5,
anchorY: 0.5
});
});
// Assets will be automatically created based on usage in the code.
// Mouse class
var Mouse = Container.expand(function () {
var self = Container.call(this);
var mouseGraphics = self.attachAsset('mouse', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.move = function (direction) {
if (direction === 'left') self.x -= self.speed;
if (direction === 'right') self.x += self.speed;
if (direction === 'up') self.y -= self.speed;
if (direction === 'down') self.y += self.speed;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xF4D03F // Init game with a cheese-like background color
});
/****
* Game Code
****/
var mouse = game.addChild(new Mouse());
mouse.x = 100;
mouse.y = 2732 / 2;
var cheese = game.addChild(new Cheese());
cheese.x = 2048 / 2;
cheese.y = 2732 / 2;
var hole = game.addChild(new Hole());
hole.x = 2048 - 100;
hole.y = 2732 / 2;
var dragNode = null;
function handleMove(obj) {
var event = obj.event;
var pos = event.getLocalPosition(game);
if (dragNode) {
dragNode.x = pos.x;
dragNode.y = pos.y;
}
if (mouse.intersects(cheese)) {
// Mouse got the cheese, move cheese to mouse position
cheese.x = mouse.x;
cheese.y = mouse.y;
}
if (cheese.intersects(hole)) {
// Cheese delivered to the hole, show game win
LK.effects.flashScreen(0x00FF00, 1000);
LK.showGameOver();
}
}
game.on('down', function (obj) {
dragNode = mouse;
handleMove(obj);
});
game.on('move', handleMove);
game.on('up', function (obj) {
dragNode = null;
});
LK.on('tick', function () {
// Game logic to be executed each tick
});
grey square, black border. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
simple light yellow button front view game console, clean, rounded edges, high resolution, graphic. Single Game Texture. In-Game asset. 2d. Blank background. High contrast.
Worn out sticker for a video game, 90s style, cheese, simple, vintage. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
wall view from top-down, game asset videogame, black color, simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. worn out sticker. 90's style. vintage. simple. top-down view. poster. sticker
top-down view, videogame character enemy, roomba, 90s style sticker, flat, no perspective, silhouette, black and white, cartoon, fun, simple, from above. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top-down view, videogame heart, 90s style sticker, flat, no perspective, silhouette, white, cartoon, fun, simple, from above. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Black square with white outline. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.