ich hab mich das auch schonmal gefragt, naja, was das mit den Winkeln angeht hab ich auch keine Ahnung, aber zum Glück gibt´s ja im jaPBe ein Codetempleate dafür. (frag mich bitte nicht, wo man den runterladen kann, das weiß ich nämlich auch nicht...)
Naja, wie schon gesagt, ich hatte auch mal sowas gemacht, villeicht hilft es...
Code: Alles auswählen
InitSprite()
InitSprite3D()
InitKeyboard()
OpenScreen(1024,768,16,"Test")
LoadSprite(1,"pfeil.bmp", #PB_Sprite_Texture)
LoadSprite(2,"kugel.bmp")
TransparentSpriteColor(1,255,0,255)
TransparentSpriteColor(2,255,0,255)
CreateSprite3D(1,1)
Sprite3DQuality(1)
#pi=3.14159265
Global x.w
Global y.w
Global trans.w
Global speed.w
Global plus.b
Global t.f
Global xs.f
Global sprite.b
Global ys.f
Global schies.b
Global g.f
g=-1 ;sonst fällt alles nach oben ^^, irgendwie reicht 1 zum Testen, bei mehr fällt´s zu schnell
plus=1
speed=1
;---Anfang Code Template
; Drehen
Repeat
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left) : winkel - 1 : If winkel <= 0 : winkel = 360 : EndIf : EndIf
If KeyboardPushed(#PB_Key_Right) : winkel + 1 : If winkel >= 360 : winkel = 0 : EndIf : EndIf
; Vorwärts
If KeyboardPushed(#PB_Key_Up)
x=x + Cos(winkel *(2*#pi/360)) * speed ; Grad zu Bogenmaß
y=y + Sin(winkel *(2*#pi/360)) * speed
EndIf
; Rückwärts
If KeyboardPushed(#PB_Key_Down)
x=x + Cos(winkel *(2*#pi/360)) * -speed
y=y + Sin(winkel *(2*#pi/360)) * -speed
EndIf
;---Ende Code Template
If KeyboardReleased(#PB_Key_Add)
speed=speed+1
EndIf
If KeyboardReleased(#PB_Key_Subtract)
speed=speed-1
EndIf
If KeyboardReleased(#PB_Key_Space)
schies=1
t=0
;XVerschiebung=44*Sin(winkel/360*2*#pi)
;YVerschiebung=22*Cos(winkel/360*2*#pi)
;X1 = x + (44/2)
;Y1 = y + (44/2)
;KreisMittelX = X1 + XVerschiebung
;KreisMittelY = Y1 + YVerschiebung
;KreisX = KreisMittelX - (44/2)
;KreisY = KreisMittelY - (44/2)
xs=x+22+22*Cos(winkel*3.1415927/180) - (7/2)
ys=y+22+22*Sin(winkel*3.1415927/180) - (7/2)
EndIf
trans=trans+plus ; sieht cooler aus, find ich ;-)
If trans=255
plus=-1
EndIf
If trans=0
plus=1
EndIf
If schies=1
; StartDrawing(ScreenOutput())
;Circle(KreisX,KreisY,22,RGB(255,255,255))
;StopDrawing()
t=t+1
xs=xs+speed*t*Cos((360-winkel)) ;Formeln aus dem Tafelwerk
ys=ys+(-g/2)*Pow(t,2)+speed*t*Sin((360-winkel))
DisplayTransparentSprite(2,xs,ys)
EndIf
Start3D()
DisplaySprite3D(1,x,y,trans)
RotateSprite3D(1,winkel,0)
Stop3D()
StartDrawing(ScreenOutput())
Locate(920,10)
DrawingMode(1)
FrontColor(255,255,255)
DrawText("Speed:"+Str(speed))
Locate(920,25)
DrawText(Str(winkel)+"°")
Locate(920,40)
DrawText("X="+Str(xs))
Locate(920,55)
DrawText("Y="+Str(ys))
StopDrawing()
FlipBuffers()
ClearScreen(0,0,0)
If KeyboardPushed(#PB_Key_0)
ClearScreen(0,0,0)
EndIf
If KeyboardPushed(#PB_Key_RightAlt)
GrabSprite(0,0,0,1024,768)
sprite=sprite+1
SaveSprite(0,"Screenshot "+Str(sprite)+".bmp")
EndIf
Until KeyboardPushed(#PB_Key_Escape)
Aber wie gesagt, ich hab nur gesagt, ich habe es *probiert*, wirklich funzen tut es nicht, aber ich hatte glücklicherweise hilfe von Kaeru Gaman, hier die
Topic.
Man braucht für das ganze übrigens noch eine kleine kugel und einen Pfeil...