Code: (Select All)
'GRAVE DAYZ
'By James D. Jarvis
' inspired by a game from usborne books (but sharing no code)
Randomize Timer
_ControlChr Off
Dim Shared g(60, 30)
Dim Shared D$(6)
Type zombietype
x As Integer 'x position
y As Integer 'y position
k As Integer 'color
m As Integer 'mobility
s As Integer 'strength
End Type
Dim Shared zom(20) As zombietype
Dim Shared zombies, zombiecount
Dim Shared px, py, psta, holes, score, lvl
Dim Shared gameflag$
gameflag$ = "playon"
Width 80, 43
_FullScreen
D$(1) = Chr$(1) 'player
D$(2) = Chr$(2) ' zombies
D$(3) = Chr$(206) 'gravestone
D$(4) = Chr$(35) 'wall
D$(5) = Chr$(177) 'hole
D$(6) = Chr$(42) 'bush
lvl = 1
psta = 250
newgame:
zombies = 5 + Int((1 + lvl) / 2)
zombiecount = zombies
px = Int(30 + Rnd * 3): py = Int(14 + Rnd * 3)
holes = 0
For x = 1 To 60
For y = 1 To 30
g(x, y) = 0
If Rnd * 20 <= lvl Then
p = Int(Rnd * 6) + 1
Select Case p
Case 3
g(x, y) = 3
Case 4
g(x, y) = 3
Case 5
If lvl < 5 Then
If holes < 6 Then
g(x, y) = 3
holes = holes + 1
End If
End If
Case 6
g(x, y) = 6
End Select
End If
If y = 1 Then g(x, y) = 4
If y = 30 Then g(x, y) = 4
If x = 1 Then g(x, y) = 4
If x = 60 Then g(x, y) = 4
Next y
Next x
If g(px, py) <> 0 Then g(px, py) = 0
For z = 1 To zombies
If lvl < 10 Then
c = Int(1 + Rnd * 4)
Select Case c
Case 1
zom(z).x = Int(Rnd * 6) + 2
zom(z).y = Int(Rnd * 6) + 2
Case 2
zom(z).x = Int(Rnd * 6) + 45
zom(z).y = Int(Rnd * 6) + 2
Case 3
zom(z).x = Int(Rnd * 6) + 2
zom(z).y = Int(Rnd * 6) + 24
Case 4
zom(z).x = Int(Rnd * 6) + 45
zom(z).y = Int(Rnd * 6) + 24
End Select
Else
c = Int(1 + Rnd * 4)
Select Case c
Case 1
zom(z).x = Int(Rnd * 59) + 2
zom(z).y = Int(Rnd * 12) + 2
Case 2
zom(z).x = Int(Rnd * 20) + 2
zom(z).y = Int(Rnd * 12) + 2
Case 3
zom(z).x = Int(Rnd * 59) + 2
zom(z).y = Int(Rnd * 12) + 2
Case 4
zom(z).x = Int(Rnd * 20) + 2
zom(z).y = Int(Rnd * 12) + 16
End Select
End If
zom(z).m = Int(1 + (1 + Rnd * lvl) / 5)
zom(z).s = Int(1 + Int((1 + Rnd * lvl) / 4))
zom(z).k = 10
Next z
Do
drawscreen
If psta > 0 Then
waitforK:
kk$ = InKey$
If kk$ = "" Then GoTo waitforK
End If
playermove (kk$)
zombiemove
For z = 1 To zombies
If zom(z).x = px And zom(z).y = py Then gameflag$ = "gotyou"
If g(zom(z).x, zom(z).y) = 5 And zom(z).s > 0 Then
score = score + 50
zombiecount = zombiecount - 1
If Rnd * 25 < lvl Then g(zom(z).x, zom(z).y) = 0 'zombies filling the holes more and more likely as the game goes on
drawscreen
Color 26, 0
For r = 1 To 6
_Limit 10
If r Mod 2 <> 0 Then
_PrintString (zom(z).x, zom(z).y), D$(2)
Else
_PrintString (zom(z).x, zom(z).y), "X"
End If
zom(z).s = 0
Next r
Color 15, 0
End If
Next z
If zombiecount = 0 Then gameflag$ = "nextlevel"
Loop Until gameflag$ <> "playon"
If gameflag$ = "gotyou" Then
For x = 5 To 11
_PrintString (15, x), "*************************************"
Next x
For x = 6 To 10
_PrintString (16, x), "..................................."
Next x
_PrintString (26, 7), "The Zombies Got You"
_PrintString (26, 9), "Play again? (Y/N)"
playask:
aa$ = InKey$
If aa$ = "" Then GoTo playask
aa$ = UCase$(aa$)
If aa$ = "Y" Then
lvl = 1
psta = 200
gameflag$ = "playon"
GoTo newgame
End If
If aa$ = "N" Then
System
Else
GoTo playask
End If
End If
If gameflag$ = "nextlevel" Then
score = lvl * 100
drawscreen
For x = 5 To 11
_PrintString (15, x), "*************************************"
Next x
For x = 6 To 10
_PrintString (16, x), "..................................."
Next x
T$ = "Completed Level " + Str$(level)
_PrintString (22, 7), T$
lvl = lvl + 1
T$ = "Press amy key for level " + Str$(lvl)
_PrintString (22, 9), T$
playask2:
aa$ = InKey$
If aa$ = "" Then GoTo playask
psta = psta + 150
gameflag$ = "playon"
GoTo newgame
End If
Sub drawscreen
Cls
For x = 1 To 60
For y = 1 To 30
If g(x, y) > 0 Then _PrintString (x, y), D$(g(x, y))
Next y
Next x
Color 14, 0
_PrintString (px, py), D$(1)
Color 15, 0
For z = 1 To zombies
Color zom(z).k, 0
If zom(z).s > 0 Then _PrintString (zom(z).x, zom(z).y), D$(2)
Next z
Color 12, 0
_PrintString (65, 3), "GRAVE DAYZ"
Color 15, 0
T$ = "Level " + Str$(lvl)
_PrintString (65, 5), T$
T$ = "Score " + Str$(score)
_PrintString (65, 8), T$
T$ = "Stamina" + Str$(psta)
If psta < 50 Then Color 12, 0
_PrintString (65, 11), T$
Color 10, 0
T$ = "Zombies " + Str$(zombiecount)
_PrintString (65, 13), T$
Color 7, 0
_PrintString (2, 32), "W,A,S,D to move (cost 1 Stamina)"
_PrintString (2, 34), "H to dig a hole (cost 10 stamina)"
_PrintString (2, 36), "You can't walk through walls, gravestones or bushes"
_PrintString (2, 38), "Avoid the zombies, get them all to return to the grave and advance a level!"
Color 15, 0
End Sub
Sub zombiemove
For z = 1 To zombies
zgx = 0
zgy = 0
If zom(z).s > 0 Then
If zom(z).y = py Then
If zom(z).x < px Then
zgx = 1
zgy = 0
End If
If zom(z).x > px Then
zgx = -1
zgy = 0
End If
Else If zom(z).x = px Then
If zom(z).y < py Then
zgx = 0
zgy = 1
End If
If zom(z).y > py Then
zgx = 0
zgy = -1
End If
End If
End If
If g(zom(z).x + zgx, zom(z).y + zgy) < 3 Or g(zom(z).x + zgx, zom(z).y + zgy) > 4 Then
zom(z).x = zom(z).x + zgx
zom(z).y = zom(z).y + zgy
End If
If Int(Rnd * 8) <= zom(z).m And zgx = 0 And zgy = 0 Then
Select Case Int(Rnd * 4)
Case 0
zgy = -1
zgx = 0
Case 1
zgy = 1
zgx = 0
Case 2
zgy = 0
zgx = 1
Case 3
zgy = 0
zgx = -1
End Select
If Int(Rnd * 6) < zom(z).m Then
If px < zom(z).x Then
zgx = -1
zgy = 0
End If
If px > zom(z).x Then
zgx = 1
zgy = 0
End If
End If
If Int(Rnd * 6) < zom(z).m And zgx = 0 Then
If py < zom(z).y Then zgy = -1
If py > zom(z).y Then zgy = 1
End If
If g(zom(z).x + zgx, zom(z).y + zgy) < 3 Or g(zom(z).x + zgx, zom(z).y + zgy) > 4 Then
zom(z).x = zom(z).x + zgx
zom(z).y = zom(z).y + zgy
End If
End If
End If
Next z
End Sub
Sub playermove (kk$)
kk$ = UCase$(kk$)
pgy = 0: pgx = 0
If psta > 0 Then
Select Case kk$
Case "W"
pgy = -1
pgx = 0
Case "A"
pgy = 0
pgx = -1
Case "S"
pgy = 1
pgx = 0
Case "D"
pgy = 0
pgx = 1
Case "H"
If psta > 9 Then
g(px, py) = 5
psta = psta - 10
End If
End Select
If pgy <> 0 Or pgx <> 0 Then
If g(px + pgx, py + pgy) < 3 Then
px = px + pgx
py = py + pgy
psta = psta - 1
End If
End If
End If
End Sub