HI all, I'm just starting to try to get the concept do the game in my head down into the simple heirechy so far I have Player class that I want to be able to attack () defend (), and move I want the player to be a fleet which is made up of ships also enemy's will be basically a player without the ability to move so do I make player the base class with fleets inheriting from that and in turn ships inheriting from fleets? and do I make enemies a child of Player even though it isn't really a player?
9/12/2017 2:11:12 PMDan Blaine
19 AnswersNew Answer
I would suggest making a Command class that has the attack and defend functions in it. then have a child Player class with the move func and any other attributes you would like to define this class. then make a child Enemy class that takes on any attributes you want for it specifically. This is just another way to think about it and keeps the Player and Enemy classes completely separate from each other. hope it helps some.
I'm going to make 5 different kinds of ships with a variable that holds an int for attack and one for defense I want my players attack to be based on the number of ships and types of those ships so would ships be a child of fleet so then given your post I would have a command class with the children player, enemy, and fleet which has a child ships?
I'll make the ships a function of fleets and enemy and player children of fleets I think this will work for me thanks
i would make the fleet class separate and make each child ship class of fleet. you would then need the attack func to call the parent fleet and then child ship for each player/enemy. and each ship would have the attack number and defense number based on size, power, etc. im not gonna lie kinda passing my realm of expertise. im still learning this stuff, and im sure this is only one way to do it.
what language are you writing in?
thats what i was gonna suggest. im gonna follow this cause im curious how this works out.
lol every day I look at this code and see a better way https://code.sololearn.com/cg80kRMVg2Uj/?ref=app
great answer ill work it out and hopefully post some code soon
I'll be using my unity game engine but I don't think that will change my code drastically
here is the beginning of my ships class, obviously I'll be adding a bunch more ship types and I have been starting to think that the fleet class will hold an array of ships () and then return the total defense or attack at the end
I'm thinking now that I look closer.at that code I only need to pass in the number of ships because the other stuff is constant
its looking good so far.
oh wow that link updates the code as I do, very nice solo learn. Anyway I'm just formatting that to run with my unity game engine so it may look weird from here on out
ah, that feeling when you work the bugs
you code is looking good. any chance you can comment it to help see your thought process
yes, sorry that's my bad habit
my next project is setting up a battle system, I have already made the controls for flying the spaceship and I think the rest of the help I need falls out of the scope that can be done on this app