'Blubber Dragon V.2.04 NoEMS
'A Draco RedScale Game, FREEWARE
'**************************************
'Bad, slow code? Then make it better! Read README.TXT.
'- Send suggestions, hints and/or bug reports to janne.koponen@saunalahti.fi
'* Sorry, can't make a real windows version...I'm not that good programmer!
'$INCLUDE: 'BLUBBERD\DECLARS.BAS'

'$DYNAMIC
DIM SHARED Mouth(0 TO 8) AS Mouth
DIM SHARED FatFood(1 TO 100) AS FatFood
DIM SHARED Bubble(1 TO 5) AS Bubble

'Character becomes Bouncy or Helium inflated
JSize = DQBsize(0, 0, 175, 175)
DIM SHARED Bouncy(JSize) AS INTEGER

'Invisible clouds, fog...etc.
JSize = DQBsize(31, 0, 90, 29)
DIM SHARED Cloud(JSize) AS INTEGER
DIM SHARED CloudG1(JSize) AS INTEGER
DIM SHARED CloudG2(JSize) AS INTEGER
DIM SHARED CloudX(1 TO 100) AS INTEGER
DIM SHARED CloudY(1 TO 100) AS INTEGER
DIM SHARED CloudType(1 TO 100) AS INTEGER
'Invisible water
JSize = DQBsize(0, 0, 79, 0)
DIM SHARED Water(JSize) AS INTEGER

'Palette
DIM SHARED Pal AS STRING * 786

ON ERROR GOTO QUIT

RANDOMIZE TIMER

INIT   'Initialize DQB 1.61 + DQBRel and DS4QB++ 1.2

GAME  'The game itself

QUIT: 'Error handler
IF Game.Level% = 0 THEN QUIT

'This is to fix game crashes during play
IF ERR = 53 THEN
Error53Num% = Error53Num% + 1
IF ShowErrors% = 1 THEN
JPRINT VIDEO, "QB-ERROR 53. TRYING TO RESUME...", 20, 140, 15
DQBwait 100
END IF
IF DQBkey(KEYESC) THEN QUIT
RESUME 0
END IF
IF ERR = 75 THEN
Error75Num% = Error75Num% + 1
IF ShowErrors% = 1 THEN
JPRINT VIDEO, "QB-ERROR 75. TRYING TO RESUME...", 20, 140, 15
DQBwait 100
END IF
IF DQBkey(KEYESC) THEN QUIT
RESUME 0
END IF

QUIT  'Close program

REM $STATIC
DEFSNG A-Z
SUB GAME

'Fatgas needs to be loaded only once
IF DQBloadImage(TEMPLAYER, 0, 0, "DATA\OTHER\OBJ.BMP", Pal, 0, 0) THEN QUIT
DQBget TEMPLAYER, 31, 62, 90, 91, VARSEG(CloudG1(0)), VARPTR(CloudG1(0))
DQBget TEMPLAYER, 31, 93, 90, 122, VARSEG(CloudG2(0)), VARPTR(CloudG2(0))

'----------------------------
NEWGAME:
Game.Lives% = 2   'Number of extra lives
DQBsetpal Pal 'Reset palette

'Stop looping sounds
PLAYSOUND "STOPWEATHER", 0

'Campaign Select
SELECTCAMPAIGN

'Character Select
SELECTCHAR

'Load character sounds
LOADSOUNDS 0

'----------------------------
NEWLEVEL:
DQBsetpal Pal 'Reset palette

'Music Select
SELECTMUSIC

'Load level and graphics
LOADGFX

'Load invisible water with right color
DQBline TEMPLAYER, 0, 0, 79, 0, FloodCol%
DQBget TEMPLAYER, 0, 0, 79, 0, VARSEG(Water(0)), VARPTR(Water(0))
DQBclearLayer TEMPLAYER

'Load weather sounds
LOADSOUNDS 1

'Reset pills, bubbles, player, points, red wall, etc.
FOR Food = 1 TO 100
FatFood(Food).OY = 3000
NEXT Food
FOR Bub = 1 TO 5
Bubble(Bub).LIFE2 = 0
NEXT Bub
Game.Fires% = 3      'Reset Special Abilities
Player.OX% = 200 '/10
Player.OY% = 99
Player.DIRECTION% = 0
Player.FAT% = 0
Player.OLDFAT% = Player.FAT%
Player.FATTEN% = 0
Player.MSG% = 0
Player.FLY% = 0
Player.SLIDE% = 0
Player.INFLATE% = 0
Player.ROT1% = 0
Player.ROT2% = 0
PHIT% = 0                         'Reset wall to bump into
PPOINTS% = 0                      'Reset game points
Player.SPRINT% = Player.MAXSPRINT%  'Reset player's run time
WAIT.PILL% = 0                    'Reset number of extra pills
WAIT.PILLTIME% = 0   'If > 1000 Frames (25 seconds with 40fps) THEN WAIT.PILL% = WAIT.PILL% + 1
MessageDelay% = 120  'Set message time for Level Name text
Player.PILL$ = ""    'Reset pill effects
Player.PILLTIME% = 0 'Reset pill time

'Clouds (Normal and black)
IF Game.Clouds% > 100 THEN Game.Clouds% = 100
IF Game.Clouds% > 75 AND Game.GFX% = 1 THEN Game.Clouds% = 75
IF Game.Clouds% > 50 AND Game.GFX% = 0 THEN Game.Clouds% = 50
IF DQBloadImage(TEMPLAYER, 0, 0, "DATA\OTHER\OBJ.BMP", Pal, 0, 0) THEN QUIT
IF Game.CloudType% <> 1 THEN DQBget TEMPLAYER, 31, 0, 90, 29, VARSEG(Cloud(0)), VARPTR(Cloud(0))
IF Game.CloudType% = 1 THEN DQBget TEMPLAYER, 31, 31, 90, 59, VARSEG(Cloud(0)), VARPTR(Cloud(0))

'Randomize cloud position
IF Game.Clouds% > 0 THEN
FOR Fog = 1 TO Game.Clouds%
CloudX(Fog) = INT(RND * 3200): CloudY(Fog) = INT(RND * Game.CloudAlt%) - 20
CloudType(Fog) = 0
NEXT Fog
END IF

'Music
IF Game.Music$ <> "" THEN
IF MusicPlaying$ <> Game.Music$ THEN LOADMUSIC 0 'Load new music
IF MusicPlaying$ = Game.Music$ THEN LOADMUSIC 1 'Restart music
END IF
IF Game.Music$ = "" THEN LOADMUSIC 0

'Start looping weather sounds
IF Weather% > 0 AND Weather% < 4 THEN PLAYSOUND "RAIN", 0
IF Weather% = 4 THEN PLAYSOUND "WIND1", 0
IF Weather% = 5 THEN PLAYSOUND "WIND2", 0
IF Weather% = 6 THEN PLAYSOUND "WIND3", 0

'Start looping background sound
IF BGSoundOdd% = 0 THEN PLAYSOUND "BGSOUNDL", 0

'Wind sound, not snowing
IF Weather% < 4 THEN
t% = 0: IF Game.Wind% >= 20 OR Game.Wind% <= -20 THEN PLAYSOUND "WIND3", 0: t% = 1
IF t% = 0 THEN IF Game.Wind% >= 15 OR Game.Wind% <= -15 THEN PLAYSOUND "WIND2", 0: t% = 1
IF t% = 0 THEN IF Game.Wind% >= 10 OR Game.Wind% <= -10 THEN PLAYSOUND "WIND1", 0
END IF

'----------------------------
GAMELOOP:
DQBclearLayer READY
IF Level.GFX3$ <> "" THEN IF DQBloadImage(TEMPLAYER2, 0, 0, "DATA\LEVELS\" + Game.Campaign$ + "\" + Level.GFX3$, Pal, 0, 0) THEN QUIT

'The mouth region of the player
IF Player.DIRECTION% = 0 THEN FATX% = (Player.OX% / 10) + Mouth(INT(Player.FAT% / 100)).X2
IF Player.DIRECTION% = 1 THEN FATX% = (Player.OX% / 10) + Mouth(INT(Player.FAT% / 100)).X
FATY% = Player.OY% + Mouth(INT(Player.FAT% / 100)).Y
FATXP% = Mouth(INT(Player.FAT% / 100)).W
FATYP% = Mouth(INT(Player.FAT% / 100)).H
IF Player.PILL$ = "BOU" OR Player.PILL$ = "GAS" THEN FATX% = -100: FATXP% = 2

'Player bumps the red wall
IF INT(Player.OX% / 10) + Mouth(INT(Player.FAT% / 100)).CHARW - INT(Player.ROT1% / 10) < 0 THEN
IF PHIT% = 0 THEN PLAYSOUND "BUMPWALL2L", 0: Game.AddScore% = Game.AddScore% - 5
IF PHIT% = 1 THEN PLAYSOUND "BUMPWALL1L", 0: Game.AddScore% = Game.AddScore% + 10
IF PHIT% = 1 THEN PPOINTS% = PPOINTS% + 3: PHIT% = 0
Player.OX% = Player.OX% + 200: Player.MOVE% = 0: Player.FRAME% = 0
IF Player.PILL$ = "BOU" THEN Player.MOVE% = 1
END IF
IF INT(Player.OX% / 10) + Mouth(INT(Player.FAT% / 100)).CHARW2 + INT(Player.ROT1% / 10) > 319 THEN
IF PHIT% = 1 THEN PLAYSOUND "BUMPWALL2R", 0: Game.AddScore% = Game.AddScore% - 5
IF PHIT% = 0 THEN PLAYSOUND "BUMPWALL1R", 0: Game.AddScore% = Game.AddScore% + 10
IF PHIT% = 0 THEN PPOINTS% = PPOINTS% + 3: PHIT% = 1
Player.OX% = Player.OX% - 200: Player.MOVE% = 0: Player.FRAME% = 0
IF Player.PILL$ = "BOU" THEN Player.MOVE% = 2
END IF

'Draw background and shelter
IF DQBloadImage(TEMPLAYER, 0, 0, "DATA\LEVELS\" + Game.Campaign$ + "\" + Level.GFX1$, Pal, 0, 0) THEN QUIT
DQBcopyLayer TEMPLAYER, READY
IF BG2.Draw% = 0 THEN DQBcopyTransLayer DESTLAYER, READY
IF BG3.Draw% = 0 AND Level.GFX3$ <> "" THEN DQBcopyTransLayer TEMPLAYER2, READY

'Low GFX detail flood
IF FloodY% < 200 AND Game.GFX% = 0 THEN DQBboxf READY, 0, FloodY%, 319, 199, FloodCol%

'Draw player's shadow
IF Game.Shadow% = 1 THEN
IF Game.GFX% = 1 THEN DQBellipse READY, INT(Player.OX% / 10) + 53, 195, (Mouth(INT(Player.FAT% / 100)).CHARW2 - Mouth(INT(Player.FAT% / 100)).CHARW - (INT(99 - Player.OY%) / 5)) / 2, 4, 8
IF Game.GFX% = 2 THEN
DQBclearLayer TEMPLAYER
DQBellipse TEMPLAYER, INT(Player.OX% / 10) + 53, 195, (Mouth(INT(Player.FAT% / 100)).CHARW2 - Mouth(INT(Player.FAT% / 100)).CHARW - (INT(99 - Player.OY%) / 5)) / 2, 4, 8
DQBpaint TEMPLAYER, INT(Player.OX% / 10) + 53, 195, 8
DQBcopyTransLayer TEMPLAYER, READY
END IF
END IF

'Draw player
t% = 0
IF Player.INFLATE% = 1 THEN t% = Mouth(INT(Player.FAT% / 100)).CHARH
DRAWPLAYER t%
t% = 0

'Get inflated player
IF Player.INFLATE% = 1 THEN
Player.INFLATE% = 2
Player.ROT1% = 0: Player.ROT2% = 0
IF Player.PILL$ = "BOU" THEN DQBget TEMPLAYER2, 0, 0, 105, 98, VARSEG(Bouncy(0)), VARPTR(Bouncy(0))
IF Player.PILL$ = "GAS" THEN DQBget TEMPLAYER2, 0, 0, 175, 175, VARSEG(Bouncy(0)), VARPTR(Bouncy(0))
DQBclearLayer TEMPLAYER2
IF Level.GFX3$ <> "" THEN IF DQBloadImage(TEMPLAYER2, 0, 0, "DATA\LEVELS\" + Game.Campaign$ + "\" + Level.GFX3$, Pal, 0, 0) THEN QUIT
END IF

'Draw inflated player
IF Player.INFLATE% = 2 THEN
IF Player.PILL$ = "GAS" THEN
Player.ROT1% = Player.ROT1% + 1
IF Player.DIRECTION% = 0 THEN Player.ROT2% = Player.ROT2% + INT(RND * 2): IF Player.ROT2% > 255 THEN Player.ROT2% = 0
IF Player.DIRECTION% = 1 THEN Player.ROT2% = Player.ROT2% - INT(RND * 2): IF Player.ROT2% < 0 THEN Player.ROT2% = 255
DQBrPut READY, INT(Player.OX% / 10) - 35, Player.OY% - 39, VARSEG(Bouncy(0)), VARPTR(Bouncy(0)), Player.ROT2%, 100 + INT(Player.ROT1% / 10)
END IF
IF Player.PILL$ = "BOU" THEN
Player.ROT1% = Player.FLY%
DQBsPut READY, INT(Player.OX% / 10) - INT(Player.ROT1% / 2), Player.OY% + INT(Player.ROT1% / 2), VARSEG(Bouncy(0)), VARPTR(Bouncy(0)), 106 + Player.ROT1%, 99 - Player.ROT1%
END IF
END IF

'Player drowns
IF FATY% >= FloodY% AND Player.FAT% < Player.MAXFAT% AND Player.PILL$ <> "BOU" AND Player.PILL$ <> "GAS" THEN
IF Player.SPRINT% > 1 THEN Player.SPRINT% = Player.SPRINT% - INT(RND * 3)
IF Player.SPRINT% = 0 THEN Player.FAT% = Player.FAT% + INT(RND * 11) + 25: Player.SPRINT% = INT(Player.MAXSPRINT%) / 3: PLAYSOUND "DROWN", 0
IF Player.FAT% > Player.MAXFAT% THEN Player.FAT% = Player.MAXFAT%
END IF

'Bubbles
FOR Bub = 1 TO 5
IF Bubble(Bub).LIFE2 > 0 THEN
'Bubble still flying
IF Bubble(Bub).LIFE > 0 THEN
Bubble(Bub).LIFE = Bubble(Bub).LIFE - 1
t% = INT(RND * 4): IF t% = 0 THEN Bubble(Bub).OX = Bubble(Bub).OX + INT(RND * 2) - INT(RND * 2)
t% = 0: Bubble(Bub).OY = Bubble(Bub).OY - INT(RND * 2)
DQBellipse READY, Bubble(Bub).OX, Bubble(Bub).OY, Bubble(Bub).SIZE + INT(RND * 2), Bubble(Bub).SIZE + INT(RND * 2), 1
END IF
'Bubble popped
IF Bubble(Bub).LIFE = 0 THEN
Bubble(Bub).LIFE2 = Bubble(Bub).LIFE2 - 1
IF Bubble(Bub).OY > FloodY% THEN Bubble(Bub).LIFE2 = 0
DQBpset READY, Bubble(Bub).OX + INT(RND * Bubble(Bub).SIZE * 3) - INT(RND * Bubble(Bub).SIZE * 3), Bubble(Bub).OY + INT(RND * Bubble(Bub).SIZE * 3) - INT(RND * Bubble(Bub).SIZE * 3), 1
DQBpset READY, Bubble(Bub).OX + INT(RND * Bubble(Bub).SIZE * 3) - INT(RND * Bubble(Bub).SIZE * 3), Bubble(Bub).OY + INT(RND * Bubble(Bub).SIZE * 3) - INT(RND * Bubble(Bub).SIZE * 3), 1
DQBpset READY, Bubble(Bub).OX + INT(RND * Bubble(Bub).SIZE * 3) - INT(RND * Bubble(Bub).SIZE * 3), Bubble(Bub).OY + INT(RND * Bubble(Bub).SIZE * 3) - INT(RND * Bubble(Bub).SIZE * 3), 1
END IF
END IF
NEXT Bub

'Create bubbles
t% = -1
IF Player.FAT% > 0 THEN t% = INT(RND * (133 - INT(Player.FAT% / INT(Player.MAXFAT% / 100))))
IF Player.PILL$ = "DRU" THEN t% = INT(RND * 60)
IF FATY% >= FloodY% THEN t% = INT(RND * 50): IF Player.SPRINT% < 5 THEN t% = INT(RND * 2)
IF Player.PILL$ = "FAT" THEN t% = INT(RND * 20)
IF t% = 0 THEN
FOR Bub = 1 TO 5
IF t% = 0 THEN
IF Bubble(Bub).LIFE2 = 0 THEN
IF Player.DIRECTION% = 0 THEN Bubble(Bub).OX = FATX% + FATXP%
IF Player.DIRECTION% = 1 THEN Bubble(Bub).OX = FATX%
Bubble(Bub).OY = FATY% + INT(FATYP% / 2) + INT(RND * 3) - INT(RND * 3)
Bubble(Bub).SIZE = 1 + INT(RND * 3)
IF Player.PILL$ = "DRU" THEN Bubble(Bub).SIZE = Bubble(Bub).SIZE + INT(RND * 2)
IF Player.PILL$ = "FAT" THEN Bubble(Bub).SIZE = Bubble(Bub).SIZE + INT(RND * 3)
Bubble(Bub).LIFE = INT(RND * 120)
Bubble(Bub).LIFE2 = 20 + INT(RND * 20)
t% = 1
END IF
END IF
NEXT Bub
END IF
t% = 0

'FatFood (Pills)
PPOINTSF% = PPOINTS% + Game.MinPills% + WAIT.PILL%
IF PPOINTSF% > Game.MaxPills% THEN PPOINTSF% = Game.MaxPills%
IF PPOINTSF% < Game.MinPills% THEN PPOINTSF% = Game.MinPills%
IF PPOINTSF% > 100 THEN PPOINTSF% = 100
'Waiting puts more pills in game
WAIT.PILLTIME% = WAIT.PILLTIME% + 1
IF WAIT.PILLTIME% > 1000 THEN
WAIT.PILLTIME% = 0: IF PPOINTSF% < Game.MaxPills% THEN WAIT.PILL% = WAIT.PILL% + 1
Game.AddScore% = Game.AddScore% - 50
END IF
'Move pills
FOR Food = 1 TO PPOINTSF%
IF FatFood(Food).SPEED = 0 THEN FatFood(Food).OY = 3000
FatFood(Food).OY = FatFood(Food).OY + FatFood(Food).SPEED
IF INT(FatFood(Food).OY / 10) > FloodY% THEN FatFood(Food).SPEED = 2
'Pill hits shelter (Not Indestructible One)
t% = DQBpoint(DESTLAYER, FatFood(Food).OX, INT(FatFood(Food).OY / 10))
IF t% > 0 THEN
DQBpset DESTLAYER, FatFood(Food).OX, INT(FatFood(Food).OY / 10), 0
'Big pill causes bigger hole to shelter
IF FatFood(Food).SIZE = 1 THEN
DQBpset DESTLAYER, FatFood(Food).OX + 1, INT(FatFood(Food).OY / 10), 0
DQBpset DESTLAYER, FatFood(Food).OX - 1, INT(FatFood(Food).OY / 10), 0
DQBpset DESTLAYER, FatFood(Food).OX, INT(FatFood(Food).OY / 10) + 1, 0
END IF
FatFood(Food).OY = 3000
END IF
'Pill hits shelter2 (Indestructible Terrain)
IF Level.GFX3$ <> "" THEN
t% = DQBpoint(TEMPLAYER2, FatFood(Food).OX, INT(FatFood(Food).OY / 10))
IF t% > 0 THEN FatFood(Food).OY = 3000
END IF
'Zig zag pill
IF FatFood(Food).WAY = 1 THEN
FatFood(Food).OX = FatFood(Food).OX - 4 + INT(RND * 9)
IF FatFood(Food).OX > 318 THEN FatFood(Food).OX = 318
IF FatFood(Food).OX < 1 THEN FatFood(Food).OX = 1
END IF
'Slow moving pill
IF FatFood(Food).WAY = 2 THEN FatFood(Food).OY = FatFood(Food).OY - INT(FatFood(Food).SPEED / 1.5)
'Slow moving + Super Zig Zag pill
IF FatFood(Food).WAY = 3 THEN
FatFood(Food).OY = FatFood(Food).OY - INT(FatFood(Food).SPEED / 1.5)
FatFood(Food).OX = FatFood(Food).OX - 6 + INT(RND * 13)
IF FatFood(Food).OX > 318 THEN FatFood(Food).OX = 318
IF FatFood(Food).OX < 1 THEN FatFood(Food).OX = 1
END IF
'Pill hits the ground
IF FatFood(Food).OY > 1970 THEN
'Reset pill back up
FatFood(Food).OY = 0: FatFood(Food).OX = 5 + INT(RND * 310): FatFood(Food).EFFECT = INT(RND * 80): FatFood(Food).SPEED = 5 + INT(RND * 15): FatFood(Food).WAY = INT(RND * 10)
'The chance that an extra life comes is 1/3
IF FatFood(Food).EFFECT = 4 THEN t% = INT(RND * 3): IF t% > 0 THEN FatFood(Food).EFFECT = INT(RND * 80)
'The chance that a bouncy pill comes is 1/2
IF FatFood(Food).EFFECT = 7 THEN t% = INT(RND * 2): IF t% > 0 THEN FatFood(Food).EFFECT = INT(RND * 80)
'Set correct COLOR and SIZE for pills
IF FatFood(Food).EFFECT = 0 THEN FatFood(Food).PCOLOR = 89: FatFood(Food).SIZE = 1   'White       (+5P + Lose Weight)
IF FatFood(Food).EFFECT = 1 THEN FatFood(Food).PCOLOR = 14: FatFood(Food).SIZE = 1   'Yellow      (+5P + Get Special)
IF FatFood(Food).EFFECT = 2 THEN FatFood(Food).PCOLOR = 166: FatFood(Food).SIZE = 1  'Dark Brown  (Drains Run power + Slows Down)
IF FatFood(Food).EFFECT = 3 THEN FatFood(Food).PCOLOR = 165: FatFood(Food).SIZE = 1  'Brown       (Gives Run power + More Speed)
IF FatFood(Food).EFFECT = 4 THEN FatFood(Food).PCOLOR = 253: FatFood(Food).SIZE = 1  'Purple      (Extra life - Rare)
IF FatFood(Food).EFFECT = 5 THEN FatFood(Food).PCOLOR = 254: FatFood(Food).SIZE = 1  'Dark Purple (Fattening, 3 times)
IF FatFood(Food).EFFECT = 6 THEN FatFood(Food).PCOLOR = 0: FatFood(Food).SIZE = 1    'Invisible   (Randomize Fatness)
IF FatFood(Food).EFFECT = 7 THEN FatFood(Food).PCOLOR = 2: FatFood(Food).SIZE = 1    'Big Green   (Bouncy)
IF FatFood(Food).EFFECT = 8 THEN FatFood(Food).PCOLOR = 246: FatFood(Food).SIZE = 1  'Big Black   (Dark Vision)
IF FatFood(Food).EFFECT = 9 THEN FatFood(Food).PCOLOR = INT(RND * 255) + 1: FatFood(Food).SIZE = 1   'Any color (Drug)
IF FatFood(Food).EFFECT > 9 THEN FatFood(Food).PCOLOR = 2: FatFood(Food).SIZE = 0    'Green (Fatten 10-30)
IF FatFood(Food).EFFECT > 30 THEN FatFood(Food).PCOLOR = 9: FatFood(Food).SIZE = 0   'Blue  (Fatten 30-50)
IF FatFood(Food).EFFECT > 50 THEN FatFood(Food).PCOLOR = 176: FatFood(Food).SIZE = 0 'Red   (Fatten 50-70)
IF FatFood(Food).EFFECT > 70 THEN FatFood(Food).PCOLOR = 246: FatFood(Food).SIZE = 0 'Black (Fatten 70-80)
END IF
'Draw pill
IF FatFood(Food).PCOLOR > 0 THEN DQBpset READY, FatFood(Food).OX, INT(FatFood(Food).OY / 10), FatFood(Food).PCOLOR
DRAWCOLOR% = 246
IF FatFood(Food).SIZE = 1 THEN DRAWCOLOR% = FatFood(Food).PCOLOR
IF DRAWCOLOR% > 0 THEN
DQBpset READY, FatFood(Food).OX + 1, INT(FatFood(Food).OY / 10), DRAWCOLOR%
DQBpset READY, FatFood(Food).OX - 1, INT(FatFood(Food).OY / 10), DRAWCOLOR%
DQBpset READY, FatFood(Food).OX, INT(FatFood(Food).OY / 10) + 1, DRAWCOLOR%
DQBpset READY, FatFood(Food).OX, INT(FatFood(Food).OY / 10) - 1, DRAWCOLOR%
END IF
'Draw big pill sides
IF FatFood(Food).SIZE = 1 THEN
DQBpset READY, FatFood(Food).OX + 1, INT(FatFood(Food).OY / 10) + 1, 246
DQBpset READY, FatFood(Food).OX + 1, INT(FatFood(Food).OY / 10) - 1, 246
DQBpset READY, FatFood(Food).OX - 1, INT(FatFood(Food).OY / 10) + 1, 246
DQBpset READY, FatFood(Food).OX - 1, INT(FatFood(Food).OY / 10) - 1, 246
DQBpset READY, FatFood(Food).OX + 2, INT(FatFood(Food).OY / 10), 246
DQBpset READY, FatFood(Food).OX - 2, INT(FatFood(Food).OY / 10), 246
DQBpset READY, FatFood(Food).OX, INT(FatFood(Food).OY / 10) + 2, 246
DQBpset READY, FatFood(Food).OX, INT(FatFood(Food).OY / 10) - 2, 246
END IF
'Pill gets to mouth region
IF Player.FAT% < Player.MAXFAT% THEN
t% = 0
IF FatFood(Food).OX > FATX% AND FatFood(Food).OX < FATX% + FATXP% THEN t% = 1
IF t% = 1 AND FatFood(Food).OY / 10 > FATY% AND FatFood(Food).OY / 10 < FATY% + FATYP% THEN t% = 2
IF t% = 2 THEN
FatFood(Food).OY = 3000
IF FatFood(Food).EFFECT > 9 THEN Player.FATTEN% = Player.FATTEN% + FatFood(Food).EFFECT
IF FatFood(Food).EFFECT > 9 THEN PLAYSOUND "INFLATE", FatFood(Food).EFFECT
IF FatFood(Food).EFFECT > 9 AND Player.FATTEN% >= 50 THEN Message$ = "DIALOG1:": Player.MSG% = 1
IF FatFood(Food).EFFECT = 0 THEN PPOINTS% = PPOINTS% + 5: Player.FATTEN% = Player.FATTEN% - 75 - INT(RND * 75)
IF FatFood(Food).EFFECT = 0 THEN Game.AddScore% = Game.AddScore% + 25
IF FatFood(Food).EFFECT = 0 THEN Message$ = "LOSTWEIGHT:": Player.MSG% = 1: PLAYSOUND "SWALLOW", 0
IF FatFood(Food).EFFECT = 1 THEN PPOINTS% = PPOINTS% + 5: IF Game.Fires% < 3 THEN Game.Fires% = Game.Fires% + 1
IF FatFood(Food).EFFECT = 1 THEN Message$ = "GETSPECIAL:": Player.MSG% = 1
IF FatFood(Food).EFFECT = 1 THEN Game.AddScore% = Game.AddScore% + 25: PLAYSOUND "GETSPECIAL", 0
IF FatFood(Food).EFFECT = 2 THEN Player.PILL$ = "SLO": Player.PILLTIME% = 40 * INT(RND * 6 + 15)
IF FatFood(Food).EFFECT = 2 THEN Message$ = "DIZZY:": Player.MSG% = 1
IF FatFood(Food).EFFECT = 2 THEN Game.AddScore% = Game.AddScore% - 15: PLAYSOUND "POWERB", 0
IF FatFood(Food).EFFECT = 3 THEN Player.PILL$ = "RUN": Player.PILLTIME% = 40 * INT(RND * 6 + 15)
IF FatFood(Food).EFFECT = 3 THEN Message$ = "ENERGETIC:": Player.MSG% = 1
IF FatFood(Food).EFFECT = 3 THEN Game.AddScore% = Game.AddScore% + 50: PLAYSOUND "POWERU", 0
IF FatFood(Food).EFFECT = 4 THEN IF Game.Lives% < 3 THEN Game.Lives% = Game.Lives% + 1
IF FatFood(Food).EFFECT = 4 THEN Message$ = "EXTRALIFE:": Player.MSG% = 1
IF FatFood(Food).EFFECT = 4 THEN Game.AddScore% = Game.AddScore% + 150: PLAYSOUND "EXTRALIFE", 0
IF FatFood(Food).EFFECT = 5 AND Player.PILL$ <> "FAT" THEN Player.PILL$ = "FAT": Player.PILLTIME% = 40 * 10
IF FatFood(Food).EFFECT = 5 THEN Message$ = "MEGAFAT:": Player.MSG% = 1
IF FatFood(Food).EFFECT = 5 THEN Game.AddScore% = Game.AddScore% - 50: PLAYSOUND "MEGAFAT", 0
IF FatFood(Food).EFFECT = 6 THEN Player.PILL$ = "SLO": Player.PILLTIME% = 40 * 5: Player.FAT% = INT(RND * Player.MAXFAT%)
IF FatFood(Food).EFFECT = 6 THEN Message$ = "RANDOMIZEFAT:": Player.MSG% = 1
IF FatFood(Food).EFFECT = 6 THEN Game.AddScore% = Game.AddScore% + 50: PLAYSOUND "RANDOMIZE", 0
IF FatFood(Food).EFFECT = 7 THEN Player.PILL$ = "BOU": Player.PILLTIME% = 40 * INT(RND * 11 + 5): Player.FLY% = 5
IF FatFood(Food).EFFECT = 7 THEN Message$ = "BOUNCY:": Player.MSG% = 1: Player.INFLATE% = 1
IF FatFood(Food).EFFECT = 7 THEN Game.AddScore% = Game.AddScore% + 50: PLAYSOUND "BOUNCY", 0
IF FatFood(Food).EFFECT = 8 THEN Player.PILL$ = "DAR": Player.PILLTIME% = 40 * INT(RND * 6 + 15)
IF FatFood(Food).EFFECT = 8 THEN Message$ = "DARKEN:": Player.MSG% = 1
IF FatFood(Food).EFFECT = 8 THEN Game.AddScore% = Game.AddScore% - 25: PLAYSOUND "POWERB", 0
IF FatFood(Food).EFFECT = 9 THEN Player.PILL$ = "DRU": Player.PILLTIME% = 40 * INT(RND * 6 + 15)
IF FatFood(Food).EFFECT = 9 THEN Message$ = "DRUG:": Player.MSG% = 1
IF FatFood(Food).EFFECT = 9 THEN Game.AddScore% = Game.AddScore% - 25: PLAYSOUND "POWERB", 80
IF Player.PILL$ <> "DRU" AND Player.PILL$ <> "" THEN DQBsetpal Pal
END IF
END IF
NEXT Food

'Load cloud graphics
IF DQBloadImage(TEMPLAYER, 0, 0, "DATA\OTHER\OBJ.BMP", Pal, 0, 0) THEN QUIT

'Move and draw clouds (fog), helium bubbles and fatgas
IF Game.Clouds% > 0 THEN
FOR Fog = 1 TO Game.Clouds%
CloudX(Fog) = CloudX(Fog) + Game.Wind%
'Normal cloud
IF Game.CloudType% > -1 AND CloudType(Fog) = 0 THEN RelSpriteTrans READY, INT(CloudX(Fog) / 10), CloudY(Fog), VARSEG(Cloud(0)), VARPTR(Cloud(0))
'Helium bubble
IF CloudType(Fog) = 1 THEN
IF CursorAnim% < 20 THEN DQBxput TEMPLAYER, 31, 124, 90, 153, READY, INT(CloudX(Fog) / 10), CloudY(Fog)
IF CursorAnim% >= 20 THEN DQBxput TEMPLAYER, 31, 155, 90, 184, READY, INT(CloudX(Fog) / 10), CloudY(Fog)
'Helium bubble Effect
IF Player.PILL$ <> "BOU" AND Player.PILL$ <> "GAS" AND Player.FAT% < Player.MAXFAT% THEN
IF INT(CloudX(Fog) / 10) + 30 > INT(Player.OX% / 10) + Mouth(INT(Player.FAT% / 100)).CHARW AND INT(CloudX(Fog) / 10) + 30 < INT(Player.OX% / 10) + Mouth(INT(Player.FAT / 100)).CHARW2 THEN
IF CloudY(Fog) + 15 > Player.OY% + Mouth(INT(Player.FAT% / 100)).CHARH AND CloudY(Fog) + 15 < 198 - (99 - Player.OY%) THEN
IF Game.Wind% < 0 AND Player.DIRECTION% = 1 THEN CloudX(Fog) = 3400
IF Game.Wind% < 0 AND Player.DIRECTION% = 0 THEN CloudX(Fog) = 3400: Player.PILL$ = "GAS": Player.PILLTIME% = 40 * INT(RND * 6 + 5): Player.FLY% = Player.FLY% + 5: Player.INFLATE% = 1: PLAYSOUND "INFLATE", 80: Game.AddScore% = Game.AddScore% - 25: _
                                                                                              Message$ = "HELIUM:": Player.MSG% = 1
IF Game.Wind% > 0 AND Player.DIRECTION% = 0 THEN CloudX(Fog) = 3400
IF Game.Wind% > 0 AND Player.DIRECTION% = 1 THEN CloudX(Fog) = 3400: Player.PILL$ = "GAS": Player.PILLTIME% = 40 * INT(RND * 6 + 5): Player.FLY% = Player.FLY% + 5: Player.INFLATE% = 1: PLAYSOUND "INFLATE", 80: Game.AddScore% = Game.AddScore% - 25: _
                                                                                              Message$ = "HELIUM:": Player.MSG% = 1
END IF
END IF
END IF
END IF
'Fat Gas
IF CloudType(Fog) = 2 THEN
IF CursorAnim% < 20 THEN RelSpriteTrans READY, INT(CloudX(Fog) / 10), CloudY(Fog), VARSEG(CloudG1(0)), VARPTR(CloudG1(0))
IF CursorAnim% >= 20 THEN RelSpriteTrans READY, INT(CloudX(Fog) / 10), CloudY(Fog), VARSEG(CloudG2(0)), VARPTR(CloudG2(0))
'Fat Gas Effect
IF Player.PILL$ <> "BOU" AND Player.PILL$ <> "GAS" AND Player.FAT% < Player.MAXFAT% THEN
IF INT(CloudX(Fog) / 10) + 30 > INT(Player.OX% / 10) + Mouth(INT(Player.FAT% / 100)).CHARW AND INT(CloudX(Fog) / 10) + 30 < INT(Player.OX% / 10) + Mouth(INT(Player.FAT / 100)).CHARW2 THEN
IF CloudY(Fog) + 15 > Player.OY% + Mouth(INT(Player.FAT% / 100)).CHARH AND CloudY(Fog) + 15 < 198 - (99 - Player.OY%) THEN
IF Game.Wind% < 0 AND Player.DIRECTION% = 0 THEN Player.FATTEN% = Player.FATTEN% + INT(RND * 3): PLAYSOUND "INFLATEGAS", 0
IF Game.Wind% > 0 AND Player.DIRECTION% = 1 THEN Player.FATTEN% = Player.FATTEN% + INT(RND * 3): PLAYSOUND "INFLATEGAS", 0
IF Player.FATTEN% > 100 THEN Player.FATTEN% = 100
END IF
END IF
END IF
END IF
'Air Plane
IF CloudType(Fog) = 3 THEN
IF Game.Wind% < 0 THEN
IF CursorAnim% < 20 THEN DQBxput TEMPLAYER, 92, 62, 133, 91, READY, INT(CloudX(Fog) / 10), CloudY(Fog)
IF CursorAnim% >= 20 THEN DQBxput TEMPLAYER, 92, 93, 133, 122, READY, INT(CloudX(Fog) / 10), CloudY(Fog)
END IF
IF Game.Wind% > 0 THEN
IF CursorAnim% < 20 THEN DQBxput TEMPLAYER, 92, 124, 133, 153, READY, INT(CloudX(Fog) / 10), CloudY(Fog)
IF CursorAnim% >= 20 THEN DQBxput TEMPLAYER, 92, 155, 133, 184, READY, INT(CloudX(Fog) / 10), CloudY(Fog)
END IF
'Air Plane Effect
IF Player.PILL$ <> "BOU" AND Player.PILL$ <> "GAS" AND Player.FAT% < Player.MAXFAT% THEN
IF INT(CloudX(Fog) / 10) + 30 > INT(Player.OX% / 10) + Mouth(INT(Player.FAT% / 100)).CHARW AND INT(CloudX(Fog) / 10) + 30 < INT(Player.OX% / 10) + Mouth(INT(Player.FAT / 100)).CHARW2 THEN
IF CloudY(Fog) + 15 > Player.OY% + Mouth(INT(Player.FAT% / 100)).CHARH AND CloudY(Fog) + 15 < 198 - (99 - Player.OY%) THEN
IF Game.Wind% < 0 AND Player.DIRECTION% = 1 THEN CloudX(Fog) = 3400: PLAYSOUND "HIT", 0
IF Game.Wind% < 0 AND Player.DIRECTION% = 0 THEN CloudX(Fog) = 3400: Player.OX% = Player.OX% - 100: PLAYSOUND "HIT", 0: Message$ = "PLANE:": Player.MSG% = 1
IF Game.Wind% > 0 AND Player.DIRECTION% = 0 THEN CloudX(Fog) = 3400: PLAYSOUND "HIT", 0
IF Game.Wind% > 0 AND Player.DIRECTION% = 1 THEN CloudX(Fog) = 3400: Player.OX% = Player.OX% + 100: PLAYSOUND "HIT", 0: Message$ = "PLANE:": Player.MSG% = 1
END IF
END IF
END IF
END IF
'Cloud goes out of side boundaries
IF CloudX(Fog) > 3200 AND Game.Wind% > 0 OR CloudX(Fog) < -500 AND Game.Wind% < 0 THEN
CloudType(Fog) = 0
IF HeliumOdd% > -1 THEN t% = INT(RND * HeliumOdd%): IF t% = 0 THEN CloudType(Fog) = 1
IF FatgasOdd% > -1 THEN t% = INT(RND * FatgasOdd%): IF t% = 0 THEN CloudType(Fog) = 2
IF PlaneOdd% > -1 THEN t% = INT(RND * PlaneOdd%): IF t% = 0 THEN CloudType(Fog) = 3
IF Game.Wind% > 0 THEN CloudX(Fog) = -600 - INT(RND * 200)
IF Game.Wind% < 0 THEN CloudX(Fog) = 3200 + INT(RND * 200)
CloudY(Fog) = INT(RND * Game.CloudAlt%) - 20
IF CloudType(Fog) > 0 THEN CloudY(Fog) = INT(RND * 180)
IF CloudType(Fog) = 3 THEN CloudY(Fog) = 100 + INT(RND * 60)
END IF
NEXT Fog
END IF

'Draw backgrounds in front of character
IF BG2.Draw% = 1 THEN DQBcopyTransLayer DESTLAYER, READY
IF BG3.Draw% = 1 AND Level.GFX3$ <> "" THEN DQBcopyTransLayer TEMPLAYER2, READY
IF Level.GFX4$ <> "" THEN
IF DQBloadImage(TEMPLAYER, 0, 0, "DATA\LEVELS\" + Game.Campaign$ + "\" + Level.GFX4$, Pal, 0, 0) THEN QUIT
DQBcopyTransLayer TEMPLAYER, READY
END IF

'Add weather + flood
WEATHERSUB

'Flooding
IF FloodAmount% > 0 THEN
FloodAmount% = FloodAmount% + 1
IF Weather% = 1 THEN FloodAmount% = FloodAmount% + INT(RND * 2)
IF Weather% = 2 THEN FloodAmount% = FloodAmount% + INT(RND * 3)
IF Weather% = 3 THEN FloodAmount% = FloodAmount% + INT(RND * 4)
IF Weather% = 5 THEN FloodAmount% = FloodAmount% + INT(RND * 2)
IF Weather% = 6 THEN FloodAmount% = FloodAmount% + INT(RND * 3)
FloodY% = 200 - INT(FloodAmount% / 100)
END IF
IF FloodY% < 0 THEN FloodY% = 0
'Draw flood (medium & high GFX)
IF FloodY% < 200 AND Game.GFX% > 0 THEN
FOR t% = FloodY% TO 199
RelSpriteTrans READY, 0, t%, VARSEG(Water(0)), VARPTR(Water(0))
RelSpriteTrans READY, 80, t%, VARSEG(Water(0)), VARPTR(Water(0))
RelSpriteTrans READY, 160, t%, VARSEG(Water(0)), VARPTR(Water(0))
RelSpriteTrans READY, 240, t%, VARSEG(Water(0)), VARPTR(Water(0))
NEXT t%
END IF

'Show Goal (Red wall)
IF PHIT% = 0 THEN DQBline READY, 319, 0, 319, 199, 4
IF PHIT% = 1 THEN DQBline READY, 0, 0, 0, 199, 4

'Continue to game2 sub (PART 1)
GAME2 0

'Show Mouth and Number of Pills - DEBUG! (Q, 16)
IF DQBkey(16) THEN
IF FATX% > 0 THEN DQBbox READY, FATX%, FATY%, FATX% + FATXP%, FATY% + FATYP%, INT(RND * 255) + 1
DQBbox READY, INT(Player.OX% / 10) + Mouth(INT(Player.FAT% / 100)).CHARW, Player.OY% + Mouth(INT(Player.FAT% / 100)).CHARH, INT(Player.OX% / 10) + Mouth(INT(Player.FAT% / 100)).CHARW2, 198 - (99 - Player.OY%), INT(RND * 255) + 1
JPRINT READY, "Pills:" + STR$(PPOINTSF%) + " /" + STR$(Game.MaxPills%), 10, 50, 4
JPRINT READY, "In 1000 One More Pill:" + STR$(WAIT.PILLTIME%), 10, 60, 4
IF Player.PILLTIME% <> 0 THEN JPRINT READY, "Special Pill Effect: " + Player.PILL$, 10, 70, 4
IF Player.PILLTIME% = 0 THEN JPRINT READY, "Special Pill Effect: None", 10, 70, 4
JPRINT READY, "Special Pill Effect Left:" + STR$(Player.PILLTIME%), 10, 80, 4
END IF

'Restart time
IF Game.Lives% > 0 AND Player.FAT% = Player.MAXFAT% THEN
JPRINT READY, "ENTER=Restart, ESC=Quit, F1=Help", 35, 90, 4
IF DQBkey(KEYENTER) THEN Game.Lives% = Game.Lives% - 1: DO: LOOP UNTIL DQBkey(KEYENTER) = FALSE: GOTO NEWLEVEL
END IF

'Play background sound
IF BGSoundOdd% > 0 THEN t% = INT(RND * BGSoundOdd%): IF t% = 0 THEN PLAYSOUND "BGSOUND", 0

PLAYSOUNDS ""              'Play sounds from soundbuffer
DQBcopyLayer READY, VIDEO  'No drawing to READY below this
WAITFRAME                  'Wait frames (Slow down game)

'Player's Controls
IF Player.OY% = 99 OR Player.MIDAIR% = 1 AND Player.PILL$ <> "GAS" OR FATY% + 20 > FloodY% OR Player.PILL$ = "BOU" THEN
IF Player.PILL$ <> "BOU" AND Player.PILL$ <> "GAS" THEN Player.MOVE% = 0
IF Player.PILL$ <> "DRU" THEN
IF NoMouse% = 0 THEN
IF (Player.OX% / 10) + 49 > DQBmouseX THEN Player.MOVE% = 2
IF (Player.OX% / 10) + 57 < DQBmouseX THEN Player.MOVE% = 1
END IF
IF DQBkey(KEYLEFT) AND DQBkey(KEYRIGHT) = FALSE THEN Player.MOVE% = 2
IF DQBkey(KEYRIGHT) AND DQBkey(KEYLEFT) = FALSE THEN Player.MOVE% = 1
END IF
IF Player.PILL$ = "DRU" THEN
IF NoMouse% = 0 THEN
IF (Player.OX% / 10) + 49 > DQBmouseX THEN Player.MOVE% = 1
IF (Player.OX% / 10) + 57 < DQBmouseX THEN Player.MOVE% = 2
END IF
IF DQBkey(KEYLEFT) AND DQBkey(KEYRIGHT) = FALSE THEN Player.MOVE% = 1
IF DQBkey(KEYRIGHT) AND DQBkey(KEYLEFT) = FALSE THEN Player.MOVE% = 2
END IF
END IF
'Jump (Up Arrow + Mouse Right Button)
IF Player.OY% = 99 AND Mouth(INT(Player.FAT% / 100)).JPOWER > 0 AND Player.SPRINT% > 15 THEN
IF NoMouse% = 0 AND DQBkey(KEYUP) = FALSE THEN IF DQBmouseRB = TRUE THEN Player.FLY% = Player.FLY% - Mouth(INT(Player.FAT% / 100)).JPOWER: Player.SPRINT% = Player.SPRINT% - 15
IF DQBkey(KEYUP) THEN Player.FLY% = Player.FLY% - Mouth(INT(Player.FAT% / 100)).JPOWER: Player.SPRINT% = Player.SPRINT% - 15
END IF
'Swim up (Up Arrow + Mouse Right Button)
IF Player.OY% < 99 AND Mouth(INT(Player.FAT% / 100)).JPOWER > 0 AND Player.SPRINT% > 1 AND FATY% + 20 > FloodY% THEN
IF NoMouse% = 0 AND DQBkey(KEYUP) = FALSE THEN IF DQBmouseRB = TRUE THEN Player.FLY% = Player.FLY% - 3: Player.SPRINT% = Player.SPRINT% - 1
IF DQBkey(KEYUP) THEN Player.FLY% = Player.FLY% - 3: Player.SPRINT% = Player.SPRINT% - 1
END IF

'Reset player frame if he doesn't move
IF Player.MOVE% = 0 THEN Player.LIIKS% = 0: Player.FRAME% = 0

'Running (CTRL, 29 + Mouse Left Button)
SPRINT% = 0
IF NoMouse% = 0 AND DQBmouseLB = TRUE AND Player.SPRINT% > 0 AND Player.FAT% < Player.MAXFAT% AND Player.PILL$ <> "GAS" THEN SPRINT% = 1
IF DQBkey(29) AND Player.SPRINT% > 0 AND Player.FAT% < Player.MAXFAT% AND Player.PILL$ <> "GAS" THEN SPRINT% = 1
IF SPRINT% = 1 THEN Player.SPRINT% = Player.SPRINT% - 1
IF SPRINT% = 0 AND Player.SPRINT% < Player.MAXSPRINT% THEN Player.SPRINT% = Player.SPRINT% + INT(RND * 2)

'Move left (LEFT ARROW)
IF Player.MOVE% = 2 AND Player.FAT% < Player.MAXFAT% THEN
'Normal & slippery terrain
IF Terrain% < 2 THEN
IF SPRINT% = 0 THEN Player.OX% = Player.OX% - Mouth(INT(Player.FAT% / 100)).SPEED: Player.DIRECTION% = 1: Player.LIIKS% = Player.LIIKS% + 1
IF SPRINT% = 1 THEN Player.OX% = Player.OX% - Mouth(INT(Player.FAT% / 100)).SPEED2: Player.DIRECTION% = 1: Player.LIIKS% = Player.LIIKS% + 2
END IF
'Sticky terrain
IF Terrain% = 2 THEN
IF Player.OY% > 96 THEN
IF SPRINT% = 0 THEN Player.OX% = Player.OX% - INT((Mouth(INT(Player.FAT% / 100)).SPEED) / 2): Player.DIRECTION% = 1: Player.LIIKS% = Player.LIIKS% + 1
IF SPRINT% = 1 THEN Player.OX% = Player.OX% - INT((Mouth(INT(Player.FAT% / 100)).SPEED2) / 2): Player.DIRECTION% = 1: Player.LIIKS% = Player.LIIKS% + 2
END IF
IF Player.OY% <= 96 THEN
IF SPRINT% = 0 THEN Player.OX% = Player.OX% - Mouth(INT(Player.FAT% / 100)).SPEED: Player.DIRECTION% = 1: Player.LIIKS% = Player.LIIKS% + 1
IF SPRINT% = 1 THEN Player.OX% = Player.OX% - Mouth(INT(Player.FAT% / 100)).SPEED2: Player.DIRECTION% = 1: Player.LIIKS% = Player.LIIKS% + 2
END IF
END IF
END IF

'Move right (RIGHT ARROW)
IF Player.MOVE% = 1 AND Player.FAT% < Player.MAXFAT% THEN
'Normal & slippery terrain
IF Terrain% < 2 THEN
IF SPRINT% = 0 THEN Player.OX% = Player.OX% + Mouth(INT(Player.FAT% / 100)).SPEED: Player.DIRECTION% = 0: Player.LIIKS% = Player.LIIKS% + 1
IF SPRINT% = 1 THEN Player.OX% = Player.OX% + Mouth(INT(Player.FAT% / 100)).SPEED2: Player.DIRECTION% = 0: Player.LIIKS% = Player.LIIKS% + 2
END IF
'Sticky terrain
IF Terrain% = 2 THEN
IF Player.OY% > 96 THEN
IF SPRINT% = 0 THEN Player.OX% = Player.OX% + INT((Mouth(INT(Player.FAT% / 100)).SPEED) / 2): Player.DIRECTION% = 0: Player.LIIKS% = Player.LIIKS% + 1
IF SPRINT% = 1 THEN Player.OX% = Player.OX% + INT((Mouth(INT(Player.FAT% / 100)).SPEED2) / 2): Player.DIRECTION% = 0: Player.LIIKS% = Player.LIIKS% + 2
END IF
IF Player.OY% <= 96 THEN
IF SPRINT% = 0 THEN Player.OX% = Player.OX% + Mouth(INT(Player.FAT% / 100)).SPEED: Player.DIRECTION% = 0: Player.LIIKS% = Player.LIIKS% + 1
IF SPRINT% = 1 THEN Player.OX% = Player.OX% + Mouth(INT(Player.FAT% / 100)).SPEED2: Player.DIRECTION% = 0: Player.LIIKS% = Player.LIIKS% + 2
END IF
END IF
END IF

'Immobile trying to move
IF Player.MOVE% > 0 AND Player.FAT% = Player.MAXFAT% AND FATY% < FloodY% THEN Player.LIIKS% = Player.LIIKS% + 1

'Player moving frames
IF Player.LIIKS% > 10 THEN Player.FRAME% = Player.FRAME% + 1: Player.LIIKS% = 0
IF Player.FRAME% > 3 THEN Player.FRAME% = 0

'Weight gain and lost sounds
IF INT(Player.FAT% / 100) > INT(Player.OLDFAT% / 100) AND FATY% < FloodY% THEN PLAYSOUND "BELCH", INT(Player.FAT% / Player.MAXFAT%) * 10
IF INT(Player.FAT% / 100) < INT(Player.OLDFAT% / 100) THEN PLAYSOUND "LOSEWEIGHT", 0
Player.OLDFAT% = Player.FAT%

'Slippery terrain
IF Terrain% = 1 AND Player.OY% < 99 AND Player.MOVE% = 1 AND Player.SLIDE% < 0 THEN Player.SLIDE% = 0
IF Terrain% = 1 AND Player.OY% < 99 AND Player.MOVE% = 2 AND Player.SLIDE% > 0 THEN Player.SLIDE% = 0
IF Terrain% = 1 AND Player.FAT% < Player.MAXFAT% AND Player.OY% = 99 THEN
IF Player.MOVE% = 0 THEN
IF Player.SLIDE% > 0 THEN Player.SLIDE% = Player.SLIDE% - 1: Player.OX% = Player.OX% + Mouth(INT(Player.FAT% / 100)).SPEED
IF Player.SLIDE% < 0 THEN Player.SLIDE% = Player.SLIDE% + 1: Player.OX% = Player.OX% - Mouth(INT(Player.FAT% / 100)).SPEED
END IF
IF Player.MOVE% = 1 THEN
IF SPRINT% = 0 THEN Player.SLIDE% = Player.SLIDE% + 1: IF Player.SLIDE% < 0 THEN Player.OX% = Player.OX% - Mouth(INT(Player.FAT% / 100)).SPEED * 2
IF SPRINT% = 1 THEN Player.SLIDE% = Player.SLIDE% + 2: IF Player.SLIDE% < 0 THEN Player.OX% = Player.OX% - Mouth(INT(Player.FAT% / 100)).SPEED2 - Mouth(INT(Player.FAT% / 100)).SPEED
IF Player.SLIDE% > 2 * (Mouth(INT(Player.FAT% / 100)).SPEED) THEN Player.SLIDE% = 2 * (Mouth(INT(Player.FAT% / 100)).SPEED)
END IF
IF Player.MOVE% = 2 THEN
IF SPRINT% = 0 THEN Player.SLIDE% = Player.SLIDE% - 1: IF Player.SLIDE% > 0 THEN Player.OX% = Player.OX% + Mouth(INT(Player.FAT% / 100)).SPEED * 2
IF SPRINT% = 1 THEN Player.SLIDE% = Player.SLIDE% - 2: IF Player.SLIDE% > 0 THEN Player.OX% = Player.OX% + Mouth(INT(Player.FAT% / 100)).SPEED2 + Mouth(INT(Player.FAT% / 100)).SPEED
IF Player.SLIDE% < -2 * (Mouth(INT(Player.FAT% / 100)).SPEED) THEN Player.SLIDE% = -2 * (Mouth(INT(Player.FAT% / 100)).SPEED)
END IF
END IF

'Gravity
IF Player.FLY% > 100 THEN Player.FLY% = 100
IF Player.FLY% < -100 THEN Player.FLY% = -100
IF 198 - (99 - Player.OY%) = FloodY% AND Player.FLY% > 0 THEN PLAYSOUND "FALLTOWATER", 0
IF 198 - (99 - Player.OY%) > FloodY% AND Player.FLY% > 10 THEN PLAYSOUND "FALLTOWATER", 0
IF FATY% + 20 > FloodY% AND Player.FLY% < -10 THEN Player.FLY% = -10
Player.OY% = Player.OY% + INT(Player.FLY% / 5)
Player.FLY% = Player.FLY% + 1: IF 198 - (99 - Player.OY%) > FloodY% AND Player.FLY% > 10 THEN Player.FLY% = 10
IF Player.OY% = 99 AND Player.PILL$ <> "BOU" THEN Player.FLY% = 0
IF Player.OY% > 99 AND Player.PILL$ <> "BOU" THEN Player.OY% = 99: Player.FLY% = 0: IF FloodY% > 195 THEN PLAYSOUND "HIT", 0
IF Player.OY% + Mouth(INT(Player.FAT% / 100)).CHARH - INT(Player.ROT1% / 10) < Game.CeilingAlt% THEN Player.OY% = Game.CeilingAlt% - Mouth(INT(Player.FAT% / 100)).CHARH + 5 + INT(RND * 6) + INT(Player.ROT1% / 10): Player.FLY% = 5 + INT(RND * 6): _
                                               Player.MOVE% = INT(RND * 3): IF FloodY% > 50 THEN PLAYSOUND "HIT", 0
IF Player.OY% + Mouth(INT(Player.FAT% / 100)).CHARH - INT(Player.ROT1% / 10) < 0 THEN Player.OY% = -Mouth(INT(Player.FAT% / 100)).CHARH + INT(Player.ROT1% / 10)

'Continue to game2 sub (PART 2)
GAME2 1

'The completion of level (Stop raining, next level after all fallen down)
IF PPOINTS% >= Game.MaxPoints% THEN
DQBsetpal Pal 'Reset palette
JPRINT VIDEO, "Completed Level" + STR$(Game.Level%) + "!", 80, 80, 7
Game.Level% = Game.Level% + 1: Game.Score% = Game.Score% + Game.AddScore%
JPRINT VIDEO, "Current Score:" + STR$(Game.Score%), 80, 120, 6
DQBwait 100
IF Game.Level% <= Game.Levels% THEN GOTO NEWLEVEL
END IF
'The completion of campaign
IF Game.Level% > Game.Levels% THEN
DQBclearLayer READY
t% = INT(RND * 7)
IF t% = 0 THEN IF DQBloadImage(READY, 0, 0, "DATA\OTHER\BG01.PCX", Pal, 0, 0) THEN QUIT
IF t% = 1 THEN IF DQBloadImage(READY, 0, 0, "DATA\OTHER\BG02.PCX", Pal, 0, 0) THEN QUIT
IF t% = 2 THEN IF DQBloadImage(READY, 0, 0, "DATA\OTHER\BG03.PCX", Pal, 0, 0) THEN QUIT
IF t% = 3 THEN IF DQBloadImage(READY, 0, 0, "DATA\OTHER\BG04.PCX", Pal, 0, 0) THEN QUIT
IF t% = 4 THEN IF DQBloadImage(READY, 0, 0, "DATA\OTHER\BG05.PCX", Pal, 0, 0) THEN QUIT
IF t% = 5 THEN IF DQBloadImage(READY, 0, 0, "DATA\OTHER\BG06.PCX", Pal, 0, 0) THEN QUIT
IF t% = 6 THEN IF DQBloadImage(READY, 0, 0, "DATA\OTHER\BG07.PCX", Pal, 0, 0) THEN QUIT
t% = 0
DQBcopyTransLayer READY, VIDEO
JPRINT VIDEO, "End Of Campaign!", 80, 80, 6
DQBwait 100
JPRINT VIDEO, "Score:" + STR$(Game.Score%), 20, 100, 6
DQBwait 100

'Select score message
IF Game.Score% > 0 THEN
IF (Game.Score% / 1000) > 0 THEN JScore$ = "SCORE1:"
IF (Game.Score% / 1000) > .6 * Game.Levels% THEN JScore$ = "SCORE2:"
IF (Game.Score% / 1000) > .7 * Game.Levels% THEN JScore$ = "SCORE3:"
IF (Game.Score% / 1000) > .8 * Game.Levels% THEN JScore$ = "SCORE4:"
IF (Game.Score% / 1000) > .9 * Game.Levels% THEN JScore$ = "SCORE5:"
IF (Game.Score% / 1000) > 1 * Game.Levels% THEN JScore$ = "SCORE6:"
IF (Game.Score% / 1000) > 1.05 * Game.Levels% THEN JScore$ = "SCORE7:"
IF (Game.Score% / 1000) > 1.1 * Game.Levels% THEN JScore$ = "SCORE8:"
IF (Game.Score% / 1000) > 1.15 * Game.Levels% THEN JScore$ = "SCORE9:"
IF (Game.Score% / 1000) > 1.2 * Game.Levels% THEN JScore$ = "SCORE10:"

'Get score message
OPEN "DATA\CHARS\" + CharacterDir$ + "\DIALOG.DAT" FOR INPUT AS #1
IF LOF(1) THEN
DO
INPUT #1, JTEMP$
LOOP UNTIL JTEMP$ = JScore$: JScore$ = ""
INPUT #1, JTEMP$
IF JTEMP$ <> "" THEN JPRINT VIDEO, JTEMP$, 20, 120, 6
INPUT #1, JTEMP$
IF JTEMP$ <> "" THEN PLAYSOUNDS JTEMP$
ELSE JError$ = "DATA\CHARS" + CharacterDir$ + "DIALOG.DAT not found!": QUIT
END IF
CLOSE #1
END IF

IF Game.Score% > 0 THEN DQBwait 250
GOTO NEWGAME
END IF

'Special Ability (SPACE)
IF DQBkey(KEYSPACE) AND Game.Fires% > 0 AND Player.FAT% < Player.MAXFAT% THEN Fire% = 1
IF DQBkey(KEYSPACE) = FALSE AND Fire% = 1 THEN

PLAYSOUND "USESPECIAL", 0
Message$ = "USESPECIAL:": Player.MSG% = 1
Fire% = 0: Game.Fires% = Game.Fires% - 1
'Fire Breath (Ability 0)
IF Player.ABILITY% = 0 THEN
DQBboxf VIDEO, 0, 0, 319, 199, 14
DQBwait 10
'Reset pills
FOR Food = 1 TO 100
FatFood(Food).OY = -INT(RND * 2000): FatFood(Food).OX = 5 + INT(RND * 310): FatFood(Food).EFFECT = INT(RND * 80): FatFood(Food).SPEED = 5 + INT(RND * 15): FatFood(Food).WAY = INT(RND * 10)
'The chance that an extra life comes is 1/3
IF FatFood(Food).EFFECT = 4 THEN t% = INT(RND * 3): IF t% > 0 THEN FatFood(Food).EFFECT = INT(RND * 80)
'The chance that a bouncy pill comes is 1/2
IF FatFood(Food).EFFECT = 7 THEN t% = INT(RND * 2): IF t% > 0 THEN FatFood(Food).EFFECT = INT(RND * 80)
'Set correct COLOR and SIZE for pills
IF FatFood(Food).EFFECT = 0 THEN FatFood(Food).PCOLOR = 89: FatFood(Food).SIZE = 1   'White       (+5P + Lose Weight)
IF FatFood(Food).EFFECT = 1 THEN FatFood(Food).PCOLOR = 14: FatFood(Food).SIZE = 1   'Yellow      (+5P + Get Special)
IF FatFood(Food).EFFECT = 2 THEN FatFood(Food).PCOLOR = 166: FatFood(Food).SIZE = 1  'Dark Brown  (Drains Run power + Slows Down)
IF FatFood(Food).EFFECT = 3 THEN FatFood(Food).PCOLOR = 165: FatFood(Food).SIZE = 1  'Brown       (Gives Run power + More Speed)
IF FatFood(Food).EFFECT = 4 THEN FatFood(Food).PCOLOR = 253: FatFood(Food).SIZE = 1  'Purple      (Extra life - Rare)
IF FatFood(Food).EFFECT = 5 THEN FatFood(Food).PCOLOR = 254: FatFood(Food).SIZE = 1  'Dark Purple (Fattening, 3 times)
IF FatFood(Food).EFFECT = 6 THEN FatFood(Food).PCOLOR = 0: FatFood(Food).SIZE = 1    'Invisible   (Randomize Fatness)
IF FatFood(Food).EFFECT = 7 THEN FatFood(Food).PCOLOR = 2: FatFood(Food).SIZE = 1    'Big Green   (Bouncy)
IF FatFood(Food).EFFECT = 8 THEN FatFood(Food).PCOLOR = 246: FatFood(Food).SIZE = 1  'Big Black   (Dark Vision)
IF FatFood(Food).EFFECT = 9 THEN FatFood(Food).PCOLOR = INT(RND * 255) + 1: FatFood(Food).SIZE = 1   'Any color (Drug)
IF FatFood(Food).EFFECT > 9 THEN FatFood(Food).PCOLOR = 2: FatFood(Food).SIZE = 0    'Green (Fatten 10-30)
IF FatFood(Food).EFFECT > 30 THEN FatFood(Food).PCOLOR = 9: FatFood(Food).SIZE = 0   'Blue  (Fatten 30-50)
IF FatFood(Food).EFFECT > 50 THEN FatFood(Food).PCOLOR = 176: FatFood(Food).SIZE = 0 'Red   (Fatten 50-70)
IF FatFood(Food).EFFECT > 70 THEN FatFood(Food).PCOLOR = 246: FatFood(Food).SIZE = 0 'Black (Fatten 70-80)
NEXT Food
'Destroy helium bubbles
IF Game.Clouds% > 0 THEN
FOR Fog = 1 TO Game.Clouds%
IF CloudType(Fog) = 1 THEN CloudX(Fog) = 3400
NEXT Fog
END IF
END IF
'Energy + Lose Effect (Ability 1)
IF Player.ABILITY% = 1 THEN
DQBboxf VIDEO, 0, 0, 319, 199, 15
DQBwait 10
Player.PILL$ = "RUN": Player.PILLTIME% = 40 * 15: Player.INFLATE% = 0: DQBsetpal Pal
END IF
'Instant Bounce (Ability 2)
IF Player.ABILITY% = 2 THEN
DQBboxf VIDEO, 0, 0, 319, 199, 4
DQBwait 10
Player.PILL$ = "BOU": Player.PILLTIME% = 40 * 4: Player.FLY% = 5: Player.INFLATE% = 1
END IF

END IF

'Pause (P, 25)
IF DQBkey(25) THEN DQBsetpal Pal: PAUSE% = 1
IF PAUSE% = 1 THEN
DQBclearLayer VIDEO: DQBprint VIDEO, "Paused. Press ENTER to continue.", 25, 90, 7
DQBprint VIDEO, "Current Score:" + STR$(Game.Score%), 25, 110, 7
DQBprint VIDEO, "Score To Add:" + STR$(Game.AddScore%), 25, 120, 7
DO: LOOP UNTIL DQBkey(KEYENTER)
DO: LOOP UNTIL DQBkey(KEYENTER) = FALSE
PAUSE% = 0
END IF

'Skip Level (L, 28)
IF DQBkey(38) AND Player.FAT% < Player.MAXFAT% THEN
DQBsetpal Pal 'Reset palette
Game.Level% = Game.Level% + 1
JPRINT VIDEO, "Skipped Level! No Score!", 60, 80, 7
DQBwait 80
IF Game.Level% <= Game.Levels% THEN GOTO NEWLEVEL
END IF

'Change music (M, 50)
IF DQBkey(50) AND MusicToUse% > 0 THEN MusicToUse% = 1: DQBsetpal Pal: SELECTMUSIC

'Help (F1, 59)
IF DQBkey(59) THEN DQBsetpal Pal: HELP

'Low Graphic Level (F2, 60)
IF DQBkey(60) THEN Game.GFX% = 0: Message$ = "Low GFX Level": MessageDelay% = 50
'Medium Graphic Level (F3, 61)
IF DQBkey(61) THEN Game.GFX% = 1: Message$ = "Medium GFX Level": MessageDelay% = 50
'High Graphic Level (F4, 62)
IF DQBkey(62) THEN Game.GFX% = 2: Message$ = "High GFX Level": MessageDelay% = 50
'Enable/Disable Fatigue Sounds (F5, 63)
IF DQBkey(63) AND Game.HearFatigue% = 0 THEN Game.HearFatigue% = 1: DO: LOOP UNTIL DQBkey(63) = FALSE: Message$ = "Fatigue Sound Enabled": MessageDelay% = 50
IF DQBkey(63) AND Game.HearFatigue% = 1 THEN Game.HearFatigue% = 0: DO: LOOP UNTIL DQBkey(63) = FALSE: Message$ = "Fatigue Sound Disabled": MessageDelay% = 50

'Increase/Decrease Frames to Wait (F7, 65 - F8, 66)
IF DQBkey(65) AND Game.WAIT! >= 5000 THEN Game.WAIT! = Game.WAIT! - 5000: DO: LOOP UNTIL DQBkey(65) = FALSE: Message$ = "Wait Time -5000," + STR$(Game.WAIT!): MessageDelay% = 50
IF DQBkey(66) THEN Game.WAIT! = Game.WAIT! + 5000: DO: LOOP UNTIL DQBkey(66) = FALSE: Message$ = "Wait Time +5000," + STR$(Game.WAIT!): MessageDelay% = 50

'Mouse On/Off (F9, 67)
IF DQBkey(67) AND NoMouse% = 0 THEN NoMouse% = 1: DO: LOOP UNTIL DQBkey(67) = FALSE: Message$ = "Mouse Disabled": MessageDelay% = 50
IF DQBkey(67) AND NoMouse% = 1 THEN NoMouse% = 0: DO: LOOP UNTIL DQBkey(67) = FALSE: Message$ = "Mouse Enabled": MessageDelay% = 50: DQBsetMousePos 160, 100

'Save Settings (F10, 68)
IF DQBkey(68) THEN
DO: LOOP UNTIL DQBkey(68) = FALSE
Message$ = "New GAME.DAT saved.": MessageDelay% = 50
OPEN "DATA\GAME.DAT" FOR OUTPUT AS #1
WRITE #1, NoMouse%
WRITE #1, Game.GFX%
WRITE #1, Game.HearFatigue%
WRITE #1, Game.SndVol%
WRITE #1, ShowErrors%
WRITE #1, Game.WAIT!
CLOSE #1
END IF

'Screenshot (F12, 88)
IF DQBkey(88) THEN IF DQBsaveImage(READY, 0, 0, 319, 199, "OTHER\SCRNSHOT.BMP", Pal, 1) THEN Message$ = "Unable To Take Screenshot!": MessageDelay% = 50

'Quit (Esc)
IF DQBkey(KEYESC) THEN DQBfadeTo 0, 0, 0: QUIT

'Start a new game (Backspace, 14)
IF DQBkey(14) THEN DQBfadeTo 0, 0, 0: DQBclearLayer VIDEO: GOTO NEWGAME

'Continue to game2 sub (PART 3)
GAME2 2

IF Player.LIIKS% = 0 AND Player.PILL$ <> "BOU" AND Player.PILL$ <> "GAS" THEN
'Footstep sounds
IF Player.OY% = 99 AND FloodY% > 190 THEN
IF Player.FRAME% = 1 AND Mouth(INT(Player.FAT% / 100)).FOOTSND1 = 1 THEN PLAYSOUND "FOOTSTEP", 0
IF Player.FRAME% = 3 AND Mouth(INT(Player.FAT% / 100)).FOOTSND2 = 1 THEN PLAYSOUND "FOOTSTEP", 0
'Player moving sound 1
IF Player.FRAME% = 1 AND Mouth(INT(Player.FAT% / 100)).MOVESND11 = 1 THEN PLAYSOUND "MOVESOUND1", 0
IF Player.FRAME% = 3 AND Mouth(INT(Player.FAT% / 100)).MOVESND12 = 1 THEN PLAYSOUND "MOVESOUND1", 0

'Player moving sound 2 (More fat -> More sound volume)
IF Player.FAT% > 0 THEN
IF Player.FRAME% = 1 AND Mouth(INT(Player.FAT% / 100)).MOVESND21 = 1 THEN PLAYSOUND "MOVESOUND2", INT((Player.FAT% / Player.MAXFAT%) * 100)
IF Player.FRAME% = 3 AND Mouth(INT(Player.FAT% / 100)).MOVESND22 = 1 THEN PLAYSOUND "MOVESOUND2", INT((Player.FAT% / Player.MAXFAT%) * 100)
END IF
END IF
END IF

GOTO GAMELOOP

END SUB

SUB SELECTCHAR

JError$ = "Errors in CHARS.DAT!"
Character% = 1
JSelect% = 0

SELECTCHARACTER:
DO: LOOP UNTIL DQBkey(KEYUP) = FALSE AND DQBkey(KEYDOWN) = FALSE AND DQBmouseLB = FALSE AND DQBmouseRB = FALSE

'Use character's own cursor
CursorType% = INT(RND * 8) + 1
IF Character% = 1 THEN CursorType% = 2
IF Character% = 2 THEN CursorType% = 1

OPEN "DATA\CHARS\CHARS.DAT" FOR INPUT AS #1
IF LOF(1) THEN
INPUT #1, Characters%
DO
INPUT #1, JTEMP$
LOOP UNTIL JTEMP$ = STR$(Character%) + ":"
INPUT #1, CharacterDir$
ELSE JError$ = "DATA\CHARS\CHARS.DAT not found!": QUIT
END IF
CLOSE #1

OPEN "DATA\CHARS\" + CharacterDir$ + "\CHAR.DAT" FOR INPUT AS #1
IF LOF(1) THEN
INPUT #1, CharacterName$
INPUT #1, Player.MAXFAT%
IF Player.MAXFAT% > 8 OR Player.MAXFAT% < 1 THEN JError$ = "Data\Chars\" + CharacterDir$ + "\Char.dat MAXFAT out of range 1-8": QUIT
Player.MAXFAT% = Player.MAXFAT% * 100
INPUT #1, Player.ABILITY%
INPUT #1, Player.MAXSPRINT%

OPEN "DATA\CHARS\" + CharacterDir$ + "\SOUND.DAT" FOR INPUT AS #2
IF LOF(2) THEN
DO
INPUT #2, JTEMP$
LOOP UNTIL JTEMP$ = "MOVESOUND:"

INPUT #1, Mouth(0).SPEED, Mouth(1).SPEED, Mouth(2).SPEED, Mouth(3).SPEED, Mouth(4).SPEED, Mouth(5).SPEED, Mouth(6).SPEED, Mouth(7).SPEED, Mouth(8).SPEED
INPUT #1, Mouth(0).SPEED2, Mouth(1).SPEED2, Mouth(2).SPEED2, Mouth(3).SPEED2, Mouth(4).SPEED2, Mouth(5).SPEED2, Mouth(6).SPEED2, Mouth(7).SPEED2, Mouth(8).SPEED2
INPUT #1, Player.MIDAIR%
INPUT #1, Mouth(0).JPOWER, Mouth(1).JPOWER, Mouth(2).JPOWER, Mouth(3).JPOWER, Mouth(4).JPOWER, Mouth(5).JPOWER, Mouth(6).JPOWER, Mouth(7).JPOWER, Mouth(8).JPOWER
INPUT #1, Mouth(0).CHARW, Mouth(1).CHARW, Mouth(2).CHARW, Mouth(3).CHARW, Mouth(4).CHARW, Mouth(5).CHARW, Mouth(6).CHARW, Mouth(7).CHARW, Mouth(8).CHARW
INPUT #1, Mouth(0).CHARW2, Mouth(1).CHARW2, Mouth(2).CHARW2, Mouth(3).CHARW2, Mouth(4).CHARW2, Mouth(5).CHARW2, Mouth(6).CHARW2, Mouth(7).CHARW2, Mouth(8).CHARW2
INPUT #1, Mouth(0).X, Mouth(1).X, Mouth(2).X, Mouth(3).X, Mouth(4).X, Mouth(5).X, Mouth(6).X, Mouth(7).X, Mouth(8).X
INPUT #1, Mouth(0).X2, Mouth(1).X2, Mouth(2).X2, Mouth(3).X2, Mouth(4).X2, Mouth(5).X2, Mouth(6).X2, Mouth(7).X2, Mouth(8).X2
INPUT #1, Mouth(0).Y, Mouth(1).Y, Mouth(2).Y, Mouth(3).Y, Mouth(4).Y, Mouth(5).Y, Mouth(6).Y, Mouth(7).Y, Mouth(8).Y
INPUT #1, Mouth(0).W, Mouth(1).W, Mouth(2).W, Mouth(3).W, Mouth(4).W, Mouth(5).W, Mouth(6).W, Mouth(7).W, Mouth(8).W
INPUT #1, Mouth(0).H, Mouth(1).H, Mouth(2).H, Mouth(3).H, Mouth(4).H, Mouth(5).H, Mouth(6).H, Mouth(7).H, Mouth(8).H
INPUT #1, Mouth(0).CHARH, Mouth(1).CHARH, Mouth(2).CHARH, Mouth(3).CHARH, Mouth(4).CHARH, Mouth(5).CHARH, Mouth(6).CHARH, Mouth(7).CHARH, Mouth(8).CHARH

INPUT #2, Mouth(0).FOOTSND1, Mouth(1).FOOTSND1, Mouth(2).FOOTSND1, Mouth(3).FOOTSND1, Mouth(4).FOOTSND1, Mouth(5).FOOTSND1, Mouth(6).FOOTSND1, Mouth(7).FOOTSND1, Mouth(8).FOOTSND1
INPUT #2, Mouth(0).FOOTSND2, Mouth(1).FOOTSND2, Mouth(2).FOOTSND2, Mouth(3).FOOTSND2, Mouth(4).FOOTSND2, Mouth(5).FOOTSND2, Mouth(6).FOOTSND2, Mouth(7).FOOTSND2, Mouth(8).FOOTSND2
INPUT #2, Mouth(0).MOVESND11, Mouth(1).MOVESND11, Mouth(2).MOVESND11, Mouth(3).MOVESND11, Mouth(4).MOVESND11, Mouth(5).MOVESND11, Mouth(6).MOVESND11, Mouth(7).MOVESND11, Mouth(8).MOVESND11
INPUT #2, Mouth(0).MOVESND12, Mouth(1).MOVESND12, Mouth(2).MOVESND12, Mouth(3).MOVESND12, Mouth(4).MOVESND12, Mouth(5).MOVESND12, Mouth(6).MOVESND12, Mouth(7).MOVESND12, Mouth(8).MOVESND12
INPUT #2, Mouth(0).MOVESND21, Mouth(1).MOVESND21, Mouth(2).MOVESND21, Mouth(3).MOVESND21, Mouth(4).MOVESND21, Mouth(5).MOVESND21, Mouth(6).MOVESND21, Mouth(7).MOVESND21, Mouth(8).MOVESND21
INPUT #2, Mouth(0).MOVESND22, Mouth(1).MOVESND22, Mouth(2).MOVESND22, Mouth(3).MOVESND22, Mouth(4).MOVESND22, Mouth(5).MOVESND22, Mouth(6).MOVESND22, Mouth(7).MOVESND22, Mouth(8).MOVESND22

ELSE JError$ = "DATA\CHARS\" + CharacterDir$ + "\CHAR.DAT or SOUND.DAT not found!": QUIT
END IF
END IF

CLOSE

'Load character select image
IF DQBloadImage(READY, 0, 0, "DATA\CHARS\" + CharacterDir$ + "\SELECT.BMP", Pal, 0, 0) THEN QUIT

JPRINT READY, STR$(Character%) + " /" + STR$(Characters%), 5, 10, 7

JPRINT READY, CharacterName$, 80, 10, 7

JPRINT READY, "Maximum Weight Gain:" + STR$(Player.MAXFAT%), 10, 25, 7

IF Player.ABILITY% = 0 THEN JPRINT READY, "Special Ability: Fire Storm", 10, 40, 7
IF Player.ABILITY% = 1 THEN JPRINT READY, "Special Ability: Energy + Lose Effect", 10, 40, 7
IF Player.ABILITY% = 2 THEN JPRINT READY, "Special Ability: Instant Bounce", 10, 40, 7

JPRINT READY, "Press UP and DOWN arrows to change", 10, 160, 7
JPRINT READY, "Press SPACE to select ", 10, 170, 7
JPRINT READY, "Press ESC to QUIT game ", 10, 180, 7
JPRINT READY, "Press Backspace in the game to return", 10, 190, 7
DQBcopyLayer READY, VIDEO
DQBcopyLayer READY, TEMPLAYER2

DO
'Change campaign with mouse
JX% = 5: JX2% = 65: JY% = 5: JY2% = 20
IF DQBmouseX > JX% AND DQBmouseX < JX2% AND DQBmouseY > JY% AND DQBmouseY < JY2% THEN
DQBbox READY, JX%, JY%, JX2%, JY2%, INT(RND * 255) + 1
IF DQBmouseRB = TRUE AND Character% > 1 THEN Character% = Character% - 1: GOTO SELECTCHARACTER
IF DQBmouseLB = TRUE AND Character% < Characters% THEN Character% = Character% + 1: GOTO SELECTCHARACTER
END IF
'Select campaign with mouse
JX% = 75: JX2% = 310: JY% = 5: JY2% = 20
IF DQBmouseX > JX% AND DQBmouseX < JX2% AND DQBmouseY > JY% AND DQBmouseY < JY2% THEN
DQBbox READY, JX%, JY%, JX2%, JY2%, INT(RND * 255) + 1
IF DQBmouseLB = TRUE THEN JSelect% = 1
END IF
'Draw mouse cursor
CURSOR
DQBcopyLayer READY, VIDEO
DQBcopyLayer TEMPLAYER2, READY
IF DQBkey(KEYUP) AND Character% > 1 THEN Character% = Character% - 1: GOTO SELECTCHARACTER
IF DQBkey(KEYDOWN) AND Character% < Characters% THEN Character% = Character% + 1: GOTO SELECTCHARACTER
IF DQBkey(KEYESC) THEN JError$ = "": DQBfadeTo 0, 0, 0: QUIT
WAITFRAME
LOOP UNTIL DQBkey(KEYSPACE) OR JSelect% = 1
DO: LOOP UNTIL DQBkey(KEYSPACE) = FALSE AND DQBmouseLB = FALSE AND DQBmouseRB = FALSE
JSelect% = 0

JError$ = ""

END SUB

