thiagoaraujocampos / trabalho_final_poo

Trabalho Final de Programação Orientada a Objetos
MIT License
2 stars 1 forks source link

Observações do SFML #2

Open thiagoaraujocampos opened 4 years ago

thiagoaraujocampos commented 4 years ago

Lembrando que as tarefas estão em #1

Resumo sobre algumas coisas do SFML

Imagens

Tipos de imagem permitidas

Bitmap for example does not support transparency encoding and are generally quite large, but lose no image details and are simple to work with. Gif has some patent issues and should generally be avoided. Png seems like genuinely a good mix between features, size and quality and is well supported by content creation tools.

No SFML (em comparação com Allegro) é vantajoso o uso de .png com fundo transparente, visto que trabalhar com mascara não é muito satisfatório.

Lembrar: O tamanho das spritesheets devem ser no tamanho X e Y de acordo com tamanho fixado por cada frame. (Uma provável preferência por quadrados aqui mas não sei dizer ainda)

Exemplos do jogo Derrota Contínua

Spritesheet da personagem spritesheet feminino

Tela principal tela principal

Mapa do jogo mapa


Músicas

Tipos de músicas permitidas

The major difference between sound effect and music is the sound effect stays resident in memory, while a Music file is streamed from disk.

You will notice a very noticeable exception from that list, the mp3 format. That is because the mp3 format is encumbered by a number of patents and should be avoided to protect yourself from potential licensing fees. Fortunately the ogg format offers similar file sizes and similar audio quality as the mp3 format without the licensing pitfalls.

O uso de músicas no projeto é bem custoso. Levando isso em consideração, será de uma certa relevância verificar, com cuidado, quais músicas serão usadas.

Efeitos sonoros

Não sei ainda

Exemplos em código

Exemplo básico

  int main() {
  RenderWindow window(VideoMode(800, 600), "SFML window");

  Texture texture;
  if (!texture.loadFromFile("cute_image.jpg"))
    return EXIT_FAILURE;
  Sprite sprite(texture);

  CircleShape circulo(20);
  circulo.setFillColor(Color::Red);

  Font font;
  if (!font.loadFromFile("arial.ttf"))
    return EXIT_FAILURE;
  Text text("Hello SFML", font, 50);

  Music music;
  if (!music.openFromFile("nice_music.ogg"))
    return EXIT_FAILURE;
  music.play();

  Event event;

  while (window.isOpen()) {
    while (window.pollEvent(event)) {
      if (event.type == Event::Closed)
        window.close();
      if (event.type == Event::EventType::KeyPressed) {
        if (event.key.code == Keyboard::Escape) {
          window.close();
        }
      }
    }
    window.clear();
    window.draw(sprite);
    window.draw(circulo);
    window.draw(text);
    window.display();
  }
  return EXIT_SUCCESS;
}