When generating random forests on my world:
Create Event:
execute code:
//VARIABLES
//-sprite_rotation
direction = random(360)
image_angle = direction
//FOREST_GEN
forestDensity = random_range(50,200)
repeat (forestDensity)
{ forestWidth = random_range(-500,500)
forestHeight = random_range(-500,500)
instance_create(x + forestWidth,y + forestHeight,tree_trunk)
}
Works perfectly fine but having that many instances of 'tree_trunk' and' tree_branch' causes the entire game to drop to about 1-5 fps. Any fix for this?
Im thinking I could make 'tree_branch' a surface rather than an object but 'tree_trunk' is needed for collision checking.
Tips on Reducing CPU Usage?
Started by ParaplegicPenguin, Jun 06 2012 11:22 PM
2 replies to this topic
#1
Posted 06 June 2012 - 11:22 PM
#2
Posted 07 June 2012 - 04:35 AM
Simple solution, make the tree full with branches and make the collision area for only the trunk;
I mean to use one object with the trunk and branches in one image, then for this image make the collision box set for only that small area of the trunk
I mean to use one object with the trunk and branches in one image, then for this image make the collision box set for only that small area of the trunk
Edited by Conan87, 07 June 2012 - 04:36 AM.
#3
Posted 07 June 2012 - 09:49 AM
Also, you could consider placing tiles for the trees and then check for collisions with the tiles by writing your own algorithm calling tile_layer_find() a few times to see if there's to tree in the direction you're trying to move. Tiles take a LOT less processing time than instances, so it's worth looking into.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











