RefresherTowel
Member
Hey guys,
I'm trying to create a destructible terrain that a drill can drill through. Initially I was using objects to fill the screen and then get destroyed, but that is obviously a memory hog and also didn't look great. So I've moved onto surfaces (not even really sure if this is the best way to go about it, but it certainly runs faster than objects).
I'm creating an 'infinite' terrain by having a room that is the size of my game screen (right now 480 x 960) with a view enabled and then simply having the view follow the falling drill through this code in the Step event:
The drill just uses basic gravity to fall. Then I'm drawing a rectangle the size of the view onto a surface, having that surface be drawn following the view_xview and view_yview, and then having the drill subtract a section where ever it is through a subtraction blend mode.
obj_dirtdraw Draw Event:
obj_drill Draw Event:
This is my first real foray into using surfaces and it's not working as I expected. Instead of the surface 'following' the drill, the surface is acting as though the drill is actually moving down and exiting the bottom of the screen, while the drill itself is still being followed by the view. If that sounds vaguely confusing, here's a youtube link to what I'm talking about (about halfway through the vid I restart the game so you can see the problem in action):
You can clearly see the drill is actually moving down, with a vspeed of 10.10, it's obviously being followed by the view, yet the drill destruction moves down and off the screen.
Any help would be greatly appreciated.
I'm trying to create a destructible terrain that a drill can drill through. Initially I was using objects to fill the screen and then get destroyed, but that is obviously a memory hog and also didn't look great. So I've moved onto surfaces (not even really sure if this is the best way to go about it, but it certainly runs faster than objects).
I'm creating an 'infinite' terrain by having a room that is the size of my game screen (right now 480 x 960) with a view enabled and then simply having the view follow the falling drill through this code in the Step event:
Code:
view_yview[0] = round(y-(view_hview[0]/2));
obj_dirtdraw Draw Event:
Code:
if (surface_exists(surface)) {
draw_surface(surface,view_xview[0],view_yview[0]);
}
else {
surface = surface_create(view_wview[0],view_hview[0]);
surface_set_target(surface);
draw_set_color(make_color_rgb(118,84,50));
draw_rectangle(view_xview[0],view_yview[0],view_xview[0]+view_wview[0],view_yview[0]+view_hview[0],0)
surface_reset_target();
}
Code:
if (surface_exists(obj_dirtdraw.surface)) {
surface_set_target(obj_dirtdraw.surface);
draw_set_blend_mode(bm_subtract);
draw_set_color(c_black);
draw_sprite(spr_destruct,0,x,y);
draw_set_blend_mode(bm_normal);
surface_reset_target();
draw_self();
}
draw_text(x,y-10,"Spd: "+string(vspeed));
You can clearly see the drill is actually moving down, with a vspeed of 10.10, it's obviously being followed by the view, yet the drill destruction moves down and off the screen.
Any help would be greatly appreciated.