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
| function checkMaxMinPos(a, b, aW, aH, bW, bH, maxX, minX, maxY, minY) { | |
| 'use strict'; | |
| if (a.left < b.left) { | |
| if (a.left < minX) { | |
| minX = a.left; | |
| } | |
| } else { | |
| if (b.left < minX) { | |
| minX = b.left; |
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
| // jQuery | |
| function doObjectsCollide(a, b) { // a and b are your objects | |
| //console.log(a.offset().top,a.position().top, b.position().top, a.width(),a.height(), b.width(),b.height()); | |
| var aTop = a.offset().top; | |
| var aLeft = a.offset().left; | |
| var bTop = b.offset().top; | |
| var bLeft = b.offset().left; | |
| return !( | |
| ((aTop + a.height()) < (bTop)) || |
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
| var ENGLISH = "abcdefghijklmnopqrstuvwxyz".split(""); // [a,b,c,d,...] |
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
| function doObjectsCollide(a, b) { // a and b are your objects | |
| return !( | |
| ((a.getY() + a.getHeight()) < (b.getY())) || | |
| (a.getY() > (b.y + b.getHeight())) || | |
| ((a.getX() + a.getWidth()) < b.getX()) || | |
| (a.getX() > (b.getX() + b.getWidth())) | |
| ); | |
| } | |
| // for kinetic version > 5.1 |
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
| function getRandom(min, max) { | |
| return Math.floor(Math.random() * (max - min + 1) + min); | |
| } |
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
| GameState.prototype.animateNumber = function(num, fn, step, speed, endFn) { | |
| var _step = step || 10; | |
| var _speed = speed || 10; // in seconds because this is total | |
| var repeats = Math.ceil(num / _step); | |
| var animSpeed = (_speed / repeats) * 1000; // in ms | |
| var _endFn = endFn || function() { | |
| game.time.events.remove(this); | |
| }; | |
| var _timer = game.time.create(true); | |
| _timer.start(); |
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
| // PHASER KEYBOARD KEYS // | |
| Phaser.Keyboard.A = "A".charCodeAt(0); | |
| Phaser.Keyboard.B = "B".charCodeAt(0); | |
| Phaser.Keyboard.C = "C".charCodeAt(0); | |
| Phaser.Keyboard.D = "D".charCodeAt(0); | |
| Phaser.Keyboard.E = "E".charCodeAt(0); | |
| Phaser.Keyboard.F = "F".charCodeAt(0); | |
| Phaser.Keyboard.G = "G".charCodeAt(0); | |
| Phaser.Keyboard.H = "H".charCodeAt(0); | |
| Phaser.Keyboard.I = "I".charCodeAt(0); |
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
| class Cell: UITableViewCell { | |
| override func drawRect(rect: CGRect) { | |
| var bubbleSpace = CGRectMake(20.0, self.bounds.origin.y, self.bounds.width - 20, self.bounds.height) | |
| let bubblePath1 = UIBezierPath(roundedRect: bubbleSpace, byRoundingCorners: .TopLeft | .TopRight | .BottomRight, cornerRadii: CGSize(width: 20.0, height: 20.0)) | |
| let bubblePath = UIBezierPath(roundedRect: bubbleSpace, cornerRadius: 20.0) | |
| UIColor.greenColor().setStroke() | |
| UIColor.greenColor().setFill() |
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
| // | |
| // CoreGraphics+AspectRatio.swift | |
| // EmptySpriteKitGame | |
| // | |
| // Created by Jamie Kosoy on 11/6/15. | |
| // Copyright © 2015 Arbitrary. All rights reserved. | |
| // | |
| import UIKit | |
| import Foundation |
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
| import Foundation | |
| /// Execute a function on a background thread and then handle result | |
| /// in main thread. | |
| func doBackgroundTask<Params, Result>( | |
| params: Params, | |
| backgroundTask: (Params) -> Result, | |
| onComplete: (Result) -> ()) | |
| { | |
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { |