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

Pages: 1 ... 3 4 [5]
Graphics / Re: Spawning bullets
« on: May 02, 2012, 10:45:57 am »
I've never done something like this and might be wrong, but for me the most practical way would be to create a bullet object upon firing which has speed and angle (or a vector) attributes (given it is 2D), and store it into some container. You simply go through the whole container each time and do the movement, if the bullet hits something the instance gets destroyed and removed from the container.

That is, of course, only if you need the bullet to be visible, otherwise you simply calculate the place of impact and show the animation/whatever there.

P.S.: I'm a Beginner, so idk.

Feature requests / Re: sf::Text coloring chosen characters?
« on: April 29, 2012, 07:16:54 pm »
Why don't you simply post your solution? You might even get a hint or two.

Graphics / Image::Copy causing crash.
« on: May 03, 2011, 04:57:50 pm »

Okay, after deleting my first thread this will be my new first one.  :D

Once again, I'm quite new to programming, so please excuse if my problems might be caused by my wrong understanding.

My problem is the following:
I'm trying to create an Image of variable size that copies certain information from a "dummy-image". My problem occurs while trying to slice the dummy into four parts and copy each part into the corresponding corners of the new Image.

My actual try looks something like this:
Code: [Select]
NI ... The new (variable) image.
DI ... The dummy.
NW/NH ... New image Width/Height
DW/DH ... Dummy Width/Height

NI.Copy(DI, 0, 0, rect(0, 0, DW/2, DH/2))
NI.Copy(DI, NW-DW/2, 0, rect(DW/2, 0, DW/2, DH/2))
NI.Copy(DI, 0, NH-DH/2, rect(0, DH/2, DW/2, DH/2))
NI.Copy(DI, (NW-DW/2)-2, NH-DH/2, rect(DW/2, DH/2, DW/2, DH/2))

The dummy looks like this:

And the code is creating this:

The crash seems to be caused by the last line (responsible for the box in the lower right corner). Like this, there is an offset of 2 pixels being drawn, but if I change the
Code: [Select]
(NW-DW/2)-2 in the last line into
Code: [Select]
NW-DW/2 the program will crash.

Am I handling the coordinates wrong? If so, why does it work perfectly fine for the other three boxes?

I'm using SFML2 on Windows 7 64 Bit.


Oh, the last line from the actual code:
Code: [Select]
ImgBackground.Copy(*DummyBackground, (ImgBackground.GetWidth() - DummyBackground->GetWidth()/2)-2, ImgBackground.GetHeight() - DummyBackground->GetHeight()/2, sf::IntRect(DummyBackground->GetWidth()/2, DummyBackground->GetHeight()/2, DummyBackground->GetWidth()/2, DummyBackground->GetHeight()/2));

Pages: 1 ... 3 4 [5]