TGC Codebase Backup



First Instance Display Request by _ RealUnReal _

15th Oct 2004 13:50
Summary

This Function will allow a user of your Software to set the desired resolution of your program, It will record the settings to a file and load them each time your program is starte



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    REM Project: *******************
REM Created: 15/10/2004 12:43:22
REM
REM ***** Main Source File *****
REM

Global Display_Width As Integer
Global Display_Height As Integer
Global Display_Depth As Integer

      Display_Width = 640
      Display_Height = 480
      Display_Depth = 16

Rem ****************Program Start**********************
Load_Display_Setup()
End
Rem *****************Program End***********************

Function Load_Display_Setup()
If File Exist("Display.Dat")
   Open To Read 1, "Display.Dat"
      Read Long 1, Display_Width
      Read Long 1, Display_Height
      Read Long 1, Display_Depth
   Close File 1

   Set Display Mode Display_Width, Display_Height, Display_Depth

Else
   Setup_Display()
   Open To Write 1, "Display.Dat"
         Write Long 1, Display_Width
         Write Long 1, Display_Height
         Write Long 1, Display_Depth
      Close File 1
EndIf
EndFunction

Function Setup_Display()

   If Check Display Mode(Display_Width, Display_Height, Display_Depth)
      Set Display Mode Display_Width, Display_Height, Display_Depth
      Set Global Collision Off
      Sync On
      Color BackDrop 0
      Autocam Off
      Sync
   Else
      End
   EndIf

         Position Camera 0, 0, -6
         Make Object Box 1, 3, 1, 3
         Position Object 1, 0, 2.15, 0

         Display_Resolution()
         Create_Display_MenuItems()

      Accept = 0
      Repeat



         If Pick Object(MouseX(), MouseY(), 1, 1)
            Yrotate Object 1, Object Angle y(1) + 0.20
         Else
            Yrotate Object 1, Object Angle Y(1) + 0.10
         EndIf

         If Pick Object(MouseX(), MouseY(), 2, 2)
            If Object Position Z(2) > -2.0
               Position Object 2, 0, 0, Object Position Z(2) - 0.1
            EndIf
            If Display_Width <> 640
               If MouseClick() = 1
                  Display_Width = 640
                  Display_Height = 480
                  Display_Resolution()
               EndIf
            EndIf
         Else
            If Object Position Z(2) < 0.0
               Position Object 2, 0, 0, Object Position Z(2) + 0.1
            EndIf
         EndIf

         If Pick Object(MouseX(), MouseY(), 3, 3)
            If Object Position Z(3) > -2.0
               Position Object 3, 0, Object Position Y(3) + 0.015, Object Position Z(3) - 0.1
            EndIf
            If Display_Width <> 800
               If MouseClick() = 1
                  Display_Width = 800
                  Display_Height = 600
                  Display_Resolution()
               EndIf
            EndIf
         Else
            If Object Position Z(3) < 0.0
               Position Object 3, 0, Object Position Y(3) - 0.015, Object Position Z(3) + 0.1
            EndIf
         EndIf

         If Pick Object(MouseX(), MouseY(), 4, 4)
            If Object Position Z(4) > -2.0
               Position Object 4, 0, Object Position Y(4) + 0.025, Object Position Z(4) - 0.1
            EndIf
            If Display_Width <> 1024
               If MouseClick() = 1
                  Display_Width = 1024
                  Display_Height = 768
                  Display_Resolution()
               EndIf
            EndIf
         Else
            If Object Position Z(4) < 0.0
               Position Object 4, 0, Object Position Y(4) - 0.025, Object Position Z(4) + 0.1
            EndIf
         EndIf

         If Pick Object(MouseX(), MouseY(), 5, 5)

               If MouseClick() = 1
                Accept = 1
               EndIf

         EndIf

      Sync
      Until Accept

Rem ************************Delete Objects***********************
      For Count = 1 to 5
         Delete Image Count
         Delete Object Count
      Next Count

EndFunction

Function Display_Resolution()

         Create Bitmap 1, 256, 32
         Set Current Bitmap 1
         CLS RGB(50,50,255)
         Center Text 127, 8, "Display " + STR$(Display_Width) + " X " + STR$(Display_Height) + " X " + STR$(Display_Depth)
         Get Image 1, 0, 0, 255, 31

         Set Current Bitmap 0
         Delete Bitmap 1


         Texture Object 1, 1
EndFunction

Function Create_Display_MenuItems()

   Create Bitmap 1, 255, 32
   Set Current Bitmap 1

   CLS RGB(50,50,255)
   Center Text 127, 8, "640 X 480"
   Get Image 2, 0, 0, 255, 31

   CLS RGB(50,50,255)
   Center Text 127, 8, "800 X 600"
   Get Image 3, 0, 0, 255, 31

   CLS RGB(50,50,255)
   Center Text 127, 8, "1024 X 768"
   Get Image 4, 0, 0, 255, 31

   CLS RGB(50,50,255)
   Center Text 127, 8, "ACCEPT"
   Get Image 5, 0, 0, 255, 31

   Set Current Bitmap 0
   Delete Bitmap 1

   Make Object Plain 2, 2, 0.5
   Texture Object 2, 2
   Make Object Plain 3, 2, 0.5
   Texture Object 3, 3
   Make Object Plain 4, 2, 0.5
   Texture Object 4, 4
   Make Object Plain 5, 2, 0.5
   Texture Object 5, 5

   Position Object 2, 0, 0, 0
   Position Object 3, 0, -1, 0
   Position Object 4, 0, -2, 0
   Position Object 5, 0, -3, 0


EndFunction