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
16
General / Re: Using Events to check for inputs ?
« on: April 07, 2018, 05:16:00 am »
Yeah, thanks Laurent.
Also if I used while wouldn't that means that when I have an input the whole other section of the program that does some stuff wouldn't run and my program would be stuck at the input section ?

17
General / Re: Using Events to check for inputs ?
« on: April 06, 2018, 04:59:06 pm »
Got it, also is it better to
sf::Event event;
        while (win.pollEvent(event))
        {
            if (event.type == sf::Event::KeyPressed)
            {
                if (event.key.code == sf::Keyboard::Space) chara.jump();
            }
        }
 

or

sf::Event event;
        if (win.pollEvent(event))
        {
            if (event.type == sf::Event::KeyPressed)
            {
                if (event.key.code == sf::Keyboard::Space) chara.jump();
            }
        }
 

18
General / Using Events to check for inputs ?
« on: April 06, 2018, 04:03:24 pm »
Should I use Events to check for inputs to i.e move my character or should I use the other one ??

i.e
Code: [Select]
        sf::Event event;
        while (win.pollEvent(event))
        {
            if (event.type == sf::Event::KeyPressed)
            {
                if (event.key.code == sf::Keyboard::Space) chara.jump();
            }
        }

or

Code: [Select]
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) chara.jump();

which one is better?

19
how do you register libwinpthread-1.dll to windows ?

20
thank you :D

21
General / thor related problems, procedure cannot be found in libthor dll
« on: December 26, 2017, 02:26:37 pm »
any suggestion on how to fix this ?

22
General / Re: Multi line text field(box)
« on: September 19, 2017, 05:10:50 pm »
oops, maybe I should have read the definition of each widget instead of just reading the name, my bad

23
General / Re: Multi line text field(box)
« on: September 13, 2017, 04:22:24 pm »
I certainly did, and I could not find anything related to multi line text box i TGUI

24
General / Multi line text field(box)
« on: September 03, 2017, 06:11:44 pm »
hi, is there such a thing as multi line text field (box) like JTextArea in either sfgui or tgui ?
also, if there is none...how to make one ?

25
General / Re: actions happened too fast ??
« on: July 30, 2017, 04:40:58 pm »
it moved too fast...
when I didn't put update... the pixels are in random position
when I put update I expect to see the movement of it...instead it turns into this diagonal line with half red and half blue

26
General / actions happened too fast ??
« on: July 30, 2017, 04:22:33 pm »
hi, I have a sfml program where it is comprised of pixel...it is a battle of pixel and it moved according to a set speed...but the way it moved when i run it is instantaneously moved...

main.cpp
#include <TGUI/TGUI.hpp>
#include "pixels/pixels.hpp"
#include <iostream>

int main()
{

    const float speed = 0.01;
    sf::RenderWindow win{sf::VideoMode{450, 400}, "pixel vs pixel"};

    Pixels p1{sf::Color::Red, sf::Vector2f{200, 400}, sf::Vector2f{0, 0}, (200 * 400) / 2, speed};
    Pixels p2{sf::Color::Blue, sf::Vector2f{200, 400}, sf::Vector2f{250, 0}, (200 * 400) / 2, speed};

    while (win.isOpen())
    {
        sf::Event event;
        while (win.pollEvent(event))
        {
            if (event.type == sf::Event::Closed) win.close();
        }

        p1.update(p2);
        p2.update(p1);

        win.clear();
        win.draw(p1);
        win.draw(p2);
        win.display();
    }
}

 

Pixels.hpp
class Pixels : public sf::Drawable, public sf::Transformable
{
private :
    virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
    {
        states.transform *= getTransform();
        states.texture = 0;
        target.draw(m_vertices, states);
    }
    sf::VertexArray m_vertices;
    const float speed = 0;
public :
    Pixels(sf::Color color, sf::Vector2f start, sf::Vector2f end, int numbers, float pspeed);
    void update(Pixels& pixels);
    sf::Vector2f& getPoint(size_t index);
    size_t getPointCount();
};
 

pixels.cpp
#include <cstdlib>
#include <ctime>
#include "pixels.hpp"

Pixels::Pixels(sf::Color color, sf::Vector2f start, sf::Vector2f end, int numbers, float pspeed) :
    speed(pspeed)
{
    srand(time(0));
    m_vertices.setPrimitiveType(sf::PrimitiveType::Points);
    m_vertices.resize((size_t) numbers);
    for (size_t i = 0; i < m_vertices.getVertexCount(); ++i)
    {
        m_vertices[i].color = color;
        float temp_x = (rand() % (int) start.x) + (int) end.x;
        rand();
        float temp_y = (rand() % (int) start.y) + (int) end.y;
        m_vertices[i].position = sf::Vector2f{temp_x, temp_y};
    }
}

void Pixels::update(Pixels& pixels)
{
    for (int i = 0; i < m_vertices.getVertexCount(); ++i)
    {
        if (i >= pixels.getPointCount())
        {
            if (getPoint(i).x < pixels.getPoint(pixels.getPointCount() - 1).x)
            {
                m_vertices[i].position = sf::Vector2f{m_vertices[i].position.x + speed, m_vertices[i].position.x};
            }
            else if (getPoint(i).x > pixels.getPoint(pixels.getPointCount() - 1).x)
            {
                m_vertices[i].position = sf::Vector2f{m_vertices[i].position.x - speed, m_vertices[i].position.x};
            }
            if (getPoint(i).y < pixels.getPoint(pixels.getPointCount() - 1).y)
            {
                m_vertices[i].position = sf::Vector2f{m_vertices[i].position.y, m_vertices[i].position.y + speed};
            }
            else if (getPoint(i).y > pixels.getPoint(pixels.getPointCount() - 1).y)
            {
                m_vertices[i].position = sf::Vector2f{m_vertices[i].position.y, m_vertices[i].position.y - speed};
            }
            continue;
        }
        if (getPoint(i).x < pixels.getPoint(i).x)
        {
             m_vertices[i].position = sf::Vector2f{m_vertices[i].position.x + speed, m_vertices[i].position.x};
        }
        else if (getPoint(i).x > pixels.getPoint(i).x)
        {
            m_vertices[i].position = sf::Vector2f{m_vertices[i].position.x - speed, m_vertices[i].position.x};
        }
        if (getPoint(i).y < pixels.getPoint(i).y)
        {
             m_vertices[i].position = sf::Vector2f{m_vertices[i].position.y, m_vertices[i].position.y + speed};
        }
        else if (getPoint(i).y > pixels.getPoint(i).y)
        {
            m_vertices[i].position = sf::Vector2f{m_vertices[i].position.y, m_vertices[i].position.y - speed};
        }
    }
}

sf::Vector2f& Pixels::getPoint(size_t index)
{
    return m_vertices[index].position;
}

size_t Pixels::getPointCount()
{
    return m_vertices.getVertexCount();
}

 

27
Graphics / Re: removing sf::VertexArray from the middle
« on: July 30, 2017, 04:16:24 pm »
yeah...I looked at the implementation it is simple indeed :D
but I think I can just copy the entire code and just add a simple remove function :D

28
Graphics / Re: removing sf::VertexArray from the middle
« on: July 30, 2017, 02:27:38 pm »
ah, thank you,I will take the first option...that being said...why don't sf::VertexArray has erase option ?

29
Graphics / Re: removing sf::VertexArray from the middle
« on: July 30, 2017, 02:09:30 pm »
like sf::VertexArray::Erase(2);

30
Graphics / removing sf::VertexArray from the middle
« on: July 30, 2017, 02:04:53 pm »
is it possible ??

Pages: 1 [2] 3 4 5