Skip to content

Commit

Permalink
starting to incorporate BAGEL framework
Browse files Browse the repository at this point in the history
  • Loading branch information
stemkoski committed Feb 24, 2022
1 parent b738012 commit 9bef801
Show file tree
Hide file tree
Showing 3 changed files with 922 additions and 0 deletions.
48 changes: 48 additions & 0 deletions js/BAGEL-game-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

// must inject game class, this.gameClass
AFRAME.registerComponent("BAGEL-game-player", {

schema:
{
controllerListenerId: {type: 'string', default: "#controller-data"},
canvasId: {type: 'string', default: "#game-canvas"},
},

init: function ()
{
this.controllerData = document.querySelector(this.data.controllerListenerId).components["controller-listener"];
},

tick: function ()
{
if ( !this.gameClass )
return;

if ( !this.gameInstance )
{
this.game = new this.gameClass();

this.game.canvas = document.querySelector(this.data.canvasId);

// assume 640 x 480? 800 x 600?

// this.canvas.width = width;
// this.canvas.height = height;
this.game.context = this.game.canvas.getContext("2d");

// read inputs from Quest controllers
// (e.g. this.game.input.leftAxisX, this.game.input.buttonA.pressed)
this.game.input = this.controllerData;

this.game.clock = new THREE.Clock();

this.game.start();
}


this.update();


},

});
Loading

0 comments on commit 9bef801

Please sign in to comment.