Last active
August 29, 2015 14:13
-
-
Save arturcarvalho/2c3af68d4e99fb151fd8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getFloorY = function(item) { | |
return dims.atticHeight + item.room * dims.roomHeight - dims.floorHeightChars - item.height; | |
} | |
if() { // below bsment | |
} else { // above | |
if (item.dragged) { | |
for (var i = 0; i < floors.length; i++) { | |
if(item.y < getFloorY(item) && item.room !== i) { // (room !== i) just to reduce assignments | |
item.room = i; | |
break; | |
} | |
}; | |
} else { | |
if (item.y >= getFloorY(item)) { // on the ground, stop the fall, animate | |
item.y = getFloorY(item); | |
item.body.velocity.y = 0; | |
item.onFloor = true; | |
item.state = (game.rnd.frac() > 0.5) ? 0 : 1; // walk left or right | |
} | |
} | |
} | |
------------ | |
function doBooks(){ | |
bookGroup = game.add.group(); | |
//if there are books left, add them to piles in the basement | |
if(books > 0) { | |
var lastBookPile, i = 0; | |
for (i < books; i++) { | |
if(i > 0 && lastBookPile) { | |
lastBookPile.frame += 1; | |
} | |
if(i % 10 === 0){ | |
var floorBasementY = overallHeight - dims.floorHeightBooks; | |
var nudgeBasementBooks = 180; | |
var newBookPile = game.add.sprite(nudgeBasementBooks + (i*36), floorBasementY, 'bookPileSheet'); | |
bookGroup.add(newBookPile); | |
lastBookPile = newBookPile; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment