Sign in to follow this  
hypno_

your unit classes in c++

Recommended Posts

hi all, having done the map, visibility, scrolling etc. i am about to implement a class for handling the units in my isometric game (laser squad-alike). instead of re-inventing the wheel i thought i might as well ask if any of you guys have developed their own classes for this and if you are willing to show what attributes and methods your classes contain. of course you might have different requirements, but i am sure i could catch a few ideas off it and realize aspects i didn't yet even think about. so if you happen to have code for a class like this ready - i'd appreciate it if you'd show it here, even if it's only the function declarations. hypno_

Share this post


Link to post
Share on other sites
Quote:
Original post by hypno_instead of re-inventing the wheel i thought i might as well ask if any of you guys have developed their own classes for this and if you are willing to show what attributes and methods your classes contain.


Now, let me know if I'm wrong here, but shouldn't you really being doing this yourself. After all, part of what you're doing is a learning exercise and if you just grab other people's code and classes for things like this then you'll not be helping yourself.

I'd highly recommend you do this yourself so that you can learn from your mistakes and find out what *you* need for *your* game.

Share this post


Link to post
Share on other sites
it's just about seeing how other people did it and if i'm missing anything when creating my own class... you probably know what tedious work it can be to implement things that should have been there from the start, but have not.

like using this class everywhere and then doing an ugly hack to get a certain functionality so i won't have to rewrite all code completely. i'm not going to rip the code - in this case, it's vb anyway. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by hypno_
it's just about seeing how other people did it and if i'm missing anything when creating my own class... you probably know what tedious work it can be to implement things that should have been there from the start, but have not.

Agreed, but it's a good way to learn. ;)

Of course, it depends on whether learning is your primary goal. :)

Share this post


Link to post
Share on other sites
Visual Basic is 40% slower then c++ in math and code execution but it has full use of all of the DirectX libraries which run at the same speed as if they were used in a c++ game, so don’t count VB out for anything especially on the fast computers most of own today. VB can programmed many times faster then c++. Visual Basic is essentially the ideal language for a hobbits. I a c++ programmer, learned VB to cut down on development time.

My game is a multiplayer RTS for about 250 simultaneous connections. If I have a problem with slow code for the server, just remember computer power is cheaper then the time it would take for me to recode it into c++, but if I must I can.


As for the server side units. The most important part is the unit manager. All of my units have a unique ID independent of he player‘s who control the unit, when I wish to work with a unit I request the unit by its ID and the manager returns a reference to the unit itself so that I may operate on it directly. The manger also controls the creation and removal of units. A second Unit manger which utilizes the first unit manger controls the interaction between units such as combat, movement, and restructuring. The second manger also interfaces with the human players across the internet, handling all of the unit control issues.

Each Unit has a number of dynamic lists, they contain a list of players who are authorized to control specific properties of a unit, such as Move, Attack, Disband, Restructure (split, or combine with other units), share control and change ownership. Each list also has a custom list manger, similar to the unit manger.

Each unit has combat characteristics that are referenced to from a list of unit statistics created within a unit editor. When combat occurs the list for each units is referred to. Then the units combat statistics are multiplied by the units manpower. Some of the stats are Maximum Attack Strength, Minimum Attack Strength, Move Speed, Bombard Range, Maximum Bombard Strength , Minimum Bombard Strength.

The combat calculators determine the number of casualties for each unit affected and the appropriate manpower is subtracted from the units manpower property.

As for the client side units. They are shallow representations of each server side unit. The client also has the master list of unit statistics to refer to, the unit control lists and an estimate of the units attack and bombard strength. When the client orders a unit to do something he must first be authorized, when the server received the order request, authorization is checked, if the player is authorized the order is then passed to the unit control manager mentioned above. If the order as accepted then al of the clients who can view the unit are then updated to the units status (movement, restructuring, casualties….)

The units on the client side are represented graphically, the sprite manger works in the same ways as the unit manager.

That’s all for now, if you wish to know more reply with a specific question. Am willing to explain the workings of every facet of the game.

I just launched the website the day before yesterday. Forgive the unprofessional look and the tremendous lack of content. I intent to rewrite this post into an article and post it on the site .

www.SquareDanceStudios.com

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this