Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/465607168931405824
Moved the most important parts to the beginning. Simplified by removing "joining sentences" and other redundancy.
Source Link
Anko
  • 13.5k
  • 10
  • 56
  • 82

Performance and How can I improve my collision detection in C++detection's performance?

I've written aI'm new to programming and want to speed up the collision detection in my C++ 2D platformer game engine from scratch in C++. Right now the

Currently, only the player's collision detection that works is for the player. The way I have it setup right now is on each: Every frame a player, the player's update function iterates through every single tile on the level tile (which is pretty largemany) to seeand checks if the player hitbox is collidingcollides with the obstacleit.

I have two questions about this. I'm really a novice at programming, so I may be way off on this, but this seems like a really chunky way of doing it. Is this bad practice? If the level gets large enough, is iterating through this list going to take forever like it seems it should?

My second question builds off of that.: If I start adding for example, enemies into the engine, and give them a similar method for collision detection, can I expect performance drops? I'd like some insight from more experienced people on a better way of setting this up. I would just imagine that having ~20 enemies on the screen all iterating through all possible objects for collision with a list could get slow fast.

Performance and collision detection in C++

I've written a 2D platformer game engine from scratch in C++. Right now the only collision detection that works is for the player. The way I have it setup right now is on each frame a player update function iterates through every single tile on the level (which is pretty large) to see if the player hitbox is colliding with the obstacle.

I have two questions about this. I'm really a novice at programming, so I may be way off on this, but this seems like a really chunky way of doing it. Is this bad practice? If the level gets large enough, is iterating through this list going to take forever like it seems it should?

My second question builds off of that. If I start adding for example, enemies into the engine, and give them a similar method for collision detection, can I expect performance drops? I'd like some insight from more experienced people on a better way of setting this up. I would just imagine that having ~20 enemies on the screen all iterating through all possible objects for collision with a list could get slow fast.

How can I improve my collision detection's performance?

I'm new to programming and want to speed up the collision detection in my C++ 2D platformer game engine.

Currently, only the player's collision detection works: Every frame, the player's update function iterates through every level tile (which is pretty many) and checks if the player hitbox collides with it.

I may be way off on this, but this seems like a really chunky way of doing it. Is this bad practice? If the level gets large enough, is iterating through this list going to take forever like it seems it should?

My second question builds off of that: If I start adding for example enemies into the engine and give them a similar method for collision detection, can I expect performance drops? I'd like some insight from more experienced people on a better way of setting this up. I would just imagine that having ~20 enemies on the screen all iterating through all possible objects for collision with a list could get slow fast.

Source Link
barwin
  • 63
  • 1
  • 3

Performance and collision detection in C++

I've written a 2D platformer game engine from scratch in C++. Right now the only collision detection that works is for the player. The way I have it setup right now is on each frame a player update function iterates through every single tile on the level (which is pretty large) to see if the player hitbox is colliding with the obstacle.

I have two questions about this. I'm really a novice at programming, so I may be way off on this, but this seems like a really chunky way of doing it. Is this bad practice? If the level gets large enough, is iterating through this list going to take forever like it seems it should?

My second question builds off of that. If I start adding for example, enemies into the engine, and give them a similar method for collision detection, can I expect performance drops? I'd like some insight from more experienced people on a better way of setting this up. I would just imagine that having ~20 enemies on the screen all iterating through all possible objects for collision with a list could get slow fast.