Seite 1 von 1

kann Eigenes Intro nicht überspingen

Verfasst: 13.10.2004 14:16
von benpicco
Kann mir jemand sagen, warum das hier nicht geht???
Ich möchte nämlich mit Esc mein Intro überspringen lassen können. Es geht aber nicht!!!
Woran könnte das liegen?

Code: Alles auswählen

For x= 1 To 250
DisplaySprite(32,0,0)
DisplayTransparentSprite(61,x,10)
FlipBuffers()
If KeyboardPushed(#PB_Key_Escape)
Goto start
EndIf
Next
Ich hab´s auch schon hiermitt probiert:

Code: Alles auswählen

For x=800 To 250 Step -1
DisplaySprite(32,0,0)
DisplayTransparentSprite(61,250,10)
DisplayTransparentSprite(62,250,80)
DisplayTransparentSprite(63,x,140)
FlipBuffers()
If KeyboardPushed(1)
Goto start
EndIf
Next
Ich kann Escape drücken sooft ich will, es passiert nichts!
Danke schonmal für die Hilfe!

Verfasst: 13.10.2004 14:23
von sbehrens

Code: Alles auswählen

InitKeyboard()
und

Code: Alles auswählen

ExamineKeyboard()
fehlen, bitte beim nächsten mal CodeTags benutzen!

Code: Alles auswählen

InitKeyboard()
Repeat
  ExamineKeyboard()
  ...
Until KeyboardPushed(#PB_Key_Escape)
;oder auch wahlweise KeyboardReleased(#PB_Key_Escape)
mfG
Basti

//Edit: Sprungmarken würde ich generell vermeiden!

Verfasst: 13.10.2004 14:33
von benpicco
Das mit dem Examine hab ich im richtigen code schon.
Das mit den code tags vergess ich nur immer...

Verfasst: 13.10.2004 14:39
von sbehrens

Code: Alles auswählen

For x=1 To 250
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    Goto start
  Else
    DisplaySprite(32,0,0)
    DisplayTransparentSprite(61,x,10)
    FlipBuffers()
  Endif
Next

Code: Alles auswählen

ExamineKeyboard()
Muss jedes mal wieder aufgerufen werden :!: (Wenn du das schon so hast, dann wär es schon praktisch, wenn du den ganzen Code veröffentlichst, so wie du ihn hast) Und

Code: Alles auswählen

InitKeyboard()
muss nur einmal am Anfang stehen. (Bitte editiere dein Beitrag nochmal, um CodeTags zu setzten.)

mfG
Basti

Verfasst: 13.10.2004 14:50
von benpicco
ptI hat geschrieben:ExamineKeyboard()[/code]Muss jedes mal wieder aufgerufen werden :!: (Wenn du das schon so hast, dann wär es schon praktisch, wenn du den ganzen Code veröffentlichst, so wie du ihn hast)
Danke,das war´s!
Hier nochmal der code:

Code: Alles auswählen

InitSprite()     
InitKeyboard()   
InitMouse() 
InitSound()    
OpenScreen(800,600,16,"DeepSea") 
Dim SharkX(30)
Dim SharkY(30)
Global Maus_Knopf.b         
Global Punkte.w                    
Global Time.w
Global Harpune.b
Global zufall.b
harpune = 6
LoadSprite(0,"Grafik\Ziel.bmp",0)
LoadSprite(32,"Grafik\unterwasser.bmp",0) 
TransparentSpriteColor(0,255,0,255)
LoadSound(0,"sound\schuss.wav")
LoadSound(1,"sound\klick.wav")
LoadSound(2,"sound\intro.wav")
LoadSound(3,"sound\drum.wav")
LoadSound(4,"sound\laden.wav")
LoadSound(5,"sound\clap.wav")
For X=1 To 30
LoadSprite(x,"Grafik\fish.bmp",0)
TransparentSpriteColor(x,195,195,195)
Next
For x=1 To 10
LoadSprite(40+x,"grafik\blood" + Str(x) + ".bmp",0)
TransparentSpriteColor(x+40,255,0,255)
Next
For x=1 To 5
LoadSprite(60+x,"grafik\intro" + Str(x) + ".bmp",0)
TransparentSpriteColor(x+60,255,0,255)
Next
For x=0 To 6
LoadSprite(51+x,"grafik\harpune" + Str(x) + ".bmp",0)
TransparentSpriteColor(x+51,255,0,255)
Next
For X=1 To 15
sharkX(x) = -(Random(60))
sharkY(x) = Random(580)
Next
PlaySound(3,1)
For x= 1 To 250
DisplaySprite(32,0,0)
DisplayTransparentSprite(61,x,10)
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
Goto start
EndIf
Next
For x= 800 To 80 Step -1
DisplaySprite(32,0,0)
DisplayTransparentSprite(61,250,10)
DisplayTransparentSprite(62,250,x)
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
Goto start
EndIf
FlipBuffers()
Next
For x=800 To 250 Step -1
DisplaySprite(32,0,0)
DisplayTransparentSprite(61,250,10)
DisplayTransparentSprite(62,250,80)
DisplayTransparentSprite(63,x,140)
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(1)
Goto start
EndIf
Next
PlaySound(2)
For x=600 To 200 Step -1
DisplaySprite(32,0,0)
DisplayTransparentSprite(61,250,10)
DisplayTransparentSprite(62,250,80)
DisplayTransparentSprite(63,250,140)
DisplayTransparentSprite(64,x+50,x)
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(1)
StopSound(2)
Goto start
EndIf
Next
Delay(1000)
DisplayTransparentSprite(65,250,300)
FlipBuffers()
Delay(3000)
start:
Delay(1000)
Repeat
ExamineMouse()
ExamineKeyboard()
If MouseButton(1) And Maus_Knopf = 0 And harpune >0
Maus_Knopf=1
harpune = harpune -1
PlaySound(0)
For x=1 To 15
If MouseX() > sharkX(x) And MouseX() < sharkX(x) + 74 And MouseY() > sharkY(x) And MouseY() < sharkY(x) + 54 
For y=1 To 10
DisplayTransparentSprite(y+40,MouseX()-30,MouseY()-30)
DisplayTransparentSprite(0,MouseX()-32,MouseY()-32)
FlipBuffers()
Delay(15)
Next
sharkX(x) = -40
sharkY(x) = Random(460)
Punkte = Punkte +10
Goto shot
EndIf
Next
ElseIf harpune = 0 And MouseButton(1) And Maus_Knopf = 0
PlaySound(1)
EndIf
shot:
Delay(1)
Time = Time +1
For X=1 To 15
If sharkX(x)>800
Punkte = Punkte -2
sharkX(x) = -40
sharkY(x) = Random(580)
EndIf
Next
DisplaySprite(32,0,0)
For x=1 To 15
DisplayTransparentSprite(x,sharkX(x),sharkY(x))
Next
DisplayTransparentSprite(harpune+51,580,480)
DisplayTransparentSprite(0,MouseX()-32,MouseY()-32)
StartDrawing(ScreenOutput()) 
DrawingMode(1)               
Locate(10,0)                  
FrontColor(255,0,0)          
DrawText("Punkte:" + Str(Punkte)) 
Locate(730,0)                
FrontColor($EF,$FD,$10)          
DrawText("Time:" + Str(60-time/100)) 
StopDrawing()                
FlipBuffers()
If MouseButton(1) = 0 
Maus_Knopf = 0       
EndIf
If MouseButton(2) = 1
harpune = 6
Punkte = Punkte -5
PlaySound(4)
EndIf
For x=1 To 15
sharkX(x)= sharkX(x) +1
zufall = Random(5)
If zufall = 2
sharkY(x) = sharkY(x) + 1
ElseIf zufall =4
sharkY(x) = sharkY(x) - 2
EndIf
Next         
Until KeyboardPushed(1) Or time > 6000
Delay(1000)
CloseScreen() 
If ReadFile(0,"high.score")
highscore$  =   ReadString()
MessageRequester("Game Over","Highscore: "+highscore$ + Chr(10) + "Your Score: "+Str(punkte),0)
CloseFile(0)
If punkte > Val(highscore$)
PlaySound(5)
Enumeration
  #Window_0
EndEnumeration
Global Image0
Image0 = CatchImage(0, ?Image0)
DataSection
Image0:
  IncludeBinary "grafik\Fish.bmp"
EndDataSection


  If OpenWindow(#Window_0, 269, 87, 400, 160,  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New Highscore!")
    If CreateGadgetList(WindowID())
      StringGadget(1, 80, 110, 190, 20, "")
      ButtonGadget(2, 280, 110, 30, 20, "Ok")
      TextGadget(3, 40, 90, 180, 20, "Enter Your Name!")
      TextGadget(4, 40, 70, 110, 20, "New Highscore!")
      StringGadget(5, 190, 40, 180, 20, highscore$, #PB_String_ReadOnly)
      TextGadget(6, 190, 20, 180, 20, "Old Highscore:")
      ImageGadget(7, 0, 0, 74, 54, Image0)
      StringGadget(8, 10, 110, 60, 20, Str(punkte), #PB_String_ReadOnly | #PB_String_BorderLess)
      
    EndIf
  EndIf
   Repeat
    EventID = WaitWindowEvent()
      If EventID = #PB_Event_CloseWindow 
        Quit = 1
       ElseIf EventGadgetID() = 2
         OpenFile(0,"high.score")
         WriteStringN(Str(punkte) + " " +GetGadgetText(1))
         CloseFile(0)
         End 
      EndIf
  Until Quit=1
EndIf
End
EndIf 
End 

Die dateien gibt´s unter http://mitglied.lycos.de/benpicco/FishShot.zip (ich werd gleich updaten!)

Verfasst: 13.10.2004 16:11
von sbehrens
(Nur so nebenbei, falls du es noch noch nicht machst, ich würde immer einrücken. :allright: )

mfG
Basti