===================================================================
--- original.js
+++ change.js
@@ -1,17 +1,43 @@
/****
-* Initialize Game
+* Classes
****/
-//<Assets used in the game will automatically appear here>
//<Write entity 'classes' with empty functions for important behavior here>
+var Ball = Container.expand(function () {
+ var self = Container.call(this);
+ var ballGraphics = self.attachAsset('ball', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ self.x += self.speedX;
+ self.y += self.speedY;
+ if (self.x < 0 || self.x > 2048) {
+ self.speedX *= -1;
+ }
+ if (self.y < 0 || self.y > 2732) {
+ self.speedY *= -1;
+ }
+ };
+});
+
+/****
+* Initialize Game
+****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
+//<Assets used in the game will automatically appear here>
// Initialize variables
+var ball = game.addChild(new Ball());
+ball.x = 1024;
+ball.y = 1366;
+ball.speedX = 5;
+ball.speedY = 5;
var randomNumber = Math.floor(Math.random() * 100) + 1;
var guessText = new Text2('Guess a number between 1 and 100.', {
size: 100,
fill: "#ffffff"