User prompt
The player controls Santa. Santa moves to wherever the player taps or clicks.
User prompt
when the cursor is stationary santa still moves towards it. when a player clicks or taps, santa continues moving towards that point as long as the click or tap is held down.
User prompt
santa moves towards the mouse cursor even if the player isn't clicking
User prompt
Santa cannot move above the lower one third of the screen
User prompt
The player controls Santa. Santa moves towards the location of the mouse cursor or towards the last place the player tapped.
Initial prompt
Special Delivery!
var House = Container.expand(function () { var self = Container.call(this); var houseGraphics = self.createAsset('house', 'House Graphics', .5, .5); self.isNaughty = false; self.setNaughty = function (naughty) { self.isNaughty = naughty; }; self.getNaughty = function () { return self.isNaughty; }; }); var Present = Container.expand(function () { var self = Container.call(this); var presentGraphics = self.createAsset('present', 'Present Graphics', .5, .5); self.deliver = function () {}; }); var Santa = Container.expand(function () { var self = Container.call(this); var santaGraphics = self.createAsset('santa', 'Santa Graphics', .5, .5); self.targetPosition = null; self.move = function (targetPos) { if (targetPos) { self.targetPosition = targetPos; } if (self.targetPosition) { var dx = self.targetPosition.x - self.x; var dy = self.targetPosition.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 1) { self.x += dx / distance; var newY = self.y + dy / distance; self.y = newY > 2732 * 2 / 3 ? newY : 2732 * 2 / 3; } } }; self.dropPresent = function () {}; }); var Game = Container.expand(function () { var self = Container.call(this); var isMouseDown = false; stage.on('down', function (obj) { isMouseDown = true; var pos = obj.event.getLocalPosition(self); santa.move(pos); }); stage.on('up', function (obj) { isMouseDown = false; }); var houses = []; var presents = []; var santa = self.addChild(new Santa()); santa.x = 2048 / 2; santa.y = 2732 / 2; for (var i = 0; i < 10; i++) { var house = new House(); house.x = Math.random() * 2048; house.y = Math.random() * 2732; houses.push(house); self.addChild(house); } LK.on('tick', function () { if (isMouseDown && santa.targetPosition) { santa.move(); } for (var i = 0; i < houses.length; i++) { if (santa.intersects(houses[i]) && !houses[i].getNaughty()) { var present = new Present(); present.x = santa.x; present.y = santa.y; presents.push(present); self.addChild(present); present.deliver(); } } for (var i = presents.length - 1; i >= 0; i--) { if (presents[i].isDelivered()) { presents[i].destroy(); presents.splice(i, 1); } } }); });
===================================================================
--- original.js
+++ change.js
@@ -35,13 +35,18 @@
};
self.dropPresent = function () {};
});
var Game = Container.expand(function () {
- stage.on('move', function (obj) {
+ var self = Container.call(this);
+ var isMouseDown = false;
+ stage.on('down', function (obj) {
+ isMouseDown = true;
var pos = obj.event.getLocalPosition(self);
santa.move(pos);
});
- var self = Container.call(this);
+ stage.on('up', function (obj) {
+ isMouseDown = false;
+ });
var houses = [];
var presents = [];
var santa = self.addChild(new Santa());
santa.x = 2048 / 2;
@@ -53,8 +58,11 @@
houses.push(house);
self.addChild(house);
}
LK.on('tick', function () {
+ if (isMouseDown && santa.targetPosition) {
+ santa.move();
+ }
for (var i = 0; i < houses.length; i++) {
if (santa.intersects(houses[i]) && !houses[i].getNaughty()) {
var present = new Present();
present.x = santa.x;
overhead view of simple box house christmas decorations giant christmas tree out front video game asset 2d blank background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
overhead view of drab house with giant prohibition symbol snowy lawn video game asset 2d blank background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
overhead view of charred remains of a completely burned down box house snowy lawn video game asset 2d blank background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Santa on sleigh pulled by reindeer blank background no shadows flying forward away straight top down Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
simple red christmas ornament 2d blank background high contrast no shadows in game asset Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
simple snowflake In-Game asset. 2d. Blank background. High contrast. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
old white scroll unfurled blank no shadows Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top down simple wrapped red present with gold bow. In-Game asset. 2d. Blank background. High contrast. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top down plate of cookies glass of milk. In-Game asset. Blank background. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.