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

Author Topic: newbie looking for help with collision matter  (Read 908 times)

0 Members and 1 Guest are viewing this topic.

monster153

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
newbie looking for help with collision matter
« 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

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: newbie looking for help with collision matter
« Reply #1 on: October 02, 2014, 12:52:25 am »
Please read this carefully.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Hapax

  • Hero Member
  • *****
  • Posts: 3360
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: newbie looking for help with collision matter
« Reply #2 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:
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

monster153

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: newbie looking for help with collision matter
« Reply #3 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

 

anything