Hallo!
Ihr kennt mich ja vielleicht schon aus meiner Crosshair thread, wobei ihr mir ja auch super geholfen habt doch im moment kann ich mir echt nichtmehr weiterhelfen...
Ich wollte nur eine einfache kollisionsabfrage machen und nun, wenn sich player 2 DREHT denkt er, player 1 hätte eine wand berührt bekommt einen fehler und schmiert ab...-.-
Hier der code:
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] Graphics 1024,768,32,1
Type set Field x Field y Field richtung Field cx Field cy Field winkel Field health Field ammor Field w1 Field w2 Field ammow2 Field ammo2w2 Field w3 Field ammow3 Field ammo2w3 Field choosen Field change End Type
Global p1.set=New set Global p2.set=New set p1\health=100 p2\health=100
Include \"win_load.dll\"
Global hud=LoadImage(\"../gfx/HUD.bmp\") Global tileset=LoadAnimImage(\"../gfx/tileset.bmp\",64,64,0,2) Global crosshair=LoadImage(\"../gfx/cross.bmp\")
MaskImage hud,255,0,255 MaskImage tileset,255,0,255 MaskImage crosshair,255,0,255
Global kA=0:Dim feld(50,50):Dim feld2(50,50):Dim player1(180):Dim player2(180) Global font=LoadFont(arial,50,1,0,0) Const p1xpos=224 Const p2xpos=736 Const ypos=302
SetBuffer BackBuffer() SetFont font
ladeeingabe()
For x=0 To 50
For y=0 To 50 If feld2(x,y)=2 Then p1\x=(x*64-p1xpos)*(-1)-32:p1\y=(y*64-ypos)*(-1)-32 If feld2(x,y)=3 Then p2\x=(x*64-p1xpos)*(-1)-32:p2\y=(y*64-ypos)*(-1)-32 Next Next
TFormFilter 0
For i=0 To 180
player1(i)=LoadImage(\"../gfx/player1.bmp\") MaskImage player1(i),255,0,255 MidHandle player1(i) RotateImage player1(i),i*2 player2(i)=LoadImage(\"../gfx/player2.bmp\") MaskImage player2(i),255,0,255 MidHandle player2(i) RotateImage player2(i),i*2 Text 0,0,\"Drehen der Bilder schon bei \"+i+\" GRAD!\" Flip Cls Next
While Not KeyDown(1)
malen() drehen() cross() bewegung()
full()
hud()
define()
Flip Cls Wend
End
Function define()
Include \"win_32.dll\"
End Function
Function cross()
p1\cx=p1xpos+(Cos(p1\winkel-90)*p1current\distance)-32 p1\cy=ypos+(Sin(p1\winkel-90)*p1current\distance)-32 p2\cx=p2xpos+(Cos(p2\winkel-90)*p2current\distance)-32 p2\cy=ypos+(Sin(p2\winkel-90)*p2current\distance)-32
End Function
Function kollisionen(x,y)
If ImagesCollide(tileset,x*64,y*64,1,player1(p1\winkel/2),p1xpos,ypos,0)=True Then If p1\richtung=0 Then Text 0,0,\"hallo\" Else Text 0,0,\"pip2\" EndIf EndIf If ImagesCollide(tileset,x*64,y*64,1,player2(p2\winkel/2),p2xpos,ypos,0)=True Then If p2\richtung=0 Then Text 0,0,\"pip3\" Else Text 0,0,\"pip4\" EndIf EndIf
End Function
Function hud()
DrawImage hud,0,0
Text 40,690,p1\health,1,1 Text 552,690,p2\health,1,1 Text 0,50,p1\winkel Text 0,100,p1\x Text 0,150,p1\y Text 0,200,p2\winkel Text 0,250,p2\x Text 0,300,p2\y
End Function
Function drehen() If KeyDown(205) Then p2\winkel=p2\winkel+2 If KeyDown(203) Then p2\winkel=p2\winkel-2 If KeyDown(30) Then p1\winkel=p1\winkel-2 If KeyDown(32) Then p1\winkel=p1\winkel+2
If p1\winkel=360 Then p1\winkel=0 If p1\winkel=-2 Then p1\winkel=360 If p2\winkel=360 Then p2\winkel=0 If p2\winkel=-2 Then p2\winkel=360
End Function
Function bewegung()
If KeyDown(200) Then p2\richtung=0:p2\x=p2\x+(Sin(p2\winkel)*2)*(-1):p2\y=p2\y+(Cos(p2\winkel)*2) If KeyDown(208) Then p2\richtung=1:p2\x=p2\x+(Sin(p2\winkel)*2):p2\y=p2\y+(Cos(p2\winkel)*2)*(-1) If KeyDown(17) Then p1\richtung=0:p1\x=p1\x+(Sin(p1\winkel)*2)*(-1):p1\y=p1\y+(Cos(p1\winkel)*2) If KeyDown(31) Then p1\richtung=1:p1\x=p1\x+(Sin(p1\winkel)*2):p1\y=p1\y+(Cos(p1\winkel)*2)*(-1)
End Function
Function malen()
For x=0 To 50 For y=0 To 50 view1() If feld(x,y)=>0 Then DrawImage tileset,x*64+p1\x,y*64+p1\y,feld(x,y) view2() If feld(x,y)=>0 Then DrawImage tileset,x*64+p2\x+512,y*64+p2\y,feld(x,y) full() kollisionen(x,y) Next Next view1() DrawImage player1(p1\winkel/2),p1xpos,ypos DrawImage player2(p2\winkel/2),(p2\x*(-1)+p1\x)+p2xpos-512,(p2\y*(-1)+p1\y)+ypos DrawImage crosshair,p1\cx,p1\cy view2() DrawImage player2(p2\winkel/2),p2xpos,ypos DrawImage player1(p1\winkel/2),(p1\x*(-1)+p2\x)+p1xpos+512,(p1\y*(-1)+p2\y)+ypos DrawImage crosshair,p2\cx,p2\cy
End Function
Function ladeeingabe()
Eingabe$=Input(\"Levelname? \")
If FileType(\"../levels/\"+Eingabe+\".dod\")=0 Then Text 0,0,\"Datei nicht gefunden...beliebige Taste zum Beenden!\":Flip:Cls:WaitKey():End
If FileType(\"../levels/\"+Eingabe+\".dod\")=1 Then
laden=ReadFile(\"../levels/\"+Eingabe+\".dod\") For x=0 To 50 For y=0 To 50 feld(x,y)=ReadLine(laden) feld2(x,y)=ReadLine(laden) Next Next
EndIf
End Function
Function view1()
Viewport 0,0,512,768
End Function
Function view2()
Viewport 512,0,1024,768
End Function
Function full()
Viewport 0,0,1024,768
End Function
PS:Wer mit dem Code net viel anfangen kann (ohne GFX etc.) [url=http://5k41.5k.funpic.de/Privat/Fighters for Glory.rar]HIER[/url] ein link...
|