• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Render Engine only working in one direction

T

TurtleBitAlex

Guest
Hello. Iv recently made a render engine to deactivate things that aren't in the visible area of the player. when first spawning in the game has good fps. but when going right through the map the fps starts to lower.
When I go back left away back to the spawn the fps starts to go back up. I'm just wondering if when going right it doesn't unload whats on the left but when I go back it unloads whats on the right that's just a theory though.
CREATE CODE
Code:
vx = camera_get_view_x(view_camera[0]); //camera x
vy = camera_get_view_y(view_camera[0]); //camera y
vw = camera_get_view_width(view_camera[0]); //camera width
vh = camera_get_view_height(view_camera[0]); //camera height
vh=vh+500
vw=vw+500
alarm[0]=1; //activate area
STEP CODE
Code:
vx = camera_get_view_x(view_camera[0]); //camera x
vy = camera_get_view_y(view_camera[0]); //camera y
vw = camera_get_view_width(view_camera[0]); //camera width
vh = camera_get_view_height(view_camera[0]); //camera height
if (instance_exists(obj_entity_player))
{
x=obj_entity_player.x;
y=obj_entity_player.y;
}
ALARM 0 CODE
Code:
instance_deactivate_region(vx,vy,vx+vw,vy+vh,false,false);

instance_activate_region(vx,vy,vx+vw,vy+vh,true);
alarm[0]=30;
vx = camera_get_view_x(view_camera[0]); //camera x
vy = camera_get_view_y(view_camera[0]); //camera y
 
T

TinCan

Guest
You really don't need the alarm. Just call put this at the very beginning of your step code:
Code:
instance_deactivate_all(true);
instance_activate_region(vx,vy,vx+vw,vy+vh,true);
It will first deactivate all objects, and then reactivate the ones within the view before rendering the frame. You won't see it happen, and you don't have to worry about anything outside the view staying active.
 
Top