1
Graphics / I think this works.
« on: October 18, 2010, 02:14:11 am »
Hopefully this is correct.
Bullet.h
Bullet.cpp
Bullet.h
Code: [Select]
#ifndef BULLET_H_INCLUDED
#define BULLET_H_INCLUDED
#include <SFML/Graphics.hpp>
class Bullet
{
private:
static bool init_done;
static sf::Image Image;
sf::Sprite bulletSprite;
public:
Bullet();
~Bullet();
void draw(sf::RenderWindow &App);
static bool Init(const std::string& ImageFile)
{
init_done = true;
return Image.LoadFromFile(ImageFile);
}
};
#endif // BULLET_H_INCLUDED
Bullet.cpp
Code: [Select]
#include "bullet.h"
sf::Image Bullet::Image;
bool Bullet::init_done = false;
Bullet::Bullet()
{
if(!init_done) Init("bullet.png");
bulletSprite.SetImage(Image);
}
Bullet::~Bullet()
{
}
void Bullet::draw(sf::RenderWindow &App)
{
App.Draw(bulletSprite);
}