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

Pages: [1]
1
General discussions / Re: Separating Input, Updates, and Rendering
« on: August 31, 2014, 04:06:13 pm »
Oh okay, that makes sense :)

Thanks

2
General discussions / Separating Input, Updates, and Rendering
« on: August 31, 2014, 03:36:38 pm »
I was wondering if it is essential to separate input updates and rendering from each other in a game, and if so then why? I can't really find anything about this online and my only ideas are that the may get confusing and it may impact frames per second...

Does anyone know why we game programmers?

Thanks

3
General / Text loses quality when increasing window size
« on: August 26, 2014, 02:10:34 pm »
At the moment my program stays at 1080x720 resolution, and everything looks fine. However if you make the window larger in any way then text looks much less detailed and clear.

Is there a way to get around this and make the text keep it's quality?

4
General / Re: Lag when assigning projectiles as elements in a vector
« on: March 05, 2014, 05:32:47 pm »
Okay so I came home and tried your idea of emplace_back(), and that reduced the lag by a fair bit, so thank you :D
I also had another look through my projectile class and rather than saving the projectile texture to the class before assigning it to the sprite I assigned the texture straight away. That got rid of all lag completely, so I guess it was because the computer was trying to copy the texture back into the class :')

Thank you for the help guys :D

5
General / Re: Lag when assigning projectiles as elements in a vector
« on: March 04, 2014, 10:18:03 pm »
The Projectile class inherits the sf::sprite member along with the collision function, and I passed the vector by reference I think.

6
General / Re: Lag when assigning projectiles as elements in a vector
« on: March 04, 2014, 09:43:54 pm »
It ran fine on the netbook without projectiles being fired, and the netbook could also handle updating the projectiles after they had been added to the vector. The projectile.h code is bellow:
class Projectile : public Drawable
{
protected:
        // game related stuff
        int damage;
        float speed;

        // math related stuff
        float xdif;
        float ydif;
        float distance;

public:
        Projectile();
        Projectile(int Damage, float speed, sf::Texture &Texture, sf::IntRect rect);
        ~Projectile(void);

        void resetProjectile(float xstart, float ystart, float xend, float yend); // reset the projectiles position and distance coords
        void update(); // update the projectile
}

I've managed to fix the problem with lag when checking for collisions by changing the projectile vector into a projectile* vector earlier this hour, but it's had no effect on the lag when creating the projectile. I've also noticed that there's no lag when erasing the projectiles. The netbook also had no lag in both of these cases

7
General / Re: Lag when assigning projectiles as elements in a vector
« on: March 04, 2014, 09:01:44 pm »
I've tried using it in release mode and my computer has no trouble running it then, but even in release mode my slow netbook struggles to run it. Since I want to make my game accessible for as many people as I can i'm trying to run in debug mode to simulate a bad computer. And the maximum number of projectiles I have in each projectiles container is about 20

8
General / Lag when assigning projectiles as elements in a vector
« on: March 04, 2014, 05:53:28 pm »
Hello All!
As part of my top-down shooter that I'm making I am using a vector to hold data on projectiles. Currently, when I run the game on my netbook in release mode or on my pc in debug mode my game begins to lag a lot when adding projectiles to the vector (aka shooting) and when checking for collisions between projectiles and game entities.
 
Below is the declaration of the vector in the entity.h:
std::vector<Projectile> projectiles;

Below I have the code for firing the projectiles inside a function within entity.cpp:
reloadTimer.restart();

projectiles.push_back(projectile);
// put a projectile in the back of the vector
projectiles[projectiles.size() - 1].resetProjectile(getXPosition(), getYPosition(), xtar, ytar);
// reset the projectiles position and target

And below is the code for the collision between player projectiles and enemy entities:
for(int i = 0; i < EnemyContainer.size(); i ++){
        for(int k = 0; k < player.projectiles.size(); k ++){
                if(player.projectiles[k].BBCollision(EnemyContainer[i].getSprite())){
            // if the player bullet collides with an enemy
            EnemyContainer[i].loseHealth(player.getProjDamage()); // make the enemy lose health
            player.projectiles.erase(player.projectiles.begin() + k); // "kill" the projectile
            }
        }
}

I was wondering if any of you wonderful people could help me once again and give me an idea in how to reduce lag when doing those two things? I have already used vector::reserve() in the constructor of the entity class, so I'm not sure what's the problem. Thank you very much in advance!

9
General / Re: Lag when checking for collision in a top down shooter
« on: March 01, 2014, 11:19:09 pm »
Ahh okay, thanks :D

10
General / Lag when checking for collision in a top down shooter
« on: March 01, 2014, 10:14:15 pm »
Hello all!

I'm currently programming the backbones for a top-down shooting game using SFML 2.1 and C++. I'm getting around to implementing projectiles and collision detection between projectiles and enemy units, however when I added the bounding box collision detection to my game loop it made the game drop from an even 60 FPS to a low 30 FPS.

My game-loop looks similar to this:
while(playing)
{
    //input
    //other processing
    if(BBCollision(player.getProjectile().getSprite(), enemy.getSprite()) == true){
        enemy.setDraw(false);
    }
    // output
}
And my function looks like this:
bool BBCollision(sf::Sprite sprite1, sf::Sprite sprite2){
        if(     sprite1.getPosition().x > sprite2.getPosition().x + sprite2.getGlobalBounds().width &&
                sprite1.getPosition().y > sprite2.getPosition().y + sprite2.getGlobalBounds().height &&
                sprite2.getPosition().x > sprite1.getPosition().x + sprite1.getGlobalBounds().width &&
                sprite2.getPosition().y > sprite1.getPosition().y + sprite1.getGlobalBounds().height)
                return true;
        else
                return false;
}

So can anyone point me what I did wrong and what I could do to get rid of the lag? Thank you in advance :)

11
General / Re: Image cache for a basic game
« on: February 28, 2014, 06:34:22 pm »
Okay, thanks :D

12
General / Image cache for a basic game
« on: February 28, 2014, 06:19:02 pm »
Hello All!

I already understand what a cache is, but I have a question about using one in my game. Firstly, what would be the best way to implement a cache using SFML and c++? I assume I'd need to make a collection of global textures that could be accessed from anywhere, but how should I do it?
Secondly, what kind of things should I load into the cache and what shouldn't I load? I think that I should load in the texture containing my common enemies and the texture containing different projectiles, but what other things should I be using there?

Thank you!

13
General / Re: What's the best method to give an entity a "search" range?
« on: February 26, 2014, 09:22:17 pm »
Okay, thank you :)

14
General / What's the best method to give an entity a "search" range?
« on: February 26, 2014, 09:10:21 pm »
Hello all!
I just have a quick (and fairly noob-ish) question about enemies in a game having a "search" range. Say for instance I want to have a turret that will attack an enemy unit within a specified range, what is the best and most efficient way of finding an enemy unit if you have more than one enemy?

I was thinking about having the turret find the distance between itself and every enemy in the container and then selecting the closest one that is within it's range. However wouldn't that just make the game lag if there are more turrets added? So which method would you guys say is the best for making a "search" range?

Thanks :D

Pages: [1]