Its the first time building a game.
how can i make collision connect with all my monsters without having to set each monster in the buffer with a collision function.
I’m trying to make one
collision.collisionTouch(monsters, missiles)
this is an example
class Collision{
constructor(){
this.position = {
x : 0,
y : 0
}
}
collisionObjects( object1, object2){
//collision work
}
}
class Monster {
constructor(){
this.position = {
x : 0,
y : 0
}
playerUpdate(){
// player update content here
}
}
}
class Missile {
constructor(){
this.position = {
x : 0,
y : 0
}
}
missileUpdate(){
//missile update draw ect
}
}
// GAME SET
const collision = new Collision();
const monster = new Monster();
const monsterTwo = new Monster();
const missile = new Missile();
function buffer(){
collision.collisionTouch(monster, missile);
collision.collisionTouch(monsterTwo, missile);
}
I don’t know if im gonna be allowed to do that or if im gonna be force to set it up one by one. Im just trying to decrease the coding.
Sorry if you guys don’t understand I speak Spanish Working on English here =)