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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - gl0w

Pages: [1] 2
1
General / SFML Linker error vs 2010
« on: January 11, 2012, 07:51:17 pm »
Could you explain how you fix it?

thanks

2
Graphics / How do i get the position of the center of my sprite?
« on: August 28, 2011, 03:39:28 am »
Thanks for both of you. Really appreciated


pac.GetPosition().x + pac.GetCenter().x + pac.GetPosition().y + pac.GetCenter().y  works. I can get the center position of the sprite on the screen.

Not sure, if there is another way around for do that ?

3
Graphics / How do i get the position of the center of my sprite?
« on: August 27, 2011, 03:03:11 pm »
Quote from: "Lo-X"
SFML 1.6 I guess :

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


I tried that, with pac.SetCenter(0.5*BLOCKSIZE, 0.5*BLOCKSIZE);

And it actually set's the Center to 10/10, because i can see it on debug mode.
The problem is when i try to get the global position of the center on the screen with:

pac.TransformToGlobal(pac.GetCenter()).x;
pac.TransformToGlobal(pac.GetCenter()).y;

PacPosX = pac.GetCenter().x
PacPosY = pac.GetCenter().y

or

PacPosX = pac.GetPosition().x
PacPosX = pac.GetPosition().y

it still gives me the position of the upper left corner :(

SFML 1.6 here.

thanks

4
Graphics / How do i get the position of the center of my sprite?
« on: August 26, 2011, 10:58:49 pm »
Quote from: "MorleyDev"
pac.GetPosition().x + pac.GetCenter().x?



Hm.. well, never though about it. But i can try.

 I already tried using:
pac.TransformToGlobal(pac.GetCenter()).x;
pac.TransformToGlobal(pac.GetCenter()).y;

and then

PacPosX = pac.GetCenter().x
PacPosY = pac.GetCenter().y

but it doesn't work either.

thanks!

5
Graphics / How do i get the position of the center of my sprite?
« on: August 26, 2011, 08:59:55 pm »
Hello,

I want to get the position of the center of my sprite, so i have tried the following:

pac.SetCenter(0.5*BLOCKSIZE, 0.5*BLOCKSIZE);

But then when i use the pac.GetPosition().x/y it doesn't give me the center of the sprite, instead it gives me the upper left corner of the sprite.

How can i change this to work?

thanks

6
General / Pac man game
« 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.

7
General / Pac man game
« 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 :\

8
General / Pac man game
« 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 ?

9
General / Pac man game
« 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. :\

10
General / Pac man game
« on: August 13, 2011, 08:00:12 pm »
Quote from: "SCPM"
Casting to int ought to merely truncate the number, not round it up or down.  But I think my mistake is that pac.GetPosition gets the top-left x/y coordinate of the sprite by default, when you really need the sprite's center.  You would have to use pac.GetCenter().x/y (which you would first need to transform to global coordinates).


I understand now!
But, i'm trying to undertstand how to ue the pac.getcenter, and how to transform to global coordinates, i know that first i need to use the pac.setcenter right? With something like (width/2, height/2)...

Could you please give me some tips?

11
General / Pac man game
« on: August 13, 2011, 02:36:18 pm »
Quote from: "SCPM"
Quote from: "gl0w"
Quote from: "Vit"
Pac-Man is tile-based; your array should be the size of your tile grid. For example, if each of your tiles was 20x20 pixels, and your screen size was 640x480, your tile grid would be 32x24 tiles. Each element in your array would then represent a 20x20 square on the screen.
When you want to move Pac-Man on the screen, you'll need to find out which tile he'll be moving to first. For example, assuming your tile array starts from the top-left, to move right you'll need to check board[pacman.x + 1][pacman.y]. If the element is passable, you can start moving him into the tile; otherwise, do nothing (as he's trying to move into a wall).


Hello,

Could you please tell me what do you mean by "board[pacman.x + 1][pacman.y]" is the position X and Y on the screen? if yes, how can i compare a float number with a integer on the board? I'm not understanding.

Could you kindly explain?
thank you.


Hello:
You would do something like this:
Code: [Select]
if (board[int(PacMan.GetPosition().x/tileWidth) + 1][int(PacMan.GetPosition().y/tileHeight)] == 0)  // Where 0 denotes a passable tile
       // Code for moving PacMan to the right;

As you can see, by wrapping the PacMan.GetPostion().x/y values with int( ), you can cast the floats as int.  The formula will allow you to get the square Pac-Man is on.  For example, on a 640x480 screen with a grid of 32x24 tiles and PacMan's x/y at 100,78, PacMan is at square board[3][3].  The code will check if board[4][3] is a passable square, and if it is, allow PacMan to move there.  I hope that helps!


Hello SCPM,

First, thanks for your help! Actually i was already doing that.
The problem is that sometimes when converting to int (pac.GetPosition().x/BLOCKSIZE) it convers the number up, and sometimes down, so, sometimes, the pacman two tiles before hit the wall, it stops, and sometimes he dont. Because the number was rounded to 1, when the pacman is actually on position 2... do you understand what i mean?

note: i'm using the pac.Move(0, -MAX_SPEED); function to move the pacman, is that okay? or there is better option to do it?

Thank you and regards

12
General / Pac man game
« on: August 12, 2011, 11:53:06 pm »
Quote from: "Vit"
Pac-Man is tile-based; your array should be the size of your tile grid. For example, if each of your tiles was 20x20 pixels, and your screen size was 640x480, your tile grid would be 32x24 tiles. Each element in your array would then represent a 20x20 square on the screen.
When you want to move Pac-Man on the screen, you'll need to find out which tile he'll be moving to first. For example, assuming your tile array starts from the top-left, to move right you'll need to check board[pacman.x + 1][pacman.y]. If the element is passable, you can start moving him into the tile; otherwise, do nothing (as he's trying to move into a wall).


Hello,

Could you please tell me what do you mean by "board[pacman.x + 1][pacman.y]" is the position X and Y on the screen? if yes, how can i compare a float number with a integer on the board? I'm not understanding.

Could you kindly explain?
thank you.

13
General / Re: Ghost pathfinding for Pacman help please.
« on: August 10, 2011, 10:47:22 pm »
Quote from: "Mr Random"
Hi guys I've been making a simple game of pacman. Currently I have the map, Pac-pills, Pac-man, Movement and Powerpills in the game all working as intended.

I'm trying to implement my first ghost and get him fully working before worrying about the others

I really need help making my ghost chase Pacman, After some research I'd like to use Dijkstra's algorithm and nodes but I cant figure out how to implement these into pacman.

I've found several tutorials that show how to use the algorithm, finding a path between 3 or 4 nodes.
 
The main things I'm having problems with is giving a node a position in my map, how to make the ghost move according to the nodes positions and how to detect which node is closest to the player.

Any help would be appreciated.


Hii,

I'm trying to make a pacman game aswell, and i'm getting difficult making the map, and let or not the pacman hit the walls. Could you please share your code? i'm using an array representing my screen. And i have 1, and 0 on the array, 1 represents a wall...

Any help would be appreciated.

thank you!!

14
General / Pac man game
« on: July 25, 2011, 02:41:23 pm »
Anyone can give me some tips?

THank you!

15
General / Pac man game
« on: July 21, 2011, 12:49:40 am »
Hello guys,

I have some progress in my pacman game.

But it's not working as expected yet.

I'm working on the pacman labyrinth.

This is what i have for check if the pacman hits the wall or not.

(not the entire code)
#define BLOCKSIZE 32 //size of my pacman sprite
#define MATRIX_WIDTH 640/BLOCKSIZE // 640/480 is the size of my screen
#define MATRIX_HEIGHT 480/BLOCKSIZE

int tabuleiro [MATRIX_WIDTH][MATRIX_HEIGHT];  //board


so i load a map from a file with 0, and 1 into the array
Code: [Select]
void loadMap(int number)
{
int x=0;
int y=0;
string line;
ifstream map;

switch(number)
{
case 1:
map.open("mapa1.txt");
while(map && y<MATRIX_HEIGHT)
{
getline(map,line);
while(x<MATRIX_WIDTH)
{
tabuleiro[x][y]=line[x]-'0';
x++;
}
y++;
x=0;
}
}
map.close();
}


i draw a wall in the screen from the position on the array

Code: [Select]
for(int x=0;x<MATRIX_WIDTH;x++)
for(int y=0;y<MATRIX_HEIGHT;y++)
if(tabuleiro[x][y] == 1)
{
Wall.SetPosition((float)(x*BLOCKSIZE),(float)(y*BLOCKSIZE));
App.Draw(Wall);
}


then i check if the pacman goes into a wall by a position of the pacman, and checking if the position in the array have a 1 (wall)

Code: [Select]
void movePac(int direction, float ElapsedTime)
{
// Desenhar image pac correspondente no ecrã
setImage(direction);

int x= (int)(pac.GetPosition().x/BLOCKSIZE +1);
int y= (int)(pac.GetPosition().y/BLOCKSIZE +1);
float x_x= (pac.GetPosition().x/BLOCKSIZE);
float y_y= (pac.GetPosition().y/BLOCKSIZE);
std::stringstream stream;
stream << "x:" << x_x << "-y:" << y_y << "Wall: " << tabuleiro[x][y];
string st;
stream>>st;
textoPontos.SetText(st);
textoPontos.SetPosition(300, 400);

switch (direction)
{
case UP:
if ((tabuleiro[x][y-1]!=WALL)) //
pac.Move(0, -MAX_SPEED * ElapsedTime);
break;

case DOWN:
if ((tabuleiro[x+1][y]!=WALL))
{
pac.Move(0,  MAX_SPEED * ElapsedTime);
}
break;

case RIGHT:
if ((tabuleiro[x+1][y]!=WALL))
if (pac.GetPosition().x + 35 < 640)
pac.Move(MAX_SPEED * ElapsedTime, 0);
//pac.SetPosition(pac.GetPosition().x + 1, pac.GetPosition().y);
else
pac.SetPosition(0, pac.GetPosition().y);
break;

case LEFT:
if ((tabuleiro[x-1][y]!=WALL))
if (pac.GetPosition().x + 35 > 0)
pac.Move(-MAX_SPEED * ElapsedTime, 0);
else
pac.SetPosition(640, pac.GetPosition().y);
break;

}
}


what happens is that sometimes it detects a wall and stops, and sometimes he dont. And, sometimes he stops a position after the wall.

Well, maybe there is a better way to do it...
I appreciate your help :)

Pages: [1] 2
anything