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

Pages: [1]
1
Thanks, I had to change the increments and use events in case another newbie had this problem. Appreciate the patience  ;)

2
I tried this but it doesn't work and I don't know why, where's the problem in my code? The increment operators?



                        int bullm = 0;
                        int x = 1;
                       
                        if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
                        {
                                bullm = +x;
                        }
                       


                        if (bullm == 0)
                        {
                               
                                bull1.setFillColor(sf::Color::Yellow);
                                bull2.setFillColor(sf::Color::Yellow);
                                bull3.setFillColor(sf::Color::Yellow);
                                bull4.setFillColor(sf::Color::Yellow);
                        }
                        if (bullm == 1)
                        {
                               
                                bull1.setFillColor(sf::Color::Yellow);
                                bull2.setFillColor(sf::Color::Yellow);
                                bull3.setFillColor(sf::Color::Yellow);
                                bull4.setFillColor(sf::Color::Transparent);
                        }
                        if (bullm == 2)
                        {
                                bull1.setFillColor(sf::Color::Yellow);
                                bull2.setFillColor(sf::Color::Yellow);
                                bull3.setFillColor(sf::Color::Transparent);
                                bull4.setFillColor(sf::Color::Transparent);
                        }
                        if (bullm == 3)
                        {
                                bull1.setFillColor(sf::Color::Yellow);
                                bull2.setFillColor(sf::Color::Transparent);
                                bull3.setFillColor(sf::Color::Transparent);
                                bull4.setFillColor(sf::Color::Transparent);
                        }
                        if (bullm == 4)
                        {
                                bull1.setFillColor(sf::Color::Transparent);
                                bull2.setFillColor(sf::Color::Transparent);
                                bull3.setFillColor(sf::Color::Transparent);
                                bull4.setFillColor(sf::Color::Transparent);
                        }
 

3
Graphics / Way to detect how many times the mouse has been pressed?
« on: June 01, 2015, 07:37:01 pm »
I would like to know how one would somehow remove (well, set it's colour transparent) a rec shape, one by one, each time the mouse is clicked. So the first time you click the mouse, it removes the first shape, then when you click it again, it removes the second one, and so on. Perhaps there is a simple solution to this, I'm not sure... It's quite a basic problem with probably an easy fix, but I'm fairly new to this  8)

4
Graphics / Re: Question about textures and shapes
« on: May 27, 2015, 10:19:59 pm »
Aha, it works perfectly now thanks  :)

5
Graphics / Re: Question about textures and shapes
« on: May 27, 2015, 10:03:47 pm »
Oops I forgot the extension  :P Corrected it

It says after .setTexture "No suitable conversion function from sf::Texture to const sf::Texture* exists"

6
Graphics / Question about textures and shapes
« on: May 27, 2015, 09:56:34 pm »
I would like to set the texture of a RectangleShape, but I don't understand how you do it like in the documentation. Can someone tell me how to do it please? I created my texture and rectangleshape but I don't know how you actually set it. My code doesn't seem to work.

sf::Texture rectex;
rectex.loadFromFile("resources/texture");

rectangle.setTexture(rectex);
 

7
Graphics / Loop a sprite's movement?
« on: May 27, 2015, 05:56:05 pm »
I'm a bit stuck with this one, I'm trying to make a sprite move back and forth forever, while the game loop is running. At first I tried to use a timer/clock function, but I couldn't get a library/function that I could use. What I have tried now though is having 2 invisible rects, one at each end of the sprite's path. So when the sprite intersects one, it's direction is reversed and so on. However in my code I can't figure out where I've gone wrong. Any thoughts? Sorry if it is a bit hard to understand in the code.


        bool targmright = false; // bool for moving the sprite right
        bool targmleft = true; // bool for moving the sprite left

                        if (targmleft == true) // "targ" is the sprite I mention
                        {
                       
                                targ.move(-1, 0);
                               
                                if (targb.intersects(targlb))   // if the sprite's bounding box intersects the left bounding box
                                {
                                        targmright = true;
                                targmleft = false;
}
                               
                                       
                       
                        }

                        if (targmright == true)
                        {

                                targ.move(1, 0);
                       
                               
                                if (targb.intersects(targrb))
                                {
                                        targmright = true;
                                        targmleft = false;
                                }

                        }
 

8
Audio / Re: (Noob question) How do you play music once?
« on: May 27, 2015, 05:05:57 pm »
Thanks for both the answers, I got it to work now.

9
Audio / (Noob question) How do you play music once?
« on: May 27, 2015, 04:43:59 pm »
Hi, as the title says I'm new to this. But anyways I can't think how one would check if a sound file had finished playing or something like that, so I can play it just once? The problem I have is that when the left mouse button is pressed, it constantly plays the music file over and over again until it is not pressed. I can't figure out how to play it just once. What am I missing here?

Pages: [1]
anything