The Armor Games website will be down for maintenance on Monday 10/7/2024
starting at 10:00 AM Pacific time. We apologize for the inconvenience.

ForumsProgramming ForumBasic Logic help

3 3830
redfawx
offline
redfawx
5 posts
Nomad

ok just needed some help with some logic that was giving me a bit of trouble. Ok so Im in the midst of making a platformer sidescroller but im not sure how to handle multiple weapon's amunition, clips. I know that a messy way would be assigning individual variables for each thing such as a pistols ammo and clips but is there a way to compile that in an easier way.

heres a basic example of my logic
berrettabullets:number = 9;
berrettaclips:number = 2;
and so on for other guns
is there an easier way?

  • 3 Replies
beech
offline
beech
107 posts
Nomad

i would probably go about this by using a Class for each weapon type that extends a base weapon class - then assign the property within each sub-class - this way all other references to any weapon are 'generic' and the property is always available for use by other calling methods.

WhitePerson
offline
WhitePerson
21 posts
Nomad

Im a noob but try changing it.


example:
var berrettabullets:number = 9;
or
berrettabullets = 9
gaboloth
offline
gaboloth
1,612 posts
Peasant

Umm... what whiteperson? However, I think beech was right, make a weapon class with all the vars and the basic code and then extend the weapon classes to it. Probably it will be useful to do it for the bullets classes too, because I think the movement code for them will be quite the same.

Showing 1-3 of 3