Seite 2 von 7

Verfasst: 18.01.2006 17:54
von Macros

Code: Alles auswählen

DisplayTransparentSprite(AniFrame, position_x, position_y)

Verfasst: 18.01.2006 18:13
von Janiboy
Kann nur hoffen, ich nerv euch nicht, aber was ist daran wieder falsch? spielt die animation einfach nicht ab!

Code: Alles auswählen


If InitSprite() = 0                                                
  MessageRequester("Fehler","Konnte dx nicht finden",0)          
EndIf                                                        


If InitKeyboard()=0                                                
  MessageRequester("Fehler","Konnte dx nicht finden",0)            
EndIf                                                              

If OpenScreen(800,600,32,"Vollbild") = 0                          
  MessageRequester("Fehler","Konnte kein Vollbild erstellen ",0) 
EndIf                                                              

If LoadSprite(0,"Fighter.bmp",0)=0                                
EndIf
If LoadSprite(1,"Fighter1.bmp",0)=0
EndIf 

position_x = 0 
position_y = 0 

Repeat                                                
If IsScreenActive()                                   
  ClearScreen(0,0,0)                                
  DisplayTransparentSprite(AniFrame, x, y) 
  FlipBuffers()
  Delay(200)
  AniFrame + 1
  If AniFrame => 1 : AniFrame = 0 : EndIf
EndIf 

  ExamineKeyboard()                                  

  If KeyboardPushed(#PB_Key_Right)                    
    position_x + 5                                      
    If position_x > 700                              
      position_x = 700                                
    EndIf                                            
  EndIf                                              

  If KeyboardPushed(#PB_Key_Left)                    
    position_x  - 5                                  
If position_x < 0                              
          position_x = 0                            
    EndIf                                            
  EndIf                                              
                                          

  If KeyboardPushed(#PB_Key_Up)                      
    position_y  - 5                                  
    If position_y < 0                                
      position_y = 0                                  
    EndIf                                            
  EndIf                                              

  If KeyboardPushed(#PB_Key_Down)                    
    position_y + 5                                    
    If position_y > 500                              
      position_y = 500                                
    EndIf                                            
  EndIf                                              
 
  DisplayTransparentSprite(AniFrame, position_x, position_y)

   If KeyboardPushed(#PB_Key_Escape)                
     End                                              
   EndIf                                            
ForEver  
Danke im Vorraus,
Janiboy

Verfasst: 18.01.2006 18:21
von Macros
Dass was ich dir gepostet hab einsetzen:

Code: Alles auswählen

If InitSprite() = 0                                               
  MessageRequester("Fehler","Konnte dx nicht finden",0)         
EndIf                                                       


If InitKeyboard()=0                                               
  MessageRequester("Fehler","Konnte dx nicht finden",0)           
EndIf                                                             

If OpenScreen(800,600,32,"Vollbild") = 0                         
  MessageRequester("Fehler","Konnte kein Vollbild erstellen ",0)
EndIf                                                             

If LoadSprite(0,"Fighter.bmp",0)=0                               
EndIf
If LoadSprite(1,"Fighter1.bmp",0)=0
EndIf

position_x = 0
position_y = 0

Repeat                                               
If IsScreenActive()                                   
  ClearScreen(0,0,0)                               
  DisplayTransparentSprite(AniFrame, x, y) ;<--------------------------------------------------------
  FlipBuffers()
  Delay(200)
  AniFrame + 1
  If AniFrame => 1 : AniFrame = 0 : EndIf
EndIf

  ExamineKeyboard()                                 

  If KeyboardPushed(#PB_Key_Right)                   
    position_x + 5                                     
    If position_x > 700                             
      position_x = 700                               
    EndIf                                           
  EndIf                                             

  If KeyboardPushed(#PB_Key_Left)                   
    position_x  - 5                                 
If position_x < 0                             
          position_x = 0                           
    EndIf                                           
  EndIf                                             
                                         

  If KeyboardPushed(#PB_Key_Up)                     
    position_y  - 5                                 
    If position_y < 0                               
      position_y = 0                                 
    EndIf                                           
  EndIf                                             

  If KeyboardPushed(#PB_Key_Down)                   
    position_y + 5                                   
    If position_y > 500                             
      position_y = 500                               
    EndIf                                           
  EndIf                                             
 
  DisplayTransparentSprite(AniFrame, position_x, position_y)

   If KeyboardPushed(#PB_Key_Escape)               
     End                                             
   EndIf                                           
ForEver  
PS: doch du nervst :D , aber ich helf dir trotzdem

edit : das untere DisplayTransparentSprite(AniFrame, position_x, position_y)
kannst du weglassen.

Verfasst: 18.01.2006 18:34
von Macros
So jetzt korrigierter Code mit Animation, flüssiger Bewegung.

Code: Alles auswählen

If InitSprite() = 0                                               
  MessageRequester("Fehler","Konnte dx nicht finden",0)         
EndIf                                                       


If InitKeyboard()=0                                               
  MessageRequester("Fehler","Konnte dx nicht finden",0)           
EndIf                                                             

If OpenScreen(800,600,32,"Vollbild") = 0                         
  MessageRequester("Fehler","Konnte kein Vollbild erstellen ",0)
EndIf                                                             

If LoadSprite(0,"C:\Dokumente und Einstellungen\Udo\Eigene Dateien\Eigene Bilder\Desktopback\MandelbrotPic004.bmp",0)=0                               
EndIf
If LoadSprite(1,"C:\Dokumente und Einstellungen\Udo\Eigene Dateien\Eigene Bilder\Desktopback\MandelbrotPic005.bmp",0)=0
EndIf

position_x = 0
position_y = 0

Repeat                                               
  If IsScreenActive()                                   
    ClearScreen(0,0,0)                               
    DisplayTransparentSprite(AniFrame, position_x, position_y)
    FlipBuffers()
    
    If delay<0
      AniFrame + 1
      If AniFrame > 1 : AniFrame = 0 : EndIf
      delay=100
    Else 
      delay-1
    EndIf
    ExamineKeyboard()                                 
    
    If KeyboardPushed(#PB_Key_Right)                   
      position_x + 5                                     
      If position_x > 700                             
        position_x = 700                               
      EndIf                                           
    EndIf                                             
    
    If KeyboardPushed(#PB_Key_Left)                   
      position_x  - 5                                 
      If position_x < 0                             
        position_x = 0                           
      EndIf                                           
    EndIf                                             
    
    
    If KeyboardPushed(#PB_Key_Up)                     
      position_y  - 5                                 
      If position_y < 0                               
        position_y = 0                                 
      EndIf                                           
    EndIf                                             
    
    If KeyboardPushed(#PB_Key_Down)                   
      position_y + 5                                   
      If position_y > 500                             
        position_y = 500                               
      EndIf                                           
    EndIf                                             
    
    
    
    If KeyboardPushed(#PB_Key_Escape)               
      End                                             
    EndIf 
    
  Else
    Delay(20)    
  EndIf                                      
ForEver 
Die Bilderpfade wieder verbessern.

Verfasst: 18.01.2006 20:45
von Janiboy
Ok, klappt alles danke, aber nach einem durchlauf zeigt der debugger transparentsprite als fehler an. Außerdem wüsst ich gern, wie man die animation von einem tastendruck abhänging macht, d.h. dass sie erst nach drücken einer taste ausgelöst wird

Code: Alles auswählen

If InitSprite() = 0                                                
  MessageRequester("Fehler","Konnte dx nicht finden",0)          
EndIf                                                        


If InitKeyboard()=0                                                
  MessageRequester("Fehler","Konnte dx nicht finden",0)            
EndIf                                                              

If OpenScreen(800,600,32,"Vollbild") = 0                          
  MessageRequester("Fehler","Konnte kein Vollbild erstellen ",0) 
EndIf                                                              

If LoadSprite(0,"Fighter.bmp",0)=0                                
EndIf 
If LoadSprite(1,"Fighter1.bmp",0)=0 
EndIf 
If LoadSprite(2,"Fighter2.bmp",0)=0                                
EndIf 
If LoadSprite(3,"Fighter3.bmp",0)=0 
EndIf 
If LoadSprite(4,"Fighter4.bmp",0)=0                                
EndIf 

position_x = 0 
position_y = 0 

Repeat                                                
  If IsScreenActive()                                    
    ClearScreen(0,0,0)                                
    DisplayTransparentSprite(AniFrame, position_x, position_y) 
    FlipBuffers() 
    
    If delay<60 
      AniFrame + 1 
      If AniFrame > 5 : AniFrame = 0 : EndIf 
      delay=100 
    Else 
      delay-1 
    EndIf 
    ExamineKeyboard()                                  
    
    If KeyboardPushed(#PB_Key_Right)                    
      position_x + 5                                      
      If position_x > 700                              
        position_x = 700                                
      EndIf                                            
    EndIf                                              
    
    If KeyboardPushed(#PB_Key_Left)                    
      position_x  - 5                                  
      If position_x < 0                              
        position_x = 0                            
      EndIf                                            
    EndIf                                              
    
    
    If KeyboardPushed(#PB_Key_Up)                      
      position_y  - 5                                  
      If position_y < 0                                
        position_y = 0                                  
      EndIf                                            
    EndIf                                              
    
    If KeyboardPushed(#PB_Key_Down)                    
      position_y + 5                                    
      If position_y > 500                              
        position_y = 500                                
      EndIf                                            
    EndIf                                              
    
    
    
    If KeyboardPushed(#PB_Key_Escape)                
      End                                              
    EndIf 
    
  Else 
    Delay(200)    
  EndIf 
ForEver      
Danke im Vorraus,
Janiboy

Verfasst: 18.01.2006 20:48
von Macros
Mach aus
if AniFrame >5
if AniFrame >4
und es läuft.

Tastenabhängig:

If Keyboardrelesaed(#pb_key_next)
AniFrame+1
if AniFrame >4
aniframe=0
endif
endif

Verfasst: 18.01.2006 21:04
von Janiboy
Jetzt sieht er "Else" als falsch an. Oh mann, vorher hat es funktioniert. Liegt das an der Tastaturabhängigen Abfrage?

Verfasst: 18.01.2006 21:18
von Macros
Hier nur die Repeatschleife:

Code: Alles auswählen

Repeat                                               
  If IsScreenActive()                                   
    ClearScreen(0,0,0)                               
    DisplayTransparentSprite(AniFrame, position_x, position_y)
    FlipBuffers()
    
    ; If delay<60
      ; AniFrame + 1
      ; If AniFrame > 4 : AniFrame = 0 : EndIf
      ; delay=100
    ; Else
      ; delay-1
    ; EndIf
    ExamineKeyboard()                                 
    
    If KeyboardReleased(#PB_Key_PageDown)
      AniFrame+1
      If AniFrame >4
        AniFrame=0
      EndIf
    EndIf
    
    If KeyboardPushed(#PB_Key_Right)                   
      position_x + 5                                     
      If position_x > 700                             
        position_x = 700                               
      EndIf                                           
    EndIf                                             
    
    If KeyboardPushed(#PB_Key_Left)                   
      position_x  - 5                                 
      If position_x < 0                             
        position_x = 0                           
      EndIf                                           
    EndIf                                             
    
    
    If KeyboardPushed(#PB_Key_Up)                     
      position_y  - 5                                 
      If position_y < 0                               
        position_y = 0                                 
      EndIf                                           
    EndIf                                             
    
    If KeyboardPushed(#PB_Key_Down)                   
      position_y + 5                                   
      If position_y > 500                             
        position_y = 500                               
      EndIf                                           
    EndIf                                             
    
    
    
    If KeyboardPushed(#PB_Key_Escape)               
      End                                             
    EndIf 
    
  Else
    Delay(20)    
  EndIf                                      
ForEver 

Verfasst: 18.01.2006 21:36
von Janiboy
Perfekt, jetzt klappts :allright:

Doch weitere fragen folgen sogleich :wink: : Wie bekomme ich es hin, dass ich die taste nur zu halten brauche, um eine animation abzuspielen, noch muss man sie ja jedes mal einzeln drücken.

Danke im Vorraus,
Janiboy

Verfasst: 18.01.2006 21:44
von Macros
Statt Keyboardreleased(
KeyboardPushed(
einsetzten, aber dass wird dir wieder zu schnell sein,
bau deshalb wieder das Delay ein.
(Ich meine nicht den Befehl, sondern die Spielerei mit der Variable von vorhin)