T
I've never worked with surfaces, I have no idea how to do.If you want to do THAT specifically, it's just simply drawing the sprite of the player again inside a small surface. You'll just have to write a bit of code to get the player's x and y as well as his sprite so you can display an alternate reverse sprite.
I've never worked with surfaces, I have no idea how to do.Drawing the front sprite using a surface, in the same X and Y position of the player, but with the Y slightly higher (more negative)
Or use dynamic rendering masks to only allow drawing in the section where the mirror is.Can use draw_sprite_part() or draw_sprite_part_ext() for the reflection as well, drawing only the part that is within the scope of the mirror. Bounds required left as an exercise for the interested reader.
// draw the mirror sprite
draw_sprite(sprite_index,0,x,y);
// mirror position
_xx = x+32;
_yy = y+32;
// create the mirror
_surf = surface_create(52,18); // mirror size
surface_set_target(_surf);
draw_clear_alpha(c_black,0);
draw_sprite(spr_player,1,obj_player.x - _xx, (_yy - obj_player.y) + 64); // draw player inverted
surface_reset_target();
draw_surface(_surf,_xx,_yy); // draw mirror
surface_free(_surf) // clear mirror
if it's not too much trouble, can i ask a question?
GML:// draw the mirror sprite draw_sprite(sprite_index,0,x,y); // mirror position _xx = x+32; _yy = y+32; // create the mirror _surf = surface_create(52,18); // mirror size surface_set_target(_surf); draw_clear_alpha(c_black,0); draw_sprite(spr_player,1,obj_player.x - _xx, (_yy - obj_player.y) + 64); // draw player inverted surface_reset_target(); draw_surface(_surf,_xx,_yy); // draw mirror surface_free(_surf) // clear mirror
You can also draw anything you want inside the mirror.
Because it is necessary to subtract the player's position from the position of the surface, since the surface is drawn in position 0.if it's not too much trouble, can i ask a question?
in draw_sprite why subtract obj_player.x - _xx. I can't understand. Because x in draw_sprite is aligned with that of the player in the game, why with just obj_player.x doesn't it work? because the sprite drawing follows x from obj_player
I simulated, basically what happens to x and y from the draw_sprite as I understand it and x doesn't match.Because it is necessary to subtract the player's position from the position of the surface, since the surface is drawn in position 0.