• 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
Eindacor_DS

Projectile Class Format

4 posts in this topic

I've been learning c++ for about 6 or 7 months now, and I've been messing around with a few systems that I'll hopefully use in a game I'll make one day. I don't know anything about graphics yet, so most of my experiments have been more about managing classes. For my latest experiment, I want to set up the system that delivers different types of effects to an enemy from a bullet fired by the player. For instance, it could have a freeze property that slows the enemy down, or a shock property that does added damage to shields  and so on. My initial instinct is to make a projectile class contains has a vector of effect classes as a member. The player too, will have a vector of effects as a member. When the player fires a bullet, the player object's vector is copied onto the projectile. When the projectile connects with an enemy, it runs through the list of effects and applies each.

 

My concern/question is: is that too much information for each projectile to contain, or is this a somewhat typical setup? If I have dozens or maybe even hundreds of projectiles, each with that much information associated, could that become a dangerous amount of processing to run for every frame?

 

Like I said, I'm pretty new to programming, so if this is way off I'd appreciate a pointer or two. But if this will work for the small scale that I'm at now I'll continue building the system just for practice. Basically I just don't want any bad habits to develop this early in my education.

 

Thanks in advance

0

Share this post


Link to post
Share on other sites

I think you've pretty much got the right idea. When you talk about vectors I assume you are talking about std::vector? One thing I'd suggest is to not copy vectors into the projectile class as this may start getting expensive depending on the size of the vector and how many times per frame you are doing it. Instead I would either have the projectile store a pointer back to the character that created it. This way you can access the effect vector you were talking about without any copying. Or use bit flags to hold a projectiles effects rather than a vector. This will reduce memory consumption and probably be faster to process. You can read a little about bit manipulation here

 

These options depend on what information you need to store and how it will be accessed.

2

Share this post


Link to post
Share on other sites

Will every projectile be different? I do not think so, we can say that every projectile behaves according to its type. Make every projectile have some kind of reference to its type (enum, pointer, reference, ID...). That is 8 bytes overhead at most, which is perfectly okay. You then modify the enemy using the projectile type and are okay.

2

Share this post


Link to post
Share on other sites

I want to set up the system that delivers different types of effects to an enemy from a bullet fired by the player. For instance, it could have a freeze property that slows the enemy down, or a shock property that does added damage to shields  and so on.

...
My concern/question is: is that too much information for each projectile to contain, or is this a somewhat typical setup? If I have dozens or maybe even hundreds of projectiles, each with that much information associated, could that become a dangerous amount of processing to run for every frame?

Is it too much? I don't think so. Is it typical? Sort of, RPGs for example often have elemental damage properties. For your initial design, implement whatever gets you there. Iterate if necessary.

Keep in mind you'll need far more design than you probably expect. For example, how do you freeze a generic player-controlled entity? A generic enemy? A generic object in the world?

Stacking effects will be a problem. In certain games, ice cancels fire. On others (such as Torchlight) the various elemental damages are applied independently.

 

As said, those projectile types are going to be "static" in behaviour (albeit they might have random values on a per-instance basis).  I strongly suggest the use of a reference type or a pointer. As for the values themselves, a preallocated std::vector will probably be fine (personally I think all bullets should be born equal).

I don't think the system "by itself" should care about who shoot the projectile. But sure it would be handy to have this property on another system to understand who-killed-who. As a side note, there's the need to generalize this in Damage entities if you care about environmental damage.

Bit fields at this stage are very early optimization, they don't look very appealing in a very hi-level system like this.

 

As a side note, consider lambda functions and std::function.

2

Share this post


Link to post
Share on other sites

These responses are great, thank you all. I'll look into all the references that were given, this is the exact kind of info I need going forward. Much appreciated.

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