In your case I would just use this Tower base class and subclass it with all the towers at every single level possible that you can instantiate as startup, like BlueTowerLv1, BlueTowerLv2, GreenTowerLv1, etc, with a reference from BlueTowerLv1 to BlueTowerLv2 so that it knows what tower to use when leveling up (a null/nil for next_tower could indicate that the tower has reached a maximum level). You'd want the factory to also handle permanent tower upgrades, as it will be the one to know what upgrades to what and how. It would go something like this (excuse the Java syntax): public static Tower makeGreenTower() Just make a class that knows about the various defaults, and ask it to make whatever flavour of tower you want at the time. You do have a valid point that making a subclass just to set some default values seems ridiculous. 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. One-time license fee for downloads to up to 2 console systems and 2 portable systems that are associated with the purchasing account.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. This item has been sublicensed to you by Sony Computer Entertainment America. If you do not wish to accept all these terms, do not purchase or use this item. Purchase or use of this item is subject to the PlayStation®Network Terms of Service and User Agreement. VECTOR TD ™2009 CANDYSTAND.COM, FUNTANK LLC ALL RIGHTS RESERVED Can you defeat the quick Yellow Sprinters? Are you equipped to deal with the armored Hard Greys? Only strategic placement of eleven types of towers, plus upgrades and boosts to enhance them, can ensure a victory against the Vectoid threat. There are seven species of Vectoids, each with their own strengths and weaknesses. The simulator comes compiled with 8 of the most common paths used by these enemies and the full range of attacking towers at our disposal.Įliminate each wave of Vectoids before they reach the end of the path by constructing towers. The year is 2067, and Earth is under attack from a race we have codenamed 'Vectoids.' What you are holding in your hands is a computer simulation designed to train commanders in the art of defending from the ongoing threat they pose.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |