Difference between revisions of "Talk:SDL:Tutorials:Simple Engine Framework"

From GPWiki
Jump to: navigation, search
m (Sion doesn't come here anymore. :()
(Alternatives)
 
Line 115: Line 115:
 
We haven't seen Sion for a long time. His last visit to the forum was 2008. If the page needs an update and you think you're up to the job, feel free.
 
We haven't seen Sion for a long time. His last visit to the forum was 2008. If the page needs an update and you think you're up to the job, feel free.
 
[[User:Codehead|Codehead]] 12:01, 22 April 2012 (UTC)
 
[[User:Codehead|Codehead]] 12:01, 22 April 2012 (UTC)
 +
 +
I think https://github.com/Ratstail91/Codebase is a pretty good alternative, although admittedly the earliest version of codebase came from this page. It's amazing to see how something like Scions framework could evolve into my codebase.

Latest revision as of 05:42, 10 May 2012

Thanks 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.

- sik0fewl 18:25, 21 Mar 2005 (EST)

Suggestions And Improvements

I 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)



Hey Andre, welcome to the GPwiki and thanks for your suggestions!

- 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)

Questions

Wot'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.

I know that the source in the code that's in archive for you to download is required to be Public Domain, but I don't know about code that's actually on the page. It's either FDL or Pub. Domain. If you're reading this, you could ask in the forums. --Snoolas 14:58, 5 Sep 2005 (EDT)

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)

You are exactly right. m_lFrameTickValue is not being used. It is a variable that I used for keeping the framerate steady, but now the engine uses time based calculations instead, so it's really just a left-over. The elapsed time since the last update is calulated in CEngine::DoThink(), and time is then passed to the concrete engines Think() method. It is then responsible for updating the logic according to the time passed. Here's the code that finds the elapsed time, it pretty straight-forward:
/** Handles the updating routine. **/
void CEngine::DoThink() 
{
	long iElapsedTicks = SDL_GetTicks() - m_lLastTick;
	m_lLastTick = SDL_GetTicks();

	Think( iElapsedTicks );

	m_iFPSTickCounter += iElapsedTicks;
}
Thanks for letting me know about the unused variable, I didn't mean to confuse you. I'll remove it right away :)
-- Sion 10:14, 11 December 2005 (EST)
No problem, thanks for clearing that up. --68.160.34.253 20:17, 12 December 2005 (EST)

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)

I'm running Linux and I was wondering this too. Does SDL_WaitEvent() produce the same results or does it not 'release some system resources'? Thanks. --DannyW 11:54, 27 July 2007 (EDT)


Destructor and atexit will lead to that SDL_Quit is twice executed.

Alternatives

Does anybody mind if I post my version?

--Ratstail91 15:06, 16 April 2011 (BST)

Please feel free, that's what the wiki is about. I'd ask you to start a new page (like SDL:Tutorials:Another Simple Engine Framework or SDL:Tutorials:Alternate Simple Engine Framework ) for additional versions rather than overwriting the existing one, unless there are errors in the existing content.

Codehead 16:07, 16 April 2011 (BST)

cool thanks, I'll sort out the copyright stuff, even though I might just use the regular GPWiki copyright if I can...

--Ratstail91 10:41, 17 April 2011 (BST)

I'm back! My engine was partially inspired by this. However, it doesn't look anything like this. Plus, it also has systems to put pictures onscreen, collision code, audio, networking, and whatever else I feel like adding. Who's interested? --Ratstail91 14:48, 6 June 2011 (BST)

It'd be great to see what you've come up with.

Codehead 15:23, 6 June 2011 (BST)

I've finished the engine! The binary version is packaged and ready to go. I'm just writing the tutorials for now, but hopefully I can get some of my class mates using it soon :). I won't be releasing the source yet, I'm still kind of attached to it. When I finish the tutorials, and have them all tested by my friends I will release the binary online. I think it's a bit rude advertising it here, but I'm still going to make a page for it on the GP wiki, even though it will be uploaded somewhere else. It's called KAGE, by the way.

KAGE: Kayne's All-purpose Game Engine

Ratstail91 14:02, 22 June 2011 (BST)


Thanks for moving that to the bottom of the page, that helped my ego. </sarcasm> Ratstail91 15:06, 22 June 2011 (BST)

LOL, Just wikifying it. Otherwise it looked like Sion wrote it. Codehead 15:53, 22 June 2011 (BST)

Yeah fair enough. Does Sion even maintain this page anymore? Ratstail91 00:43, 24 June 2011 (BST)

It's been a while since I've been here, and I'm ashamed to admit that I never actually posted my code. I'll remove my page. On another note, after all of the things that I've seen and learnt, I'm confident enough to say that this page needs a rewrite. If nobody objects, I'll get to it now. Also, I don't think that Scion actually watches this page anymore. --Ratstail91 12:03, 18 April 2012 (UTC)

We haven't seen Sion for a long time. His last visit to the forum was 2008. If the page needs an update and you think you're up to the job, feel free. Codehead 12:01, 22 April 2012 (UTC)

I think https://github.com/Ratstail91/Codebase is a pretty good alternative, although admittedly the earliest version of codebase came from this page. It's amazing to see how something like Scions framework could evolve into my codebase.