News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Begginer Question - OpenScreen Problem

Started by lancel00t, March 07, 2008, 11:11:25 AM

Previous topic - Next topic

lancel00t

I am an absolute begginer to PlayBasic but I like it a lot. I am playing around with the spaceinvaders tutorial and I am stuck on getting a basic window to display the FPS. I have a laptop with windows vista home premium and directx 10 and an intel 965 mobile express video card, if that helps at all =). What is happening is that the source code compiles and links just fine but the executable will crash no matter what I seem to change in the source code, at this point in time. Here is the source code where I left off:

PlayBASIC Code: [Select]
; PROJECT : PB
; AUTHOR : Robert
; CREATED : 3/7/2008
; EDITED : 3/7/2008
; ---------------------------------------------------------------------
#If PlayBasicVersion<170
#abort "Compile time error. This program requires PlayBasic V.1.7.0 or higher."
#EndIf

Explicit True

Constant SCREEN_WIDTH = 800
Constant SCREEN_HEIGHT = 600
Constant SCREEN_DEPTH = 24
Constant WINDOWED = 1
Constant FULLSCREEN = 2
Constant FPS_RATE = 60

Global GameCamera
Global RealFPS

SetFPS FPS_RATE
OpenScreen SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH, WINDOWED

GameCamera = NewCamera()

Do
RealFPS = FPS()
CaptureToScene
;Research "CaptureToScene()"
ClsScene
UpdateGame()
DrawCamera GameCamera
Sync
Loop

PSub UpdateGame()
Text 0,0, "Inside the main loop counting FPS: " + Str$(RealFPS) + " FPS"
EndPsub










Any help would be greatly appreciated!   







kevin

#1
 There is an issue with calling openscreen twice in 1.7x editions at the moment (reported here (login required).  Therefore, don't do this.  


 OpenScreen SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH, WINDOWED


You should set the Screen Size through the Project Settings.. I.e.   Project / Settings / Screen  


lancel00t

Back again. The initial question is now answered and the first problem is solved. Now I am dealing with something a little more mysterious. The program compiles and now executes but with the following source code it will simply go in to a Windows state of "Not Responding." Any thoughts?


; PROJECT : PB
; AUTHOR  : Robert
; CREATED : 3/7/2008
; EDITED  : 3/7/2008
; ---------------------------------------------------------------------
#If PlayBasicVersion<170
#abort "Compile time error. This program requires PlayBasic V.1.7.0 or higher."
#EndIf

Explicit True

Constant FPS_RATE = 60

Global GameCamera
Global RealFPS
Global ArialFontIndex

SetFPS FPS_RATE

GameCamera = NewCamera()

ArialFontIndex = LoadNewFont("C:\Windows\Fonts\Arial.ttf", 24, 0)
SetFont ArialFontIndex

Do
RealFPS = FPS()
CaptureToScene
;Research "CaptureToScene()"
ClsScene
UpdateGame()
DrawCamera GameCamera
Sync
Loop

PSub UpdateGame()
Print "Inside the main loop counting FPS: " + Str$(RealFPS) + " FPS"
EndPsub

kevin

 works fine here.




Explicit True

Constant FPS_RATE = 60
SetFPS FPS_RATE


global ArialFontIndex = LoadNewFont("Arial", 24, 0)
SetFont ArialFontIndex


Do
cls rgb(100,20,3)
UpdateGame(fps())

Sync
Loop


PSub UpdateGame(CurrentFpsValue)
Print "Inside the main loop counting FPS: " + Str$(CurrentFpsValue) + " FPS"
EndPsub