January 15, 2021, 05:21:52 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Auto-set graphics mode by Neo Genesis10 [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Auto-set graphics mode by Neo Genesis10 [ 1+ years ago ] (Read 552 times)
BlitzBot
Jr. Member
Posts: 1
[bb] Auto-set graphics mode by Neo Genesis10 [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:42 AM »
Title :
Auto-set graphics mode
Author :
Neo Genesis10
Posted :
1+ years ago
Description :
Call this function to set your graphics mode. It auto detects what the system is capable of and saves an ini file with the users settings, which can then be altered simply later on. The file is in text format, so is easily altered. You could also edit this function to include other things into your ini file such as difficulty settings, lives or other general setups.
Code :
Code: BlitzBasic
Function
GraphicsMode
(
)
ini =
ReadFile
(
"setup.ini"
)
; reads ini file
If
ini <>
0
; Check if ini file exists
Repeat
a$ =
ReadLine
(
ini
)
; read lines
Until
a$ =
"[graphics]"
; ...until it finds the one we need
a$ =
ReadLine
(
ini
)
; read the following line
For
x =
1
To
Len
(
a$
)
; cycle through till it finds a comma
l$ =
Mid
$
(
a$,x,
1
)
If
l$ =
","
num = x
Exit
EndIf
Next
depth =
ReadLine
(
ini
)
If
depth =
0
depth =
16
; if omitted, default to 16-bit for compatibility
scr_w =
Left
(
a$, num-
1
)
; grab the screen width
scr_h =
Right
(
a$,
(
Len
(
a$
)
- num
)
)
If
scr_h <
480
Or
scr_w <
640
scr_h =
480
scr_w =
640
EndIf
If
GfxModeExists
(
scr_w,scr_h,depth
)
=
False
; if the graphics mode doesnt exist
scr_w =
GfxModeWidth
(
1
)
; set it up in basic mode
scr_h =
GfxModeHeight
(
1
)
depth =
16
EndIf
CloseFile
(
ini
)
Else
scr_w =
0
scr_h =
0
Cls
Flip
Cls
Print
"Set Graphics Mode"
For
i =
1
To
CountGfxModes
(
)
Print
i+
") "
+
GfxModeWidth
(
i
)
+
" x "
+
GfxModeHeight
(
i
)
+
" x "
+
GfxModeDepth
(
i
)
Next
.entermode
mode =
Input
(
">"
)
If
mode <
0
Or
Mode >
CountGfxModes
(
)
Goto
entermode
scr_w =
GfxModeWidth
(
mode
)
scr_h =
GfxModeHeight
(
mode
)
depth =
GfxModeDepth
(
mode
)
ini =
WriteFile
(
"setup.ini"
)
WriteLine
ini,
"[graphics]"
WriteLine
ini,scr_w+
","
+scr_h
CloseFile
(
ini
)
EndIf
Graphics
scr_w,scr_h,depth
SetBuffer
BackBuffer
(
)
Return
End Function
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Auto-set graphics mode by Neo Genesis10 [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal