Skip to content

Commit

Permalink
Issue #98 Implemented torch lighting to follow player
Browse files Browse the repository at this point in the history
  • Loading branch information
hal255 committed Dec 1, 2018
1 parent 3fa4ed9 commit 816a867
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
Binary file added client/assets/img/fogLayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion client/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ config.default.player = {
src: "../spriteLocation.png"
};

config.default.fog = {
key: "fog",
src: "assets/img/fogLayer.png"
}

config.default.blocks = {
full: {
score: 25,
Expand All @@ -190,7 +195,7 @@ config.default.blocks = {
config.default.score = {
style : {
font: "bold 30px Courier",
color: "#fff",
fill: "#fff",
},
interface: {},
amount: 0,
Expand Down
2 changes: 1 addition & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<script type="text/javascript" src="js/gameLoopTools/neutralMap.js"></script>
<script type="text/javascript" src="js/gameLoopTools/playerUtilities.js"></script>
<script type="text/javascript" src="js/gameLoopTools/blockUtilities.js"></script>
<script type="text/javascript" src="js/loadingScreen.js"></script>
<script type="text/javascript" src="js/gameLoopTools/fogUtilities.js"></script>
<script type="text/javascript" src="js/gameLoop.js"></script>
<script type="text/javascript" src="js/gameOverState.js"></script>
<script type="text/javascript" src="js/stateManager.js"></script>
Expand Down
1 change: 1 addition & 0 deletions client/js/gameLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ gameLoop = {
];
gameLoop.player.sprite = game.add.sprite(...playerStartData);
playerUtilities.create(gameLoop.player);
fogUtilities.create(gameLoop.player);
// clicking the mouse during this state will change the control type to mouse
game.input.onDown.add(() => { gameLoop.player.controlType = config.default.controls.mouse; });

Expand Down
7 changes: 7 additions & 0 deletions client/js/gameLoopTools/fogUtilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const fogUtilities = {};
fogUtilities.create = (player) => {
let fogSprite = game.make.sprite(0, 0, config.default.fog.key);
let fogCenter = [0.5, 0.5];
fogSprite.anchor.setTo(...fogCenter);
player.sprite.addChild(fogSprite);
};
1 change: 1 addition & 0 deletions client/js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ loadState = {
game.load.image(config.loader.placeHolder.key, config.loader.placeHolder.src);
game.load.image(config.default.blocks.quarter.key, config.default.blocks.quarter.src);
game.load.image(config.default.neutralMap.key, config.default.neutralMap.src);
game.load.image(config.default.fog.key, config.default.fog.src);

// Game over loads
game.load.image(config.gameOverState.restartButton.key, config.gameOverState.restartButton.src);
Expand Down

0 comments on commit 816a867

Please sign in to comment.