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 - Tex Killer

Pages: 1 ... 13 14 [15] 16 17
Feature requests / Pixel Manipulation
« on: December 08, 2011, 07:10:17 am »
I think he meant something like:

Code: [Select]
texture.GetPixel(x, y).SetColor(sf::Color::Black);
texture.GetPixel(x, y).SetAlpha(0.5);

With the Update method suggested by nitrix that could be done as well, but it is a little bit more difficult.

Graphics / Re: Questions on My First Tile Map
« on: December 08, 2011, 04:49:30 am »
Quote from: "justcolorado"
In the examples I saw here everybody was using Vectors
am I better off using a Vector, if so why?

It is common to use vectors on the list of tiles, but not on the map. The map usually is a multidimension vector, like you said, but it is usually of numbers, that represent positions on the list of tiles, so that the same number could be on multiple positions of the map. That way you would only have one sprite object for each different tile.

As of the second question, it is not advisable to use image alpha for collision, as it would be heavy for the processor. Usually you define manually where is the collision for each different kind of tile you have, then you use this information whenever you want to check for collisions.

Window / Switch RenderWindow from Windowed<->Fullscreen (v1.6)
« on: November 30, 2011, 09:53:29 pm »
I've just commented that what sbroadfoot90 might help you, you would just had to use the right command to get the events. I said that it was SFML 2.0 only, and I said that there was another equivalent method for SFML 1.6, just that.
Sorry if I sounded offensive, that was not my intention.

Window / Switch RenderWindow from Windowed<->Fullscreen (v1.6)
« on: November 30, 2011, 03:38:46 pm »
Quote from: "pkersey"
Thanks for your considerations, but sorry, I think your information is innacurate because, as I've reported previously, I've been using SFML 1.6. PollEvents() is SFML 2.0 only.

sbroadfoot90's information is still valid. You don't seem to have read this tutorial on the tutorial section:
PollEvents is just the 2.0 version of GetEvent.

About your problem, I'm sorry, but I cannot help.

Window / [SOLVED]Need sf::Clock to be more specific
« on: November 23, 2011, 05:28:58 pm »
Code: [Select]
int timer = FootImgClock.GetElapsedTime();
Code: [Select]
int timer = FootImgClock.GetElapsedTime() * 2;
and you will have 2 animation frames per second, instead of one.
But I think you should study more of the basics before attempting to do something.

Window / [SOLVED]Need sf::Clock to be more specific
« on: November 23, 2011, 05:28:01 am »
The measured time is a float representing the ammount of seconds that has passed. By putting it into an integer, you are cutting the smaller parts and taking only the integer part. If you want milliseconds, just multiply the float by 1000 before truncationg it into an integer.

General / how to create a grid?
« on: November 22, 2011, 03:05:06 pm »
So, lets put it into steps.

1) Load your image(s) containing the tiles. I suggest using one only image with all the tiles, and using the sprite to set the correct SubRect for each tile. That way, you will have an array of sprites, each representing one different kind of tile, and one image.
2) Create your map matrix. Usually, this is done using a matrix of numbers: each number representing one position of the sprites array. Lets supose that the tile on the second sprite of the array is on the second and third columns of the first line; The map matrix will have:
Code: [Select]
map[0][1] = 2;
map[0][2] = 2;

Remember that, as the positions start at 0, the second position is 1, and 2 is the third.
3) Loop though your map matrix, as you specified on your opening post, and print one sprite at each iteration. Don't forget to set the right position to the sprite before printing it, or else all of your sprites would be printed on the default position, one on top of the other.
3.1) To get the right sprite is easy:
If the number is zero, then we have no tile on the position... Nothing to be done. Any other positive number will give us the sprite by that formula:
Code: [Select]
sf::Sprite rightSprite = sprites[map[line][column] - 1];
We've put - 1 on the positions because they starts at 0 on the array, and on our map we consider them starting from 1.
3.2) To set the right position, we must know the size for each tile. The best way is to have tiles of the same size. Then, we can get the position with:
Code: [Select]
int xPosition = column * tileSize;
int yPosition = line * tileSize;

That way, if we are printing the first line (line = 0), its y position would be 0. If we are printing the second (line = 1), it y position is tilesize. And so on.
Then to put the position on the sprite:
Code: [Select]

I think that is more than enough for you to make a tile based map.

General / how to create a grid?
« on: November 22, 2011, 10:21:38 am »
Read the SFML tutorials on creating windows and printing sprites. After that, you should be able to make your own logic on how to do what you want.
You may want to search for printing "tiles" as well, as I think that is what you want to do.

By the way, your fors misses the closing parentheses at the end: ")".

Graphics / sf::Color check to see if image has a lot of red
« on: November 18, 2011, 04:33:44 pm »
I don't know other aproaches, although I think there are many...

You have to check a few things:
• The red channel must be the bigger, as you suggested, but you must ensure it has a considerable gap between it and the other channels. The color 255, 254, 254, for instance, is mostly white, and not red.
• The other two channels must be balanced, as it will change the color if you have one of them bigger than the other. 255, 150, 0 is orange, and not red. 255, 150, 150 is light red.

General / Tutorial "Opening a window" code doesn't work righ
« on: November 17, 2011, 03:32:09 am »
Quote from: "Bacu"
today's problem. I've #included <SFML\Graphics>...

It should be SFML/Graphics.hpp

General / [SOLVED] SFML 2.0 restricitng how far sf::View can move.
« on: November 17, 2011, 12:37:46 am »
Take the second if and add this:

Code: [Select]
    view_center.x = view_size.x / 2;
    view_center.y = player_pos.y;

You might also want to check your variable declarations... Each one's type is written differently.

General / Optimizations?
« on: November 16, 2011, 07:04:29 am »
You are using pixel positions as matrix indexes...
Try it like this:

Code: [Select]
int left = CameraView.Left / 32;
int right = (CameraView.Left + CameraView.Width) / 32 + 1;
int top = CameraView.Top / 36;
int bottom = (CameraView.Top + CameraView.Height) / 36 + 1;
for (int bx = left; bx <= right; bx++)
   for (int by = top; by <= bottom; by++)

Graphics / Help with logic behind displaying game map?
« on: November 16, 2011, 03:20:32 am »

General / Optimizations?
« on: November 16, 2011, 03:08:37 am »
In case of tile based sprites printed from a matrix, if you have fixed size tiles, you can know exactly where to begin and where to end printing.
Take the left border X position of your camera and divide by the tile size to get the X index of the first tile to print on the matrix. Divide the X position of your right border by the tile size and add 1 to make sure it goes past the screen, and you have the last X index you are going to print.

Same goes for Y.

Then you have just to iterate on these positions and print them.

General / Key events on sfml2
« on: November 13, 2011, 04:32:47 pm »
Replace Event.KeyPressed on the switch for Event.Key.Code.

Pages: 1 ... 13 14 [15] 16 17