Created
April 16, 2016 23:09
-
-
Save AlexBezuska/e5df878b31e7859f32e60ffee1664310 to your computer and use it in GitHub Desktop.
This file contains 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
"use strict"; | |
module.exports = function(ecs, game) { // eslint-disable-line no-unused-vars | |
ecs.addEach(function(entity, context) { // eslint-disable-line no-unused-vars | |
var viewportPosition = game.entities.get(entity, "position"); | |
var viewportSize = game.entities.get(entity, "size"); | |
var cameraPosition = game.entities.get(0, "position"); | |
var cameraSize = game.entities.get(0, "size"); | |
context.fillStyle = "black"; | |
context.fillRect( | |
cameraPosition.x, | |
cameraPosition.y, | |
cameraSize.width, | |
viewportPosition.y - cameraPosition.y | |
); | |
context.fillRect( | |
viewportPosition.x + viewportSize.width, | |
cameraPosition.y, | |
cameraSize.width - (viewportPosition.x + viewportSize.width), | |
cameraSize.height | |
); | |
context.fillRect( | |
cameraPosition.x, | |
viewportPosition.y + viewportSize.height, | |
cameraSize.width, | |
cameraSize.height - (viewportPosition.y + viewportSize.height) | |
); | |
context.fillRect( | |
cameraPosition.x, | |
cameraPosition.y, | |
viewportPosition.x - cameraPosition.x, | |
cameraSize.height | |
); | |
}, "viewPort"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment