Für's erste^^

Code: Alles auswählen
;Initialisierung
InitSprite()
InitMouse()
InitKeyboard()
;Globale
Global x=10
Global y=10
Global sx=500
Global sy=350
Global mx=550
Global my=370
;Konstante
#ges=1
OpenScreen(1024,768,32,"Spritebewegung");Öffnet den Screen
;Laden der Sprites
For xg = 1 To 9
LoadSprite(10+xg,"Figuren\Female Paladin\FP_000"+Str(xg) + ".bmp",0)
TransparentSpriteColor(10+xg,RGB(0,0,128))
Next
For xg = 10 To 72
LoadSprite(10+xg,"Figuren\Female Paladin\FP_00"+Str(xg) + ".bmp",0)
TransparentSpriteColor(10+xg,RGB(0,0,128))
Next
;Erstellen des Mauspunktes
CreateSprite(1,4,4)
StartDrawing(SpriteOutput(1))
Circle(2,2,2,RGB(0,100,200))
StopDrawing()
TransparentSpriteColor(1,0)
;Setzen der Animationvariabeln
Global B1=8
Global B2=16
Global B3=24
Global B4=32
Global B5=40
Global B6=48
Global B7=56
Global B8=64
Global anim1=0
Global anim2=0
Global anim3=0
Global anim4=0
Global anim5=0
Global anim6=0
Global anim7=0
Global anim8=0
;Die Hauptschleife
Repeat
ExamineMouse(); Maus Aktivieren
ExamineKeyboard(); Keyboard Aktivieren
ClearScreen(0);Screen Löschen
DisplayTransparentSprite(1,MouseX(),MouseY());der Mauspunkt
If MouseButton(#PB_MouseButton_Left);überprüft ob die Linke Maustaste gedrückt wurde
mx= MouseX() ; gleichsetzen mit Maus
my= MouseY()
x = mx;gleichsetztung Mauskoordinate X
y = my;gleichsetztung Mauskoordinate Y
;gleichsetzen mit Maus
EndIf
If x=0 And y=0; überbrüfen ob Graphik das Zile erreicht hat
DisplayTransparentSprite(11,sx,sy); ansonsten bild anzeigen
Else
x = mx;gleichsetztung Mauskoordinate X
y = my;gleichsetztung Mauskoordinate Y
x - (sx+40); subtrahieren ZielX - StandX
y - (sy+80) ; subtrahiern ZielY- StandY
;Richtungsüberprüfung
;3
If x<0 And Y=0
anim3+1
If anim3/8
anim3=0
B3+1
If B3>32
B3=25
EndIf
EndIf
DisplayTransparentSprite(10+B3,sx,sy)
sx-#ges
;2
ElseIf x<0 And y>0
anim2+1
If anim2/8
anim2=0
B2+1
If B2>24
B2=17
EndIf
EndIf
DisplayTransparentSprite(10+B2,sx,sy)
sx-#ges
sy+#ges
;1
ElseIf x=0 And y>0
anim1+1
If anim1/8
anim1=0
B1+1
If B1>16
B1=9
EndIf
EndIf
DisplayTransparentSprite(10+B1,sx,sy)
sy+#ges
;8
ElseIf x>0 And y>0
anim8+1
If anim8/8
anim8=0
B8+1
If B8>72
B8=65
EndIf
EndIf
DisplayTransparentSprite(10+B8,sx,sy)
sx+#ges
sy+#ges
;7
ElseIf x>0 And y=0
anim7+1
If anim7/8
anim7=0
B7+1
If B7> 64
B7=57
EndIf
EndIf
DisplayTransparentSprite(10+B7,sx,sy)
sx+#ges
;6
ElseIf x>0 And y<0
anim6+1
If anim6/8
anim6=0
B6+1
If B6>56
B6=49
EndIf
EndIf
DisplayTransparentSprite(10+B6,sx,sy)
sx+#ges
sy-#ges
;5
ElseIf x=0 And y<0
anim5+1
If anim5/8
anim5=0
B5+1
If B5>48
B5=41
EndIf
EndIf
DisplayTransparentSprite(10+B5,sx,sy)
sy-#ges
;4
ElseIf x<0 And y<0
anim4+1
If anim4/8
anim4=0
B4+1
If B4>40
B4=33
EndIf
EndIf
DisplayTransparentSprite(10+B4,sx,sy)
sx-#ges
sy-#ges
EndIf
EndIf
FlipBuffers();Vertauscht die Buffer
Until KeyboardPushed(#PB_Key_Escape)