Controls:
Mouse = Move
Arrowkeys = fire
Space = BLOW EVERYTHING UP!
Code: Select all
If InitMouse() = 0
MessageRequester("Error","Error loading Mouse!")
EndIf
If InitKeyboard() = 0
MessageRequester("Error","Error loading Keyboard!")
EndIf
If InitSprite() = 0
MessageRequester("Error","Error loading DirectX!")
EndIf
If InitSprite3d() = 0
MessageRequester("Error","No 3d video card found")
EndIf
Procedure Error(Text.s)
MessageRequester("Error!",Text)
EndProcedure
If OpenWindow(0,0,0,500,500,#PB_Window_ScreenCentered|#PB_Window_TitleBar|#PB_Window_SystemMenu ,"Half Life 2000") = 0
Error("Failed to open window!")
ElseIf CreateGadgetList(WindowID(0)) = 0
Error("Failed to open gadget list!")
ElseIf OpenWindowedScreen(WindowID(0),0,0,500,500,0,0,0) = 0
Error("Failed to open screen!")
EndIf
UseWindow(0)
ClearScreen(0,128,0)
GrabSprite(1,0,0,30,5);Ship
ClearScreen(0,0,128)
GrabSprite(0,0,0,50,15);block
ClearScreen(255,255,0)
GrabSprite(2,0,0,2,20);lazer up/down
GrabSprite(3,0,0,20,2);lazer left/right
ClearScreen(0,0,128)
GrabSprite(4,0,0,16,16,#PB_Sprite_Texture);smoke
CreateSprite3D(4,4)
Structure block
Col.l
Y.l
Speed.l
Health.l
T.l
EndStructure
NewList block.block()
NewList laz.block()
Procedure AddBlock(Col,Speed)
AddElement(block())
block()\Col = Col
block()\Y = 500
block()\Speed = Speed
block()\Health = 100
EndProcedure
Procedure AddLaz(Col,Y,Speed,T)
Beep_(5000+Random(1000)-500,10)
AddElement(Laz())
laz()\Col = Col
laz()\Y = Y
laz()\Speed = Speed
laz()\t = t
EndProcedure
Structure smoke
x.f
y.f
xs.f
ys.f
zoom.f
trans.f
EndStructure
NewList smoke.smoke()
Procedure addsmoke(X,Y)
AddElement(SMoke())
Smoke()\X = X
Smoke()\Y = Y
Smoke()\XS = (Random(1000)-500)/100
Smoke()\YS = (Random(1000)-500)/100
Smoke()\Zoom = 1
Smoke()\Trans = 255
EndProcedure
Procedure UpdateSmoke()
If CountList(Smoke()) > 0
ResetList(Smoke())
While NextElement(Smoke())
Smoke()\X + Smoke()\XS - 1
Smoke()\Y + smoke()\YS - 1
Smoke()\Zoom + 2
Smoke()\Trans - 10
If Smoke()\Trans < 10
DeleteElement(Smoke())
Continue
EndIf
ZoomSprite3D(4,Smoke()\Zoom,Smoke()\Zoom)
DisplaySprite3D(4,Smoke()\X,Smoke()\Y,Smoke()\Trans)
Wend
EndIf
EndProcedure
Procedure UpdateBlocks()
If CountList(block()) > 0
ResetList(block())
While NextElement(Block())
If CountList(Laz()) > 0
ResetList(Laz())
While NextElement(Laz())
If SpritePixelCollision(0,(block()\Col-1)*50,block()\y,2,Laz()\Col,Laz()\Y)
block()\Health - 25
Beep_(3000+Random(1000)-500,10)
If Laz()\T = 1
Addsmoke(Laz()\Col,Laz()\Y+10)
ElseIf Laz()\T = 2
Addsmoke(Laz()\Col+10,Laz()\Y)
ElseIf Laz()\T = 3
Addsmoke(Laz()\Col+10,Laz()\Y)
ElseIf Laz()\T = 4
Addsmoke(Laz()\Col,Laz()\Y+10)
EndIf
If block()\Health < 1
DeleteElement(block())
For Z = 1 To 10
Beep_(1000+Random(1000)-500,1)
Next Z
Continue
EndIf
DeleteElement(laz())
Continue
EndIf
Wend
EndIf
DisplaySprite(0,(block()\Col-1)*50,block()\y)
block()\Y - block()\Speed
If block()\Y = -25
DeleteElement(block())
Continue
EndIf
Wend
EndIf
EndProcedure
Procedure UpdateLaz()
If CountList(Laz()) > 0
ResetList(Laz())
While NextElement(Laz())
If Laz()\T = 1
DisplaySprite(2,Laz()\Col,Laz()\Y)
Laz()\Y + Laz()\Speed
If Laz()\Y > 500
DeleteElement(Laz())
Continue
EndIf
ElseIf Laz()\T = 2
DisplaySprite(3,Laz()\Col,Laz()\Y)
Laz()\Col + Laz()\Speed
If Laz()\Col < -20
DeleteElement(Laz())
Continue
EndIf
ElseIf Laz()\T = 3
DisplaySprite(3,Laz()\Col,Laz()\Y)
Laz()\Col - Laz()\Speed
If Laz()\Col > 500
DeleteElement(Laz())
Continue
EndIf
ElseIf Laz()\T = 4
DisplaySprite(2,Laz()\Col,Laz()\Y)
Laz()\Y - Laz()\Speed
If Laz()\Y < -20
DeleteElement(Laz())
Continue
EndIf
EndIf
Wend
EndIf
EndProcedure
Procedure NewGame(Level.l)
Repeat
ClearScreen(0,200,255)
UpdateLaz()
UpdateBlocks()
ExamineMouse()
DisplayTransparentSprite(1,MouseX(),MouseY())
LazCooldown - 1
If LazCooldown < 0
LazCooldown = 0
EndIf
Start3D()
UpdateSmoke()
Stop3D()
FlipBuffers()
Counter + 1
If Counter = 20
Counter = 0
For X = 1 To 10
RandomNumber = Random(1)
If RandomNumber = 1
AddBlock(X,2)
EndIf
Next X
EndIf
If WindowEvent() = #PB_Event_CloseWindow
End
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
If KeyboardPushed(#PB_Key_Down)
If LazCooldown = 0
AddLaz(MouseX()+15,MouseY(),15,1)
LazCooldown = 3
EndIf
EndIf
If KeyboardPushed(#PB_Key_Up)
If LazCooldown = 0
AddLaz(MouseX()+15,MouseY()-20,15,4)
LazCooldown = 3
EndIf
EndIf
If KeyboardPushed(#PB_Key_Right)
If LazCooldown = 0
AddLaz(MouseX(),MouseY()+2,15,2)
LazCooldown = 3
EndIf
EndIf
If KeyboardPushed(#PB_Key_Left)
If LazCooldown = 0
AddLaz(MouseX(),MouseY()+2,15,3)
LazCooldown = 3
EndIf
EndIf
If KeyboardReleased(#PB_Key_Space)
ClearList(block())
For Z = 1 To 100
Addsmoke(Random(500),Random(500))
Beep_(Random(2000),10)
Next Z
EndIf
ForEver
EndProcedure
NewGame(1)
