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 - paulomag2106

Pages: [1] 2
1
Graphics / Re: Tilemap collision with player
« on: January 08, 2014, 01:13:38 pm »
Yeah, I'm starting to get that =/

2
Graphics / Re: Tilemap collision with player
« on: January 08, 2014, 12:34:06 am »
hmm, the thing with the negative coordinates I believe won't be a problem, since my game is intended to be divided in "rooms", in a way that the player will never be able to be at a position LESS than (0, 0), because these rooms will be all closed up by tiles, except for "doors" or passages into other rooms.

the part about sliding when up/down walls when pushing the player diagonally might also not be a problem, since in the end he won't be able to simple walk diagonally - he will either be jumping or falling.

apart from that, I think I understand what you're going for in this code/pseudocode :D. I'll see what I can get done with it. Thanks again! Oh, and sorry for the lack of abstraction with data structures, it's a bad habit for sure. Gotta make a cleaner code Oo...

Cheers!

3
Graphics / Re: Tilemap collision with player
« on: January 07, 2014, 08:59:19 pm »
oh, sorry, right and bottom collisions are working correcly, and top and left are glitchy. sorry bout that Oo...

4
Graphics / Re: Tilemap collision with player
« on: January 07, 2014, 07:49:40 pm »
Hey, eigenbom, so I tried this function below:
void newMove(Player& player, int& levelWidth, const int* level)
{
       
        player.tileX = player.getPosition().x/32;
        player.tileY = player.getPosition().y/32;

        leftTileUp = player.tileX - 1 + player.tileY * levelWidth;
        leftTileDown = player.tileX - 1 + (player.tileY + 1) * levelWidth;
        rightTileUp = player.tileX + 1 + player.tileY * levelWidth;
        rightTileDown = player.tileX + 1 + (player.tileY + 1) * levelWidth;
        underTile = player.tileX + (player.tileY + 2) * levelWidth;
        topTile = player.tileX + (player.tileY - 1) * levelWidth;

        // get input
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
        {
                player.moveVecX = -6;
                player.tileX = player.getPosition().x/32;
        }
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
        {
                player.moveVecX = 6;
                player.tileX = player.getPosition().x/32;
        }
        else
                player.moveVecX = 0;

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
        {
                player.moveVecY = -6;
                player.tileY = player.getPosition().y/32;
        }
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
        {
                player.moveVecY = 6;
                player.tileY = player.getPosition().y/32;
        }
        else
                player.moveVecY = 0;
       
        // getTiles
        if(player.moveVecX < 0 && (level[leftTileUp] != 0 || level[leftTileDown] != 0))
                player.moveVecX = 0;
        else if(player.moveVecX > 0 && (level[rightTileUp] != 0 || level[rightTileDown] != 0))
                player.moveVecX = 0;
        if(player.moveVecY < 0 && level[topTile] != 0)
                player.moveVecY = 0;
        else if(player.moveVecY > 0 && level[underTile] != 0)
                player.moveVecY = 0;

        // move player
        player.move(player.moveVecX, player.moveVecY);
}
 

and now, the player box KINDA moves ok... it detects collision to his right ok, and at his top ok, right and bottom is still glitchy (I THINK it's because of floor/ceil rounding of player position to tileX/tileY int value).

What do you think? I sorta feel like I'm close to an answer, but I think a few variables are still missing, or something...

5
Graphics / Re: Tilemap collision with player
« on: January 07, 2014, 04:43:43 pm »
WOW, that's totally cool! I bet many people have the same doubts I've been going through, and it's really nice to see a code example start-to-finish of a tilebased, topdown game.

Looks truly amazing, eigenbom.

By the way, I took a quick look at the tigsource post you made for Moonman, and I gotta say: you've got something FANTASTIC on the works right there, sir! The liquid mechanics remind me of Starbound (did you get inspired from them, or they from you? :))!

6
Graphics / Re: Tilemap collision with player
« on: January 07, 2014, 12:11:56 am »
Dude, I saw today a game you made in 2012 or something.... called Moon... moonman? I think it's something in those lines... I LOVE what you did with the water tiles (when you dig beneath them, and they fall like particles or something)!

I also saw in that post that you did something using Box2D in the game, but how did you otherwise do the collisions and tilemap drawing in that project? Totally brill!

By the way, I'm still scratching my head over your response... the names of classes and variables and the structure of the whole thing escape me. As I said, I'm still a beginner at this thing.

Anyway, I truly appreciate all the help, no matter my difficulties and such.

Cheers, man!

7
Graphics / Re: Tilemap collision with player
« on: January 06, 2014, 12:01:07 pm »
Oh, I see :D! So your Map2D class is somewhat like the "TileMap" class in the Vertex Array tutorial, right?

Thanks a million, eigenbom! Never thought I'd find someone so nice and helpful in a forum (though it seems that the SFML forums are full of helpful people).

Anyway, I'll give it a try, see how it behaves! Thanks, man!

8
Graphics / Re: Tilemap collision with player
« on: January 05, 2014, 02:19:32 pm »
Oh, sorry, when I asked what you meant, I was talking about the part "World& world" reference in the bool function...

what would that "World" class be?

Thanks!

9
Graphics / Re: Tilemap collision with player
« on: January 05, 2014, 12:58:01 pm »
sorry for annoying you so much, eigenbom, but when you say "bool RectOverlapsWorld(const sf::IntRect& rect, const World& world)" in the example code... what kind of class/struct is that?

because it is not a standart class from sfml library, nor did I declare it yet anywhere in my code, neither did you in your example... I'm confused =S...

10
Graphics / Re: Tilemap collision with player
« on: December 31, 2013, 04:03:31 pm »
Sorry I'm taking so long to answer. Between Christmas and New Year's, I haven't been too active with programming.

I KINDA understand your code, eigenbom, I guess I'll try to implement it to see if works... either way, you've been of much help!

I'll come back once I've tried it to say if it worked or not. If it DOES work, I'm sure a bunch of people might be interested in it ;)!

11
Graphics / Re: Tilemap collision with player
« on: December 23, 2013, 11:11:41 am »
What you described makes perfect sense. I believe that's how games like Flashback and Prince of Persia (the original) worked, right?

I'll try another way around it, though, cause I wanted to create something that allows free movement for the character.

But anyway, eigenbom, you were VERY helpful and on the spot with my doubts and questions, so I can only be ever thankful!

Cheers and Merry Christmas ^^!

12
Graphics / Re: Tilemap collision with player
« on: December 21, 2013, 04:23:05 pm »
Alright!! collision works PERFECTLY with the tileX tileY system! Hooray... Now, I need to find a way to make the player be able to move freely, other than in increments of *tile size*...

tileX and tileY have to be full integers in order to get level[tileX + tileY * tile size] correctly. And the player has to move in multiples of tile size, otherwise, he will collide with a tiny-micro-puny-map(is this a map made for ants?).

anybody got an idea how I could work around that =/?

Thanks, everybody, in advance.

13
Graphics / Re: Tilemap collision with player
« on: December 20, 2013, 01:00:43 pm »
wow, thanks a lot, eigenbom! you were very helpful!

i'll attempt to implement it on my "game". :D

14
Graphics / Re: Tilemap collision with player
« on: December 19, 2013, 07:47:51 pm »
I have another question TT_TT....

sorry for being such a noob, but... if, by following the tutorial, we have a 1 dimension array/list... how can I separate the X from the Y position of things when checking for collisions?

because following your example, and creating the TileUnderPlayer int, the X position interferes in the math, making the behavior of the object all weird Oo....

15
Graphics / Re: Tilemap collision with player
« on: December 19, 2013, 02:32:32 pm »
Thank you very much, eigenbom. I'll try to do this on my own code, and see if I can make my player move more freely instead of increments of Tilesize.

Anyway, it's a great start!

thank you!  :)

Pages: [1] 2