optimization - Java game development. Making a tile-map faster. Advices on optimisations -
i'm trying make fully-automated game engine needs working based on events. problem i'm facing i've made map class , it's initialized in game class. it's static , 1 map exists game. new maps loaded clearing objects in current map , adding new maps. can see source of map class here.
http://code.google.com/p/game-engine-for-java/source/browse/src/com/gej/map/map.java
the main problems comes in collision detection, i'm using brute-force collision detection should not. slows down game lot , wanna check collisions objects nearer object. i've been using maploader interface construct maps. i'm thinking calling collision() method of objects in thread might help. how-ever map objects updated in game class.
here's game class if in case might help
http://code.google.com/p/game-engine-for-java/source/browse/src/com/gej/core/game.java
there's problem some-times, objects aren't destroyed. i'm calling map's removeobject() method takes 1-second delay , times wont remove at-all.
it gives me 48-64 fps in platform game 158 objects in game. in space-invaders style game, gives me 20-30 fps. advice on optimization appreciated...
if me tutorial binary spacing etc., thankful.
two suggestions looking @ code: first thing should try minimize object allocation in collision detection, don't create new rectangles, work on data have writing directly collision detection algorithm.
second more important thing: collision detection engine should work using 2 levels:
- a coarse level of collision excludes objects surely far collide (you can use many techniques here, binary spatial partition algorithm of big colliding blobs, or hierarchical structure of objects)
- a fine level compute specific details collision can occur, more precise algorithms
Comments
Post a Comment