This is how to replace the windows border that is by standard in windowed mode with your own border. The aim is to give the new border the same functions but a better look. The first thing we need to do is to change the global game settings, as we do not want to draw the standard windows border. You find that option under “Graphics” and it says “Don’t draw a border in windowed mode”.
Next thing that you need to do is to draw your new border and add it as a sprite. The border should preferably be drawn plain, maybe with a caption but without buttons. It should be as wide as you want to, suggestively as wide as the room (by standard 640 pixels).
Create a new object and set your new sprite as sprite. Put it into the room, usually it would be placed at position (0,0) but if your sprite is shorter than the width of the room you may align it any way you want or even centre it.
if (mouse_check_button(mb_left)==true) {
if (position_meeting(mouse_x,mouse_y,self)) {
window_set_position(window_get_x()+mouse_x-start_x,window_get_y()
+mouse_y-start_y)
}
}
}
The equation might be a little tricky to understand. What it says is basically this: left position of the screen plus the position of the mouse in your game (where top left corner is 0) minus the start position (where you first pressed the mouse). So in numbers the equation might be 100 + 100 – 50, this is 150. Let’s say this was the x position, the game window will have moved 50 pixels to the left.
start_x and start_y needs to be initialized, and reinitialized every time the mouse button is pressed again, so preferably you would put this code in the left mouse button pressed event:
start_x = mouse_x;
start_y = mouse_y;
.
Users logged in:
Comments
Loading comments...