Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;
- ; ****************************************************************
- ; * * * * * * * * * * * * * * * * * * * * * *
- ; Zombie_Survivor * * * * * * * * * * * * * * * * * * * * *
- ; * * * * * * * * * * * * * * * * * * * * *
- ; ****************************************************************
- ; Initialization of all the used ressources
- ;
- If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() =0
- MessageRequester("Error", "Can't open DirectX 7 or later", 0)
- End
- EndIf
- If InitSound() = 0
- MessageRequester("Error", "Can't open DirectX 7 Or Sound Card is not present", 0)
- End
- EndIf
- ; Our bullet structure, which will be used by the linkedlist Bullet()
- Structure Bullet
- x.w
- y.w
- Width.w
- Height.w
- Image.w
- SpeedX.w
- SpeedY.w
- EndStructure
- Global NewList Bullet.Bullet()
- Structure Explosion
- x.w
- y.w
- State.w
- Delay.w
- EndStructure
- Global NewList Explosion.Explosion()
- Structure Alien
- x.w
- y.w
- Width.w
- Height.w
- Speed.w
- StartImage.w
- EndImage.w
- ImageDelay.w
- NextImageDelay.w
- ActualImage.w
- Armor.w
- EndStructure
- Global NewList Aliens.Alien()
- Procedure AddBullet(Sprite, x, y, SpeedX, SpeedY)
- AddElement(Bullet())
- Bullet()\x = x
- Bullet()\y = y
- Bullet()\Width = SpriteWidth(Sprite)
- Bullet()\Height = SpriteHeight(Sprite)
- Bullet()\Image = Sprite
- Bullet()\SpeedX = SpeedX
- Bullet()\SpeedY = SpeedY
- EndProcedure
- MessageRequester("Willkommen !", "Zombies 4-Ever, aber jetzt wollen sie DIR an den Kragen. Töte so viele wie möglich, ohne zu sterben!"+Chr(10)+Chr(10)+"Auf den Tasten W, A, S & D läufst du."+Chr(10)+"Auf der linken Maustaste kannst du schießen. "+Chr(10)+"Mit Shift(links) und der Leertaste kannst du dich drehen."+Chr(10)+"Viel Spaß.", 0)
- ;
- ; Now, open a 640*480 - 16 bits colours screen
- ;
- Path$ = "Data\"
- ; SetRefreshRate(60
- ;
- If OpenScreen (800,600, 16, "Zombie_fever")
- LoadSprite(99,Path$+"Beginning.bmp")
- Repeat
- ExamineKeyboard()
- FlipBuffers()
- ClearScreen(RGB(0,0,0))
- DisplaySprite(99,0,0)
- Until KeyboardPushed(#PB_Key_Space)
- Gegend = 20
- PlayerSpeedX = 6
- PlayerSpeedY = 6
- BulletSpeed = 10
- ;
- ; Load the sound effects
- ;
- LoadSound(0, Path$+"Famas.wav")
- LoadSound(1, Path$+"Death_1.wav")
- LoadSound(2, Path$+"Death_2.wav")
- LoadSound(3, Path$+"Death_3.wav")
- LoadSound(20, Path$+"reload.wav")
- For k=-1 To 7
- LoadSprite(k, Path$+"Player_"+Str(k)+".bmp", 0) ; 8 Spieler Bilder
- Next
- LoadSprite(29, Path$+"Player_29.bmp", 0)
- LoadSprite(50, Path$+"Leben_1.bmp", 0) ;1-3Herz(en)
- LoadSprite(51, Path$+"Leben_2.bmp", 0) ;1-3Herz(en)
- LoadSprite(52, Path$+"Leben_3.bmp", 0) ;1-3Herz(en)
- LoadSprite(53,Path$+"End.bmp", 0) ;Game over
- LoadSprite( 9, Path$+"Bullet_1.bmp", 0) ;Schuesse
- LoadSprite(30,Path$+"Bullet_2.bmp",0)
- LoadSprite(31,Path$+"Bullet_3.bmp",0)
- For k=0 To 5
- LoadSprite(k+10, Path$+"Ennemy_3_"+Str(k+1)+".bmp", 0) ;Zombies:bewegung
- Next
- For k=2 To 9
- LoadSprite(k+30, Path$+"Explosion_"+Str(k)+".bmp", 0) ;Tod der Zombies und des Spielers
- Next
- a=50
- LoadSprite(21, Path$+"Back_1.bmp", 0)
- LoadSprite(20, Path$+"Back_0.bmp", 0) ;Hintergrundbild
- Score=0
- ammo=30
- PlayerImage = 0
- PlayerWidth = SpriteWidth(3)
- PlayerHeight = SpriteHeight(3)
- PlayerX = 300
- PlayerY = 400
- Repeat
- FlipBuffers() ; This should be always in the loop, the events are handle by this functions
- If IsScreenActive() ; Check if is active or not (ALT+TAB symptom :)
- db = 1-db
- If Score >= 20
- ;Gegend =21
- EndIf
- For BackX=0 To 800 Step 800 ;Macht den Hintergrund
- For BackY=-1200 To 600 Step 600 ;siehe eine zeile höher
- DisplaySprite(Gegend, BackX, BackY) ;siehe 2 zeilen höher
- Next
- Next
- StartDrawing(ScreenOutput()) ;Scoreanzeige
- DrawingMode(#PB_2DDrawing_Transparent )
- DrawText(0,35,"Score: "+ Str(Score*10),RGB(99,00,00))
- If Zombierunde<= 200 And Zombierunde>190
- DrawText(10,400,"1",RGB(99,00,00))
- EndIf
- If Zombierunde<= 190
- DrawText(10,400,"2",RGB(99,00,00))
- EndIf
- StopDrawing()
- Gosub CheckCollisions
- Gosub MovePlayers
- Gosub DisplayBullets
- Gosub NewAlienWave
- Gosub DisplayAliens
- Gosub DisplayExplosions
- If BulletDelay > 0
- BulletDelay-1
- EndIf
- If ScrollDelay = 0
- ScrollY+1
- ScrollDelay = 0
- Else
- ScrollDelay-1
- EndIf
- If ScrollY>31
- ScrollY = 0
- EndIf
- Else
- ; The screen is no more active but our game multitask friendly, so we stop the sounds and
- ; add a delay to not eat the whole CPU. Smart hey ? :)
- StopSound(-1)
- Delay(20)
- EndIf
- Until KeyboardReleased(#PB_Key_Escape) Or a=53 ;beendet das spiel nachdem esc gedrückt wurde, oder drei Zombies(Alien) einen gekillt haben.
- Else
- MessageRequester("Waponez II", "Can't open a 800*600 8 bit screen !", 0)
- EndIf
- CloseScreen()
- MessageRequester("Ende","Du hast "+Str(Score)+" Zombies gekillt!!!",#PB_MessageRequester_Ok)
- result= MessageRequester("Ende","Game over!")
- If result= #PB_MessageRequester_No
- MessageRequester("Ende","Ciao"+Chr(10)+"Bis zum nächsten mal!")
- EndIf
- End
- MovePlayers:
- Fire = 0
- PlayerImage=0 ; nach vorne schauen
- LebenImage=52
- ExamineMouse()
- ExamineKeyboard()
- If KeyboardPushed(#PB_Key_LeftShift)
- PlayerImage=1
- EndIf
- If KeyboardPushed(#PB_Key_Space)
- PlayerImage=2
- EndIf
- If KeyboardPushed(#PB_Key_A)
- PlayerX-PlayerSpeedX
- EndIf
- If KeyboardPushed(#PB_Key_D)
- PlayerX+PlayerSpeedX
- EndIf
- If KeyboardPushed(#PB_Key_W)
- PlayerY-PlayerSpeedY
- EndIf
- If KeyboardPushed(#PB_Key_S)
- PlayerY+PlayerSpeedY
- EndIf
- ;If KeyboardPushed(#PB_Key_Space)
- ; PlayerImage = 29 ; Schuss!
- ;EndIf
- DisplayTransparentSprite (a,0,-30)
- If PlayerX < 0 : PlayerX = 0 : EndIf
- If PlayerY < 0 : PlayerY = 0 : EndIf
- If PlayerX > 800-PlayerWidth : PlayerX = 800-PlayerWidth : EndIf
- If PlayerY > 600-PlayerHeight : PlayerY = 600-PlayerHeight : EndIf
- If Dead = 1
- AddElement(Explosion())
- Explosion()\x = PlayerX
- Explosion()\y = PlayerY
- Dead = 0
- Else
- If DeadDelay>0
- DeadDelay-1
- If db=1
- If DeadDelay < 200
- DisplayTransparentSprite(PlayerImage, PlayerX, PlayerY)
- EndIf
- EndIf
- Else
- DisplayTransparentSprite(PlayerImage, PlayerX, PlayerY)
- EndIf
- EndIf
- ExamineMouse()
- If MouseButton(#PB_MouseButton_Left) And PlayerImage =0 ;Schuss
- If BulletDelay = 0
- If DeadDelay < 100
- BulletDelay = 30
- ; AddBullet() syntax: (#Sprite, x, y, SpeedX, SpeedY)
- AddBullet(9, PlayerX+17 , PlayerY-40, 0 , -BulletSpeed) ; vorne
- ammo-1
- PlaySound(0, 0) ; soundeffekte
- EndIf
- EndIf
- EndIf
- If MouseButton(#PB_MouseButton_Left) And PlayerImage =1 ;Schuss
- If BulletDelay = 0
- If DeadDelay < 100
- BulletDelay = 30
- AddBullet(30, PlayerX-11, PlayerY-6 , -BulletSpeed, -BulletSpeed) ; links-oben
- ammo-1
- PlaySound(0, 0) ; sound effekte
- EndIf
- EndIf
- EndIf
- ExamineMouse()
- If MouseButton(#PB_MouseButton_Left) And PlayerImage=2 ;Schuss
- If BulletDelay = 0
- If DeadDelay < 100
- BulletDelay = 30
- AddBullet(31, PlayerX+45, PlayerY-6 , BulletSpeed, -BulletSpeed) ; Front-Right bullet
- ammo-1
- PlaySound(0, 0) ; soundeffekte
- EndIf
- EndIf
- EndIf
- Return
- If ammo<=0
- PlaySound(20)
- EndIf
- DisplayBullets:
- ResetList(Bullet())
- While NextElement(Bullet()) ; Process all the bullet actualy displayed on the screen
- If Bullet()\y < 0 ; If a bullet is now out of the screen, simply delete it..
- DeleteElement(Bullet())
- Else
- If Bullet()\x < 0 ; If a bullet is now out of the screen, simply delete it..
- DeleteElement(Bullet())
- Else
- If Bullet()\x > 800-Bullet()\Width
- DeleteElement(Bullet())
- Else
- If Bullet()\y > 600
- DeleteElement(Bullet())
- Else
- DisplayTransparentSprite(Bullet()\Image, Bullet()\x, Bullet()\y) ; Display the bullet..
- Bullet()\y + Bullet()\SpeedY
- Bullet()\x + Bullet()\SpeedX
- EndIf
- EndIf
- EndIf
- EndIf
- Wend
- Return
- NewAlienWave:
- If AlienDelay = 0
- AddElement(Aliens())
- If Boss = 1
- Aliens()\x = 100
- Aliens()\y = -16
- Aliens()\Width = SpriteWidth(50)
- Aliens()\Height = SpriteHeight(50)
- Aliens()\Speed = 2
- Aliens()\StartImage = 50
- Aliens()\EndImage = 50
- Aliens()\ImageDelay = 1
- Aliens()\NextImageDelay = 1
- Aliens()\ActualImage = 50
- Aliens()\Armor = 20
- AlienDelay = 80
- Else
- Aliens()\x = Random(800)
- Aliens()\y = -32
- Aliens()\Width = SpriteWidth(10)
- Aliens()\Height = SpriteHeight(10)
- Aliens()\Speed = 3
- Aliens()\StartImage = 10
- Aliens()\EndImage = 15
- Aliens()\ImageDelay = 4
- Aliens()\NextImageDelay = Aliens()\ImageDelay
- Aliens()\ActualImage = 10
- Aliens()\Armor = 5
- AlienDelay = Random(200) ;; Zombie wave
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- If Score => 10
- AlienDelay = Random(150)
- ;newwave()
- EndIf
- If Score => 20
- AlienDelay = Random(100)
- ;newwave()
- EndIf
- If Score => 30
- AlienDelay = Random(80)
- ;newwave()
- EndIf
- If Score => 40
- AlienDelay = Random(70)
- ;newwave()
- EndIf
- If Score => 50
- AlienDelay = Random(60)
- ;newwave()
- EndIf
- If Score => 70
- AlienDelay = Random(30)
- ;newwave()
- EndIf
- If Score => 100
- AlienDelay = Random(10)
- ;newwave()
- EndIf
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- EndIf
- Else
- AlienDelay-1
- EndIf
- Return
- DisplayAliens:
- ResetList(Aliens())
- While NextElement(Aliens())
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- If PlayerX>Aliens()\x
- Aliens()\x +1
- EndIf
- If Playerx <Aliens()\x
- Aliens()\x -1
- EndIf
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- DisplayTransparentSprite(Aliens()\ActualImage, Aliens()\x, Aliens()\y)
- Aliens()\y + Aliens()\Speed
- If Aliens()\NextImageDelay = 0
- Aliens()\ActualImage+1
- If Aliens()\ActualImage > Aliens()\EndImage
- Aliens()\ActualImage = Aliens()\StartImage
- EndIf
- Aliens()\NextImageDelay = Aliens()\ImageDelay
- Else
- Aliens()\NextImageDelay-1
- EndIf
- If Aliens()\Armor <= 0
- AddElement(Explosion())
- Explosion()\x = Aliens()\x
- Explosion()\y = Aliens()\y
- Score+1
- DeleteElement(Aliens())
- Else
- If Aliens()\y > 600
- DeleteElement(Aliens())
- EndIf
- EndIf
- Wend
- Return
- CheckCollisions:
- ResetList(Aliens())
- While NextElement(Aliens())
- ResetList(Bullet())
- While NextElement(Bullet())
- If SpritePixelCollision(Bullet()\Image, Bullet()\x, Bullet()\y, Aliens()\ActualImage, Aliens()\x, Aliens()\y)
- Aliens()\Armor-5
- DeleteElement(Bullet())
- EndIf
- Wend
- If DeadDelay = 0 ; No more invincible...
- If SpritePixelCollision(PlayerImage, PlayerX, PlayerY, Aliens()\ActualImage, Aliens()\x, Aliens()\y)
- Dead = 1
- DeadDelay = 300
- AddElement(Explosion())
- Explosion()\x = Aliens()\x
- Explosion()\y = Aliens()\y
- DeleteElement(Aliens())
- LebenImage-1
- a+1
- EndIf
- EndIf
- Wend
- Return
- ; DisplayExplosion:
- ; -----------------
- ;
- ; Once an explosion has been declared (an aliens has been destroyed or the player...), it will be
- ; displayed inside this routine. The object remains until the end of the explosion (all the pictures
- ; have been displayed). Then the object is removed with DeleteElement().
- ;
- DisplayExplosions:
- ResetList(Explosion())
- While NextElement(Explosion()) ; Take the explosions objects, one by one.
- ; For each object, display the current explosion image (called state here)
- DisplayTransparentSprite(Explosion()\State+31, Explosion()\x, Explosion()\y)
- If Explosion()\Delay = 0
- If Explosion()\State = 0 ; Play the sound only at the explosion start.
- PlaySound(Random(3), 0)
- EndIf
- If Explosion()\State < 7
- Explosion()\State+1
- Explosion()\Delay = 3
- Else
- DeleteElement(Explosion())
- EndIf
- Else
- Explosion()\Delay-1
- EndIf
- Wend
- Return
Add Comment
Please, Sign In to add comment