• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Publius190

.XNA design Question

6 posts in this topic

Hi, I have to admit i'm very new to programming and i'm really only in the design phase of creating my game.

So heres my question:

In the final game (top down roguelike shooter) i'm going to have a few different characters you can start out as. Each character will have a different weapon type, different movespeed, different texture, animation, etc. Also i'm planning on having each character's main weapon be somewhat customizable.

In order to code this would it be easier to create a seperate class for each character with methods for moving, collision detection, firing, etc. Or should i have a main player class with methods that call each character class.

I guess while i'm writing this it does sound better to go with the second option, but i'm having trouble deciding what i would need to do in the player class and what would definately need to be done in the character class.

Any help at all would be great.
0

Share this post


Link to post
Share on other sites
From the basic description you've presented I think you should only use 1 class, calling it player or character.

These things you mention weapon type, different movespeed, different texture, animation would then be the members for the class and would change depending on the character. You would set these when you make an instance of you character object.

You would then have your moving, collision detection, firing, etc methods that make use of these variables. However, if these methods vary greatly between the different characters then you should consider inheritance.

You don't really provide enough information to give a complete answer.
1

Share this post


Link to post
Share on other sites
I agree with wannabe there, your player class (the code) sounds completely separable from the assets that will make each character unique: namely the texture and animation frames. The player class can call a generic render() method and the texture appropriate to the chosen character will be drawn. All the other variables are just that, variables, and the class can easily change those values at the point of character creation.

Just stay as simple as possible in code design until it makes sense to start breaking things out, pre-optimization and overly elaborate class hierarchies are bad traps to fall into. :)
0

Share this post


Link to post
Share on other sites
I have a question based off the answers given.

Would it be better to have a base character class that has universal members that all would have, texture, position, animations, sounds, move speed, etc.

Then have a different class for each character type that inherits from the base character class, but gives it`s unique values to the members? Would that be the best way?
0

Share this post


Link to post
Share on other sites
If the only difference between the characters is the values of the member variables, there is no need to create a sub-class for each character type.

You can have a single character class and simply pass in the correct values when you construct it.

Only if the different characters behaved in fundamentally different ways would you need to consider adding classes specific to each character type.
0

Share this post


Link to post
Share on other sites
[quote name='WavyVirus' timestamp='1339519426' post='4948540']
If the only difference between the characters is the values of the member variables, there is no need to create a sub-class for each character type.

You can have a single character class and simply pass in the correct values when you construct it.

Only if the different characters behaved in fundamentally different ways would you need to consider adding classes specific to each character type.
[/quote]

But, say you wanted a multiplayer game. Even if the only thing that differeniates different characters is different values, wouldn't it be better/easier to have unique classes for each character that inherits from the base character class, and then when people are selecting their character, you could set their character type to the class for the unique character, rather than constantly calling functions that are hardcoded in and would set the values for each specific character?
0

Share this post


Link to post
Share on other sites
[quote name='MrTwiggy' timestamp='1339520797' post='4948557']
[quote name='WavyVirus' timestamp='1339519426' post='4948540']
If the only difference between the characters is the values of the member variables, there is no need to create a sub-class for each character type.

You can have a single character class and simply pass in the correct values when you construct it.

Only if the different characters behaved in fundamentally different ways would you need to consider adding classes specific to each character type.
[/quote]

But, say you wanted a multiplayer game. Even if the only thing that differeniates different characters is different values, wouldn't it be better/easier to have unique classes for each character that inherits from the base character class, and then when people are selecting their character, you could set their character type to the class for the unique character, rather than constantly calling functions that are hardcoded in and would set the values for each specific character?
[/quote]

What's particularly hard about this?
[CODE]
//player constructor
public Player(int health, float speed, String name, Texture2D spriteSheet)
{
this.health = health;
this.speed = speed;
this.name = name;
this.spriteSheet = spriteSheet;
}
//create 4 different players
Player player1 = new Player(100, 20f, "Jimbo", Content.Load<Texture2D>("ArcherSprite"));
Player player2 = new Player(120, 12f, "Tank", Content.Load<Texture2D>("KnightSprite"));
Player player3 = new Player(60, 16f, "PaperTiger", Content.Load<Texture2D>("MageSprite"));
Player player4 = new Player(75, 16f, "Healzorz", Content.Load<Texture2D>("ClericSprite"));
[/CODE]

You CAN make as obtuse and intricate of a class hierarchy as you want, but when all the character types are essentially identical functionality-wise, and only differ on pretty basic variables, calling a constructor once with unique values is easy, cheap, and reduces headache in code maintenance. Not to mention avoiding code duplication, which you're going to do a lot if you start subclassing for each archetype.
0

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  
Followers 0