Creating classes with SDL library

Started by
3 comments, last by exOfde 10 years, 4 months ago

My only reason for asking this question is because in high school for a java project we had to use GridWorld and every class we made had to extend the Actor class in order to work properly. Right now I am using C++ and the SDL library, and I have been trying to find as many resources as I can on it, but not all of the questions I have have been answered. For now my only pressing concern is, when I create a class whether for a player character, npc, or an item, does that class need to extend from some SDL class like how in Gridworld every class had to extend from Actor?

Advertisement

You don't need to in order to get things done with SDL. There might be a few classes in there that require this, but from my experience of making a character walk on the screen, I didn't need to.

The reason why I underlined need is simply because you probably can. I don't have a lot of experience with SDL so I don't know the structure of the classes, but you probably can inherit from some classes to make things easier/more clear.

Well, SDL is a C library. C doesn't have classes. That should make the answer obvious.

If you're asking whether you should develop a massive rooted class hierarchy like Java requires, that's a different kettle of fish. I don't recommend it but if it lets you finish your game because you can leverage the tool you already have and can focus on game writing instead of learning new techniques, it might be your best strategy.

Stephen M. Webb
Professional Free Software Developer

Well, SDL is a C library. C doesn't have classes. That should make the answer obvious.

If you're asking whether you should develop a massive rooted class hierarchy like Java requires, that's a different kettle of fish. I don't recommend it but if it lets you finish your game because you can leverage the tool you already have and can focus on game writing instead of learning new techniques, it might be your best strategy.

Well, this. Shows how much I know about SDL. Probably mixed it up with SMFL I guess. :)

Well, SDL is a C library. C doesn't have classes. That should make the answer obvious.

If you're asking whether you should develop a massive rooted class hierarchy like Java requires, that's a different kettle of fish. I don't recommend it but if it lets you finish your game because you can leverage the tool you already have and can focus on game writing instead of learning new techniques, it might be your best strategy.

jup I can only agree. The only thing you could do, if you want use classes, to create Wrapper classes for SDL. I do this often just for fun, but it helps alot if you want quick develop something with SDL and use classes. But that decision is up to you!!! You are completly free from what you are doing, but you have also the task to do all the work alone. ( I mean the work a managed language/framework do for you)

And I can suggest you SFML. It's a bit easier then SDL and do much more for you. you could say SDL is just a thin c like layer and SFML instead oop wall.

This topic is closed to new replies.

Advertisement