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.


Topics - AzkaIsHere

Pages: [1]
1
General / collision between elements in different vectors and classes
« on: August 15, 2018, 03:39:03 am »
Hello, I have been trying many times to write the collision between the bullet vector and enemy vector of sprites... None were succesful, can someone tell me methods for that?

2
General / Friends can't open my games
« on: August 09, 2018, 03:13:16 pm »
Hello guys, I need help on this, I've been trying for months to share my games with my friends but when they open the .exe they always get errors. I tried copying and pasting the sfml libs with the exe, but still noting, what should I do?

3
General / intersection between sprites from different classes
« on: April 19, 2018, 02:41:33 pm »
Hello guys I am struggling while trying to make this intersection between my tree and rock sprite but they are in different classes and I don't know how to make the command in this situation since I just started using classes with sprites.

this is the tree class:

class Tree
{
public:
        Tree(string treerectory)
        {
                t.loadFromFile(treerectory);
        }
       
        void treeTexture()
        {
                for (size_t i = 0; i < 1000; i++)
                {
                        tree[i].setTexture(t);
                        tree[i].setScale(1, 2);
                }
        }

        void treePosition()
        {
                for (size_t i = 0; i < 1000; i++)
                {
                        tree[i].setPosition(rand() % 10560 + 0.f, rand() % 10560 + 0.f);
                }
        }

        void treeDraw(RenderWindow &app)
        {
                for (size_t i = 0; i < 1000; i++)
                {
                        app.draw(tree[i]);
                }
        }

        void treeSelfCollision()
        {
                srand(time(0));

                for (size_t i = 0; i < 1000; i++)
                {
                        if (tree[i].getGlobalBounds().intersects(tree[1000].getGlobalBounds()))
                        {
                                tree[i].move(rand() % 15 - 15, rand() % 15 - 15);
                        }
                }
        }

private:
        Texture t;
        Sprite tree[1000];
};
 

and this is the rock class:

class Rock
{
public:
        Rock(string rockrectory)
        {
                r.loadFromFile(rockrectory);
        }

        void rockTexture()
        {
                for (size_t i = 0; i < 1000; i++)
                {
                        rock[i].setTexture(r);
                }
        }

        void rockPosition()
        {
                for (size_t i = 0; i < 1000; i++)
                {
                        rock[i].setPosition(rand() % 10560 + 0, rand() % 10560 + 0);
                }
        }

        void rockDraw(RenderWindow &app)
        {
                for (size_t i = 0; i < 1000; i++)
                {
                        app.draw(rock[i]);
                }
        }

        void rockSelfCollision()
        {
                for (size_t i = 0; i < 1000; i++)
                {
                        if (rock[i].getGlobalBounds().intersects(rock[1000].getGlobalBounds()))
                        {
                                rock[i].move(rand() % 15 - 15, rand() % 15 - 15);
                        }
                }
        }

private:
        Texture r;
        Sprite rock[1000];
};
 

I want to make a function to check if the tree and the rock are intersected, how do I do?

4
General / tree sprite doesn't draw
« on: April 18, 2018, 10:31:12 pm »
hello, I have a problem, my trees don't spawn in the map, this is the tree class:

class Tree
{
public:
   Tree(string directory)
   {
      t.loadFromFile(directory);
   }
   
   void treeTexture()
   {
      for (size_t i = 0; i < 1000; i++)
      {
         tree.setTexture(t);
         tree.setScale(1, 2);
      }
   }

   void treePosition()
   {
      for (size_t i = 0; i < 1000; i++)
      {
         tree.setPosition(rand() % 10560 + 0, rand() % 10560 + 0);
      }
   }

   void treeDraw(RenderWindow &app)
   {
      for (size_t i = 0; i < 1000; i++)
      {
         app.draw(tree);
      }
   }

private:
   Texture t;
   Sprite tree[1000];
};

and this is the main function:

Tree tree("shapes/world/tree.png");

tree.treeDraw(app);

can you tell me why I can't see them?

5
General / put the player at the center of the view from another class
« on: April 18, 2018, 08:43:55 pm »
hello guys I am struggling with this error:

no instance of overloaded function "sf::View::setCenter" matches the argument list

that comes when I do this:


   void playerposition()
   {
      player.getPosition();
   }

from my player class and then in the main function I write this:

Player p1;

p1.playerposition();

anyone can explain why the error?

6
Graphics / unhandled exception stack overflow in sprite
« on: April 07, 2018, 02:03:50 pm »
yesterday I wrote this code to make trees spawn randomly anywere in the map:

for (int i = 0; i < 1000; i++)
        {
                tree[i].setTexture(tr);
                tree[i].setPosition(rand() % 10560 + 0, rand() % 10560 + 0);
                tree[i].setScale(1, 2);
        }

and then

for (int i = 0; i < 1000; i++)
                {
                        app.draw(tree[i]);
                }

-------------------------------------

But today i wrote that again for yellow flowers:


        for (int i = 0; i < 1000; i++)
        {
                yellow_flower[i].setTexture(y_f);
                yellow_flower[i].setPosition(rand() % 10560 + 0, rand() % 10560 + 0);
        }

and then

                for (int i = 0; i < 1000; i++)
                {
                        app.draw(yellow_flower[i]);
                }


but when I added these new loops, this error occurs to me:

Unhandled exception at 0x01017D59 in MyGame.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x00402000).
      

7
Graphics / spawn more trees with one sprite
« on: April 06, 2018, 11:21:46 pm »
Hi, I have an image that is a tree and I want to make it so that it spawns 500 trees all around the map, but I don't know how to draw multiple times the same image, I know that you need vectors and for loops, but I didn't understand much about how that works, can someone explain how to do that? thanks in advance

8
General / knockback to collision
« on: February 17, 2018, 10:04:12 pm »
hey guys I am making a game where two sprite have to collide and when they do they have to take a knockback to the opposite position of the collision point. can someone tell me an example on how to do that or maybe just explain or link some tutorial?

9
General / sprite rect for animations makes the character change position
« on: February 02, 2018, 01:04:37 pm »
help guys I am trying to get an animated sprite for the character of my game that gets a rect of the sprite which changes if he goes right,left,up or down.
here is the code:

            if (e.key.code == sf::Keyboard::W) {
               character.setTextureRect(IntRect(-30,97,60,30));
               character.move(0, -5);

            }

the problem here is that when I press "w" the character changes position a bit to the right and doesn`t stay in the position where the previous frame of the animation was, the movement works correctly after it goes right. hulp plz.

10
General / sf::Sprite::setTextureRect': function does not take 2 arguments
« on: January 30, 2018, 11:34:28 am »
help I just wrote this:

s1.setTextureRect(sf::IntRect(10, 10, 32, 32));

into my code and it says:

sf::Sprite::setTextureRect': function does not take 2 arguments.

could you tell me what it is about? on the tutorials the same exact command works.

11
General / Delay between commands
« on: January 29, 2018, 01:18:39 am »
Hello, I need to do an animation of a sprite that goes darker and darker until black so I set the color darker and darker with a sleep command every darker color, like this:

If (keyboard::iskeypressed(keyboard::return)) {
Sprite.setcolor(color(200,200,200));
Sleep(seconds(1));
Sprite.setcolor(color(100,100,100));
Sleep(seconds(1));
Sprite.setcolor(color(0,0,0));
}

This doesn't work, when I click return there is 1 delay that is the sum of all the delays I put and then only the last color is applied. Please help

Pages: [1]