Seite 2 von 2

Verfasst: 10.06.2008 10:28
von Jilocasin
Ich will ja nichts sagen, aber ist das nicht dasselbe wie das hier?

Code: Alles auswählen

InitSprite()
InitKeyboard()

Structure POINTF
  x.f
  y.f
EndStructure

Box.POINTF
Impulse.POINTF

#DOING = #True

OpenScreen(800, 600, 16, "Bla")

Repeat
  ClearScreen(0)
  ExamineKeyboard()
  
  StartDrawing(ScreenOutput())
    Box(Box\x, Box\y, 32, 32, $FFFFFF)
  StopDrawing()
  
  If KeyboardPushed(#PB_Key_Left)
    Impulse\x - 0.5
  EndIf
  If KeyboardPushed(#PB_Key_Right)
    Impulse\x + 0.5
  EndIf
  
  If KeyboardPushed(#PB_Key_Up)
    Impulse\y - 0.5
  EndIf
  If KeyboardPushed(#PB_Key_Down)
    Impulse\y + 0.5
  EndIf
  
  Box\x + Impulse\x
  Box\y + Impulse\y
  
  If KeyboardPushed(#PB_Key_Right) = 0 And KeyboardPushed(#PB_Key_Left) = 0
    Impulse\x * 0.9
  EndIf
  
  If KeyboardPushed(#PB_Key_Up) = 0 And KeyboardPushed(#PB_Key_Down) = 0
    Impulse\y * 0.9
  EndIf
  
  CompilerIf #DOING
    If Box\x < 0
      Box\x = 0
      Impulse\x = - Impulse\x
    EndIf
    If Box\y < 0
      Box\y = 0
      Impulse\y = - Impulse\y
    EndIf
    
    If Box\x > 800 - 32
      Box\x = 800 - 32
      Impulse\x = - Impulse\x
    EndIf
    If Box\y > 600 - 32
      Box\y = 600 - 32
      Impulse\y = - Impulse\y
    EndIf
  CompilerElse
    If Box\x < 0
      Box\x = 0
    EndIf
    If Box\y < 0
      Box\y = 0
    EndIf
    
    If Box\x > 800 - 32
      Box\x = 800 - 32
    EndIf
    If Box\y > 600 - 32
      Box\y = 600 - 32
    EndIf
  CompilerEndIf
  
  FlipBuffers()
Until KeyboardPushed(1)
Korrigiert mich bitte, falls in dem Originalcode irgendwas anders ist, was hier fehlt /:->

Edit: Ach.. ich hab die Sache mit der Reibung vergessen.. tut mir Leid, vergesst den Code :oops:

Verfasst: 10.06.2008 14:59
von Kaisky007
Du kannst es ja nochmal vollständig machen, wär cool, denn ich bin neugierig! xD

funktioniert denn mein beispiel?