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 ... 221 222 [223] 224 225 226
3331
Window / Re: Insert and remove text not working with Events
« on: February 10, 2014, 07:29:52 pm »
Try this for your hex for backspace:
0x00000008

3332
Window / Re: OpenGL Context Flashes on Screen when Created
« on: February 10, 2014, 07:25:18 pm »
Does it still flash white if you do this:
testWindow.create(sf::VideoMode::getDesktopMode(), "TEST WINDOW", sf::Style::None);
window.clear(sf::Color::Black);
window.display();

3333
Graphics / Re: Help with Tile collisions
« on: February 10, 2014, 07:17:52 pm »
Do you only have one tile that would be tested for collision? Could it be "colliding" with a different tile that should be collided with?

That code is fine as long as your tile data is an array which goes through each x before y (i.e. like the tutorial tilemap does). It also relies on the fact that your tile map is located at the top-right corner, the tile size you use to calculate the grid sizes is correct, and the grid size is correct.

How are you testing this? Are you placing a sprite in one place explicitly, running the code, checking to see if text is output, and then ending the code. Or, are you moving the sprite without closing the program?

3334
Window / Re: Insert and remove text not working with Events
« on: February 10, 2014, 07:10:59 pm »
Wouldn't this make more sense:
else if(event.type == sf::Event::TextEntered)
            {
                if(event.text.unicode != 0x000008)
                {
                   insert_last_char(text, event.text.unicode);
                   showing_text.setString(text);
                }
                else
                {
                    remove_last_char(text);
                    showing_text.setString(text);
                }

3335
Graphics / Re: [Beginner] Help with Bouncing Circles
« on: February 10, 2014, 06:10:02 pm »
I'm not sure I fully understand the code here, but why are you moving the balls in the direction they were travelling before the collision, after finding that they've collided? Could it be possible that the new speeds should be calculated before the balls get moved?

3336
Graphics / Re: [SOLVED] Help with Tile collisions
« on: February 10, 2014, 05:51:01 pm »
it still returns true and thinks that it's on the same tile as the player was on (400, 300).
How do you know it thinks that? How are you testing to see if it's still true?

I'm using the same information you have given me regarding this collision.
The information I gave you was to detect which tile the origin of the sprite was in (so you could work out whether it was supposed to collide or not). For the actual collision detection, you would need to test the boundary boxes for the sprite against the tiles' boundary boxes.

3337
General discussions / Re: Is SFML right for me?
« on: February 10, 2014, 03:58:14 am »
It can be. It's easy to use and really powerful. It manages to abstract away a lot of the really low-level stuff but still allows you to get down there if you need to.
One thing to note is that SFML doesn't do 3D. If you don't need 3D, or you can use OpenGL (you can use OpenGL 3D graphics in a SFML window along with SFML's 2D graphics), I'd recommend sticking it out with SFML.

3338
Graphics / Re: [Beginner] Help with Bouncing Circles
« on: February 10, 2014, 03:53:32 am »
Why don't you simply write it like this?
if (Collision(Ball[i].getPosition(), Ball[j].getPosition()))
Or just do that :p Much simpler ;)

3339
Graphics / Re: [Beginner] Help with Bouncing Circles
« on: February 09, 2014, 09:22:42 pm »
Are you sure that I can just remove it? It would give me a different result...
It wouldn't. You're subtracting zero. Removing that subtraction would change nothing. The (mass + mass) must stay, however, and leaving in the (mass - mass) won't harm anything so it's possibly safer to leave it there.

... the problem with the sticky balls
You have the vector values the wrong way around for the collision. X comes before Y.

Use:
if (Collision(
  sf::Vector2f(Ball[i].getPosition().x, Ball[i].getPosition().y),
  sf::Vector2f(Ball[j].getPosition().x, Ball[j].getPosition().y))
rather than:
if (Collision(
  sf::Vector2f(Ball[i].getPosition().y, Ball[i].getPosition().x),
  sf::Vector2f(Ball[j].getPosition().y, Ball[j].getPosition().x))

3340
General / Re: Creating a tilemap from image pixel data?
« on: February 09, 2014, 07:50:21 pm »
You might also consider using a map editor like this free one: Mappy

3341
Graphics / Re: [Beginner] Help with Bouncing Circles
« on: February 09, 2014, 07:39:18 pm »
It's mass1 - mass2. It's the difference between the two masses. At the moment (and I didn't think I'd have to point this out explicitly) you are subtracting something from itself and it will always be zero. If the circles were to have different masses, you would use them there, but since they're all the same, you can remove (mass-mass) since it is 0.

The vectors (i.e. sf::Vector2f) are for the positions and velocities so that x and y can be conveniently in one variable. In some cases, calculation can be applied to the vector rather than directly to its components.

3342
Graphics / Re: [Beginner] Help with Bouncing Circles
« on: February 09, 2014, 04:56:52 pm »
I think that mass might be the only value that shouldn't be a vector since it's a single value. :p Vectors (in this case) are for positions, velocities etc.

As for your calculations, Nexus pointed out a tiny bit of your code that you should really study:
(mass - mass)
What does it do?

3343
Graphics / Re: Beginner Tile Map 2d
« on: February 09, 2014, 04:01:31 pm »
You could create your own. It only needs an image with tiles of size 32 x 32. Since I'm feeling generous, I'm going to provide you with a simple image that should work with that code.
You will have to put save it to your computer, put it in the correct folder/directory, and rename the image or change the filename ("tileset") in this line of the code:
if (!map.load("tileset.png", sf::Vector2u(32, 32), level, 16, 8))


Please note that I am no artist.

3344
Graphics / Re: Vertex array not drawing all points
« on: February 09, 2014, 03:34:34 pm »
Points (or lines) expand half their width (0.5) in each direction, the coordinate that you give is the center. So if you want your point/line to fully cover a pixel, you must give its center position, which is xxx.5.
That explains everything. Thanks :)

3345
General / Re: Arkanoid tutorial errors
« on: February 09, 2014, 03:05:30 am »
I just played around with your constants/window creation code and it turns out that the only thing that you would need to change in it would be to make your constants the right type :p (i.e. unsigned int instead of int)
const unsigned int windowWidth{ 800 }, windowHeight{ 600 };

Also, you're welcome :)

EDIT:
This works too and looks tidier ;)
using namespace sf;
const VideoMode windowSize{ 800, 600 };
// ...
RenderWindow window{ windowSize, "Arkanoid - 1" };

Pages: 1 ... 221 222 [223] 224 225 226