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

Author Topic: Pac man game  (Read 12669 times)

0 Members and 1 Guest are viewing this topic.

SCPM

  • Newbie
  • *
  • Posts: 11
    • View Profile
Pac man game
« Reply #15 on: August 13, 2011, 08:11:20 pm »
The code would be pac.TransformToGlobal(pac.GetCenter()).x or y.  And you should do pac.SetCenter(halfOfPacMan'sWidth, halfOfPacMan'sHeight).  It should also be possible to just offset PacMan.GetPosition().x and y by adding the values here as well.

gl0w

  • Newbie
  • *
  • Posts: 20
    • View Profile
Pac man game
« Reply #16 on: August 13, 2011, 08:58:34 pm »
Quote from: "SCPM"
The code would be pac.TransformToGlobal(pac.GetCenter()).x or y.  And you should do pac.SetCenter(halfOfPacMan'sWidth, halfOfPacMan'sHeight).  It should also be possible to just offset PacMan.GetPosition().x and y by adding the values here as well.


It's not working :(

Here is what i have:

Code: [Select]
pac.SetCenter(BLOCKSIZE/2, BLOCKSIZE/2);
pac.TransformToGlobal(pac.GetCenter()).x;
pac.TransformToGlobal(pac.GetCenter()).y;

//then i should get the position on the screen and convert to the correct position on the gameboard.

PacPosX = pac.GetCenter().x/BLOCKSIZE;
PacPosY = pac.GetCenter().x/BLOCKSIZE;

// this should give me the position of the center of the pacman on the screen right?

//after this i checked for it on the gameboard.

if ((tabuleiro[PacPosX+1][PacPosY]!=WALL))
   pac.Move(MAX_SPEED, 0);


However i'm still not getting the position of the center of the pacman on the screen. :\

SCPM

  • Newbie
  • *
  • Posts: 11
    • View Profile
Pac man game
« Reply #17 on: August 13, 2011, 11:33:24 pm »
The code ought to be:
Code: [Select]
PacPosX = pac.TransformToGlobal(pac.GetCenter()).x/BLOCKSIZE;
PacPosY = pac.TransformToGlobal(pac.GetCenter()).y/BLOCKSIZE;

gl0w

  • Newbie
  • *
  • Posts: 20
    • View Profile
Pac man game
« Reply #18 on: August 13, 2011, 11:59:21 pm »
Quote from: "SCPM"
The code ought to be:
Code: [Select]
PacPosX = pac.TransformToGlobal(pac.GetCenter()).x/BLOCKSIZE;
PacPosY = pac.TransformToGlobal(pac.GetCenter()).y/BLOCKSIZE;


I have tried that, doesn't work either :( it's not getting the center position.

I have tried several ways around this, none is working. Maybe something is missing ?

gl0w

  • Newbie
  • *
  • Posts: 20
    • View Profile
Pac man game
« Reply #19 on: August 14, 2011, 03:40:33 pm »
Anyone know why i'm not getting the center of the sprite positon on the screen ?

Quote
pac.SetCenter(BLOCKSIZE/2, BLOCKSIZE/2);
pac.TransformToGlobal(pac.GetCenter()).x;
pac.TransformToGlobal(pac.GetCenter()).y;


I'm still getting the uper left corner of the sprite and not the center :\

gl0w

  • Newbie
  • *
  • Posts: 20
    • View Profile
Pac man game
« Reply #20 on: August 17, 2011, 05:45:32 pm »
Sorry for bumping this topic, i'm really trying to get my pacman game work, but, i still have the problem described below.
I'm not able to get the center position on the screen of my pacman.

Could someone from the dev team give me some tips, maybe something i'm doing wrong.


I appreciate.

 

anything