Hello folks!
After a long break, I am returning to learning Babylon. I have a crazy idea for an audio game. I’m thinking of something for the kids. To show them that exercising imagination and calming down can be very appealing.
This project is something like guided meditation, but it is the player who decides which direction to go. It is not a simple recording of music and speech. And it’s more like entertainment. Such a wolf in sheep’s clothing
I don’t know about kids in other countries, but in Poland, remote teaching is a great failure. I have two teenagers and I can also see how much electronics involve them. It is a type of drug. Therefore, I thought that I would develop my programming skills and prepare something to test.
And now the specifics, I will not bore you with my plans anymore
I prepared the scene and player controls but got stuck making the game locations.
This is my Room constructor. It will have even more parameters.
class Room {
constructor(name, width, height, depth, posX, posZ, material, descNear, descFar, bgMusic, bgMusTransition, footSteps) {
this.name = name;
this.width = width;
this.height = height;
this.depth = depth;
this.posX = posX;
this.posZ = posZ;
this.material = material;
this.descNear = descNear;
this.descFar = descFar;
this.bgMusic = bgMusic;
this.bgMusTransition = bgMusTransition;
this.footSteps = footSteps;
return BABYLON.MeshBuilder.CreateBox(name, {width: width, height: height, depth: depth});
}
}
I’m creating an instance:
let room1 = new Room(“The first place”, 2, 2, 7, 134, 236, colorGreen);
and then I have to assign color and positions separately:
room1.material = colorGreen;
room1.position.x += 134;
room1.position.z += 236;
I do not know how to write it in the constructor so the new object immediately contains the right material and the X and Z position.
So that there would be no need to write this additional code:
room1.material = colorGreen;
e.t.c.
Can someone guide me how to do it?
Thanks for any hint!