Skip to content

Commit

Permalink
Merge pull request #24 from runewake2/add-materials
Browse files Browse the repository at this point in the history
Add some materials
  • Loading branch information
runewake2 authored Aug 13, 2022
2 parents 9ac5283 + bbaa26b commit c0123f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Binary file added game/img/texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions game/src/barrier.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var obstacleSpeed = 1.5; // Changing this will impact how quickly obstacles in the game move.
var gapSize = 3; // This determines the size of the gap to create between the floor and ceiling.


class Barrier extends GameObject {
constructor() {
super();
Expand All @@ -15,6 +16,11 @@ class Barrier extends GameObject {
const boxOptions = {width: 1, height: 10, depth: 1};
this.ceilingBox = BABYLON.MeshBuilder.CreateBox("ceilingObstacle", boxOptions, scene);
this.floorBox = BABYLON.MeshBuilder.CreateBox("floorObstacle", boxOptions, scene);
// Materials impact how an object is rendered like color, texture etc.
let barrierMaterial = new BABYLON.StandardMaterial("Barrier Material", scene);
barrierMaterial.diffuseColor = BABYLON.Color3.Green();
this.ceilingBox.material = barrierMaterial;
this.floorBox.material = barrierMaterial;
this.assignLocations();
}

Expand Down
3 changes: 3 additions & 0 deletions game/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Player extends GameObject {
// Create the player object - a 1 unit square cube
const boxOptions = {width: 1, height: 1, depth: 1};
this.playerMesh = BABYLON.MeshBuilder.CreateBox("bird", boxOptions, scene);
this.playerMaterial = new BABYLON.StandardMaterial("Player Material", scene);
this.playerMesh.material = this.playerMaterial;
this.playerMesh.material.diffuseColor = BABYLON.Color3.White();
}

onDestroy() {
Expand Down

0 comments on commit c0123f1

Please sign in to comment.