why it dosen work?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by blue-speed.

hi!

want to ask why it didnt screen the picture
code]


;--------- INITIIALISIERUNG ------------------
If InitSprite() = 0
MessageRequester("Fehler","Fehler: Dx7 oder hoehernicht nicht verfuegbar",0) ; sprite initialisierung
EndIf

If InitKeyboard() = 0
MessageRequester("Fehler","Fehler: Dx7 oder hoehernicht nicht verfuegbar",0) ; keyboard initialisierung
EndIf
;---------------------------------------------



;------------ FULSCREEN ----------------------
If OpenScreen(800,600,32,"SCROLLER") = 0
MessageRequester("Fehler","Fehler: konnte keine fullscreen oeffnen",0) ; Naja is ja klar wir setzen eine fullscreen
EndIf
;---------------------------------------------

;------------ sprite laden -------------------
hgrund = LoadSprite(0,"hgrund.bmp",0)
text =LoadSprite(0,"text.bmp ",0)
;--------------------------------------------


Repeat
FlipBuffers()
ClearScreen(0,0,0)
DisplaySprite(hgrund,0,0)
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
ForEver[/code]

WOOOOOOW!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

You need:
ExamineKeyboard()

before
If KeyboardPushed(#PB_Key_Escape)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Like Paul said you need ExamineKeyboard().

But as far as I can see your code can't work because AFAIK LoadSprite() doesn't give any
handle back. What you get with 'hgrund' and 'text' is 0 or 1 -> if the loading process failed or not.
So you have to use the DisplaySprite() command in this way:

DisplaySprite(0,0,0) or DisplaySprite(1,0,0) ; you have two images

the first number is the Image ID number given with the LoadSprite() command like:

LoadSprite(0,"hgrund.bmp",0)
LoadSprite(1,"text.bmp ",0)

BTW:
A good thing would be to run the repeat loop only if all images are loaded correctly!
Your code crashes if one of the images are not loaded properly!
Also if the program can't open a screen it will crash!
The same with the DirectX stuff...

Hope this helps.



Have a nice day...
Franco
Post Reply