Created
July 5, 2017 21:34
-
-
Save Matojeje/ec1878bf849576085e43f80ca0ba311f to your computer and use it in GitHub Desktop.
[Small Basic w/ Data Extension] This will move the GameWindow using the numpad - arrows move the window by 10 pixels, [5] centers it and [7] puts it to coords [0,0]. Every second, the code checks if the window is outside the screen, and warps it back in a way so that it's fully visible. It also accounts for the taskbar.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' settings | |
includeTaskbar = 1 | |
taskbarHeight = 30 | |
gridSize = 10 | |
GameKeyboard.KeyDown = boop | |
Sub boop | |
If GameKeyboard.LastKey = "NumPad8" Then 'up | |
GameWindow.Top = GameWindow.Top - gridSize | |
ElseIf GameKeyboard.LastKey = "NumPad4" Then 'left | |
GameWindow.Left = GameWindow.Left - gridSize | |
ElseIf GameKeyboard.LastKey = "NumPad6" Then 'down | |
GameWindow.Left = GameWindow.Left + gridSize | |
ElseIf GameKeyboard.LastKey = "NumPad2" Then 'right | |
GameWindow.Top = GameWindow.Top + gridSize | |
ElseIf GameKeyboard.LastKey = "NumPad5" Then 'center | |
GameWindow.Left = (Desktop.Width/2)-(GameWindow.Width/2) | |
GameWindow.Top = (Desktop.Height/2)-(GameWindow.Height/2) | |
ElseIf GameKeyboard.LastKey = "NumPad7" Then 'top left | |
GameWindow.Top = 0 | |
GameWindow.Left = 0 | |
EndIf | |
EndSub | |
Timer.Interval = 1000 | |
Timer.Tick = check | |
Sub check | |
If includeTaskbar = 1 Then | |
If GameWindow.Top < 0 Then | |
GameWindow.Top = 0 | |
ElseIf GameWindow.Top > Desktop.Height - GameWindow.Height - taskbarHeight Then | |
GameWindow.Top = Desktop.Height - GameWindow.Height - taskbarHeight | |
EndIf | |
Else | |
If GameWindow.Top < 0 Then | |
GameWindow.Top = 0 | |
ElseIf GameWindow.Top > Desktop.Height - GameWindow.Height Then | |
GameWindow.Top = Desktop.Height - GameWindow.Height | |
EndIf | |
EndIf | |
If GameWindow.Left < 0 Then | |
GameWindow.Left = 0 | |
ElseIf GameWindow.Left > Desktop.Width - GameWindow.Width Then | |
GameWindow.Left = Desktop.Width - GameWindow.Width | |
EndIf | |
EndSub | |
'by matojeje | |
'cc-by |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment