Flyer Invasion - Just for fun :)
Posted
#1
(In Topic #100)
Regular

Posted
Regular

.Resize(1600, 900)
to your screen resolution, or it will look awkward!
Posted
Guru

I found a solution to the screen size issue with the code below: -
Code
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
For some reason the screen does not go to 'Fullscreen' and the display is a little small and sometimes it's got all sorts of things going on. Shutter failed to take a picture so I have had to take a photo on my phone! The writing is as you see on the photo.
<IMG src="http://www.cogier.com/gambas/Flyer.png">
</IMG>
Posted
Regular

Posted
Regular

Code (gambas)
- Print "Could not detect screen resolution! xrandr seems to not be installed! Falling back to default and windowed mode"
Posted
Guru

I have one question. Why do you use a variable 's' and not sData or sResult (or Similar)?
Posted
Regular

Posted
Regular

Posted
Guru

Posted
Regular

1 guest and 0 members have just viewed this.


