Slight setback, back on track

Published July 03, 2008
Advertisement
I had some annoying little problems that I, being the perfectionist that I am, had to solve before moving on to the map editor. Oops.

The inner class I mentioned was fun and interesting, and certainly a good idea in some cases, after I made some improvements I realized I didn't actually need it anymore. I moved its methods back into the GameView and it works fine again.

I also hit a small roadblock while tinkering with my Entity class, and deriving from it to allow for collision detection. (Somehow, I always get sidetracked...) Apparently, if your base class has a function overloaded at least twice, and your derived class only implements one of those, you can't call the other. You actually have to name the 'other' overload something else, basically meaning it isn't an overload any more. It feels really, really stupid. This relates to my Entity by way of the entity's position. I was going to derive Entity and add Move() functions that would only move if it didn't collide with anything, but then I realized that the position COORD would still be directly modifiable, allowing for a way around the collision detection. This isn't necessarily a bad thing, but on the other hand if you wanted to make an entity that went through walls sometimes, you could add a boolean "isGhosting" to your derived and do it based on that, still by using Move().

In short, I cut out the setter-Position() functions from the base Entity class, because Entity doesn't really need them; it's basically just an interface that provides the functionality GameView needs. And GameView doesn't need to change the position, only find out what it is for drawing - the user of the Entity is in charge of movement.


That said, the Entity isn't necessarily bound to the GameView. You could quite easily use it yourself without the GameView at all. However, in my case, when deriving from the Entity, I gave my new Body class a GameView pointer, so it can access the map layout of the GameView for collision detection. That's really at the user's discretion though (via deriving), so I wouldn't say that the Entity is coupled with the GameView.

Now, don't let me do anything else with Cripes before I finish the map editor! Sheesh :(
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement