Monday, October 11, 2010

Problems with points

So the past couple nights I've been trying to get my meteors drawn in the game. It works in my sfmltest project (a project I have installed sfml on (because it was such a pain installing I keep this one) to test little functions). After running the debugger, I've found that after the points are added in the function of the class and the program returns to the main functions, the points are no longer there. So maybe using a call by reference? Or changing the points to global variables (something I've tried but I'm unsure if I'm doing it right)? All I know is those points are not transferring to the main functions.

I've tried picking the brains of a few people (graphitemaster and Wil) on the SFML IRC channel, but my current limited vocabulary stops me from conveying my problem/question correctly. But they were very helpful in suggesting ways to improve my code. One is changing this function:

void addpoints(sf::Shape meteor)

To:
void addpoints(const sf::Shape& meteor)

I'm not entirely sure why this is better, but graphitemaster says using the former will kill his RAM, I will read up more about that later. Wil also suggested I use iterators when using vectors/deques, so I will further read up on those and try to implement them.

These past couple of nights were really like a slap in the face, I still have a lot to learn before I can really do anything with SFML. I like working on this project before I go to bed, it drains me of all my brain power and I sleep like a rock. I'm going to potentially read up on books to improve my coding skills.

Edit:
As I was shutting down my computer last night, right after writing this post I was staring at the book holding up my monitor (my monitor's stand doesn't move up and down, and it's too short so I put a book under it). It was the book for my C++ class (it's been there since the beginning of the semester)! I'm going to try actually reading that book before buying any other C++ book.

No comments:

Post a Comment