Skip to content

Commit

Permalink
Step 2.12: Add assets loader
Browse files Browse the repository at this point in the history
  • Loading branch information
DAB0mB committed Aug 29, 2018
1 parent ab7d845 commit 5761ec0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions resources/scripts/engine/assets_loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Engine.AssetsLoader = class AssetsLoader {
constructor(next) {
this.next = next;
}

// Load texture
texture(path) {
let image = new Image();
image.onload = this.next();
image.src = `${path}.png`;
return image;
}
};
1 change: 1 addition & 0 deletions views/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script type="text/javascript" src="/scripts/engine/key_states.js"></script>
<script type="text/javascript" src="/scripts/engine/layer.js"></script>
<script type="text/javascript" src="/scripts/engine/screen.js"></script>
<script type="text/javascript" src="/scripts/engine/assets_loader.js"></script>
<script type="text/javascript" src="/scripts/engine/game.js"></script>
<script type="text/javascript" src="/scripts/main.js"></script>

Expand Down

0 comments on commit 5761ec0

Please sign in to comment.