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

Pages: [1]
1
Graphics / Re: How do you return a vector2f from a function.
« on: April 24, 2017, 02:51:48 am »
My function that returns a sf::vector2f is from the functions class. I simple have created a object called function to use it.

In my game class im tryiing to use this function to return a vector2f so i know where my bullet needs to go. However i get the error term does not evaluate to a function taking two arguments.

2
Graphics / Re: How do you return a vector2f from a function.
« on: April 24, 2017, 02:17:49 am »
I updated my question to be alittle more specific sorry

3
Graphics / How do you return a vector2f from a function.
« on: April 24, 2017, 12:42:11 am »
So im trying to return a vector2f from a function. So i can use it in a function in another class that takes a vector2f.


if i have the function

template <typename t, typename u>
        sf::Vector2f checkDirection(std::vector<t>  &vtower, std::vector<u>  &vmonster)
        {
                for (int i = 0; i < vmonster.size(); i++)
                {
                        for (int k = 0; k < vtower.size(); k++)
                        {
                                if (vmonster[i].getPositionX() + vmonster[i].getRadius() + vtower[k].getRadius() > vtower[k].getTowerRangePositionX()
                                        && vmonster[i].getPositionX() < vtower[k].getTowerRangePositionX() + vmonster[i].getRadius() + vtower[k].getRadius()
                                        && vmonster[i].getPositionY() + vmonster[i].getRadius() + vtower[k].getRadius() > vtower[k].getTowerRangePositionY()
                                        && vmonster[i].getPositionY() < vtower[k].getTowerRangePositionY() + vmonster[i].getRadius() + vtower[k].getRadius())
                                {
                                        return direction(vmonster[i].getPositionX(), vmonster[i].getPositionY());
                                       
                                       
                                }

                        }
                }
        }

Im trying to return a vector2f so i can use it in this function here

for (int i = 0; i < bullet.size(); i++)
                {
                       
                        bullet[i].fire(function.checkDirection(myicetower, mymonsters)); //fire takes a vector2f
                }
 


4
I just wanna see my textures while i'm making my game instead of white boxes. Then when the game is finished ill make a resource management class

5
Oh man you are a genius that's exactly what was going on!!!! Thank you so much. You saved me hours more of a heacache!!!

6
I have a 2 classes. I have a tower class and I have a monster class. The default constructor automatically sets a position for the tower. I store the classes in a vector and run a function that returns the value of the towers x position. I can clearly see on my screen that the tower is not in the 0,0 coordinate, but it says it is anyway.

void checkcolission(TowerA tower)
{
    if (tower.getLeft() > monsterSprite.getPosition().x) /*&& tower.getTop() < monsterSprite.getPosition().y && tower.getBottom() > monsterSprite.getPosition().y*/
    {
        //std::cout << "#($)(#%*#%U#*(%*#%*#%" << std::endl;
    }
    std::cout << tower.getPositionX() << std::endl;

}

public://in my tower class
TowerA()
{
    spritetower1.setPosition(100, 50);
    towerRange.setPosition(getPositionX(), getPositionY());
}



//This is in my game class with push_backed vectors of the class
for (int i = 0; i < mymonsters.size(); i++)
{
    for (int k = 0; k < myicetower.size(); k++)
    {
        mymonsters[i].checkcolission(myicetower[k]);

    }
}

7
I know the best thing to do is create a resource manager, and when i get there i get there. But my question is if i have a sf::Texture X declared globally in one cpp and assigned to a sprite in that cpp.  Can i have sf::Texture Y declared globally in another cpp and assigned to a sprite in that cpp. It keeps telling me that texture is already defined.

8
I havent loaded textures in until i get my resource management class going. Drawing the sprites over and over in a loop dosent seem to stress the computer that much. But if there is no need to draw why draw. For example I have a render function that draws all my monsters and sprites through arrays while the window is open.
for (int i = 0; i < myfirearray.size(); i++)
        {
                window.draw(myfirearray[i]);
        }

Now this will tick through the game loop and keep drawing and drawing and drawing these sprites over and over. How bad is this. Should i not draw these in a loop? I currently don't have textures yet, because I know there not lightweight and i want to make a management class. Im not looking to create the most amazing best game in the world something simple and educational. But i dont wanna run into a problem later.

9
Uggh i realize now that textures dont survive ......... I wonder if im going to run into an raii problem later on when i try to handle this.

10
I have a draw class that creates and returns a sprite. However when i use the assignment operator all i get is a white square for the newly created sprite. Simply creating a sprite without using the function works so i know the code in my function is good.

sf::Sprite & Draw::drawTowerSprite()
{
        std::cout << "cake" << std::endl;
        sf::Texture towertexture;
        if (!towertexture.loadFromFile("tower.png", sf::IntRect(0, 0, 32, 32)))
        {
                std::cout << "Couldnt load Monster" << std::endl;
        }
        sf::Sprite spritetower1;
        spritetower1.setTexture(towertexture);
        spritetower1.setPosition(50, 50);
        return spritetower1;
}

// then in another function

Draw objects;
   newsprite = objects.drawTowerSprite(); // this will create the sprite but a white square. Does it have no texture?

Pages: [1]
anything