[WUT] AdamLvl 13
- Windows
Can you please provide some code so I can provide a relevant response?
Can you please provide some code so I can provide a relevant response?
You could just make a starter property.
//After creating the sprite
`
sprite.equipped = {
//Change this everytime the player changes to something else
description: 'Name of weapon'
//Add some more properties, like what damage is dealt, recoil, stuff like that
}
if(this.equipped.description === 'weapon you're looking for'){
execute the code
}
`
ASmartCoder i kinda meant like a system of where it can check if you have more than 1 item so that only 1 item can be equipped
pluto then just make a variable that holds the item you're... well, holding. then, check if the variable is undefined.
basically i just want it so that multiple items cannot be equipped; only one.
You could make a big sourcebook variable that would be an object, listing every item and its properties in a subobject. You could then refer to them later.
Letti42 Or if the item is a string then do equippedItem = '' to avoid complexities.
ASmartCoder Null is easier to understand. If anything, making it an empty string would make it even worse
pluto so you want to do OOP? your post isn't exactly clear on your intentions but i'll assume you want a way of constructing a class. in that case you'll need to setup something like this
var Car = (function() { /** @class */
function Car(name, brand, fuel, mileage, economy) {
this.name = name;
this.brand = brand;
this.fuel = fuel;
this.mileage = milage;
this.fuelEconomy = economy;
}
return Car;
})();
// invoke a class here
var car = new Car("Honda Civic", "Honda", 15, 53429, 30);
bro got that Honda Civic