Flyer Invasion - Just for fun :)

Post

Posted
Rating:
#1 (In Topic #100)
Avatar
Regular
jornmo is in the usergroup ‘Regular’
:D

Attachment

Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
jornmo is in the usergroup ‘Regular’
 You might want to set this line
 .Resize(1600, 900)
to your screen resolution, or it will look awkward!

Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
If only all Linux systems were the same!

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>
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
jornmo is in the usergroup ‘Regular’
Thanks cogier! That should do it, and I will try to implement it soon :) I also had some issues to get the fullscreen to work to begin with, but then it resolved for some reason unbeknownst to me... perhaps it should be reported as a bug. From here on, I will publish the updates on the farm.

Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
jornmo is in the usergroup ‘Regular’
This is what I did:

Code (gambas)

  1. Public Sub GetResolution()
  2.  
  3.  
  4.   Shell "whereis xrandr" To s
  5.   If Not InStr(s, "/usr/bin/") Then
  6.     Print "Could not detect screen resolution! xrandr seems to not be installed! Falling back to default and windowed mode"
  7.     $hWindow.FullScreen = False
  8.     Return
  9.  
  10.   $hWindow.FullScreen = True
  11.  
  12.   Shell "xrandr --current | grep '*'" To s
  13.   s = Split(Trim(s), " ")[0]
  14.   $iDesktopW = Split(s, "x")[0]
  15.   $iDesktopH = Split(s, "x")[1]
  16.  
  17.  

Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Guru
cogier is in the usergroup ‘Guru’
Yes I have looked at this and learnt a lot. I did not know you could do that. As usual - VERY IMPRESSIVE CODE! :geek:

I have one question. Why do you use a variable 's' and not sData or sResult (or Similar)?
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Regular
jornmo is in the usergroup ‘Regular’
Thank you! Glad it has helped you :) Whenever I need a variable to be used a bit here and a bit there just for temporary operations, I tend to use an i, s, f or whatever variable type I need. So, when it is just s I can reuse it all over and I do not have to declare lots of variables for each place I need a string that I really do not need to remember what's inside :)

Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Regular
jornmo is in the usergroup ‘Regular’
And I also find it to keep the code more clean and easy to read and understand.

Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Guru
cogier is in the usergroup ‘Guru’
 The latest version seems to work well.  Fullscreen works now as well.
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Regular
jornmo is in the usergroup ‘Regular’
Good! It is due a change I made based on a report from the Gambas mailing list. Resize must be set to True in order for fullscreen to work on some systems it seems. My laptop does not require it though... no idea why :)

Online now: No Back to the top
1 guest and 0 members have just viewed this.