User prompt
If player holded and moved at any direction start draw by draw object
User prompt
Make the player start draw if cursor holded on it
User prompt
Set the draw asset the draw of player when moving on the background
User prompt
make it follow left and right
User prompt
Make player follow cursor up and down
User prompt
Make player have up direction movment by click
User prompt
Make up movment
User prompt
If player moved start draw by draw object color on the screen
User prompt
If player moved draw line by draw assets
User prompt
Make drawing object for the player make it smaller then the player
User prompt
Remave the generated maze
User prompt
Please fix the bug: 'ReferenceError: playerGraphics is not defined' in or related to this line: 'var wallGraphics = self.attachAsset('Wall', {' Line Number: 46
User prompt
Make the wall small as the player
User prompt
Make the maze same as as the image of the background
User prompt
Make maze similar to the background with asset Wall
User prompt
More bigger
User prompt
Make that square bigger
User prompt
Regenerate a square maze center it in the middle of screen
User prompt
Remove the maze and all the objects in the game
User prompt
Make more and more walls
User prompt
Don't teleport the player
User prompt
If touch cube stop it and the maze till change the player direction
User prompt
Regenerate new random maze make it easy to passe by it
User prompt
Ad many radom objects of walls
User prompt
Make random respawning
/**** * Classes ****/ // Create a Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5, width: blockSize, height: blockSize }); self.speed = 8; self.vx = 0; self.vy = 0; self.update = function () { var oldX = self.x; var oldY = self.y; self.x += self.vx; self.y += self.vy; if (self.x < 0) { self.x = 0; } if (self.y < 0) { self.y = 0; } if (self.x > game.width) { self.x = game.width; } if (self.y > game.height) { self.y = 0; statusText.timeLeft = 60; // Reset the time left } }; }); // Create a Wall class var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('Wall', { anchorX: 0.5, anchorY: 0.5, width: playerGraphics.width, height: playerGraphics.height }); }); //<Assets used in the game will automatically appear here> // Create a StatusText class var StatusText = Text2.expand(function () { var self = Text2.call(this, 'Time left: 60', { size: 50, fill: 0xFFFFFF }); self.timeLeft = 60; self.update = function () { if (LK.ticks % 60 == 0) { self.timeLeft--; self.setText('Time left: ' + self.timeLeft); } }; }); /**** * Initialize Game ****/ // Check for collision with wall // Function to generate a random maze var game = new LK.Game({ width: 2048, height: 2732, backgroundColor: 0x000000 }); /**** * Game Code ****/ var background = game.attachAsset('Background1', { anchorX: 0.5, anchorY: 0.5, width: game.width, height: game.height }); background.x = game.width / 2; background.y = game.height / 2; game.addChild(background); // Add move event to the game game.move = function (x, y, obj) { // Move the player to the x position of the touch or mouse event player.x = x - player.width / 2; }; var blockSize = 100; // Add player to the bottom middle of the screen var player = game.addChild(new Player()); player.x = game.width / 2; player.y = game.height - player.height / 2; // Add status text to the top left of the screen var statusText = game.addChild(new StatusText()); statusText.x = 20; statusText.y = 20; game.down = function (x, y, obj) { // Start moving the player when touch or mouse down game.move(x, y, obj); // Check if the player touched the object if (player.intersects(obj)) { console.log("Player touched the object!"); } }; game.up = function (x, y, obj) { // Change the direction of the player when touch or mouse up player.vx = -player.vx; player.vy = -player.vy; }; // Add an update function to the game game.update = function () { // Generate maze using Wall assets for (var i = 0; i < 10; i++) { for (var j = 0; j < 10; j++) { if (Math.random() > 0.7) { // Randomly place walls var wall = new Wall(); wall.x = i * blockSize + blockSize / 2; wall.y = j * blockSize + blockSize / 2; game.addChild(wall); } } } };
===================================================================
--- original.js
+++ change.js
@@ -38,10 +38,10 @@
var self = Container.call(this);
var wallGraphics = self.attachAsset('Wall', {
anchorX: 0.5,
anchorY: 0.5,
- width: blockSize,
- height: blockSize
+ width: playerGraphics.width,
+ height: playerGraphics.height
});
});
//<Assets used in the game will automatically appear here>
// Create a StatusText class
@@ -110,7 +110,17 @@
player.vy = -player.vy;
};
// Add an update function to the game
game.update = function () {
- // Use background image as the maze
- background.visible = true;
+ // Generate maze using Wall assets
+ for (var i = 0; i < 10; i++) {
+ for (var j = 0; j < 10; j++) {
+ if (Math.random() > 0.7) {
+ // Randomly place walls
+ var wall = new Wall();
+ wall.x = i * blockSize + blockSize / 2;
+ wall.y = j * blockSize + blockSize / 2;
+ game.addChild(wall);
+ }
+ }
+ }
};
\ No newline at end of file