News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Multiple resolution choices

Started by Juha Kämäräinen, July 15, 2008, 02:54:00 PM

Previous topic - Next topic

Juha Kämäräinen

I want to have a multiple choices for openscreen.

but i dont even know how to set playbasic to get key for corresponding resolution.
I cant code and it shows..


OpenScreen 800,600,32,1
setfps 100
do
print "Welcome to Bujercon disposable man Prototype version 1.0"
print "Choose resolution"
print "1280,1024 ratio 5:4            press a"
print "1280,960 ratio 3:2             press b"
print "1280,1024 ratio 5:4 FULLSCREEN press c"
print "1280,960 ratio 3:2 FULLSCREEN  press d"
sync

;pressa:
;OpenScreen 1280,1024,32,1

   ; Read the Keyboard for the current key pressed
;if Inkey$(F) then
;      if Inkey$()

;    inkey$(a) then openscreen 1280,1024,32,1
  ;    inkey$(b) then openscreen 1280,960,32,1

waitkey
loop


Basically i need to know how to make my project know which key was pressed and choose corresponding resolution.
Check out my comic - Bujercon 1

Big C.

maybe this could be a (quick ;)) solution...


OpenScreen 800,600,32,1
SetFPS 100

Repeat
Cls RGB(0,0,0)
Print "Welcome to Bujercon disposable man Prototype version 1.0"
Print "Choose resolution"
Print "1280,1024 ratio 5:4            press a"
Print "1280,960 ratio 3:2             press b"
Print "1280,1024 ratio 5:4 FULLSCREEN press c"
Print "1280,960 ratio 3:2 FULLSCREEN  press d"

ThisChr$     =Inkey$()

If ThisChr$ = "a"
OpenScreen 1280,1024,32,1
ElseIf ThisChr$ = "b"
OpenScreen 1280,960,32,1
ElseIf ThisChr$ = "c"
OpenScreen 1280,1024,32,2
ElseIf ThisChr$ = "d"
OpenScreen 1280,960,32,2
EndIf

Flushkeys

Sync
Until EscKey() Or SpaceKey()


but remember this fact from command help "OpenScreen"

Quote Using OpenScreen within your programs can delete any previously load image media from memory.. Therefore, It's best to open the screen you wish to use at the start of your program, then leave it.

cheers Big C.

Juha Kämäräinen

Yes thank you!   ;D

Just the thing i wanted. I have created a design document of my prototype game. Now i can advance on it.  :)

After choosing the resolution it will go to game and you cant change it in middle.
Check out my comic - Bujercon 1

kevin


  also, you should be aware that trying to open a screen mode that doesn't exist will most likely end your program.  So rather than trying to force the screen open, it's best to first check if that mode is available..  You can do this with ScreenModeExist.  If the mode exists and then we open the screen..


EG



OpenScreen 800,600,32,1
SetFPS 100

NewScreenMode=false
Repeat
Cls RGB(0,0,0)
Print "Welcome to Bujercon disposable man Prototype version 1.0"
Print "Choose resolution"
Print "1280,1024 ratio 5:4            press a"
Print "1280,960 ratio 3:2             press b"
Print "1280,1024 ratio 5:4 FULLSCREEN press c"
Print "1280,960 ratio 3:2 FULLSCREEN  press d"

ThisChr$     =Inkey$()

If ThisChr$ = "a"
NewScreenMode=SafeOpenScreen(1280,960,32,1)
ElseIf ThisChr$ = "b"
NewScreenMode=SafeOpenScreen(1280,960,32,1)
ElseIf ThisChr$ = "c"
NewScreenMode=safeOpenScreen(1280,1024,32,2)
ElseIf ThisChr$ = "d"
NewScreenMode=SafeOpenScreen(1280,960,32,2)
EndIf

Flushkeys

Sync
Until EscKey() Or SpaceKey() or NewScreenMode=True

Print "DONE"
Sync
waitkey




Function SafeOpenScreen(width,height,depth,displaytype)
if (displaytype & 1)
result=false
If Width>GetDeskTopWidth() or Height>GetDeskTopHeight()
result=false
endif
endif

if (displaytype & 2)
result=ScreenmodeExist(width,Height,Depth)
endif
if Result=true
OpenScreen  Width,height,depth,DisplayType
endif

EndFunction result




Big C.

I got a deviant behaviour...

If I run your code only option c will force the screen open... without check the available screen mode I can force the screen open under option a, b and c... why?

If I remember correctly then we had a piece of code at the forum to list all the available users screen mode... I will do a search later on


kevin


A + B are windowed modes..  If you look at the code, you'll see it rejects openning windowed modes larger then the users desktop.