Kleines Spiel macht Probleme ;-)
Übersicht

dada11Betreff: Kleines Spiel macht Probleme ;-) |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hallo,
ich versuche ja im Moment so ein kleines Ballerspiel zu schreiben. Die Feindschiffe bewegen sich prima in Sinuskurven über den Schirm, der Held kann mit seinem Schiff fein nach rechts und links fliegen und schiessen kann er auch. Nur mit dem Treffen hat er Probleme ![]() Hier mal der Code: Code: [AUSKLAPPEN] Graphics 800,600
HideMouse () '################################################ Grafix Incbin "ship.png" Incbin "ship2.png" Incbin "laser.png" Incbin "explosion.png" SetMaskColor 0,0,0 Global explosion = LoadAnimImage ("incbin::explosion.png",80,80,0,5) MidHandleImage explosion Global laser = LoadImage ("laser.png") MidHandleImage laser Global ship = LoadImage ("ship.png") MidHandleImage ship Global ship2= LoadImage ("ship2.png") MidHandleImage ship2 '################################################ Soundfxs Incbin "laser.ogg" Global shot1= LoadSound("incbin::laser.ogg") Incbin "explo.ogg" Global explo= LoadSound("incbin::explo.ogg") '############################# '# Game Laser Ships and more # '############################# Global shipspeed = 6 ' Speed Left Right Move Global pos_counter=0 Global laser_ypos=0 Global laser_xpos=0 Global ship_xpos= 400 Global laser_posx:Float [50] ' Laser X Positionen Global laser_posy:Float [50] ' Laser Y Positionen Global laser_counter=0 Global score = 0 Global explo_posx=0 ' ExplosionAnim Global explo_posy=0 ' ExplosionAnim Global explosionx=-10 ' ExplosionAnim Global explosiony=-10 ' ExplosionAnim Global explo_count=0 ' ExplosionAnim Global feind_posx:Float [50] Global feind_posy:Float [50] Global feind_alive:Float [50] Global feind_counts = 50 ' Anzahlfeinde Global akt_x= 0 ' Aktuelle Positionen Global akt_y= 0 ' Aktuelle Positionen Global akt_alive=0 ' Lebt der Feind Noch ? Global feind_move=0 Global feind_speed=1 '############################ Create Feind-Daten Global makeposx=(800-(20*35))/2 Global makeposy=50 For x = 0 Until feind_counts feind_posx(x)=makeposx feind_posy(x)=makeposy feind_alive(x)=1' 1 = Feind Lebt /// 0 = Feind Ist Tot makeposx:+12 makeposy:+2 Next '############################ Create Laserpositionen For x = 0 Until 10 laser_posx(x) = -100 laser_posy(x) = 500 Next '########################################### 1. Hauptschleife Repeat Cls '######################## '# Drawship and Move It # '######################## DrawImage ship,ship_xpos,550 If ship_xpos < 25 Then Goto nomove '############## Bewegungsbegrenzung LINKS If KeyDown (KEY_LEFT) Then ship_xpos:-shipspeed #nomove If ship_xpos > 775 Then Goto nomove2 '############ Bewegungsbegrenzung RECHTS If KeyDown (KEY_RIGHT) Then ship_xpos:+shipspeed #nomove2 If KeyHit (KEY_SPACE) Then PlaySound shot1 laser_posy(laser_counter)=500 laser_posx(laser_counter)=ship_xpos laser_counter:+1 If laser_counter = 50 Then laser_counter = 0 '####################################### '# Positionen der Feinde und der Laser # '####################################### For x = 0 Until feind_counts '### Anzahl der Feinde akt_x=feind_posx(x) akt_y=feind_posy(x) akt_alive=feind_alive(x) DrawImage laser,laser_posx(x),laser_posy(x) ' Der Laser laser_posy(x):-7 If ImagesCollide (laser,laser_posx(x),laser_posy(x),0,ship2,400+Sin(feind_posx(x))*380,Sin(feind_posy(x))*200+220,0) PlaySound explo score = score+25 akt_alive = 0 laser_posy(x)=0 Else EndIf If akt_alive = 0 Then Goto noship2 DrawImage ship2,400+Sin(feind_posx(x))*380,Sin(feind_posy(x))*200+220 #noship2 akt_x:+1 akt_y:+2 feind_posx(x)=akt_x ' zurückschreiben der Werte nach der addition feind_posy(x)=akt_y Next DrawText "SCORE:"+ score,100,580 Flip Until KeyHit(KEY_ESCAPE) End ~EDITIERT~ Code-Tags eingefügt. Beim nächsten mal bitte selbst daran denken. d-bug |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group