Beginner's Guide to Game Programming
Moderator: Coders of Rage
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Beginner's Guide to Game Programming
For OGL, it looks like you have to set a special flag for non-power-of-2 images. Not sure what the effects are. http://www.gamedev.net/community/forums ... _id=466904 has some allusions.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- Moosader
- Game Developer
- Posts: 1081
- Joined: Wed May 07, 2008 12:29 am
- Current Project: Find out at: http://www.youtube.com/coderrach
- Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
- Programming Language of Choice: C++
- Location: Kansas City
- Contact:
Need moar verification
Anyone know?XianForce wrote:doesn't SDL_Quit destroy the buffer (screen) ?
The buffer/screen is just another SDL_Surface so I thought you had to free it afterwards anyway.
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: Need moar verification
When you use SDL_SetVideoMode on a surface, SDL then knows to destroy it within SDL_Quit.Moosader wrote:Anyone know?XianForce wrote:doesn't SDL_Quit destroy the buffer (screen) ?
http://www.libsdl.org/docs/html/sdlsetvideomode.htmlSDL Documentation wrote: Return Value
The framebuffer surface, or NULL if it fails. The surface returned is freed by SDL_Quit() and should not be freed by the caller.
- Moosader
- Game Developer
- Posts: 1081
- Joined: Wed May 07, 2008 12:29 am
- Current Project: Find out at: http://www.youtube.com/coderrach
- Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
- Programming Language of Choice: C++
- Location: Kansas City
- Contact:
Re: Beginner's Guide to Game Programming
Ahh oke, thanks.Bakkon wrote:When you use SDL_SetVideoMode on a surface, SDL then knows to destroy it within SDL_Quit.Moosader wrote:Anyone know?XianForce wrote:doesn't SDL_Quit destroy the buffer (screen) ?
http://www.libsdl.org/docs/html/sdlsetvideomode.htmlSDL Documentation wrote: Return Value
The framebuffer surface, or NULL if it fails. The surface returned is freed by SDL_Quit() and should not be freed by the caller.
So then, does it mess it up if you try to free it again?
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: Beginner's Guide to Game Programming
Probably nothing too bad, as I use to manually free it before I learned that. Probably equivalent to calling SDL_FreeSurface and the same surface twice. Not sure how SDL handles that.Moosader wrote: Ahh oke, thanks.
So then, does it mess it up if you try to free it again?
I take that back. Haha.
Last edited by Bakkon on Sat Jun 27, 2009 1:41 pm, edited 1 time in total.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Beginner's Guide to Game Programming
If you free it and SDL_Quit(), it can cause a crash. I forget if it crashes if you set it to NULL or if you don't, but at least one of those causes a crash.Moosader wrote:Ahh oke, thanks.
So then, does it mess it up if you try to free it again?
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- lotios611
- Chaos Rift Regular
- Posts: 160
- Joined: Sun Jun 14, 2009 12:05 pm
- Current Project: Game engine for the PC, PSP, and maybe more.
- Favorite Gaming Platforms: Gameboy Micro
- Programming Language of Choice: C++
Re: Beginner's Guide to Game Programming
I'm following the guide, and it's helping me a lot. I have one question. What should I set the maxFrame to? I am using one of your RPG style spritesheets.
"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
- Moosader
- Game Developer
- Posts: 1081
- Joined: Wed May 07, 2008 12:29 am
- Current Project: Find out at: http://www.youtube.com/coderrach
- Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
- Programming Language of Choice: C++
- Location: Kansas City
- Contact:
Re: Beginner's Guide to Game Programming
for my sprite sheets, there are four frames of animation (1-2-3-2 loop), so maxFrame will be 4.lotios611 wrote:I'm following the guide, and it's helping me a lot. I have one question. What should I set the maxFrame to? I am using one of your RPG style spritesheets.
When you go to display the sprite, it'll be something like this:
int filmstripx = (int)(player.frame * player.w);
if ( player.frame >= 3 ) // on the 4th frame, which should be frame #2
filmstripx = 2 * player.w;
masked_blit( imgPlayer, buffer, filmstripx, player.direction * player.h, player.x, player.y, player.w, player.h );
If I had put the duplicate middle (both feet down) sprite at the end instead of having the three frames, you wouldn't have to have the if statement, but since I did you have to do a little more work to make up for the 4th frame be the same as the 2nd.
Re: Beginner's Guide to Game Programming
Moosader wrote:Ahh oke, thanks.Bakkon wrote:When you use SDL_SetVideoMode on a surface, SDL then knows to destroy it within SDL_Quit.Moosader wrote:Anyone know?XianForce wrote:doesn't SDL_Quit destroy the buffer (screen) ?
http://www.libsdl.org/docs/html/sdlsetvideomode.htmlSDL Documentation wrote: Return Value
The framebuffer surface, or NULL if it fails. The surface returned is freed by SDL_Quit() and should not be freed by the caller.
So then, does it mess it up if you try to free it again?
Well I would think if something bad was going to happen, you would've noticed =p?
- lotios611
- Chaos Rift Regular
- Posts: 160
- Joined: Sun Jun 14, 2009 12:05 pm
- Current Project: Game engine for the PC, PSP, and maybe more.
- Favorite Gaming Platforms: Gameboy Micro
- Programming Language of Choice: C++
Re: Beginner's Guide to Game Programming
Thanks for your help.Moosader wrote:for my sprite sheets, there are four frames of animation (1-2-3-2 loop), so maxFrame will be 4.lotios611 wrote:I'm following the guide, and it's helping me a lot. I have one question. What should I set the maxFrame to? I am using one of your RPG style spritesheets.
When you go to display the sprite, it'll be something like this:
int filmstripx = (int)(player.frame * player.w);
if ( player.frame >= 3 ) // on the 4th frame, which should be frame #2
filmstripx = 2 * player.w;
masked_blit( imgPlayer, buffer, filmstripx, player.direction * player.h, player.x, player.y, player.w, player.h );
If I had put the duplicate middle (both feet down) sprite at the end instead of having the three frames, you wouldn't have to have the if statement, but since I did you have to do a little more work to make up for the 4th frame be the same as the 2nd.
"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Beginner's Guide to Game Programming
Not necessarily.. it took me and Andrew about 15 minutes to figure out that Lusikka's level editor was crashing because of a huge memory leak (the only reason we even noticed it was because it was so bad that the OS was terminating it at 200KB). Sometimes task manager tells you things the compiler doesn't.XianForce wrote:Well I would think if something bad was going to happen, you would've noticed =p?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
Re: Beginner's Guide to Game Programming
Well it was crashing, hence there's something wrong? So after coding in SDL for a while, I think you would notice it repeatedly doing something its not supposed to do.dandymcgee wrote:Not necessarily.. it took me and Andrew about 15 minutes to figure out that Lusikka's level editor was crashing because of a huge memory leak (the only reason we even noticed it was because it was so bad that the OS was terminating it at 200KB). Sometimes task manager tells you things the compiler doesn't.XianForce wrote:Well I would think if something bad was going to happen, you would've noticed =p?
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Beginner's Guide to Game Programming
That's why it was easy to find, but not all memory leaks cause a crash (or any visible error) within the first 10 seconds. I was just saying it could certainly be causing something bad to happen that you're not aware of.XianForce wrote: Well it was crashing, hence there's something wrong? So after coding in SDL for a while, I think you would notice it repeatedly doing something its not supposed to do.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- Moosader
- Game Developer
- Posts: 1081
- Joined: Wed May 07, 2008 12:29 am
- Current Project: Find out at: http://www.youtube.com/coderrach
- Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
- Programming Language of Choice: C++
- Location: Kansas City
- Contact:
Re: Beginner's Guide to Game Programming
:P You guys
Opinions?stereo123 wrote:Do you think OOP has any place in simple games? I made a pong in allegro with C. I'm now starting to get into actionscript (easier to share, no downloads) and the 2 books i got are full of OOP. I knew i'd have to learn it sooner or later, but i remember reading that it just wasn't needed for the kind of simple retro games that interest me.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Beginner's Guide to Game Programming
I tend to be one of those "OOP Whores" as Falco would say. I'm not saying I think it's a good thing, but I find it much easier than other programming techniques. For projects as small as pong you certainly don't need to use strict OOP standards, if any at all. It just makes things more complicated as a beginner, but I find it tends to neaten things up if you fully understand what you're doing.Moosader wrote::P You guys
Opinions?stereo123 wrote:Do you think OOP has any place in simple games? I made a pong in allegro with C. I'm now starting to get into actionscript (easier to share, no downloads) and the 2 books i got are full of OOP. I knew i'd have to learn it sooner or later, but i remember reading that it just wasn't needed for the kind of simple retro games that interest me.
[Random] In my most recent project I made a few of my Object class's member variables public!!! It made things so much easier to not have a load of accessors that served absolutely no error-checking purpose:
Code: Select all
public:
//Completely pointless accessor.
void GetXAccel(){ return xAccel; }
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!