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

Pages: [1]
1
Thank Thanks Thanks :D
for all the help

but I don't use the sfml 2.2 because I have some compatibilities problems xP

2
Well yes :
ventana = window
lalala = I had trying to make work the music and i changed the variable with a random name :P
zombie = principal class
evento = event :v
the others are for movement,speed,etc.

3


This is the Game.cpp
[spoiler]
#include <iostream>
#include "Game.h"
using namespace std;
using namespace sf;


zombie::zombie():ventana(VideoMode(800, 600),"Game") {

}

int zombie::inicia(){
    ventana.setFramerateLimit(60);
    ventana.setKeyRepeatEnabled(true);
    ventana.setVerticalSyncEnabled(true);

   if (!hero_texture.loadFromFile("hero.png")){
       return 1;
   }
    hero_texture.setSmooth(true);
    hero_texture.setRepeated(true);
    hero_sprite.setTexture(hero_texture);
    hero_sprite.setPosition(400, 400);

    if (!lalala.openFromFile("music.ogg")){
        cout << "error" <<endl;
        return -1;
    }
    lalala.setVolume(100);

}




void zombie::evento_i() {
        //Eventos de la ventana
    while(ventana.pollEvent(evento)){
        if (evento.type == Event::Closed){
           lel = false;
        }
    }
    //Eventos del heroe
    if(Keyboard::isKeyPressed(Keyboard::Up)){
        UP = true;
    }
    if(Keyboard::isKeyPressed(Keyboard::Down)){
        DOWN = true;
    }
    if(Keyboard::isKeyPressed(Keyboard::Left)){
        LEFT = true;
    }
    if(Keyboard::isKeyPressed(Keyboard::Right)){
        RIGHT = true;
    }
    if (Keyboard::isKeyPressed(Keyboard::S)){
        SOUND = true;
    }
}

void zombie::update() {
    Vector2f movimiento_heroe(0.f,0.f);
    float velocidad_heroe = 3.f;

    if (UP){
      movimiento_heroe.y-= 1.f * velocidad_heroe;
      UP = false;
    }

    if (DOWN){
      movimiento_heroe.y= 1.f * velocidad_heroe;
      DOWN = false;
    }

    if (LEFT){
      movimiento_heroe.x-= 1.f * velocidad_heroe;
      LEFT = false;
    }

    if (RIGHT){
      movimiento_heroe.x= 1.f * velocidad_heroe;
      RIGHT = false;
    }
    hero_sprite.move(movimiento_heroe);
    if(SOUND){
        music.play();
    }
}


void zombie::render() {
    lalala.play();
    ventana.clear(Color::Blue);
    ventana.draw(hero_sprite);
    ventana.display();

}

void zombie::clear(){
    ventana.close();
}

void zombie::corre(){
    inicia();
    while(lel){
        evento_i();
        update();
        render();
    }
    clear();
}
[/spoiler]

(click to show/hide)

I'm using the tutorials of the SFML 2.1 page
I'm doing bad? xD

4
I tested other and now only not load the sound : /

5
Thanks :D
I will use other to test.
I really happy that is the file and not the code.

7
Hello
I have a problem:
I starting to use SFML 2.1  and I made a simple code that show a sprite and the sprite moves. All ok
I decide to put a music to test and when i compile all ok.
when I run said this in the console:
Failed to open sound file "music.ogg" (Error : flac decoder lost sync.)
And don't play the music.
You can help me with this please?
Thanks :D

Software:
Qt Creator 3.0.1
SFML 2.1

Pages: [1]
anything