Pineapple Lake
Member
Thanks for your reply.@Pineapple I don't really understand why you are drawing the app surface that way instead of just drawing it with a calculated scale, here's how I would do it:
console create:
console stepCode:ideal_width = 320; ideal_height = 180; application_surface_draw_enable(false); window_set_size(1200,300); //or whatever display_set_gui_size(ideal_width,ideal_height);
console post-drawCode:scale = floor(min(window_get_width()/ideal_width,window_get_height()/ideal_height))
Code:var _xoff = window_get_width()/2 - (ideal_width*scale/2); var _yoff = window_get_height()/2 - (ideal_height*scale/2); draw_surface_ext(application_surface,_xoff,_yoff,scale,scale,0,c_white,1);
as for the mouse position detection thing, that's a bit of a pain. But it is possible to convert the window mouse coordinates to be relative to the room. Keep in mind, however, that this code does not take into account a moving camera. And if you start using the GUI layer for your UI, well things will just get even more complicated.
console begin step
global.mx and global.my are your new "mouse_x" and "mouse_y" Which means you can no longer use the built in mouse events. So I added this step event to obj_squareCode:var _win_w = window_get_width(); var _win_h = window_get_height(); var _ideal_w = console.ideal_width; var _ideal_h = console.ideal_height; var _game_w = _ideal_w*scale; var _game_h = _ideal_h*scale; var _xmarg = (_game_w-_win_w)/(scale*2); var _ymarg = (_game_h-_win_h)/(scale*2); global.mx = lerp(_xmarg,_ideal_w-_xmarg,window_mouse_get_x()/_win_w); global.my = lerp(_ymarg,_ideal_h-_ymarg,window_mouse_get_y()/_win_h);
And the result:Code:if(point_in_rectangle(global.mx,global.my,bbox_left,bbox_top,bbox_right,bbox_bottom)) image_blend=c_black; else image_blend=c_white;
https://gyazo.com/9bce9fa5ce2cdf4f4696f5b9581fe148
I'm drawing the app surface this way because I want the sprite and particle effects to be applied on the full canvas and not on the 320x180 canvas, it looks a lot better on a bigger canvas.
Thanks for the solution! I'm sad there's not an easier solution, I guess I need to change all mouse events for my >50 objects if I want to implement this feature.
I'm just very surprised that there is no function to change the position or aspect of the application surface; you can change the place where it's drawn, but it's not actually there. If this was possible we didn't need this workaround. Maybe I'll one day send yoyo a feature request.
Last edited: