I’ve a game where player and enemies shoot bullets. But I want to make the player bullets different.
In the game there is a main structure for every object(enemies, upgrades, player) called entity.
Then there is another one structure for objects that can move called actor.
then the structure of the bullet.
[CODE]
Entity = function(type,id,x,y,width,height,img){
//….
}
//….
Actor = function(type,id,x,y,width,height,img,hp,atkSpd){
var self = Entity(type,id,x,y,width,height,img);
//….
}
//….
Bullet = function (id,x,y,spdX,spdY,width,height,combatType){
var self = Entity(‘bullet’,id,x,y,width,height,Img.bullet);//Img.bullet is the name of the image of the bullet
//….
}
I’ve tried this:
[CODE]
Bullet = function (id,x,y,spdX,spdY,width,height,combatType){
var self = Entity(‘bullet’,id,x,y,width,height,(combatType === ‘player’ )? Img.bullet : Img.bullet1 );
//….
}
Not working… So I’ve tried this
[CODE]
Bullet = function (id,x,y,spdX,spdY,width,height,combatType){
var imagetouse = (combatType === ‘player’ )? Img.bullet : Img.bullet1;
var self = Entity(‘bullet’,id,x,y,width,height, imagetouse );
//….
}
Not working at all… Then i’ve tried this:
[CODE]
Bullet = function (id,x,y,spdX,spdY,width,height,combatType){
var self;
if ( combatType === ‘player ){
self = Entity(‘bullet’,id,x,y,width,height, Img.bullet );
}
else{
self = Entity(‘bullet’,id,x,y,width,height, Img.bullet1 );
}
//….
NOT WORKING!!!
why nothing works????????
help me please, and thanks a lot.
excuse me if there is something wrong in the post : this is my first post.
excuse me for the bad english, I’m not from America or UK.