SFML community forums

Help => General => Topic started by: monster153 on October 02, 2014, 12:50:46 am

Title: newbie looking for help with collision matter
Post by: monster153 on October 02, 2014, 12:50:46 am
hi ,

i'm new here, i'm an software engineering student  and i want to learn SFML and i just finished studying c++,

i'm building a Pacman game and i'm having a little problem creating the collision detection i've tried applying
tile map collision detection but it doesn't seems to work.

this is the link for the game https://www.mediafire.com/?ubenww12i1sx94k (https://www.mediafire.com/?ubenww12i1sx94k)
Title: Re: newbie looking for help with collision matter
Post by: Nexus on October 02, 2014, 12:52:25 am
Please read this (http://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368) carefully.
Title: Re: newbie looking for help with collision matter
Post by: Hapax on October 02, 2014, 01:17:11 am
Hi, and welcome  :)

Nexus probably meant to welcome you too but probably just forgot  ;D
He's right, though. You should be posting code here, in minimal format, so it can be copied directly from the forum. Nobody likes downloading random files. However, I 'risked' it...

You don't seem to have any collision detection at all in your source file so no wonder it doesn't work  :P

I noticed this:
                sf::Rect<float> p_rect;(pacman_pos,32,32);
                sf::Rect<float> w_rect;(wall_pos,32,32);
which, I can imagine, shouldn't have the semi-colon in the centre.

As for simple collision, why not just check to see if the tile that the player wants to move to, is one that allows movement e.g. not a wall.
If you don't know how to work out which tile your player's sprite (or any point) is currently over, this image that I made a while ago for someone else may be of some use:
(http://i.imgur.com/RwmvlfR.jpg)
Title: Re: newbie looking for help with collision matter
Post by: monster153 on October 02, 2014, 01:35:10 am
thank you very much Hapax for your help i really appreciate your help and sorry for not following the rules