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

Pages: [1]
1
Graphics / Localize mouse position
« on: December 23, 2008, 10:42:17 pm »
Hi everybody,

I want to find out if my mouse is about an area or an object (with other words, a sprite  :) ).
(this sprites are not made by myself!!!)

An example: Here the mouse can be about the Tile 1, 2 or about the empty space... the thing that could make it a bit different is, that I don´t want to use fix coordinates in my source, like
Code: [Select]
(Cursor.GetPosition().x >= 200)

So, I tried a few things, but without any succes^^
Code: [Select]
if((Cursor.GetPosition().x == Sprite1.GetPosition().x) && (Cursor.GetPosition().y == Sprite1.GetPosition().y))
Why does it not work?

Thanks in advance!

2
Graphics / Problem with sf::IntRect
« on: November 30, 2008, 04:58:05 pm »
Quote from: "Hiura"
Rect2 should be :
Code: [Select]
sf::IntRect Rect2(45, 0, 90, 45);


Thanks for your quick answer, it works fine. But i don´t know why  :D
Could someone give me a brief statement which parameter I´m using for which position, please?
Thank you very much!

3
Graphics / Problem with sf::IntRect
« on: November 30, 2008, 04:11:56 pm »
hi everybody again  :D

I´m sorry that I´ve to ask quite a lot, but sometimes I´m unable to find a possible solution.

This time I want to load some images from a sprite sheet, like this...


For this I use the sf::IntRect function... but I don´t know how to set the parameters. After I tried a few things, I allready know that the two last parameters give the size of the sprite.
So I guess the other two are standing for the position, but this won´t work
Code: [Select]

sf::IntRect Rect(0, 0, 45, 45);   /* Everything allright... the first sprite is shown.*/

sf::IntRect Rect2(45, 0, 45, 45); /*This should cut out the second sprite, but when I display it, it appears just a black screen */

sf::IntRect Rect(-45, 0, 45, 45); /*What happens now, you can see in the screenshot below...





So, what have i to do, that the second sprite is shown on the screen?

Thanks in advance!

4
Graphics / Not all tiles from TileMap are shown
« on: November 30, 2008, 03:51:50 pm »
Thank you, now it is working.

But, there is something in your code thant won´t work.

Code: [Select]

Sprite TileSprite[2];

TileSprite[0].LoadFromFile ( "grass.png" );
TileSprite[1].LoadFromFile ( "dirt.png" );


I know, this was just an example, but you aren´t able to load an image with an Sprite an things like
Code: [Select]

sf::Image Image;
sf::Sprite Sprite[2](Image);

couldn´t work as well.

I did it this way
Code: [Select]

for(int y = 0; y < mapHoehe; y++)
{
for(int x = 0; x < mapBreite; x++)
{


if(TileMap[y][x] == 1)
{
Tile1.SetPosition(x*TILE_SIZE, y*TILE_SIZE);
Window.Draw(Tile1);
}
if(TileMap[y][x] == 2)
{
Tile2.SetPosition(x*TILE_SIZE, y*TILE_SIZE);
Window.Draw(Tile2);
}


Nearly the same, so thank you very much!  :D

5
Graphics / Not all tiles from TileMap are shown
« on: November 30, 2008, 01:16:47 am »
Hi everybody,

I tried to create a little tilemap. i thought it should be no problem, but unfortunately nothing works really well  :) .

At first, my code....
Code: [Select]

//of course i don´t post everything
int TileMap[mapHoehe][mapBreite] =
{
{1,1,1},
{1,2,1},
{1,1,1},
};

for(int y = 0; y < mapHoehe; y++)
{
for(int x = 0; x < mapBreite; x++)
{
if(TileMap[y][x] == 1)
Map1 = true;
if(TileMap[y][x] == 2)
Map2 = true;
}
}

/* In the main-loop */

if(Map1 == true)
           Window.Draw(Tile1);
       
if(Map2 == true)
           Window.Draw(Tile2);


But if I start the program, just one tile is shown, instead of 9.
Thanks for your help!

6
Graphics / Strange Collision
« on: November 23, 2008, 06:59:01 pm »
Quote from: "wizardofoz"
Here you are checking X position for a possible collision...and the Y ?


I´ll check the y position when the player moves up or down... but I had the same thought and tried a combination with GetPositon().y / ..., but I got the same result as you can see on the second screenshot, just this time with the y-axis (and of course the x-axis).

7
Graphics / Strange Collision
« on: November 23, 2008, 06:01:00 pm »
Hi everyone,

first at all - I really like the SFML, but sometimes I got problems that gives me a headache  :(

I want to test the collosion between two sprites. Actually no problem with functions like for example Player.GetPosition().x or Player.GetSize().x.

But unfortunately it works rather complicated...

this is my code
Code: [Select]
if(Window.GetInput().IsKeyDown(sf::Key::Right))
if(Player.GetPosition().x + Player.GetSize().x <= Wall.GetPosition().x)
{
//not the important part...
if(Player.GetPosition().x <= 1024-Player.GetSize().x) Player.Move( 400*Window.GetFrameTime(), 0);
}



The red one should be the player, and the wall is the fence
There everything works perfect... I´m not able to move the "player" to the right side.


But there I´m also not able to move the player to the right side? Why?
thanks in advance

8
SFML wiki / Translate French pages into English.
« on: November 22, 2008, 10:41:32 pm »
Yes, would be really nice  :D

9
Graphics / Animation of some Sprites
« on: November 22, 2008, 07:37:11 pm »
Hey, thanks very much for your quick answer... now this part with the Sprite ist working perfect  :D
But it´s not possible to solve the other problem (where I write something in the console) with your proposition.
But it don´t get this problem just with the console, when I want to realize something like a jump funciton, I would write
Code: [Select]

if(Window.GetInput().IsKeyDown(sf::Key::Up))
{
          Player.Move(0, -10);
}

//a very simple solution... gravitation and other things will follow

.

But because of the "game"-loop, the Player.Move part is executed as long as I hold down the arrow key. So, is there a function to deactivate keys for a certain time - but this is perhaps really not the best solution. Over and over again I don´t know what to do  :oops:

thanks in advance!

10
Graphics / Animation of some Sprites
« on: November 19, 2008, 11:07:46 pm »
Quote from: "Wizzard"
Actually, unless you were using a helper library, it's the same thing as SDL.

In my opinion, the function "SDL_BlitSurface" is very usefull for programming animations...

Quote from: "Wizzard"

You should really just start toying with it; nothing ever makes sense to me until I use it for myself.

Yes, I know... I´m using the SFML since 3 or 4 days and of course there is still a lot to learn. Now I try to do a few things, which I would use in a game later (for example collision, animation or some easier things^^) - sometimes it is really easy to realise something with the SFML, but unfortunately not always. Thats why I asked a lot of things :)

Quote from: "Wizzard"

It would be easier to code; people just use sprite sheets because they're easier to edit.

Ok, thanks... than I´ll try this  :D


EDIT:
I´m very sorry that I´ve ask something (probably stupid easy) again :oops: , but I don´t find a good solution.

I want to do something like this:

Code: [Select]

if(Window.GetInput().IsKeyDown(sf::Key::Space))
      Window.Draw(sprite);


Ok, if I now press Space, the sprite appears until I release the space button. Similar situation when I use std::cout to write something in the console, the writing is shown again and again in the console while I´m holding the space button.
I think this is why I set my code into the Main-Loop, but out of the loop this piece of code is (of course) not working.
But I want that the sprite doesn´t disappear after I release the key. Or that the writing appears just one time...
You´re probably annoyed of my questions, but I´m not to lazy to try something by myself, it´s just that I don´t find a good or possible solution   :(

11
Graphics / Animation of some Sprites
« on: November 19, 2008, 09:51:49 pm »
Quote from: "Laurent"
You probably need to practice more before doing such things ;)


Yes, I think I´ll do this :D
And thanks for the Link!

Unfortunately it´s more complicated to make an animation with the SFML, as with the SDL...

Do you think it would be easier if I use for every animation frame an own picture instead of a sprite sheet?

12
Graphics / Animation of some Sprites
« on: November 19, 2008, 08:05:53 pm »
Thank you Laurent, now this works fine  :D

But now I got another problem (actually the mainly problem). When I used "SetSubRect", I can display one sprite of my sprite sheet on the screen, but I need an animation. Perhaps I´m not good enough at programming, but the only way (if you ask me) to animate it, would be to change the parameters of "sf::IntRect Rect( )", while the programm is running? As far as I know, this isn´t possible. So, what have I to do?

Thanks in advance!


P.S.: This would be a really interessting topic for a Tutorial, because I think that animations are one of the importants things for a (halfway) good looking game! (No matter if it is a RTS oder a simple Space Shooter!)

13
Graphics / Animation of some Sprites
« on: November 19, 2008, 02:59:42 pm »
Thanks for your answer, but unfortunately I don´t understand a few things...

Code: [Select]

sf::Sprite::SetSubRect(IntRect& SubRect);

That´s the definition...

Well, so I tried this
Code: [Select]

//Open pic with fstream... no problem
sf::Image Image;
if(!Image.LoadFromMemory(memory, size));

sf::IntRect Rect(64, 0, 64, 64); //<- Here I´m not really sure, if this are the real coordinates... I´ll see!

sf::Sprite::SetSubRect(Rect& Image);


But that doesn´t work.
As you probably can see, I´m doing something really wrong... a little bit help would be nice  :)

Thanks in advance!
woskaz0n

14
Graphics / Animation of some Sprites
« on: November 17, 2008, 08:46:43 pm »
Hi all,

befor I used the SFML, I tried to code some games with the SDL (and a little Framework).
Now I want to write a little programm, where the Player can move his character on two axes with the keyboard (the basic function of an jump´n´run game). But now I got the problem, that I don´t know, how I have to animate the Player. I allready solved that problem when I used the SDL with a little Framework, but now I want to write my programm, just with the API!

Some pictures to illustrate my problem:


Well, in this picture the Plane should lean to the right side, when the right key is pressed and to the left, while the left key is pressed. When no key is in action, the middle frame should appear on the screen! I hope I could explain this clearly enough.


Or perhaps like in this example, where the asteroid should be moving all the time in a loope.

I hope you can help me, beacause I need this animations for a lot of things I want to do.
Thanks in advance!

PS.: And sry if my english is too terrible.

Pages: [1]