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

Pages: 1 ... 217 218 [219] 220 221 ... 223
3271
Graphics / Re: [Beginner] Help with Bouncing Circles
« on: February 11, 2014, 07:05:28 pm »
It's not about "solving" it; it's about the level of accuracy you desire. It can't be 100% physically perfect, ever. It's just how close to that you want to go. The closer to perfect you go, the complicated it can become.

3273
Graphics / Re: [Beginner] Help with Bouncing Circles
« on: February 11, 2014, 05:32:19 pm »
Thanks Golden Eagle, for solving the problem :)
You're welcome.

But I noticed something like a glitch:
Why is it still not perfect? Now it's the same code as in the tutorial, isn't it?
I think you answered your own question  ;)
It's not perfect because the tutorial isn't perfect. The tutorial shows how to deal with collisions with discs and which angle and velocity they should be after a collision. One of the things it doesn't cover (if I remember correctly) is when the velocity is so large that they simple pass over one another. Obviously, that's covered by testing in the tiniest of increments at a time, which can mean needing to slow down your discs. Try it with small discs that move quickly and they'll just skip over each other  ;)
Also, when the discs go into the window edge, they are just slid back into the window at a tangent of the window's edge rather than calculating where the disc should be after bouncing.

3274
That's true for a lot of situations. However, sometimes you need to test what is going on right now, rather than what has happened in the past.

3275
Window / Re: sf::Event::Close not fired in fullscreen mode.
« on: February 11, 2014, 03:17:28 pm »
I may be wrong but I don't think Windows actually sends "close window" events to an application that is fullscreen rather than in a window. If you're using Windows, that could be the reason.

3276
Window / Re: Window does not activate if you click inside it
« on: February 11, 2014, 03:12:27 pm »
This is not fixed yet. Why isn't there a new release? Or some info/guide about this on the download site?

Quickest way to fix?
Look at my post above if you need a temporary workaround (assuming it's for Windows) to make it convenient for yourself during testing.
That said, you should probably build from the Github source if you want it to be fixed internally. I'd do it too if I didn't have enough problems building the released version last time. Me and my using stupid VS2013  >:(

3277
Graphics / Re: [Beginner] Help with Bouncing Circles
« on: February 11, 2014, 03:06:09 pm »
Your Thor library does look awesome. I'd almost certainly use it if I didn't want to work as low-level as possible to learn what's going on (I like maths etc.).
"Low as possible" means avoiding the lowest form - Windows programming. Thanks, SFML ;)

3278
Graphics / Re: [Beginner] Help with Bouncing Circles
« on: February 11, 2014, 01:45:42 am »
His code is line for line from a tutorial so I thought it'd be better for him to actually see how the tutorial code works first so I fixed that. He should definitely start using vectors; not doing so is much more error-prone. However, if he'd have converted everything to use vectors and it didn't work, it would be harder to compare with the original tutorial to see what is wrong.

3279
Graphics / Re: Help with Tile collisions
« on: February 11, 2014, 01:38:03 am »
except that it shouldn't be a floating point value...
Oh wow! I didn't even notice that gop was using float there. He did mention later that I should've put said which types to use for the code.

It was supposed to be helpful and point you in the right direction rather than write the program for you. I obviously overlooked the possibility of using floating point numbers for storage of an array index.

I shall punish myself now.

Gop, you should have a look at the tile map class that you said you adapted. You should also check the file itself...  :P

EDIT: If you changed that code, you'll just be getting random tiles to test. This could be any tile so could deceptively look like it's fixed the other, underlining problem. Trust me; keep that and find out what else is making it not work  ;)

3280
Well, you also get key released events, so it is perfectly possible to keep track of whether a key is still pressed (modulo some event delivery/processing time, but that's negligible).
Oh, that's true. Rarely very useful though  :P

3281
Window / Re: Insert and remove text not working with Events
« on: February 10, 2014, 11:36:03 pm »
std::string &remove_last_char(std::string &text)
{
        text.erase(text.size() - 1, 1);
        return text;
}
 

EDIT: Looks like Jesper beat me to it!  :)

3282
Graphics / Re: Help with Tile collisions
« on: February 10, 2014, 11:28:34 pm »
I've tested everything
Obviously not.

I'm convinced that there's something weird with the way the computer treats where the player is located at on the grid.
The calculations that I gave you will only go far as to tell you which tile (0, 1, 2, 3 in your map) is under a specific coordinate. You've been using the player sprite position for this; it's likely that your sprite's origin is at the top-left corner of the sprite so will "be in" a tile when the top-left corner is. To see if the centre is in a tile, you'll need to offset the value.

What I noticed is that a collision only happens when the player is touching the bottom of the tile. I really just want a collision which returns true if any of the sides are touched by the player.
This can also be caused by the effects of the origin being at the top-left. You can either add half of your sprite's size to its position when you calculate it's grid position, or you can just change where its origin is:
player.sprite.setOrigin(player.sprite.getLocalBounds().width / 2, player.sprite.getLocalBounds().height / 2);
You only need to do that once.

3283
Window / Re: Insert and remove text not working with Events
« on: February 10, 2014, 11:15:45 pm »
So, same result?

I'd guess, then, that it could very well be something in the remove_last_char() and insert_last_char() functions.
Can we see those?  ;D

3284
Graphics / Re: Help with Tile collisions
« on: February 10, 2014, 11:10:15 pm »
I agree that it's a good idea to check your other functions to make sure they are passing x/y values to the relevant x/y.
Your code is in many fragments here. It's impossible to try it. Why not attach it?

3285
Graphics / Re: [Beginner] Help with Bouncing Circles
« on: February 10, 2014, 11:03:16 pm »
It seems that the problem you were having is that you were assigning the new speeds as soon as you'd calculated them. This means that you calculate a new xSpeed and use the new one in the calculation for xSpeed[j]. It needs to be the same value for both calculations. You have to calculate all of the new velocities before assigning them - at the same time! It does show this in that tutorial :p
if (Collision(Ball[i].getPosition(), Ball[j].getPosition()))
{
        const float tempXSpeedI = newVelX1(xSpeed[i], xSpeed[j]);
        const float tempYSpeedI = newVelX2(xSpeed[i], xSpeed[j]);
        const float tempXSpeedJ = newVelY1(ySpeed[i], ySpeed[j]);
        const float tempYSpeedJ = newVelY2(ySpeed[i], ySpeed[j]);
        xSpeed[i] = tempXSpeedI;
        xSpeed[j] = tempYSpeedI;
        ySpeed[i] = tempXSpeedJ;
        ySpeed[j] = tempYSpeedJ;

        Ball[i].move(xSpeed[i] * dt, ySpeed[i] * dt);
        Ball[j].move(xSpeed[j] * dt, ySpeed[j] * dt);
}

It's still not perfect but they bounce now  ;)

Pages: 1 ... 217 218 [219] 220 221 ... 223