32
Hallo alle zusammen,
ich komme immoment irgendwie nicht weiter, folgendes Problem, ich möchte 2 verschiedene Schüsse haben und vom Player aus schießen, funktioniert soweit auch, nur der Schuss wird auch immer am linken oberen Bildschirmrand dargestellt. Wenn ich jetzt nur einen Schuss in der foreach angebe ist es so wie ich es haben möchte.
Der Code unten beinhaltet das meiners erachtens Wichtigste. Würde mich freuen wenn mal jemand drüber schaut.
TYPE weapon
weapon1x // x und y position waffe1
weapon1y
weapon2x // x und y position waffe2
weapon2y
ENDTYPE
GLOBAL weapons[] AS weapon
WHILE TRUE
drawthescreen()
player()
fortheshot()
mouse()
WEND
END
FUNCTION fortheshot:
IF SPRCOLL (4, playerx, playery, 5, 300, 400) Kollision mit Waffensymbol 1
waffe=1
ENDIF
IF SPRCOLL (4, playerx, playery, 7, 200, 200) Kollision mit Waffensymbol 2
waffe=2
ENDIF
IF KEY(29) AND waffe=1
LOCAL shot AS weapon
shot.weapon1x = playerx
shot.weapon1y = playery
delay = GETTIMERALL() + 500
DIMPUSH weapons[], shot
ENDIF
IF KEY(29) AND waffe=2
LOCAL shot AS weapon
shot.weapon2x = playerx
shot.weapon2y = playery
delay = GETTIMERALL() + 500
DIMPUSH weapons[], shot
ENDIF
ENDFUNCTION
FUNCTION drawthescreen:
FOR x = 0 TO 9
FOR y = 0 TO 9
DRAWSPRITE 1, x*64, y*64
NEXT
NEXT
DRAWANIM 4, pldir, playerx, playery
PRINT "<=", mx, my
DRAWSPRITE 5, 300, 400 // Item Waffe 1
DRAWSPRITE 7, 200, 200 // Item Waffe 2
FOREACH shot IN weapons[] // Schuss1 // Violett
DEC shot.weapon1y, 5
DRAWSPRITE 6, shot.weapon1x, shot.weapon1y
NEXT
FOREACH shot IN weapons[] // Schuss2 // grau
DEC shot.weapon2y, 5
DRAWSPRITE 3, shot.weapon2x, shot.weapon2y
NEXT
SHOWSCREEN
ENDFUNCTION
Hoffe, ich habe mich einigermaßen verständlich ausgedrückt. Schranzors gute Erklärung der Types ist mir eigentlich klar, oder doch nicht ganz?
Freue mich über jede Hilfe, Gruß Markus
Edit Schranz0r :
Bitte Code in den Code-Tag packen(Insert Code), danke!