Jump to content
  • Advertisement
  • entries
    1212
  • comments
    1738
  • views
    1144368

Just some code

Sign in to follow this  
johnhattan

61 views

Finally writing a bit of code, but just the underpinnings of a game engine. Not much to show off yet.

Got most of the data structures done. One thing I really liked about my old class library was that it came with some very well thought-out base classes for common simple data structures, like Point, Size, and Rectangle. In addition, it included a bigass bunch of collection classes and the best string class around. Unfortunately, though, it was designed to run on circa-1991 C++ compilers, so niceties like templates and namespaces were nowhere to be found. The old collections were typesafe, but were macro-based and problematic.

Fast-forward to 1999. The STL is stable on just about every platform around, which takes care of the collections and the strings. STL collections are not only template-ized, but they're so tight that they're implemented entirely as inline functions. Using C++ templates, I was able to rebuild char, short, and float versions of the old primitive classes (and some 3D versions) in about 1/4 the code of the originals. Templates are officially my friend. Kudos to SGI for making a well-written, portable, and free implementation of the STL.




As for graphical stuff, I'm working on the base sprite classes. My sprite objects so far are similarly handled to the way I did it before, because it worked very well in my old games implementation.

Basically I've got a class called SpriteManager, which points to all sprites being used and handles drawing, collisions and such. SpriteManagers can be attached to Window objects. Whenever the window needs to draw, it just tells the SpriteManager, which iterates through all of the sprites, drawing 'em. In my old scheme, however, there was just one static SpriteManager, which was attached to the one static Window. In my new scheme, I'm hoping to give multiple windows the ability to attach to a SpriteManager, so I can show multiple views of the same set of sprites.

Sprites will likely not be much different from the old ones. I was thinking of once again making some non-interactive non-collidable self-destructing sprites (called EyeCandy) for little graphical flourishes like explosions. I was thinking of making ways to attach behaviors to sprites, so that the EyeCandy bits can bounce-n-wiggle without me having to do it for them. I'll just attach a behavior to them, and every time I tell 'em to update, they'll find out their next position from the attached behavior.

Hopefully I can get enough of the underpinnings written soon, so I can start implementing something.




Finally, I'm taking over an interesting new part of DevGames in a couple of days, and I'll need your help. Stay tuned!
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

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
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!