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

Pages: [1]
1
Graphics / Grey box displaying around sprite's loaded image.
« on: April 01, 2011, 12:57:42 am »
I am loading a PNG file into an instance of Sprite and then calling draw. The image displays at the proper location, but also has a grey bounding box that is not part of the image itself. This box resizes with the sprite when the window is resized. How can this box be disabled/hidden?

Code where the error originates:
Code: [Select]
   
    sf::Image sfi;
    sf::Sprite sprite;
    if (!sfi.LoadFromFile(filename))
    {
        Log::debug("Failed to load file");
        return;
    }
    sprite.SetPosition(origin.x,origin.y);
    sprite.SetImage(sfi);
    target.Draw(sprite);


A screenshot showing the bounding box.
http://imgur.com/sEAsq

2
Graphics / Proper Way to Design Multiple Enemy Types
« on: January 03, 2011, 11:23:14 am »
The issue is more along the following lines:

Code: [Select]

class EnemyTracker
{
 private:
    std::vector<Enemy> _enemies;
 public:
    DrawEnemies(sf::RenderTarget& target)
    {
        for(unsigned int i = 0;i<_enemies.size();i++)
        {
          target.Draw(_enemies[i]);
        }
    }
};

class Enemy
{
 public:
    int _health,_xPos,_yPos;
};

class FastEnemy: public Enemy,sf::Sprite
{
 private:
    int _moveSpeed;

};

class BigEnemy: public Enemy,sf::Sprite
{
 private:
    int _size;
};



This is an example of the type of setup I am trying to design. Basically, each type of enemy has its own Sprite and logic, but I want to have a generic parent type so that I don't need to make a new container every time I create a new type of enemy. How can this be done in C++ while having access to SFML?

3
Graphics / Proper Way to Design Multiple Enemy Types
« on: January 02, 2011, 11:19:48 pm »
I'm working on a simple game to learn the ins and outs of SFML and am currently running into the following issue.

I want to be able to update every enemy type from a single method. My initial thoughts on this are to have a layout similiar to the following:

[Enemy Class]
    -> Holds position,speed, and strength data
    -> All enemies are subclasses of this class

[FirstEnemyType Class]
    -> Parent class is Enemy
    -> Specialized Run() method to handle specific enemy type AI

[EnemyTracker Class (Singleton)]
    -> Contains a vector of Enemy
    -> UpdateEnemies method calls Enemy.Run on all enemies

[Main Function]
    -> Call EnemyTracker.Update() to update all enemies of all types of once

The issue I'm running into is that SFML cannot call Render on the Enemy type. I've tried solving this by having Enemy be derived from sf::Sprite, but I cannot find a way to have each derived enemy type have its own Image through this method. The other solution is to have each enemy type be derived from sf::Sprite, but then I cannot update as shown above because the Enemy type has no linkage to Drawable.

What is a good solution to this design problem? I want each enemy type to have individualized graphics but desire a single touch point for updating all enemies at once.

Pages: [1]