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

Pages: [1]
1
Graphics / Re: Should i use sf::Texture or sf::VertexArray for this?
« on: September 10, 2017, 06:36:30 pm »
Oh, sorry for the mistake :P

And thank you for the insight, now i'll start coding the game and see how the perfomance turns out to be.

2
Graphics / Should i use sf::Texture or sf::VertexArray for this?
« on: September 10, 2017, 01:36:51 am »
So, i was thinking about making a game like Fire Emblem(if you don't know how it is, there's a picture bellow) in the sense that it is a Tactical RPG with a tilemap to move your units around the battlefield, until here everything is fine, but then i remembered a question that i always had when i first dived into SFML



Why is using sf::VertexArray is so much faster than using some sf::Texture? Some time ago i made a game that also used a tilemap but instead i used sf::Texture with a texture manager(so i didn't load the same texture more than one time) that i made and it did run pretty well, should i have used sf::VertexArray instead? Or just for the example that they gave on the tutorial it would be beneficial to use sf::VertexArray since there's no interaction with the person using the PC unlike a game like Fire Emblem?

I already am thanking you for reading up to this point and sorry for any bad english, it is not my native language after all.

3
Graphics / Re: How do you return a vector2f from a function.
« on: April 26, 2017, 12:43:30 am »
is checkDirection static? if so you should call it with function::checkDirection instead of function.checkDirection
(also, if function is the name of a object use the class' name instead)

4
Graphics / Re: Problem with Rotating a Sprite
« on: April 25, 2017, 11:46:57 pm »
Found out the bug, it's impossible to rotate a sprite in a specific origin and then change it to another origin so that i can position the sprite, i should use the same origin to do this.

5
Graphics / Problem with Rotating a Sprite
« on: April 25, 2017, 12:42:05 am »
So...i am making a game for my girlfriend (Pipeline) in this games i use tilesets to show the map on screen, in the spritesheet for each type of pipe there's a sprite for it, but i didn't do a seperate sprite for the pipes that are rotated, in theses cases i would rotate them on my code, and that's what i (almost) did, the thing is that my sprite is rotating but getting out of the grid in wich it should be drawn
Here's the code for the constructor of the pipe
Quote
Pipe::Pipe(const int tipoCano, const unsigned dir, const sf::Vector2f pos, const float scale) {
   std::size_t cont = 0;
   ladosPipe = std::bitset<4>(tipoCano);
   switch (ladosPipe.to_ullong()) {
      case 0b1100:
         for(int i = dir; i>0; i--) {
            cont++;
            ladosPipe >> 1;
            if (cont == 4) {
               cont = 0;
               ladosPipe = 0b1100;
            }
         }
         spriteSheet = spriteManager("Images/tilesetCanos.png", 1, 4, 256, 256, 1);
      break;
      case 0b1010:
         for (int i = dir; i>0; i--) {
            cont++;
            ladosPipe >> 1;
            if (cont == 2) {
               cont = 0;
               ladosPipe = 0b1010;
            }
         }
         spriteSheet = spriteManager("Images/tilesetCanos.png", 1, 4, 256, 256);
      break;
      case 0b1000:
         for (int i = dir; i>0; i--) {
            cont++;
            ladosPipe >> 1;
            if (cont == 4) {
               cont = 0;
               ladosPipe = 0b1000;
            }
         }
         spriteSheet = spriteManager("Images/tilesetCanos.png", 1, 4, 256, 256, 3);
      break;
   }
   spriteSheet.aplicarTexturaSprite(sprCano);
   sprCano.setOrigin(128.f, 128.f);
   sprCano.rotate(angle * dir);
   sprCano.setOrigin(0.f, 0.f);
   sprCano.scale(scale, scale);
   sprCano.setPosition(pos);
}
And where i call the constructor
Quote
Mapa::Mapa(char tipo, const sf::Vector2f pos, float scale) : Cano (nullptr) {
   if (tipo == '0') {
      spriteSheet = spriteManager("Images/tilesetCampo.png", 2, 1, 256, 256, 1);
      colocavel = true;
   }
   else if (tipo == '1') {
      spriteSheet = spriteManager("Images/tilesetCampo.png", 2, 1, 256, 256);
      colocavel = false;
   }
   else if(tipo >= '2' && tipo <= '5'){
      Cano = std::make_unique<Pipe>(Pipe(0b1000, 2, pos, 0.3125f));
      spriteSheet = spriteManager("Images/tilesetCampo.png", 2, 1, 256, 256, 1);
      colocavel = false;
   }
   else {
      Cano = std::make_unique<Pipe>(Pipe(0b1000, 0, pos, 0.3125f));
      spriteSheet = spriteManager("Images/tilesetCampo.png", 2, 1, 256, 256, 1);
      colocavel = false;
   }
   spriteSheet.aplicarTexturaSprite(tile);
   tile.setPosition(pos);
   tile.scale(scale, scale);
   this->scale = scale;
}
and last but not least, how it's shown on the screen (the red square is where the pipe should be drawn)
https://goo.gl/photos/BNS69bitmaCmq4Tg8
and the pipes' spritesheet
https://goo.gl/photos/KPiTqkJgSDTVX1H68
can anyone help me find the error?
(sorry if i wrote something wrong, english isn't my native language)

Pages: [1]
anything