Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: New to C++ and SFML - Hoping to get advice on my code...  (Read 2244 times)

0 Members and 3 Guests are viewing this topic.

bglaze

  • Newbie
  • *
  • Posts: 46
    • View Profile
New to C++ and SFML - Hoping to get advice on my code...
« on: October 11, 2011, 05:21:35 am »
Hey folks!

New to the forum, and so far I am loving SFML (though I am not sure if I am utilizing it well, yet).

In order to try to teach myself c++ and SFML, I began a small snake game, and I am hoping some people might be willing to check out the code and let me know what I can do to clean it up so far.

So far it is just the snake's head moving around the screen and dying when it hits the walls.

But I am sure that some of the code could be cleaned up. Especially in my Move_Me() SnakeHead member function such as this line:
this->SetPosition( (game.SW - this->GetImage()->GetWidth()), this->GetPosition().y );

I am wondering if there is an easier way to access my sprite's width, screen width, etc...

Anyway, here is the zip of my Code::Blocks project.

http://bglz.net/files/cpp/projects/Yellow_Snake.zip

My code, though crappy as it probably is, is always free to use, reuse, and distribute at your pleasure!

Thanks!
Brock