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
| describe("Geometry", function() { | |
| beforeEach(function() { | |
| var $canvasContainer = $('<div><canvas width="400", height="400" style="border: 1px solid gray"></canvas></div>').appendTo('body'); | |
| jasmine.getEnv().currentSpec.canvasContainer = $canvasContainer; | |
| jasmine.getEnv().currentSpec.renderCanvas = true; | |
| $canvas = $canvasContainer.find('canvas'); | |
| g = Geometry; | |
| g.ctx = $canvas[0].getContext('2d'); | |
| }); |
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
| /** | |
| * checks if 2 lines intersect TESTED | |
| * coincidentReturn: what to return if lines are coincident (exactly overlaping) | |
| * parallelReturn: what to return if lines are exactly parallel | |
| */ | |
| linesIntersect = function (a1, a2, b1, b2, coincidentReturn, parallelReturn){ | |
| var result, | |
| coincidentReturn = coincidentReturn || false, | |
| parallelReturn = parallelReturn || false, |
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
| /** | |
| * all values in percentages | |
| */ | |
| Attack = ig.Class.extend({ | |
| /** | |
| * unit this attack belongs to | |
| */ | |
| unit: null, | |
| init: function(unit){ | |
| this.unit = unit; |
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
| ig.module( | |
| 'game.entities.container' | |
| ) | |
| .requires( | |
| 'impact.entity', | |
| 'game.helpers.geometry' | |
| ) | |
| .defines(function(){ | |
| EntityObstacle = ig.Entity.extend({ |
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 pointInPolygon (point, polygon){ | |
| var i, | |
| j, | |
| c = 0, | |
| pointX = point.x, | |
| pointY = point.y; | |
| for (i = 0, j = polygon.length - 1, len = polygon.length; i < len; j = i++){ | |
| if (((polygon[i].y > pointY) != (polygon[j].y > pointY)) && (pointX < (polygon[j].x - polygon[i].x) * (pointY - polygon[i].y) / (polygon[j].y - polygon[i].y) + polygon[i].x)){ |
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
| search: function(unit, grid, start, end, heuristic) { | |
| astar.init(grid); | |
| heuristic = heuristic || astar.manhattan; | |
| var openHeap = astar.heap(); | |
| start.hexes = 0; | |
| openHeap.push(start); | |
| while(openHeap.size() > 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
| ig.module( | |
| 'game.entities.character' | |
| ) | |
| .requires( | |
| 'game.entities.clickable', | |
| 'game.entities.difference', | |
| 'plugins.entityExtensions' | |
| ) |
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
| ig.module( | |
| 'plugins.gui' | |
| ) | |
| .requires( | |
| 'impact.game', | |
| 'impact.system' | |
| ) | |
| .defines(function () { | |
| // Create GUI container |
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
| ig.module ( | |
| 'game.entities.Player' | |
| ) | |
| .requires( | |
| 'impact.entity', | |
| 'impact.game', | |
| 'impact.font' | |
| ) | |
| .defines(function(){ |
OlderNewer