Bienvenue, Invité. Merci de vous connecter ou de vous inscrire. Avez-vous oublié d'activer ?

Voir les contributions

Cette section vous permet de consulter les contributions (messages, sujets et fichiers joints) d'un utilisateur. Vous ne pourrez voir que les contributions des zones auxquelles vous avez accès.


Sujets - nigelk

Pages: [1]
1
Système / [Résolu] problème avec restart() de sf::Clock
« le: Avril 16, 2015, 02:01:06 pm »
Bonjour, j'ai un problème avec restart() qui ne fonctionne pas dans ce code et je ne comprends pas pourquoi, je cherche depuis un petit moment maintenant..
main.cpp:
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "animation.h"
#include "Lamp.h"
#include <iostream>

std::vector <Lamp*> Lamp::LampList;

int main(){
    Lamp *nouvelleLamp=new Lamp();
    while (true)
    {
            nouvelleLamp->getAnimation(0).play();
    }
    system("pause");
    return 0;
}
 
animation.h:
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

#ifndef DEF_ANIMATION
#define DEF_ANIMATION
class Animation
{
private:
    sf::Clock m_timer;
    sf::Time m_tAnim;

public:
    Animation (sf::Time time);
    void play();


};
#endif
Lamp.h:
#ifndef LAMP_H
#define LAMP_H
#include "animation.h"

using namespace std;


class Lamp
{
    public:
        Lamp();
        static std::vector <Lamp*> LampList;
        Animation getAnimation(int i) { return m_animationList[i]; }
        void addAnimation (Animation &newAnimation) { m_animationList.push_back(newAnimation);}
        std::vector <Animation> m_animationList;
};

#endif // LAMP_H
 
Lamp.cpp:
#include "Lamp.h"

Lamp::Lamp()
{
    Animation*animTemp=new Animation(sf::milliseconds(600));
    this->addAnimation(*animTemp);
    Lamp::LampList.push_back(this);
}
 
animation.cpp:
#include "animation.h"
#include <iostream>
Animation::Animation(sf::Time tAnim)
{
    m_tAnim=tAnim;
}
void Animation::play()
{
    if (m_timer.getElapsedTime()>=m_tAnim)
    {
        std::cout << m_timer.getElapsedTime().asMilliseconds() << "  ";
        m_timer.restart();
    }
}



2
Graphique / [Résolu] intégrer les images dans mon code
« le: Avril 12, 2015, 01:04:13 am »
Bonjour, voilà ma question, est-il possible d'intégrer mes images (png) dans mon code et de pouvoir les charger ensuite dans une texture par exemple ?
Reformulé je cherche n'importe quel moyen pour que mes images soient comprises dans le .exe.
Je ne souhaite garder qu'un .exe de mon jeu.
Merci d'avance :)
Nigel

Pages: [1]