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

Pages: 1 2 3 [4] 5
46
then have you rewritten the code ?
if the problem is solved after rewritting the whole code then the whole world will be happy  ;D

47
Graphics / Re: Pixel Color
« on: July 09, 2017, 04:25:28 am »
How can I read the color of a specific pixel on the screen?

What exactly do you want to achieve?

really...he said it clearly
anyways this has been answered by Gleade
so...sfml is not a raster graphic graphic library
as Gleade said the operation will be expensive
if you want to do it continuously
it is a bad idea  :P

48
Graphics / how does Transform::setOrigin works ?
« on: July 09, 2017, 04:23:32 am »
hi...
for example i have this code
Code: [Select]
rect.setOrigin(rect.getSize().x / 2, rect.getSize().y / 2);
rect.rotate(1);
rect.setOrigin(0, 0);

the rect doesn't rotate according to the origin in the middle but according to the origin of top left
why ?

49
General / Re: resetting origin over and over
« on: July 08, 2017, 05:27:34 am »
nevermind, my plan didn't work out...
when it check if the shape is out of window, the origin is still in middle :'(

50
General / resetting origin over and over
« on: July 08, 2017, 05:15:33 am »
hi, so I want to reset origin over and over :)
so it went like this
when I want to rotate the origin will be at the middle
when I want to check if the shape is out of window, the origin will be either top-left or bottom-right
does setting the origin over and over cause speed difference

51
SFML website / Re: no time where topic were made
« on: July 05, 2017, 07:36:54 am »
wait...but that opens the topic...
well...it is just sometimes I visited a really old topic...
not a real problem tho

52
SFML website / no time where topic were made
« on: July 05, 2017, 06:08:16 am »
hi...I wonder why there is no time where topic were made... ???

53
Java / Re: Sorry, I'm out
« on: June 30, 2017, 04:22:32 pm »
good luck  :D

54
Graphics / Re: sfml-graphics-2.dll is missing
« on: June 20, 2017, 12:22:04 pm »
pardon me I was copyinmg from lib rather than bin

55
Graphics / sfml-graphics-2.dll is missing
« on: June 20, 2017, 12:09:38 pm »
weird...I am pretty sure that sfml-graphics-2.dll never existed yet when I tried to open the program it said that...
I have put all the .dll excluding audio and OPENAL

56
Well, I managed to draw em' using vertex array but the problem still presents..

57
I figured the problem already..

zombie.at(i).getShape().getPoint() returns sf;:Vector corresponding to the left hand corner of the screen

58
well, rather than not getting drawn...it is drawn but it is stuck on 1 place the left-upper corner of the screen

59
well...I tried to do that...I failed instead....because now they are not drawn on the screen

btw..here's the piece of code to do what you said
if (drawZombie.getVertexCount() < zombie.size() * 4)
        {
            for (int i = 0; i < zombie.at(zombie.size() - 1).getShape().getPointCount(); ++i)
            {
                drawZombie.append(zombie.at(zombie.size() - 1).getShape().getPoint(i));
            }
        }
        for (int i = 0; i < zombie.size(); ++i)
        {
            for (int j = 0; j < zombie.at(i).getShape().getPointCount(); ++j)
            {
                drawZombie[(((i + 1) * 4) - 1) - (3 - j)].position = zombie.at(i).getShape().getPoint(j);
            }
        }
        for (int i = 0; i < drawZombie.getVertexCount(); ++i)
        {
            drawZombie[i].color = sf::Color::Green;
        }
 

and drawZombie's primitive type is of quads

60
hey guys...now I know how vertex array works..
so I have a game that has an enemy that multiplies by 2 when you killed it...
so considering I use loop to draw it...it gets too slow eventually
now.. I have this class
class Zombie
{
private :
    sf::RectangleShape Rect;
    const float speed;
    int health;
public :
    Zombie(const sf::RenderWindow& window, float speedVal, int healthVal) :
        speed(speedVal),
        health(healthVal)
    {
        std::srand(time(0));
        Rect.setSize(sf::Vector2f(37, 37));
        Rect.setOrigin(Rect.getSize().x / 2, Rect.getSize().y / 2);
        sf::Vector2f position;
        rand();
        position.x = rand() % window.getSize().x;
        rand();
        position.y = rand() % window.getSize().y;
        Rect.setPosition(position);
        Rect.setFillColor(sf::Color(0, 200, 0));
    }
    void move(User& user)
    {
        if (Rect.getPosition().x < user.getPosition().x)
        {
            Rect.move(speed, 0);
        }
        else if (Rect.getPosition().x > user.getPosition().x)
        {
            Rect.move(-(speed), 0);
        }
        if (Rect.getPosition().y < user.getPosition().y)
        {
            Rect.move(0, speed);
        }
        else if (Rect.getPosition().y > user.getPosition().y)
        {
            Rect.move(0, -(speed));
        }
        sf::Vector2f difference;
        difference.x = user.getPosition().x - Rect.getPosition().x;
        difference.y = user.getPosition().y - Rect.getPosition().y;
        float face = std::atan2(difference.y, difference.x);
        float degrees = face * pi / 180;
        Rect.setRotation(degrees);
    }
    void reInit(const sf::RenderWindow& window)
    {
        srand(time(0));
        rand();
        sf::Vector2f position;
        position.x = rand() % window.getSize().x;
        rand();
        position.y = rand() % window.getSize().y;
        Rect.setPosition(position);
        health = 50;
    }
    void decHealth(int val)
    {
        health -= val;
    }
    const int& getHealth() const
    {
        return health;
    }
    const sf::Shape& getShape() const
    {
        return Rect;
    }
    bool hit(User& user)
    {
        if (Rect.getGlobalBounds().intersects(user.getGlobalBounds())) return true;
        return false;
    }
};

 

and I have this code
std::vector<Zombie> zombie;
 

considering the fact that when it gets too big it becomes slow...
how do I compress it to vertex array rather how do I transform only a member of the vertex array

Pages: 1 2 3 [4] 5
anything