Skip to content

Commit

Permalink
Updates tiled demo to new APIs, no longer flashes red on load
Browse files Browse the repository at this point in the history
  • Loading branch information
Marak committed Mar 13, 2024
1 parent 853af6f commit 56eb8f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
19 changes: 7 additions & 12 deletions mantra-client/public/tiled.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

<body>
<script type="module" src="/mantra.js"></script>
<script type="module" src="/worlds.mantra.js"></script>
<script type="module" src="/ycraft.js"></script>
<style>
.score {
position: absolute;
Expand Down Expand Up @@ -71,25 +69,19 @@
if (graphics === 'three' || graphics === 'babylon') {
fieldOfView = 256;
}

//fieldOfView = 1024;
let game = new MANTRA.Game({
defaultPlayer: false,
defaultMovement: true,
mode: mode,
fieldOfView: fieldOfView,
useFoV: true,
physics: 'matter', // enum, 'physx', 'matter
collisions: true,
graphics: [graphics], // array enum, 'babylon', 'phaser', 'css', 'three'
camera: 'follow',
options: {
scriptRoot: '.',
assetRoot: '.'
}
plugins: ['Sutra'],
gameRoot: '.'
});

game.use('Sutra');
game.use('RBush');
game.use('SwitchGraphics');
game.use('Bullet');
Expand All @@ -101,7 +93,7 @@
game.use('CurrentFPS');

game.use('Gamepad');
game.use('GamepadGUI');
// game.use('GamepadGUI');
game.start(function () {
game.setBackground('#000000');

Expand All @@ -113,7 +105,10 @@
game.setZoom(4.5);
}

game.use('DragAndDropFileUpload');
// check if there are no query string variables, if none, use drag and drop file upload
if (!tiledmap && !source) {
game.use('DragAndDropFileUpload');
}

if (mode === 'topdown') {
game.createPlayer({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DragAndDropFileUpload {
this.bindEvents();


// TODO: remove this hard-coded event and replace with generic mappable handler
game.on('tilemap::created', () => {
// hide overlay ( for now )
this.overlay.style.visibility = 'hidden';
Expand Down

0 comments on commit 56eb8f0

Please sign in to comment.