12-30-2005, 05:28 AM
Well after listening to 90mins of Led Zeppelin and drinking a few coffees I created this. Its a pitty I didn't work faster, I had so much more planned for it. the score was acually going to be useful and it would have been able to play more than one game in a row, if you want to, just edit it to call Setup, and just add a clear map thing in there.
With 20mins left I hadn't seen it run, I wrote all subs and linked em together.
This is only a 2 player game cause I had a bug with the AI, its an easy fix but I have to put it here like this.
Enjoy.
I think I might make another one, time to have a look through my commodore 64 cassettes to find a game to rip .
PS. I'm not some old dude, I'm acually 17, despite having a C= and listen to Led Zeppelin.
With 20mins left I hadn't seen it run, I wrote all subs and linked em together.
This is only a 2 player game cause I had a bug with the AI, its an easy fix but I have to put it here like this.
Enjoy.
Code:
DECLARE SUB Menu()
DECLARE SUB Engine()
DECLARE SUB Keys(P$)
DECLARE SUB AI()
DECLARE SUB Put.Bonus()
DECLARE SUB Put.Wall()
DECLARE SUB Display.Map()
DECLARE SUB Display.Score()
DECLARE SUB Display.Boarder()
DECLARE SUB Move.Lines()
DECLARE SUB Setup()
DECLARE SUB Checkwinner()
DIM SHARED Map(40,25), Lines(2,6), times(5) as double, Game, wallmem(3)
const North = 1
const South = 2
const East = 3
const West = 4
const Slow = 1
const Normal = 2
const Fast = 3
const Alive = 1
const Dead = 2
const Player1 = 1
const Player2 = 2
Screen 16,,,1
Randomize timer
menu()
engine()
sleep
' - = - = - = - = - = - = - = - =] S U B S [= - = - = - = - = - = - = - = - = -
SUB Menu()
color 15
print "Lines"
color 7
print "1) 1 Player game"
color 15
print "2) 2 Player game"
do
P$ = inkey$
loop until P$ = "2" or P$ = chr$(27)
'if P$ = "1" then Game = Player1
if P$ = "2" then Game = Player2
if P$ = chr$(27) then end
cls
Display.Boarder()
display.map()
setup()
Call engine()
END SUB
SUB Checkwinner()
if lines(1,5) = dead or lines(2,5) = dead then
cls
if lines(1,5) = dead Then print "PLAYER 2 WINS":print "WITH A SCORE OF "+str$(lines(2,6))
if lines(2,5) = dead Then print "PLAYER 1 WINS":print "WITH A SCORE OF "+str$(lines(1,6))
print "Hit [Enter] to end"
do:P$=inkey$:loop until P$ = chr$(13)
end
end if
end sub
SUB Engine()
do
P$ = inkey$
if P$ <> "" then Call keys(P$)
if Game = Player1 then Call AI()
Call Move.Lines()
Call Checkwinner()
Call Display.score()
Call Put.bonus()
Call Put.wall()
Call display.Map()
loop until P$ = chr$(27)
END SUB
SUB Setup()
Lines(1,1) = 1
Lines(1,2) = 1
Lines(1,3) = Normal
Lines(1,4) = East
Lines(1,5) = Alive
Lines(1,6) = 0
Lines(2,1) = 40
Lines(2,2) = 21
Lines(2,3) = Normal
Lines(2,4) = West
Lines(2,5) = Alive
Lines(2,6) = 0
WallMem(1) = 0
WallMem(2) = 0
WallMem(3) = 0
END SUB
SUB Move.Lines()
if times(1) < timer - .01 then
for i = 1 to 2
if Lines(i,3) = Fast then
if lines(i,4) = North then lines(i,2) -= 1
if lines(i,4) = South then lines(i,2) += 1
if lines(i,4) = East then lines(i,1) += 1
if lines(i,4) = West then lines(i,1) -= 1
end if
next
times(1) = timer
elseif times(2) < timer - .1 then
for i = 1 to 2
if Lines(i,3) = Normal then
if lines(i,4) = North then lines(i,2) -= 1
if lines(i,4) = South then lines(i,2) += 1
if lines(i,4) = East then lines(i,1) += 1
if lines(i,4) = West then lines(i,1) -= 1
end if
next
if map(lines(1,1),lines(1,2)) = 7 then lines(1,6) +=int(rnd*20)+10
if map(lines(2,1),lines(2,2)) = 7 then lines(2,6) +=int(rnd*20)+10
if map(lines(1,1),lines(1,2)) < 5 and map(lines(1,1),lines(1,2)) <> 0 then lines(1,5) = Dead
if map(lines(2,1),lines(2,2)) < 5 and map(lines(2,1),lines(2,2)) <> 0 then lines(2,5) = Dead
for i = 1 to 2
if lines(i,1) = 0 then lines(i,5) = Dead
if lines(i,2) = 0 then lines(i,5) = Dead
if lines(i,1) = 41 then lines(i,5) = Dead
if lines(i,2) = 22 then lines(i,5) = Dead
next
map(lines(1,1),lines(1,2)) = 1
map(lines(2,1),lines(2,2)) = 2
lines(1,6) += 1
lines(2,6) += 1
times(2) = timer
elseif times(3) < timer - .4 then
for i = 1 to 2
if Lines(i,3) = Slow then
if lines(i,4) = North then lines(i,2) -= 1
if lines(i,4) = South then lines(i,2) += 1
if lines(i,4) = East then lines(i,1) += 1
if lines(i,4) = West then lines(i,1) -= 1
end if
next
times(3) = timer
end if
END SUB
SUB Keys(P$)
if P$ = "w" then lines(1,4) = North
if P$ = "s" then lines(1,4) = South
if P$ = "d" then lines(1,4) = East
if P$ = "a" then lines(1,4) = West
if game = player2 then
if P$ = "8" then lines(2,4) = North
if P$ = "5" then lines(2,4) = South
if P$ = "6" then lines(2,4) = East
if P$ = "4" then lines(2,4) = West
end if
END SUB
SUB Display.Boarder()
for i = 1 to 42
locate 1,i+9:color 7:print chr$(219)
locate 23,i+9:color 8:print chr$(219)
if i < 23 then
locate i+1,10:color 7:print chr$(219)
locate i+1,51:color 8:print chr$(219)
end if
next
END SUB
SUB Display.Map()
for x = 1 to 40
for y = 1 to 21
locate y+1,x+10
if map(x,y) = 1 then
color 9:print chr$(219)
elseif map(x,y) = 2 then
color 12:print chr$(219)
elseif map(x,y) = 3 then
color 7:print chr$(178)
elseif map(x,y) = 4 then
color 7:print chr$(219)
elseif map(x,y) = 5 then
color 7:print chr$(176)
elseif map(x,y) = 6 then
color 7:print chr$(177)
elseif map(x,y) = 7 then
color 10:print chr$(36)
elseif map(x,y) = 8 then
color 4:print chr$(83)
'else
' color 15:print chr$(219)
end if
next
next
END SUB
SUB Put.Wall()
if times(4) < timer - .25 then
if Wallmem(1) = 0 then
do
WallMem(2) = int(rnd * 40)
WallMem(3) = int(rnd * 21)
loop until Map(WallMem(2),WallMem(3)) = 0
Wallmem(1) = 4
Map(WallMem(2),WallMem(3)) = 5
elseif Wallmem(1) = 1 then
Map(WallMem(2),WallMem(3)) = 4
elseif Wallmem(1) = 2 then
Map(WallMem(2),WallMem(3)) = 3
elseif Wallmem(1) = 3 then
Map(WallMem(2),WallMem(3)) = 6
end if
Wallmem(1) = Wallmem(1) - 1
times(4) = timer
end if
END SUB
SUB Put.Bonus()
if times(5) < timer - 10 then
do
bx = int(rnd * 40)
by = int(rnd * 21)
loop until Map(bx,by) = 0
Map(bx,by) = 7
times(5) = timer
end if
END SUB
SUB AI()
if map(lines(2,1),lines(2,2)-1) > 4 then lines(2,4) = North
if map(lines(2,1),lines(2,2)+1) > 4 then lines(2,4) = South
if map(lines(2,1)+1,lines(2,2)) > 4 then lines(2,4) = East
if map(lines(2,1)-1,lines(2,2)) > 4 then lines(2,4) = West
END SUB
SUB Display.Score()
locate 1,1
color 15
print "PLAYER 1"
color 7
print "SCORE:"
print str$(lines(1,6))
print
color 15
print "PLAYER 2"
color 7
print "SCORE:"
print str$(lines(2,6))
END SUB
I think I might make another one, time to have a look through my commodore 64 cassettes to find a game to rip .
PS. I'm not some old dude, I'm acually 17, despite having a C= and listen to Led Zeppelin.