User prompt
add levels to the game
User prompt
add a way to dodge obstacles with the mouse
User prompt
make the cube dodge the obstacles
User prompt
add obstacles that the cube has to move around
User prompt
a create a but that you hit to start the game to the start menu
User prompt
add a start button to the menu
User prompt
add a start menu
User prompt
create a simple text based rpg game where you get to customize ur characters appearance
Initial prompt
test
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> //<Write entity 'classes' with empty functions for important behavior here> var Character = Container.expand(function () { var self = Container.call(this); var characterGraphics = self.attachAsset('characterShape', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.x += Math.sin(LK.ticks / 60) * 5; self.y += Math.cos(LK.ticks / 60) * 5; }; }); var Level = Container.expand(function () { var self = Container.call(this); self.obstacles = []; self.character = new Character(); self.character.x = 2048 / 2; self.character.y = 2732 / 2; self.addChild(self.character); for (var i = 0; i < 5; i++) { var obstacle = new Obstacle(); obstacle.x = Math.random() * 2048; obstacle.y = Math.random() * 2732; self.obstacles.push(obstacle); self.addChild(obstacle); } self.update = function () { for (var i = 0; i < self.obstacles.length; i++) { if (self.character.intersects(self.obstacles[i])) { LK.showGameOver(); break; } } }; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacleShape', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += 2; if (self.y > 2732) { self.y = -100; self.x = Math.random() * 2048; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ //<Write game logic code here, including initializing arrays and variables> var levels = []; for (var i = 0; i < 5; i++) { var level = new Level(); levels.push(level); game.addChild(level); } game.update = function () { for (var i = 0; i < levels.length; i++) { levels[i].update(); } }; game.down = function (x, y, obj) { for (var i = 0; i < levels.length; i++) { levels[i].character.x = x; levels[i].character.y = y; } }; game.move = function (x, y, obj) { for (var i = 0; i < levels.length; i++) { levels[i].character.x = x; levels[i].character.y = y; } };
===================================================================
--- original.js
+++ change.js
@@ -14,8 +14,31 @@
self.x += Math.sin(LK.ticks / 60) * 5;
self.y += Math.cos(LK.ticks / 60) * 5;
};
});
+var Level = Container.expand(function () {
+ var self = Container.call(this);
+ self.obstacles = [];
+ self.character = new Character();
+ self.character.x = 2048 / 2;
+ self.character.y = 2732 / 2;
+ self.addChild(self.character);
+ for (var i = 0; i < 5; i++) {
+ var obstacle = new Obstacle();
+ obstacle.x = Math.random() * 2048;
+ obstacle.y = Math.random() * 2732;
+ self.obstacles.push(obstacle);
+ self.addChild(obstacle);
+ }
+ self.update = function () {
+ for (var i = 0; i < self.obstacles.length; i++) {
+ if (self.character.intersects(self.obstacles[i])) {
+ LK.showGameOver();
+ break;
+ }
+ }
+ };
+});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacleShape', {
anchorX: 0.5,
@@ -40,36 +63,27 @@
/****
* Game Code
****/
//<Write game logic code here, including initializing arrays and variables>
-var obstacles = [];
+var levels = [];
for (var i = 0; i < 5; i++) {
- var obstacle = new Obstacle();
- obstacle.x = Math.random() * 2048;
- obstacle.y = Math.random() * 2732;
- obstacles.push(obstacle);
- game.addChild(obstacle);
+ var level = new Level();
+ levels.push(level);
+ game.addChild(level);
}
-// Initialize the character and add it to the game
-var character = new Character();
-character.x = 2048 / 2;
-character.y = 2732 / 2;
-game.addChild(character);
-// Update the game logic
game.update = function () {
- // Check for collisions between the character and the obstacles
- for (var i = 0; i < obstacles.length; i++) {
- if (character.intersects(obstacles[i])) {
- LK.showGameOver();
- break;
- }
+ for (var i = 0; i < levels.length; i++) {
+ levels[i].update();
}
};
-// Remove the interaction that changes the color of the test shape
game.down = function (x, y, obj) {
- character.x = x;
- character.y = y;
+ for (var i = 0; i < levels.length; i++) {
+ levels[i].character.x = x;
+ levels[i].character.y = y;
+ }
};
game.move = function (x, y, obj) {
- character.x = x;
- character.y = y;
+ for (var i = 0; i < levels.length; i++) {
+ levels[i].character.x = x;
+ levels[i].character.y = y;
+ }
};
\ No newline at end of file