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 - Red RevYol

Pages: [1]
1
Graphics / Re: Multiple instances of a class
« on: October 20, 2013, 06:50:16 am »
Everyone learns differently, and I tend to be on the visual side of that aspect - using pictures to help explain. Learning by using text is not visual, but it sometimes does.

I also did not say I wanted to do graphics so early at my level. I always want to do video game design with computer science in any way possible. I've also been studying C++ for over a year or so; school was slowing me down for a while, and now I am in college coming back to learning again.

Well, anyway, you can close this topic. It seems like this conversation is not going anywhere.

2
Graphics / Re: Multiple instances of a class
« on: October 20, 2013, 12:17:05 am »
I'll take your word for that, but visuals helps me learn and it helps me understand the concept more clear.

3
Graphics / Re: Multiple instances of a class
« on: October 19, 2013, 10:36:36 am »
To get this straight, I barely know Java. I am using SFML to get out of using a console based program to learn C++ which gets boring after a while. I am also new to programming. Looks like I will need to look at rvalue, lvalue, and dynamic memory.

4
Graphics / Re: Multiple instances of a class
« on: October 19, 2013, 01:43:01 am »
If you were thinking something like this:
                if (event.type == sf::Event::MouseButtonPressed)
                {
                        {
                                if (event.mouseButton.button == sf::Mouse::Left)
                                {
                                        baseAttributes *baseAttributes1 = new baseAttributes();
                                        window.draw(baseAttributes().baseOutline(mouseX, mouseY, 200));
                                }
                        }
                }
The IDE gave me an error while compiling it

5
Graphics / Re: Multiple instances of a class
« on: October 19, 2013, 12:02:39 am »
I meant I want to have multiple instances that is based off of user input. As an example, if I want to have a user press the mouse button, one instance is added to that class and it shows on the screen where the mouse pointer is at.

6
Graphics / Multiple instances of a class
« on: October 18, 2013, 11:25:25 pm »
How can I make multiple shapes using a class that has functions?

Here is my code for the class:
class baseAttributes
{
public:
        //baseAttributes();
        //~baseAttributes();
        int getRadius;
        sf::CircleShape baseOutline(int x, int y, int r)
        {
                sf::CircleShape baseShape(r, 100);

                baseShape.setFillColor(sf::Color(0, 0, 255, 15));
                baseShape.setOutlineThickness(2);
                baseShape.setOutlineColor(sf::Color(28, 87, 174));
                baseShape.setRadius(r);
                baseShape.setPosition(x - r, y - r);
                getRadius = baseShape.getRadius();

                return baseShape;
        }
        sf::CircleShape baseShape(int x, int y, int r)
        {
                sf::CircleShape base;

                base.setFillColor(sf::Color(0, 200, 0));
                base.setRadius(r);
                base.setPosition(x - r, y - r);

                return base;
        }
};

and my main
int main()
{
        sf::ContextSettings settings;
        int width = 1280;
        int height = 720;
        settings.antialiasingLevel = 8;
    sf::RenderWindow window(sf::VideoMode(width, height), "SFML works!", sf::Style::Default, settings);
        //window.setMouseCursorVisible(false);

        sf::View view;
        view.reset(sf::FloatRect(0, 0, width, height));
        view.setCenter(0, 0);
        view.setViewport(sf::FloatRect(0.f, 0.f, 1.f, 1.f));
        window.setView(view);

        int mouseX;
        int mouseY;
        baseAttributes p;
        sf::CircleShape player(40, 6);
        player.setFillColor(sf::Color::Magenta);

        //Loads font
        sf::Font OCRAStd;
        if(!OCRAStd.loadFromFile("OCRAStd.otf"));
        {
                std::cout << "Font loaded" << std::endl;
        }
        sf::Text font;
        font.setFont(OCRAStd);

        while (window.isOpen())
    {
        sf::Event event;
                //window.setFramerateLimit(120);
        while (window.pollEvent(event))
        {
            switch(event.type)
                        {
                                case sf::Event::Closed:
                                        window.close();
                                        break;
                                //case sf::Keyboard::Escape:
                                //      window.close();
                                //      break;
                        }
        }
                //if(event.type == sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
                //{
                //      window.close();
                //}
                if(event.type == sf::Event::MouseMoved)
                {
                        mouseX = event.mouseMove.x;
                        mouseY = event.mouseMove.y;
                }
               
                player.setPosition(mouseX - width/2, mouseY - height/2);

                //int px(0), py(0);
                window.clear(sf::Color::Black);
                window.draw(p.baseOutline(0, 0, 200));

                //Using Pythagorean theorem to display a shape when mouse is in circle
                if(pow(player.getPosition().x, 2) + pow(player.getPosition().y, 2) <= pow(p.getRadius, 2))
                {
                        window.draw(player);
                }

                window.display();
        }

    return 0;
}

I don't know "baseAttributes p" can have multiple instances, and I don't know what to do to make multiple shapes using that class

Pages: [1]