Talk:SDL:Tutorials:Simple Engine Framework
From GPWikiThanks for the many edits and corrections! I don't know who to thank since only the IPs are showing, but thanks anyway whoever you are! ;) --User:ostamo2 Is there a way we could show an example of using the engine by displaying a bitmap PS. The MouseMove method doesn't include infomation about the mouse buttom states (the iButton-variable). iButton will alway be 0. I'll try to fix it sometime. I also need to throw in some more error handling, making some functions const and use references to the variables in the functions for increased speed. --Sion 12:41, 21 Mar 2005 (EST) Regarding the removing of #include "SDL.h": It's not really worth a revert, but it is good practice to include SDL.h in files where you use SDL functions/types, even if it's included an included header file.
[edit] Suggestions And ImprovementsI really like your approach of writing an engine, but wouldn't it be better to use: virtual void AdditionalInit() = 0 instead of virtual void AdditionalInit() {}? Also I would suggest to declarate the virtual functions even in the CMyEngine class as virtual. Although it is not necessary most people prefer it, cuz this way you always keep in mind what kind of function this is. Sorry for my bad language skills! AndreMagnus 10:39, 4 May 2005 (EDT)
- To the question about virtual versus pure virtual, you are correct. It would probably be better to make them pure in order to force users to implement the functions. It would be even better to have the CEngine-class inheirit an interface-class (a pure virutal class), but I'll leave the structure as it is for now. EDIT: I changed all the virtual function to pure virtual functions, and sat looking at the code for a bit. It then occured to me that I don't want to force people to implement functions like WindowActive and WindowInactive or even AdditionalInit and End. The user can just implement the functions he or she want. - To the suggestion of making the implementations of the virtual functions virtual as well; good idea but it would undermine the stability of the class hierarchy. That would allow other class to inheirit the CMyEngine-class and make their own implementation of the virtual functions, but that also opens a lot of possible errors. To make it appearent that they are virtual functions, a uppercase "V" could be prefixed to the function name. Some developers use this approach to be able to tell normal and virtual functions apart. I'll leave it as it is. Making the functions virtual just to signify that they are implementations of virtual functions dosen't make much sense to me. And your written english is fine! :) Sion 17:10, 4 May 2005 (EDT) [edit] QuestionsWot's the license for this code - i.e. GPL, BSD, public domain, some random terms for usage, or maybe I have to stand on my head and do three back-flips while whistling obscure dance club mixes backwards? :) --69.132.183.189 21:16, 4 Sep 2005 (EDT) Never mind, I just saw the notice about source copyright below as I was posting this.
[edit] FrameTickValue?I was wondering what FrameTickValue is for since it is not used at all after it is defined. How do you control the fps? Thanks. --68.160.34.253 01:43, 11 December 2005 (EST)
/** Handles the updating routine. **/
void CEngine::DoThink()
{
long iElapsedTicks = SDL_GetTicks() - m_lLastTick;
m_lLastTick = SDL_GetTicks();
Think( iElapsedTicks );
m_iFPSTickCounter += iElapsedTicks;
}
[edit] WaitMessage()Anyone got portable alternative for this? Can't be that SDL doesn't have something for handling things like this. --Enmoku 15:21, 5 June 2007 (EDT)
|


