Flyer Invasion - Just for fun :)
Posted: Sunday 30th October 2016 5:16pm
Code: Select all
Public Sub ScreenSize() As String 'To capture current screen size
Dim sData, sSize, sTemp As String 'Variables to store the result of the shelled command, the size of the screen and a Temp variable
Dim siCount As Short 'To store the position in the string (e.g.1920 x 1080) of the 'x'
Shell "xrandr --current" To sData 'Shell the command and store the result in sData
For Each sTemp In Split(sData, "\n") 'For each Newline in sData..
siCount = InStr(sTemp, "current") 'See is the word 'current' exists
If siCount Then 'If it does then..
sSize = Mid(sTemp, siCount + 8, InStr(sTemp, ",", siCount) - (siCount + 8)) 'Capture only the size details (e.g. 1920 x 1080)
Break 'Get out of the loop
End If
Next
Return sSize 'Return the size
End
Public Sub Main()
Dim siSizeW, siSizeH As Short 'Variables to store the screen size Width and Height
Dim sData As String 'Variable to store the data from the ScreenSize() routine
Randomize CInt(Now)
$hWindow = New Window As "Window"
sData = ScreenSize() 'Get the current screen size
siSizeW = Val(Trim(Mid(sData, 1, InStr(sData, "x") - 1))) 'Capture the screen width only
siSizeH = Val(Trim(Mid(sData, InStr(sData, "x") + 1))) 'Capture the screen height only
Print "Screen size is " & Str(siSizeW) & " x " & Str(siSizeH) & "\n" 'Print screen size
With $hWindow
.Resize(siSizeW, siSizeH) 'Apply the collected data
'.Resizable = True
.FullScreen = True
.FrameRate = FRAMERATE
.Show()
End With
If Exist("highscore.ini") Then
$iHighScore = CInt(File.Load("highscore.ini"))
Else
$iHighScore = 0
File.Save(Application.Path &/ "highscore.ini", 0)
Endif
LevelUp()
Mouse.Hide()
$iPlayerX = $hWindow.H / 2 - $iPlayerW / 2
Music.Load("Hero Immortal.mp3") 'By Trevor Lenz, http://opengameart.org/content/hero-immortal
$hShootSound = Sound.Load("laser10.wav") 'By dklon, http://opengameart.org/content/laser-fire
$hHitSound = Sound.Load("laser8.wav") 'By dklon, http://opengameart.org/content/laser-fire
End
Public Sub GetResolution()
Dim s As String
Shell "whereis xrandr" To s
If Not InStr(s, "/usr/bin/") Then
Print "Could not detect screen resolution! xrandr seems to not be installed! Falling back to default and windowed mode"
$hWindow.FullScreen = False
Return
Endif
$hWindow.FullScreen = True
Shell "xrandr --current | grep '*'" To s
s = Split(Trim(s), " ")[0]
$iDesktopW = Split(s, "x")[0]
$iDesktopH = Split(s, "x")[1]
End