Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IncludeFile "Macros.pbi"
- Global X.w = 0
- Global Y.w = 0
- Global p1X.w = 0
- Global p1Y.w = 0
- Global p2X.w = 0
- Global p2Y.w = 0
- Global SoundEnabled.a = #True
- Global ScreenWidth.w = 1024
- Global ScreenHeight.w = 768
- Global Dead.a = #False
- Global FontSize.w = 14
- Global Score.w = 0
- Global ShieldEnabled.a = #False
- Global ShieldTimer.i = 0
- Global GameTicks.i = 1
- UseMouse.a = #False
- PlayerSpeed.a = 4
- #GameTitle = "Aspirin V1.7"
- #DeadBeef = "WASTED"
- #PausedGame = "PAUSED"
- #PlayAgain = "Play again (Y/N)?_"
- #ShieldWarnStr = "SHIELD DEPLETING"
- #FontType = "Terminal"
- #P1_Size = 8
- #P2_Size = 8
- #BulletSpeed = 5
- #BulletLength = 32
- #BerryStartSpeed = 3000
- #BerryStopSpeed = 256
- #ShieldStartSpeed = 5000
- #ShieldStopSpeed = 512
- #ShieldUseTime = 1000
- #ShieldWarningTime = 256
- #BlueEaterSpeed = 3500
- #RedEaterSpeed = 2500
- #TopBorder = 20
- #StarCount = 2048
- ; **************** SCROLL DOWN FOR PROGRAM ENTRY POINT ******************
- ; ************ THIS IS LIKE C LANGUAGE - PROCS COME FIRST ***************
- Structure Bullet
- X.w
- Y.w
- Horz.a
- EndStructure
- Global Dim TheBullets.Bullet(ScreenWidth)
- Structure Eater
- X.w
- Y.w
- DestX.w
- DestY.w
- GettingBall.a
- Enabled.a
- Frame.a
- SpriteNo.a
- LeftSide.a
- EndStructure
- Global RedEater.Eater
- Global BlueEater.Eater
- Structure BonusItem
- X.w
- Y.w
- Ticks.i
- SpriteNo.a
- EndStructure
- Global TheShield.BonusItem
- Global TheBerry.BonusItem
- Structure Star
- X.f
- Y.f
- Z.f
- ZV.f
- EndStructure
- Global Dim Stars.Star(#StarCount)
- Macro Sound(SoundNo)
- If SoundEnabled = #True
- PlaySound(SoundNo)
- EndIf
- EndMacro
- Procedure InitStarfield()
- For i = 0 To #StarCount
- Stars(i)\x = Random(1000) - 500
- Stars(i)\y = Random(1000) - 500
- Stars(i)\z = 100 + Random(900)
- Stars(i)\zv = 0.5 + Random(45) / 10
- Next
- EndProcedure
- Procedure DrawStarfield()
- TheColor.a
- SX.i
- SY.i
- For i = 0 To #StarCount
- Stars(i)\Z = Stars(i)\Z - Stars(i)\ZV
- SX = Stars(i)\X / Stars(i)\Z * 100 + (ScreenWidth / 2)
- SY = Stars(i)\Y / Stars(i)\Z * 100 + (ScreenHeight / 2)
- If SX < 0 Or SY < 0 Or SX >= ScreenWidth Or SY >= ScreenHeight Or Stars(i)\Z < 1
- Stars(i)\X = Random(1000) - 500
- Stars(i)\Y = Random(1000) - 500
- Stars(i)\Z = 100 + Random(900)
- Stars(i)\ZV = 0.5 + (Random(45) / 10)
- Else
- TheColor = 128 - (Stars(i)\Z * 0.128)
- Plot(SX, SY, RGB(TheColor, TheColor, TheColor + 64))
- EndIf
- Next
- EndProcedure
- Procedure.a GotRedBalls()
- If p1X <= X + SpriteWidth(0) + #P1_Size And p1X >= X - #P1_Size
- If p1Y <= Y + SpriteHeight(0) + #P1_Size And p1Y >= Y - #P1_Size
- ProcedureReturn #True
- EndIf
- EndIf
- ProcedureReturn #False
- EndProcedure
- Procedure.a GotBlueBalls()
- If p2X <= X + SpriteWidth(0) + #P2_Size And p2X >= X - #P2_Size
- If p2Y <= Y + SpriteHeight(0) + #P2_Size And p2Y >= Y - #P2_Size
- ProcedureReturn #True
- EndIf
- EndIf
- ProcedureReturn #False
- EndProcedure
- Procedure RandomizeBlueBalls()
- p2X = Random(ScreenWidth - (#P2_Size * 2), #P2_Size * 2)
- p2Y = Random(ScreenHeight - (#P2_Size * 2), (#P2_Size * 2) + #TopBorder)
- EndProcedure
- Procedure RandomizeRedBalls()
- p1X = Random(ScreenWidth - (#P1_Size * 2), #P1_Size * 2)
- p1Y = Random(ScreenHeight - (#P1_Size * 2), (#P1_Size * 2) + #TopBorder)
- EndProcedure
- Procedure StartNextBullet(h.a)
- ; H IS FOR HORIZONTAL. HORIZ BULLETS SET THEIR Y COORD TO A RANDOM CONSTANT POSITION
- If h = #True
- For i = 0 To ArraySize(TheBullets())
- If TheBullets(i)\Y = 0
- TheBullets(i)\Y = Random(ScreenHeight, #TopBorder)
- TheBullets(i)\Horz = #True
- ProcedureReturn
- EndIf
- Next
- Else
- For i = 0 To ArraySize(TheBullets())
- If TheBullets(i)\X = 0
- TheBullets(i)\X = Random(ScreenWidth, 1)
- TheBullets(i)\Horz = #False
- ProcedureReturn
- EndIf
- Next
- EndIf
- EndProcedure
- Procedure UpdateHorzBullets()
- ; WE KNOW IF HORZ WAS SET, THAT A NEW BULLET'S Y POSITION HAS BEEN INITIALIZED
- ; SO IF THE BULLET IS NOT GOING OFF-SCREEN, THEN UPDATE ITS POSITION
- For i = 0 To ArraySize(TheBullets())
- If TheBullets(i)\Horz = #True
- If TheBullets(i)\X >= ScreenWidth - #BulletLength
- TheBullets(i)\X = 0
- Else
- TheBullets(i)\X + #BulletSpeed
- EndIf
- EndIf
- Next
- EndProcedure
- Procedure UpdateVertBullets()
- ; HORZ IS FALSE BY DEFAULT, SO WE DON'T KNOW IF A NEW BULLET WAS INITIALIZED, WE NEED TO CHECK
- ; IF THE BULLET X WAS INITED, THEN UPDATE THE BULLET, FIRST CHECKING IF IT'S GOING OFF SCREEN
- For i = 0 To ArraySize(TheBullets())
- If TheBullets(i)\Horz = #False
- If TheBullets(i)\X <> 0
- If TheBullets(i)\Y >= ScreenHeight - #BulletLength
- TheBullets(i)\Y = #TopBorder
- Else
- TheBullets(i)\Y + #BulletSpeed
- EndIf
- EndIf
- EndIf
- Next
- EndProcedure
- Procedure CheckEaterHits(*theEater.Eater, i)
- If *theEater\Enabled = #True
- If TheBullets(i)\X <= *theEater\X + 32 And TheBullets(i)\X + #BulletLength >= *theEater\X
- If TheBullets(i)\Y < *theEater\Y + 32 And TheBullets(i)\Y >= *theEater\Y
- StartDrawing(ScreenOutput())
- Circle(*theEater\X + 16, *theEater\Y + 16, 32, #Blue)
- StopDrawing()
- If SoundStatus(4) = #PB_Sound_Stopped
- Sound(4)
- EndIf
- If TheBullets(i)\Horz = #True
- TheBullets(i)\X = 0
- Else
- TheBullets(i)\Y = #TopBorder
- EndIf
- EndIf
- EndIf
- EndIf
- EndProcedure
- Procedure DrawPersonalShield()
- StartDrawing(ScreenOutput())
- Circle(X + (SpriteWidth(0) / 2), Y + (SpriteHeight(0) / 2), 32, #Blue)
- StopDrawing()
- If SoundStatus(4) = #PB_Sound_Stopped
- Sound(4)
- EndIf
- EndProcedure
- Procedure CheckHits()
- ; CHECK HORZ HITS
- For i = 0 To ArraySize(TheBullets())
- If TheBullets(i)\Horz = #True
- If TheBullets(i)\X <= X + SpriteWidth(0) And TheBullets(i)\X + #BulletLength >= X
- If TheBullets(i)\Y < Y + SpriteHeight(0) And TheBullets(i)\Y >= Y
- If ShieldEnabled = #True
- DrawPersonalShield()
- Else
- Dead = #True
- EndIf
- EndIf
- EndIf
- CheckEaterHits(RedEater, i)
- CheckEaterHits(BlueEater, i)
- Else
- If TheBullets(i)\X <> 0
- If TheBullets(i)\Y <= Y + SpriteHeight(0) And TheBullets(i)\Y + #BulletLength >= Y
- If TheBullets(i)\X < X + SpriteWidth(0) And TheBullets(i)\X >= X
- If ShieldEnabled = #True
- DrawPersonalShield()
- Else
- Dead = #True
- EndIf
- EndIf
- EndIf
- CheckEaterHits(RedEater, i)
- CheckEaterHits(BlueEater, i)
- EndIf
- EndIf
- Next
- EndProcedure
- Procedure.a CheckBonusHits(objNo.w, objX.w, objY.w)
- If SpriteCollision(0, X, Y, objNo, objX, objY)
- Select objNo
- Case 4 ; THIS IS THE BONUS BERRY
- Score + 5
- StartNextBullet(#True)
- StartNextBullet(#False)
- Sound(0)
- Case 5 ; THIS IS THE BONUS SHIELD
- Score + 2
- ShieldEnabled = #True
- ShieldTimer = GameTicks
- Sound(6)
- EndSelect
- ProcedureReturn #True
- EndIf
- ProcedureReturn #False
- EndProcedure
- Procedure UpdateBonus(*theBonus.BonusItem)
- RequiredScore.w = 0
- StartTime.i = 0
- EndTime.i = 0
- Select *theBonus\SpriteNo
- Case 4 ; THIS IS THE BONUS BERRY
- RequiredScore = 10
- StartTime = #BerryStartSpeed
- EndTime = #BerryStopSpeed
- Case 5 ; THIS IS THE BONUS SHIELD
- RequiredScore = 16
- StartTime = #ShieldStartSpeed
- EndTime = #ShieldStopSpeed
- EndSelect
- If Score > RequiredScore And *theBonus\Ticks = 0
- If (GameTicks % StartTime) = 0
- *theBonus\Ticks = GameTicks
- *theBonus\X = Random(ScreenWidth - SpriteWidth(*theBonus\SpriteNo))
- *theBonus\Y = Random(ScreenHeight - SpriteHeight(*theBonus\SpriteNo), #TopBorder)
- Sound(5)
- EndIf
- EndIf
- If *theBonus\Ticks > 0
- If *theBonus\Ticks = (GameTicks - EndTime)
- *theBonus\Ticks = 0
- Else
- If CheckBonusHits(*theBonus\SpriteNo, *theBonus\X, *theBonus\Y)
- *theBonus\Ticks = 0
- EndIf
- DisplayTransparentSprite(*theBonus\SpriteNo, *theBonus\X, *theBonus\Y)
- EndIf
- EndIf
- EndProcedure
- Procedure StartEater(*theEater.Eater)
- If *theEater\LeftSide = #True
- *theEater\X = -64
- Else
- *theEater\X = ScreenWidth + 64
- EndIf
- *theEater\Y = Random(ScreenHeight, #TopBorder + 32)
- *theEater\Enabled = #True
- *theEater\GettingBall = #True
- EndProcedure
- Procedure EndEater(*theEater.Eater)
- If *theEater\LeftSide = #True
- *theEater\DestX = ScreenWidth + 64
- Else
- *theEater\DestX = -64
- EndIf
- *theEater\DestY = Random(ScreenHeight, #TopBorder + 32)
- *theEater\GettingBall = #False
- EndProcedure
- Procedure UpdateEater(*theEater.Eater)
- If *theEater\Enabled = #True
- If *theEater\GettingBall = #True
- If *theEater\LeftSide = #True
- *theEater\DestX = p1X - 32
- *theEater\DestY = p1Y - 16
- Else
- *theEater\DestX = p2X - 16
- *theEater\DestY = p2Y - 16
- EndIf
- If *theEater\X = *theEater\DestX And *theEater\Y = *theEater\DestY
- If *theEater\LeftSide = #True
- RandomizeRedBalls()
- Else
- RandomizeBlueBalls()
- EndIf
- If Score > 0
- Score - 1
- EndIf
- Sound(2)
- EndEater(*theEater)
- EndIf
- Else
- If *theEater\X = *theEater\DestX And *theEater\Y = *theEater\DestY
- *theEater\Enabled = #False
- EndIf
- EndIf
- If *theEater\X < *theEater\DestX
- *theEater\X + 1
- ElseIf *theEater\X > *theEater\DestX
- *theEater\X - 1
- EndIf
- If *theEater\Y < *theEater\DestY
- *theEater\Y + 1
- ElseIf *theEater\Y > *theEater\DestY
- *theEater\Y - 1
- EndIf
- If *theEater\Frame >= 3
- *theEater\Frame = 0
- EndIf
- ClipSprite(*theEater\SpriteNo, *theEater\Frame * 32, 0, 32, 32)
- DisplayTransparentSprite(*theEater\SpriteNo, *theEater\X, *theEater\Y)
- EndIf
- EndProcedure
- Procedure ResetGame()
- Dim TheBullets.Bullet(ScreenWidth)
- X = (ScreenWidth / 2) - (SpriteWidth(0) / 2)
- Y = (ScreenHeight / 2) - (SpriteHeight(0) / 2)
- RandomizeBlueBalls()
- RandomizeRedBalls()
- Score = 0
- Dead = #False
- RedEater\Enabled = #False
- BlueEater\Enabled = #False
- RedEater\GettingBall = #False
- BlueEater\GettingBall = #False
- TheBerry\Ticks = 0
- TheShield\Ticks = 0
- EndProcedure
- Procedure ShowShieldDepleting()
- StartDrawing(ScreenOutput())
- DrawingFont(FontID(2))
- WarnX.w = (ScreenWidth / 2) - TextWidth(#ShieldWarnStr) / 2
- DrawText(WarnX, ScreenHeight / 3, #ShieldWarnStr, #Red)
- StopDrawing()
- FlipBuffers()
- Sleep(2000)
- EndProcedure
- Procedure ShowDead()
- FinalScore.s = "Your final score was: " + Str(Score) + " | "
- Repeat
- StartDrawing(ScreenOutput())
- DrawStarfield()
- DrawingFont(FontID(2))
- DrawingMode(#PB_2DDrawing_Transparent)
- DeadX.w = (ScreenWidth / 2) - TextWidth(#DeadBeef) / 2
- BeerX.w = DeadX + TextWidth(#DeadBeef)
- DrawText(DeadX, ScreenHeight / 3, #DeadBeef, #Red)
- DrawingFont(FontID(1))
- DrawText((ScreenWidth / 2) - TextWidth(FinalScore + #PlayAgain) / 2, ScreenHeight / 2, FinalScore + #PlayAgain, #White)
- StopDrawing()
- DisplayTransparentSprite(1, DeadX - SpriteWidth(1), ScreenHeight / 3)
- DisplayTransparentSprite(1, BeerX, ScreenHeight / 3)
- FlipBuffers()
- Event = WindowEvent()
- ExamineKeyboard()
- If KeyboardPushed(#PB_Key_Y)
- ResetGame()
- Break
- ElseIf KeyboardPushed(#PB_Key_N) Or Event = #PB_Event_CloseWindow
- End
- EndIf
- ForEver
- EndProcedure
- Procedure ShowPause()
- Sleep(128)
- Repeat
- StartDrawing(ScreenOutput())
- DrawStarfield()
- DrawingFont(FontID(2))
- DrawingMode(#PB_2DDrawing_Transparent)
- PauseX.w = (ScreenWidth / 2) - TextWidth(#PausedGame) / 2
- DrawText(PauseX, ScreenHeight / 3, #PausedGame, #Magenta)
- StopDrawing()
- FlipBuffers()
- Event = WindowEvent()
- ExamineKeyboard()
- Until KeyboardPushed(#PB_Key_P) Or Event = #PB_Event_CloseWindow
- EndProcedure
- Procedure ShowHelp()
- theSizeX.w = ScreenWidth / 4
- theSizeY.w = ScreenHeight / 4
- theStepX.w = FontSize - 4
- theStepY.w = FontSize
- StartDrawing(ScreenOutput())
- Box(theSizeX, theSizeY, theSizeX * 2, theSizeY * 2, #Blue)
- DrawingFont(FontID(1))
- DrawText((theSizeX * 3) + theStepX, (theSizeY * 3) + theStepY, Chr(177), #Gray)
- i = theSizeX
- While i <= theSizeX * 3
- If i <> theSizeX
- DrawText(i, (theSizeY * 3) + theStepY, Chr(177), #Gray)
- EndIf
- DrawText(i, theSizeY, Chr(205), #Yellow)
- DrawText(i, theSizeY * 3, Chr(205), #Yellow)
- i + theStepX
- Wend
- i = theSizeY
- While i <= theSizeY * 3
- If i <> theSizeY
- DrawText((theSizeX * 3) + theStepX, i, Chr(177), #Gray)
- EndIf
- DrawText(theSizeX, i, Chr(186), #Yellow)
- DrawText(theSizeX * 3, i, Chr(186), #Yellow)
- i + theStepY
- Wend
- DrawText(theSizeX, theSizeY, Chr(201), #Yellow)
- DrawText(theSizeX * 3, theSizeY, Chr(187), #Yellow)
- DrawText(theSizeX, theSizeY * 3, Chr(200), #Yellow)
- DrawText(theSizeX * 3, theSizeY * 3, Chr(188), #Yellow)
- DrawingMode(#PB_2DDrawing_Transparent)
- theSizeX + FontSize
- DrawText(theSizeX, theSizeY + 20, "< GAME HELP >", #White)
- DrawText(theSizeX, theSizeY + 56, "'S' - turn sound on and off", #White)
- DrawText(theSizeX, theSizeY + 74, "'M' - toggle between mouse control/keyboard", #White)
- DrawText(theSizeX, theSizeY + 92, "'-' - decrease player speed (keyboard)", #White)
- DrawText(theSizeX, theSizeY + 110, "'+' - increase player speed (keyboard)", #White)
- DrawText(theSizeX, theSizeY + 128, "'N' - start a new game", #White)
- DrawText(theSizeX, theSizeY + 146, "'P' - pause game", #White)
- DrawText(theSizeX, theSizeY + 182, "Use XRes [SPACE] YRes as command parameter...", #White)
- If FontSize >= 10
- DrawText(theSizeX, theSizeY + 200, "to change the game window resolution.", #White)
- DrawText(theSizeX, theSizeY + 218, "Ex: 'Aspirin.exe 1920 1080' in .BAT file.", #White)
- EndIf
- DrawText(theSizeX, (theSizeY * 3) - 38, "(C) 2021 DosaidSoft(.com)", $C0C0C0)
- DrawText(theSizeX, (theSizeY * 3) - 20, "Press H again to close window.", $C0C0C0)
- StopDrawing()
- FlipBuffers()
- Sleep(256)
- Repeat
- Event = WindowEvent()
- ExamineKeyboard()
- Until KeyboardPushed(#PB_Key_H) Or Event = #PB_Event_CloseWindow
- EndProcedure
- Procedure DrawIntro()
- StartDrawing(ScreenOutput())
- DrawingFont(FontID(1))
- DrawText(0, 0, "Loading advanced DOS/5GW 64-bit engine framework V1337.7.7", #White)
- DrawText(0, 18, "(C) 2021 DosaidSoft(.com)", #White)
- DrawText(0, 54, "*** PRESS 'H' KEY IN GAME FOR HELP/SETTINGS ***", #White)
- StopDrawing()
- FlipBuffers()
- For i = 0 To 7
- StartDrawing(ScreenOutput())
- DrawingFont(FontID(1))
- DrawText(1, 72, Chr(22), #White)
- StopDrawing()
- FlipBuffers()
- ;WindowEvent()
- Sleep(500)
- StartDrawing(ScreenOutput())
- DrawingFont(FontID(1))
- DrawText(1, 72, " ", #White)
- StopDrawing()
- FlipBuffers()
- Sleep(500)
- Next
- For i = 0 To 16
- FlipBuffers()
- StartDrawing(ScreenOutput())
- DrawingFont(FontID(1))
- ;DrawingMode(#PB_2DDrawing_Transparent)
- For j = 0 To 512
- DrawText(Random(ScreenWidth), Random(ScreenHeight), Chr(Random(254, 1)), RGB(Random(255),Random(255),Random(255)))
- Next
- StopDrawing()
- Next
- EndProcedure
- ; ======================================================================================
- ; PROGRAM ENTRY POINT
- ; ======================================================================================
- If InitSprite() = 0 Or InitKeyboard() = 0 Or InitSound() = 0 Or InitMouse() = 0
- MessageRequester("Error", "Sub-system can't be initialized", 0)
- End
- EndIf
- ; WE NEED TO CHECK OUR COMMAND LINE PARAMS I.E. ASPIRIN.EXE [X RES] [Y RES]
- If CountProgramParameters() <> 0
- ScreenWidth = Val(ProgramParameter())
- ScreenHeight = Val(ProgramParameter())
- EndIf
- ; SET UP OUR WINDOW AT EITHER LOADED OR DEFAULT RES AND LOAD ALL OUR EMBEDDED RESOURCES
- OpenWindow(0, 0, 0, ScreenWidth, ScreenHeight, #GameTitle, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
- OpenWindowedScreen(WindowID(0), 0, 0, ScreenWidth, ScreenHeight)
- UsePNGImageDecoder()
- UseOGGSoundDecoder()
- CatchSprite(0, ?Dude, #PB_Sprite_AlphaBlending)
- CatchSprite(1, ?Beer, #PB_Sprite_AlphaBlending)
- CatchSprite(2, ?EaterImg, #PB_Sprite_AlphaBlending)
- CatchSprite(3, ?RightEaterImg, #PB_Sprite_AlphaBlending)
- CatchSprite(4, ?BerryImg, #PB_Sprite_AlphaBlending)
- CatchSprite(5, ?ShieldImg, #PB_Sprite_AlphaBlending)
- CatchSound(0, ?PointSound, ?EndPtr - ?PointSound)
- CatchSound(1, ?DeadSound, ?PointSound - ?DeadSound)
- CatchSound(2, ?LoseSound, ?DeadSound - ?LoseSound)
- CatchSound(3, ?SafeSound, ?LoseSound - ?SafeSound)
- CatchSound(4, ?HitSound, ?SafeSound - ?HitSound)
- CatchSound(5, ?BonusSound, ?HitSound - ?BonusSound)
- CatchSound(6, ?GetShieldSound, ?BonusSound - ?GetShieldSound)
- CatchSound(7, ?LoseShieldSound, ?GetShieldSound - ?LoseShieldSound)
- SoundVolume(0, 32)
- SoundVolume(1, 32)
- SoundVolume(2, 32)
- SoundVolume(3, 32)
- SoundVolume(4, 32)
- SoundVolume(5, 48)
- SoundVolume(6, 48)
- SoundVolume(7, 48)
- RandomizeBlueBalls()
- RandomizeRedBalls()
- ; SET UP EATER SPRITES
- RedEater\SpriteNo = 2
- RedEater\LeftSide = #True
- BlueEater\SpriteNo = 3
- BlueEater\LeftSide = #False
- TheBerry\SpriteNo = 4
- TheShield\SpriteNo = 5
- ; PUT THE DUDE AT THE CENTER SCREEN
- X = (ScreenWidth / 2) - (SpriteWidth(0) / 2)
- Y = (ScreenHeight / 2) - (SpriteHeight(0) / 2)
- ; CHECK THE SCREEN RES AND LOWER FONT SIZE (SET TO 14PT BY DEFAULT ABOVE)
- If ScreenWidth <= 320
- FontSize = 6
- ElseIf ScreenWidth <= 640
- FontSize = 8
- ElseIf ScreenWidth <= 800
- FontSize = 10
- EndIf
- LoadFont(1, #FontType, FontSize)
- LoadFont(2, #FontType, 48, #PB_Font_Bold)
- LoadFont(3, #FontType, 10)
- ; DRAW INTRO SCREEN
- DrawIntro()
- InitStarfield()
- ; MAIN GAME LOOP
- Repeat
- Event = WindowEvent()
- ExamineKeyboard()
- ; COPY OUR BACK BUFFER TO THE SCREEN AND CLEAR
- FlipBuffers()
- ClearScreen(#Black)
- ; DRAW THE CIRCLES TO CAPTURE BY THE DUDE
- ; LOOP AND DRAW ALL BULLETS
- StartDrawing(ScreenOutput())
- DrawStarfield()
- DrawingFont(FontID(1))
- If SoundEnabled = #True
- DrawText(0, 0, #GameTitle + " " + Chr(13) + Chr(13), #White)
- Else
- DrawText(0, 0, #GameTitle, #White)
- EndIf
- DrawText(ScreenWidth - 168, 0, "Score: " + Str(Score), #White)
- Box(0, #TopBorder - 2, ScreenWidth, 2, #White)
- Circle(p1X + 2, p1Y + 2, #P1_Size, $404080)
- Circle(p2X + 2, p2Y + 2, #P1_Size, $808040)
- Circle(p1X, p1Y, #P1_Size, #Red)
- Circle(p2X, p2Y, #P2_Size, #Cyan)
- DrawingFont(FontID(3))
- For i = 0 To ArraySize(TheBullets())
- If TheBullets(i)\Horz = #True
- DrawText(TheBullets(i)\X - 10, TheBullets(i)\Y - 5, Chr(15), #Yellow)
- DrawText(TheBullets(i)\X + #BulletLength, TheBullets(i)\Y - 5, Chr(62), #Cyan)
- Line(TheBullets(i)\X, TheBullets(i)\Y, #BulletLength, 1, #Cyan)
- Else
- If TheBullets(i)\X <> 0
- DrawText(TheBullets(i)\X - 4, TheBullets(i)\Y - 10, Chr(15), #Yellow)
- DrawText(TheBullets(i)\X - 3, TheBullets(i)\Y + #BulletLength, "V", #Red)
- Line(TheBullets(i)\X, TheBullets(i)\Y, 1, #BulletLength, #Red)
- EndIf
- EndIf
- Next
- StopDrawing()
- ; CHECK IF THE PLAYER COLLIDED WITH THE BALLS AND SPAWN A NEW BULLET
- ; BLUE BALL IS HORIZONTAL, ETC.
- If GotBlueBalls() = #True
- ; IF WE GOT THE BALL FIRST AND THE EATER IS TRYING TO GET IT, DISABLE HIM
- If BlueEater\GettingBall = #True
- EndEater(BlueEater)
- Sound(3)
- Else
- Sound(0)
- EndIf
- Score + 1
- RandomizeBlueBalls()
- StartNextBullet(#True)
- EndIf
- If GotRedBalls() = #True
- If RedEater\GettingBall = #True
- EndEater(RedEater)
- Sound(3)
- Else
- Sound(0)
- EndIf
- Score + 1
- RandomizeRedBalls()
- StartNextBullet(#False)
- EndIf
- ; SHOW THE BONUS BERRY AT SPECIFIED INTERVALS
- UpdateBonus(TheBerry)
- ; SHOW THE BONUS SHIELD AT SPECIFIED INTERVALS
- UpdateBonus(TheShield)
- If ShieldEnabled = #True
- If GameTicks = ShieldTimer + #ShieldUseTime
- ShieldEnabled = #False
- Sound(7)
- EndIf
- ; WARN THE PLAYER IF THE SHIELD HAS ALMOST DEPELETED
- If GameTicks = ShieldTimer + (#ShieldUseTime - #ShieldWarningTime)
- ShowShieldDepleting()
- EndIf
- EndIf
- ; CHECK IF THE GUY OR THE EATER HAS BEEN HIT BY THE BULLETS
- CheckHits()
- If KeyboardPushed(#PB_Key_0)
- Dead = #False
- EndIf
- If Dead = #True
- Sound(1)
- ShowDead()
- GameTicks = 1
- EndIf
- UpdateHorzBullets()
- UpdateVertBullets()
- ; DISPLAY OUR CHARACTER
- DisplayTransparentSprite(0, X, Y)
- ; CHECK OUR GAME TICKS TO DETERMINE IF THE EATERS SHOULD APPEAR
- ; GAME TICKS NEVER GET RESET, SO WE DO REMAINDER DIVISION (EATER WILL APPEAR ONLY IF THE TICKS ARE DIVISABLE)
- If (GameTicks % #RedEaterSpeed) = 0
- StartEater(RedEater)
- EndIf
- If (GameTicks % #BlueEaterSpeed) = 0
- StartEater(BlueEater)
- EndIf
- If (GameTicks % 15) = 0
- If RedEater\Enabled = #True
- RedEater\Frame + 1
- EndIf
- If BlueEater\Enabled = #True
- BlueEater\Frame + 1
- EndIf
- EndIf
- UpdateEater(RedEater)
- UpdateEater(BlueEater)
- ; MOVE OUR MAIN DUDE WITH ARROW KEYS OR MOUSE
- If UseMouse = #False
- If KeyboardPushed(#PB_Key_Right)
- X + PlayerSpeed
- ElseIf KeyboardPushed(#PB_Key_Left)
- X - PlayerSpeed
- EndIf
- If KeyboardPushed(#PB_Key_Up)
- Y - PlayerSpeed
- ElseIf KeyboardPushed(#PB_Key_Down)
- Y + PlayerSpeed
- EndIf
- Else
- ExamineMouse()
- X = MouseX()
- Y = MouseY()
- EndIf
- If X > ScreenWidth - SpriteWidth(0)
- X = ScreenWidth - SpriteWidth(0)
- ElseIf X < 0
- X = 0
- EndIf
- If Y > ScreenHeight - SpriteHeight(0)
- Y = ScreenHeight - SpriteHeight(0)
- ElseIf Y < #TopBorder
- Y = #TopBorder
- EndIf
- ; CHECK ALL OUR OPTION KEYS
- If KeyboardPushed(#PB_Key_H)
- ShowHelp()
- Sleep(256)
- EndIf
- If KeyboardPushed(#PB_Key_Minus)
- If PlayerSpeed > 0
- PlayerSpeed - 1
- Sleep(128)
- EndIf
- ElseIf KeyboardPushed(#PB_Key_Equals)
- If PlayerSpeed < 32
- PlayerSpeed + 1
- Sleep(128)
- EndIf
- EndIf
- If KeyboardPushed(#PB_Key_M)
- If UseMouse = #False
- UseMouse = #True
- ExamineMouse()
- ReleaseMouse(#False)
- MouseLocate(X, Y)
- Sleep(256)
- Else
- UseMouse = #False
- ReleaseMouse(#True)
- Sleep(256)
- EndIf
- EndIf
- If KeyboardPushed(#PB_Key_N)
- ResetGame()
- GameTicks = 1
- Sleep(256)
- EndIf
- If KeyboardPushed(#PB_Key_S)
- ; WAY TO INVERT A VARIABLE TRUE/FALSE
- SoundEnabled = ~ SoundEnabled
- Sleep(256)
- EndIf
- If KeyboardPushed(#PB_Key_P)
- ShowPause()
- Sleep(256)
- EndIf
- GameTicks + 1
- Until Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
- End
- DataSection
- Dude:
- IncludeBinary "dude.png"
- Beer:
- IncludeBinary "beer.png"
- EaterImg:
- IncludeBinary "eater.png"
- RightEaterImg:
- IncludeBinary "righteater.png"
- BerryImg:
- IncludeBinary "bonus.png"
- ShieldImg:
- IncludeBinary "shield.png"
- LoseShieldSound:
- IncludeBinary "loseshield.ogg"
- GetShieldSound:
- IncludeBinary "getshield.ogg"
- BonusSound:
- IncludeBinary "bonus.ogg"
- HitSound:
- IncludeBinary "ping.ogg"
- SafeSound:
- IncludeBinary "safe.ogg"
- LoseSound:
- IncludeBinary "lose.ogg"
- DeadSound:
- IncludeBinary "dead.ogg"
- PointSound:
- IncludeBinary "point.ogg"
- EndPtr:
- EndDataSection
- ; IDE Options = PureBasic 5.73 LTS (Windows - x64)
- ; Folding = -----
- ; EnableXP
- ; UseIcon = pills2.ico
- ; Executable = B:\Aspirin17.exe
- ; IncludeVersionInfo
- ; VersionField0 = 1,7,0,0
- ; VersionField1 = 1,7,0,0
- ; VersionField2 = DosaidSoft
- ; VersionField3 = Aspirin
- ; VersionField4 = 1.7
- ; VersionField5 = 1.7
- ; VersionField6 = Aspirin Video Game from TI-83 Plus
- ; VersionField7 = ASPIRIN
- ; VersionField8 = ASPIRIN
- ; VersionField9 = (C) 2021 DosaidSoft
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement