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

Pages: [1] 2
1
General / Re: main menu
« on: April 09, 2013, 05:03:32 pm »
A couple of nested if-statements for each button should do the trick. Super-pseudo-mode activate:

if (button contains mouse)
{
     Switch to highlighted state of the button

     if (mouse button is pressed)
     {
           do things
     }
}

2
General / Re: Can't record my game
« on: March 07, 2013, 07:08:19 pm »
Well it works with the style set to Default, only wish the frame-rate didn't drop. I guess this means case closed, even with the borders it will do the job.

3
General / [SOLVED]Can't record my game
« on: March 07, 2013, 06:04:56 pm »
I've tried 3 different screen recorders and none can record the game, so I am assuming that's not the problem. I can either only see the console window and the actual SFML window is invisible (even though you can see my mouse cursor moving around, the only indication of me playing the game) or I can see like the first frame of the game and then it's frozen. Why can't screen recorders pick up the SFML windows?

Here's my window if that's the issue:

sf::RenderWindow window;
window.create(sf::VideoMode::getDesktopMode(), "game", sf::Style::None);
window.setVerticalSyncEnabled(true);

I also tried setting the style to Fullscreen - nothing.

4
General / Re: Collision detection between objects stored in a vector
« on: February 24, 2013, 09:59:48 pm »
I had inherited both classes from sf::RectangleShape and used the methods from that class instead of creating my own. This resulted in the default values being used i.e. the default position of the enemy is (0, 0) and that is what was used for everything, same for global bounds, not sure why though. I simply created my own methods in the Enemy class to return the position and bounds and it works like a charm now.
Thanks Gan, testing that set me on the right track.

5
General / Re: Collision detection between objects stored in a vector
« on: February 24, 2013, 08:11:40 pm »
Thanks, but I know how to access elements in a vector (I'd like to think). I wasn't really clear in my first post and didn't explain the problem, my bad.

This is my code for updating the bullets and collision between enemies & bullets (well, the latter not so much since it doesn't work):

for (int i = 0; i < bullets.size(); ++i)
        {
                bullets[i].Rotate();
                bullets[i].Move();
                bullets[i].Draw(window);

                if(enemies[0].getGlobalBounds().intersects(bullets[i].getGlobalBounds()))
                {
                        cout<<"BOOM";
                }
        }

When the bullets and the enemy overlap in the game nothing is displayed in the console. Simply doesn't work, I must be doing something wrong, but no idea what it is.

6
General / [SOLVED]Collision detection between objects stored in a vector
« on: February 24, 2013, 04:49:43 pm »
Feels like kind of a silly question, but here goes. I know how to do collision detection between rectangles and other basic shapes simply created from the sf::RectangleShape class. You define a FloatRect for each object and that's pretty much it i.e.:

int collisionEnemy (sf::RectangleShape &bullet, sf::RectangleShape &enemy)
{
    sf::FloatRect bulletRect = bullet.getGlobalBounds();
    sf::FloatRect enemyRect = enemy.getGlobalBounds();
    return bulletRect.intersects(enemyRect);
}

Unfortunately I have no clue how to do this for objects stored in vectors, I have a vector for my bullets and a vector for my enemies (with currently only one enemy stored in it).

I don't even know where to begin.

7
General / Re: [SOLVED]Assigning a direction to bullets from a vector
« on: February 14, 2013, 08:09:29 pm »
I see. Well I have the frame limiter set to 60, which should remain consistent right? Unless I decide to run it on a typewriter. For now I will leave it as it is, although I can think of other parts of the game where your code might come in handy. Anyway, thanks for the help, I do appreciate it :D

8
General / Re: [SOLVED]Assigning a direction to bullets from a vector
« on: February 14, 2013, 07:33:05 pm »
I wasn't sure what you meant by frame time "dt", so I went ahead and did something a bit different:

int accumulator = 0; //just declaring outside the main loop

accumulator = accumulator + 1;

        if (sf::Joystick::isButtonPressed(0, 5) && accumulator > 20)
        {
                accumulator = 0;
                shooting(movementX, movementY, rightStickX, rightStickY);
                bullets.push_back( Projectiles( you.getPosition().x, you.getPosition().y, 10, 10, movementX/2, movementY/2 ) ); //nvm the params
        }

Every time the loop runs it adds "1" to the accumulator. Then, if it's above 20 && the button is pressed it will reset the accumulator and push a bullet to the vector etc.
Works fine, but is this in any way inferior to your method? It seems a helluva lot simpler :D

9
General / Re: [SOLVED]Assigning a direction to bullets from a vector
« on: February 14, 2013, 05:52:36 pm »
I love how after I marked it as [SOLVED] it suddenly got popular. Anyway new problem. The direction and everything is working fine, thanks again Weeve, but what I want to do now is to DELAY the bullets fired i.e. I hold down the fire button, but it doesn't create a constant stream, rather a new bullet is created every 0.5 seconds.
At the moment it pretty much looks like a stationary dotted line, when fired in one direction.

I'm thinking one simple way to do this is to calculate the distance between the previously fired bullet and the player and if it is lesser than, say 100 pixels, don't fire the bullet. Or is there a better way of doing it? I guess now if you back up, or accelerate towards the bullet it will impact the "recharge" time.

10
General / Re: Assigning a direction to bullets from a vector
« on: February 10, 2013, 08:52:56 pm »
Thanks, got it sorted out in no time :D

11
General / Re: Main menu buttons
« on: February 09, 2013, 03:05:41 pm »
Indeed, this is the way I did it:

if (startBtn.getGlobalBounds().contains(mouseCoordX, mouseCoordY))
                {
                        //switch to a highlighted version of the button

                        if (startBtn.getGlobalBounds().contains(mouseCoordX, mouseCoordY) && sf::Mouse::isButtonPressed(sf::Mouse::Left))
                        {
                                //do things
                        }
                }

12
General / [SOLVED]Assigning a direction to bullets from a vector
« on: February 08, 2013, 07:29:32 pm »
I have multiple bullets spawning from a vector, as long as a button is pressed, but there's a little problem with the direction. The already fired bullets also change movement when the direction is changed.
Pseudo code, I don't have the project on me right now:

vector<ProjectileClass> bullets;

//this is in my main loop-------------
if (button is pressed)
                {
                        bullets.push_back(projectile); //projectile is the object created from the ProjectileClass
                        shooting();
                }

//the "shooting" function------------
int shooting()
{
//here I'm getting the direction
        movementX = getJoystickX
        movementY = getJoystickY
               
        return 0;
}

//this function is called later in the main loop to draw and move the bullets
int ShootMove()
{
        for (int i = 0; i < bullets.size(); ++i)
        {
                window.draw(bullets[i]);
                bullets[i].move(movementX/2, movementY/2);
        }
        return 0;
}


Now what I want to achieve is to have a constant stream of bullets fired into the direction the player object is pointing at. But as you can see, while the button is pressed the movementX/Y variables are updated on each loop, influencing the already fired bullets. Is there a way I can store the movement for each object spawned from the vector?


13
Graphics / Re: Background image problems
« on: February 06, 2013, 07:32:39 pm »
That did the trick, thank you! I had no idea there was a V sync function.

14
Graphics / Background image problems
« on: February 06, 2013, 07:08:11 pm »
I have an asteroids type game with a massive image for a background (6000x4000).  I have increased the area of the level by using two sf::Views, so you can move "outside" the screen area and it will track you until you reach the edge of the second View, hence the massive image.

Anyway, the problem is that there is some tear in the image when it's being updated, like a "ripple" going up the screen whenever the image is moving. This problem is only present when using the frame limiter function:

window.setFramerateLimit(60);

Without limiting the frame-rate there is no image tearing. Is this something I have to deal with, or is it an easy fix?

15
Window / Re: Rotating object using analog stick on a game-pad.
« on: January 24, 2013, 06:45:15 pm »
Thanks Laurent, got it working in 2 minutes. Masskiller, I'll keep that in mind, cheers.

Pages: [1] 2