A
Adam Martinez
Guest
Hello. I'm currently making a paint app (like Mario Paint) and am trying to create an "undo" button for the user to remove the last thing that they drew (draw_line, draw_circle, etc.)
I'm using surfaces with a white background.
My first idea was to use a temporary surface that the player draws onto, and then copy it on top of a more permanent surface (part of the overall drawing/painting the player is making) at the right time, then "clearing" the temporary surface with a huge white sprite.
//when the player starts drawing a new line, the old line is copied from the temporary surface to the permanent surface, and the temporary surface is cleared blank with a huge white sprite, ready for the player to draw a new line
if mouse_check_button_pressed(mb_left) {
surface_set_target(surface)
surface_copy(surface,0,0,preliminary_surface)
surface_reset_target()
surface_set_target(preliminary_surface)
draw_sprite_ext(spr_white_surface,0,0,0,1,1,0,0,0)
surface_reset_target()
}
I think this isn't possible because there's no way to "draw" a surface on top of another surface... the temporary surface will just replace the permanent surface. And... I think for some reason, this code isn't working because my "eraser" tool which draws white circles onto the permanent surface now has no effect. Something is wrong.
My second idea was to use the file handling, but I don't know how to use file handling to save a series of lines and circles drawn between a mouse_check_button_pressed() and mouse_check_button_released().
Any ideas how to make this "undo" function work?
Thank you!
I'm using surfaces with a white background.
My first idea was to use a temporary surface that the player draws onto, and then copy it on top of a more permanent surface (part of the overall drawing/painting the player is making) at the right time, then "clearing" the temporary surface with a huge white sprite.
//when the player starts drawing a new line, the old line is copied from the temporary surface to the permanent surface, and the temporary surface is cleared blank with a huge white sprite, ready for the player to draw a new line
if mouse_check_button_pressed(mb_left) {
surface_set_target(surface)
surface_copy(surface,0,0,preliminary_surface)
surface_reset_target()
surface_set_target(preliminary_surface)
draw_sprite_ext(spr_white_surface,0,0,0,1,1,0,0,0)
surface_reset_target()
}
I think this isn't possible because there's no way to "draw" a surface on top of another surface... the temporary surface will just replace the permanent surface. And... I think for some reason, this code isn't working because my "eraser" tool which draws white circles onto the permanent surface now has no effect. Something is wrong.
My second idea was to use the file handling, but I don't know how to use file handling to save a series of lines and circles drawn between a mouse_check_button_pressed() and mouse_check_button_released().
Any ideas how to make this "undo" function work?
Thank you!