![]() And if at some point in the future you want to make towers that give temporary bonuses to some other towers, wouldn't you want for each one to have their own stats fields? Why on Earth would it bother you that a range value is stored in every instance of a tower? Are you trying to save the extra 2 bytes per instance? If you're severely memory constrained in your game, that's a different matter, but that doesn't sound like the problem. How should I group these properties together while still allowing individual turrets to be upgraded separately? Ideally I could be able to design these tower types in something like JSON where I can dynamically load them to the game. So my question is entirely about the design/architecture/structure of the system. ![]() Using subclasses like this would also lead into the common values being copied into every instance, so if my subclass GreenTower defaulted range=800 for all my turrets, it would mean that the value 800 would be stored separately into every instance (when they could just use a common value). Literally the only thing they would do is change the default values for the _init_'s arguments. The reason I don't just subclass Tower to create my custom tower types is because they don't really add anything to the class. but they're still individual instances, so it would feel stupid to copy all of these common properties with the same values to every instance separately. So I began with a Tower base class with all the properties I can think of: class Tower(Entity):ĭef _init_(self, image, size, position, attack_speed, attack_damage, attack_splash_radius, attack_range, cost):īut the problem is, all turrets of the same type have same range, same attack speed, same cost, etc. What this means is that I need some kind of generic way to explain how all towers of similar type work, yet I need each instance to be separated. ![]() Surface.blit(self.image, self.position, self.size)Īlright so I want my game to work similar to Vector TD, where you have multiple different types of towers that can be build, but you can build multiple instances of each type, and each instance can then be upgraded individually. So, since both minions and towers have a size and a position, as well as a sprite image, I felt like it'd be appropriate to create a common base class: class Entity:ĭef _init_(self, image, size, position): I'm personally using Python and pygame, but I'm looking for generic design answers that can be applied to any OOP language. Acquire whatever amount adjusts reasonably be expected to accomplish the best score and open new outrageous tricks.I'm trying to create a Tower Defense game where minions move through a labyrinth and you can build towers on top of the labyrinths' walls to stop the minions. Stumble into the roofs of multi-story structures, get around perilous impediments, slide submerged pinnacles and climb vertical dividers to get away from an overwhelming seismic tremor! You should pick up the pace because even a moment of deferral can cost you your life. ![]() In front of you are 15 exciting levels, in every one of which you need to rapidly settle on the best choices to lead your person along a protected course. The game " Vector" has a genuinely straightforward and natural control, which will permit you to effortlessly dominate the unbelievably terrific elements of parkour and get a remarkable gaming experience. Complete every one of the levels and attempt to gather all of the coins you can to purchase new components. Attempt to endure a surprising calamity, control the vector character bounce between the structures, slide through the obstructions on each rooftop, hop like genuine parkour proficient, and have some good times.
0 Comments
Leave a Reply. |