Class inheritance?

Started by
11 comments, last by ChaosEngine 10 years, 3 months ago


I don't understand why he would have to change the enemy class every time he creates a new enemy.

He means, every time you create a new enemy type, not a new enemy instance. It's a little messy to have a giant if/switch statement in a class like that. There are cleaner ways.

Advertisement

Yeah, there could be a switch statement for elements in an array (which would be the types, and which would also be boolean values) or however else. I gotcha though. Yeah, adding a new type would have to be done in the class.

They call me the Tutorial Doctor.


What is a good file format to use for such a file? XML?

XML is stil bloated, still costly to parse, and still has a couple of features that doesn't help in this use case. The major opinion is to create a customized binary file format fitted to your needs *if* you speak of the load file format; it is something other if you speak of file formats for the development phase where interchangeability plays a role.

There are two problems with binary source formats from a development perspective.

  1. They are difficult for developers to edit with confidence
  2. Source control can't give you a useful diff history.

OTOH, you're right about xml being bloated at runtime. One option would be to write the source data in xml/json/whatever and then write a simple tool to parse the xml into your custom binary format as a build step. This should be relatively trivial to do and then you get the best of both worlds; human readable source that is easily put into version control and fast, compact files to distribute.

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

This topic is closed to new replies.

Advertisement