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

Saving Question

5 posts in this topic

I have a component system - I users of my engine can create their own components by sub-classing Component class - and then each entity has a list of components

 

When I'm serializing/de-serializing components, considering that when I am deserializing I need to allocate any sub-classed component classes in the engine loading code without actually knowing the sub-class type (user defined) - what is a good way to do this so that the engine user does not have to rewrite any engine code?

 

IE in the engine i have a Component class with pure virtual functions "serialize(FileStream & fStream)" and "deserialize(FileStream & fStream)"

so that the engine user has to write their own versions of these functions - this works great for serializing to file - but how do I deserialize?

 

If the engine code is something like

 

serialize:

 

for each component in entity

    currentComp->serialize(fStream)

 

deserialize:

for each component found in save file

    Component * toAdd = new Component()  (How do I allocate custom user defined components?)

    entity->addComponent(Component * toAdd)

 

Thanks for any help

0

Share this post


Link to post
Share on other sites

The problem is, how to discover the correct component type engine side, if the usesr are able to write a custom (plugin) ?

 

First, I would add a factory like management class (compare L.Spiros post) and a unique id, which can be designed by the component coder himself (build in some tests to avoid dublicates etc.):

interface ComponentManager {
   serializeComponent(Stream);
   Component deserializeComponent(Stream);
   unique_id getUniqueId();
}

class ComponentManagerRegistry {
   registerComponentManager(ComponentManager); // map: unique_id -> ComponentManager
   ComponentManager getComponentManager(unique_id);
}

Each component must provide an unique id and must register itself to the component manager.Then the de-/serializsation code looks like this:

serialize:
for each Component c do
  unique_id = c.getUniqueComponentManagerId();
  ComponentManager cm = ComponentManagerRegistry.getComponentManager(unique_id);
  stream.serailizeId(uniqueId);
  cm.serializeComponent(stream,c);
end


deserialize:
while stream!=end do
  unique_id = stream.deserializeId();
  ComponentManager cm = ComponentManagerRegistry.getComponentManager(unique_id);
  Componentn new_component = cm.deserialize(stream);
end


Edited by Ashaman73
1

Share this post


Link to post
Share on other sites
There are many questions you need to answer about your engine as part of the save system.

While you can use the factory pattern (or something similar) for your game, the save/load system needs to be designed in to nearly every aspect of the game.


In the most extreme example, it is really cool when games offer a 'save game' option in the pause menu. You can stop the world mid-action, pause, save, and quit. Then some later time you can restore and everything will be as it was in the instant you paused. That means mid-animation, mid-audio, mid-effects, mid-accumulation, mid-AI, mid-physics, mid-iteration, mid-script. EVERYTHING needs to be carefully stored so that it can be completely recovered. This can be extremely challenging.

Save points and checkpoints represent among the easiest option. You only need to store the data that you would store between levels, which can be quite minimal. If you look back to many of the console games from the 1980s (3rd gen, NES and similar) the player could get a passcode of around 10-20 symbols that represented the entire saved data between levels. It basically stored the level number, the score, the time or RNG seed, the inventory, and the other minimal tidbits necessary for loading. Relatively few things need to be saved, and it can be quite easy to save off just a single very large data structure.


The point is that you need to think not just about the mechanics of serialization, but also how every game system is going to act. A comprehensive save/load system can be a very large undertaking if you don't plan for it carefully.
2

Share this post


Link to post
Share on other sites
frob: I'm thinking he meant saving game data from an editor mode, not necessarily saving player progress and world state, but I could be wrong. Good points anyway, though!
1

Share this post


Link to post
Share on other sites

So I understand making an abstract Component class and an abstract ComponentFactory class where the user must subclass both to make a new component..

 

If I take this route - how do I know which user-created factory to use when serializing/deserializing? Would I need to keep a map of factories such as std::map<CompTypeID, ComponentFactory>

where the user would need to register their new Factory type? And then for each saved component, save the CompTypeID so the engine can get the correct factory? This seems like it would work but is it overly complicated?

 

I guess dealing with user errors here would be another concern - if they didn't create a factory for their component - I guess I could just crash the engine with an error message telling them they have to make a factory for their component

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