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> // Create a new class for the character var Character = Container.expand(function () { var self = Container.call(this); // Attach the character shape to the character var characterShape = self.attachAsset('characterShape', { anchorX: 0.5, anchorY: 0.5 }); // Initialize the character's properties self.name = ''; self.gender = ''; self.hairColor = ''; self.eyeColor = ''; self.skinColor = ''; // Define the character's methods self.setName = function (name) { self.name = name; }; self.setGender = function (gender) { self.gender = gender; }; self.setHairColor = function (hairColor) { self.hairColor = hairColor; }; self.setEyeColor = function (eyeColor) { self.eyeColor = eyeColor; }; self.setSkinColor = function (skinColor) { self.skinColor = skinColor; }; }); // Create a new class for the start menu var StartMenu = Container.expand(function () { var self = Container.call(this); // Attach the start menu shape to the start menu var startMenuShape = self.attachAsset('startMenuShape', { anchorX: 0.5, anchorY: 0.5 }); // Initialize the start menu's properties self.title = 'Start Game'; self.startButton = self.attachAsset('startButtonShape', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); // Define the start menu's methods self.setTitle = function (title) { self.title = title; }; self.setStartButton = function (startButtonShape) { self.startButton = startButtonShape; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize the start menu and add it to the game var startMenu = new StartMenu(); game.addChild(startMenu); // Initialize the character var character = new Character(); // This is a simple test game with minimal functionality // Initialize a simple shape as a test object var testShape = LK.getAsset('testShape', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Add the test shape to the game game.addChild(testShape); // Define a simple update function to move the shape game.update = function () { // Move the shape in a simple pattern testShape.x += Math.sin(LK.ticks / 60) * 5; testShape.y += Math.cos(LK.ticks / 60) * 5; }; // Add a simple interaction: change color on touch game.down = function (x, y, obj) { if (startMenu.startButton.intersects(obj)) { // Start the game game.removeChild(startMenu); game.addChild(character); } else if (character.intersects(obj)) { // Customize the character character.setName('John Doe'); character.setGender('Male'); character.setHairColor('Black'); character.setEyeColor('Blue'); character.setSkinColor('White'); } }; game.up = function (x, y, obj) { // No interaction on mouse up };
===================================================================
--- original.js
+++ change.js
@@ -45,9 +45,11 @@
// Initialize the start menu's properties
self.title = 'Start Game';
self.startButton = self.attachAsset('startButtonShape', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ x: 0,
+ y: 0
});
// Define the start menu's methods
self.setTitle = function (title) {
self.title = title;
@@ -89,9 +91,9 @@
testShape.y += Math.cos(LK.ticks / 60) * 5;
};
// Add a simple interaction: change color on touch
game.down = function (x, y, obj) {
- if (startMenu.intersects(obj)) {
+ if (startMenu.startButton.intersects(obj)) {
// Start the game
game.removeChild(startMenu);
game.addChild(character);
} else if (character.intersects(obj)) {