Page 1 of 1

SDL first project

Posted: Mon Jan 24, 2011 2:51 pm
by sk1v3r
Hey, I'm fairly new and I have just created my first SDL 'experiment'
because I'm fairly new, and you guys are awesome, I wanted to see if you guys like it, and if the code is good or bad :)
http://rapidshare.com/files/444341187/rain_arrow.zip
I'm proud of it, but I have no idea if what I'm doing is right or efficient, so...
left and right click to move the stuff around :)

Re: SDL first project

Posted: Tue Jan 25, 2011 5:32 am
by adikid89
I like it! Not only is it interesting, but the code is also clean. Good job! :D

Re: SDL first project

Posted: Tue Jan 25, 2011 5:55 am
by D-e-X
Looks nice and clean, however, you should comment or rename such variables as "int i = 0;" ;)

Re: SDL first project

Posted: Tue Jan 25, 2011 6:37 am
by LeonBlade
D-e-X wrote:Looks nice and clean, however, you should comment or rename such variables as "int i = 0;" ;)
I don't think i really needs much explanation but.

Image
Squares, squares everywhere...

Re: SDL first project

Posted: Tue Jan 25, 2011 11:39 am
by D-e-X
LeonBlade wrote:
D-e-X wrote:Looks nice and clean, however, you should comment or rename such variables as "int i = 0;" ;)
I don't think i really needs much explanation but.
First of all, "but" what?

Second of all, it's his first project, and I'm just pointing out that even though "i" might be obvious here, having i, j, k, or x everywhere (in a bigger project) without a name related to its usage, (like by convention it should have) makes it unnecessarily hard to grasp the point of its existence.

Of course, people would understand those used in for loops or as counters by general, you don't have to write:

Code: Select all

int counter = 0;
int someVar = 3;
for(;counter < someVar; ++counter) {
std::cout << "HAI!" << "\n";
}
But when the counter itself is used for something specific (not just in loops, but also in if statements and others), it's good design to name it something that explains its use. I know this got redundant, but I'm just trying to get my point across. HOWEVER, note that this is partly subjective and I am no one to tell EXACTLY how it should be ;), so excuse any ignorance that might be.

Re: SDL first project

Posted: Tue Jan 25, 2011 1:00 pm
by sk1v3r
Thanks for the replies :) I'll keep in mind to name everything appropriately :)

Re: SDL first project

Posted: Tue Jan 25, 2011 1:12 pm
by xiphirx
Make sure you free your SDL Surfaces :)

Re: SDL first project

Posted: Tue Jan 25, 2011 1:21 pm
by sk1v3r
the only surface I had was the screen, I was under the impression that SDL_Quit freed the screen only. If not then oops :/

Re: SDL first project

Posted: Tue Jan 25, 2011 2:01 pm
by D-e-X
sk1v3r wrote:the only surface I had was the screen, I was under the impression that SDL_Quit freed the screen only. If not then oops :/
^ This is true, SDL_Quit() takes care of the buffer for you ;), so don't worry about it.

Re: SDL first project

Posted: Tue Jan 25, 2011 8:06 pm
by xiphirx
D-e-X wrote:
sk1v3r wrote:the only surface I had was the screen, I was under the impression that SDL_Quit freed the screen only. If not then oops :/
^ This is true, SDL_Quit() takes care of the buffer for you ;), so don't worry about it.
I have learned something then :)