setscreen ("graphics:vga")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                               Variables                                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var retcode : int
var p1x : int := 30
var p1y : int := maxy div 2
var p2x : int := maxx - 20
var p2y : int := maxy div 2
var s1x : int := p1x
var s1y : int := p1y
var s2x : int := p2x
var s2y : int := p2y
var rx : int := maxx div 2
var ry : int := maxy div 2
var rxchange : int := 2
var rychange : int := 2
var playerspeed : int := 5
var rockspeed : int := 300
var playercolor : int := 10
var p1point : int := 0
var p2point : int := 0
var bgx, bgy : int := 0
var bgcolor : int := 0
var sg : int
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                               Functions                                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function player1hit : boolean
    var hit : boolean := false
    var dot : int
    for i : p1x - 1 .. p1x + 1
	for j : p1y - 1 .. p1y + 1
	    dot := whatdotcolour (i, j)
	    if dot not= playercolor and dot not= 0 then
		hit := true
	    end if
	end for
    end for
    result (hit)
end player1hit
function player2hit : boolean
    var hit : boolean := false
    var dot : int
    for i : p2x - 1 .. p2x + 1
	for j : p2y - 1 .. p2y + 1
	    dot := whatdotcolour (i, j)
	    if dot not= playercolor and dot not= 0 then
		hit := true
	    end if
	end for
    end for
    result (hit)
end player2hit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                               Procedures                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure stars
    randomize
    randint (bgx, 0, maxx)
    randint (bgy, 0, maxy)
    randint (bgcolor, 1, 15)
    randint (sg, 1, 3)
    drawfilloval (bgx, bgy, sg, sg, bgcolor)
    delay (10)
    drawfilloval (bgx, bgy, sg, sg, 0)
end stars
procedure wait (w : int)
    var w2 := w * 1000
    var num : int := 0
    for i : 1 .. w2
	num := num + 1
    end for
end wait
procedure intro
    setscreen ("graphics:vga,noecho,nocursor")
    var randcolor : int
    randomize
    const black := 1
    const bright := 15
    var count := 0
    loop
	count := count + 1
	exit when count = 600
	exit when hasch
	randint (randcolor, black, bright)
	color (randcolor)
	locate (15, 27)
	put " %%% SHOOT'EM UP!!! %%%"
    end loop
    var count1 := 0
    loop
	count1 := count1 + 1
	exit when count1 = 600
	exit when hasch
	randint (randcolor, black, bright)
	color (randcolor)
	locate (15, 26)
	put " %%%% SHOOT'EM UP!!! %%%%"
    end loop
    var count2 := 0
    loop
	count2 := count2 + 1
	exit when count2 = 600
	exit when hasch
	randint (randcolor, black, bright)
	color (randcolor)
	locate (15, 25)
	put " %%%%% SHOOT'EM UP!!! %%%%%"
    end loop
    var count3 := 0
    loop
	count3 := count3 + 1
	exit when count3 = 400
	exit when hasch
	randint (randcolor, black, bright)
	color (randcolor)
	locate (15, 24)
	put " %%%%%% SHOOT'EM UP!!! %%%%%%"
    end loop
    var count4 := 0
    loop
	count4 := count4 + 1
	exit when count4 = 400
	exit when hasch
	randint (randcolor, black, bright)
	color (randcolor)
	locate (15, 23)
	put " %%%%%%% SHOOT'EM UP!!! %%%%%%%"
    end loop
    var count5 := 0
    loop
	count5 := count5 + 1
	exit when count5 = 400
	exit when hasch
	randint (randcolor, black, bright)
	color (randcolor)
	locate (15, 22)
	put " %%%%%%%% SHOOT'EM UP!!! %%%%%%%%"
    end loop
    var count6 := 0
    loop
	count6 := count6 + 1
	exit when count6 = 400
	exit when hasch
	randint (randcolor, black, bright)
	color (randcolor)
	locate (15, 21)
	put " %%%%%%%%% SHOOT'EM UP!!! %%%%%%%%%"
    end loop
    var count7 := 0
    loop
	count7 := count7 + 1
	exit when count7 = 400
	exit when hasch
	randint (randcolor, black, bright)
	color (randcolor)
	locate (15, 20)
	put " %%%%%%%%%% SHOOT'EM UP!!! %%%%%%%%%%"
    end loop
    loop

	exit when hasch
	randint (randcolor, black, bright)
	color (randcolor)
	locate (15, 19)
	put " %%%%%%%%%%% SHOOT'EM UP!!! %%%%%%%%%%%"
    end loop
    play ("16>C< ")
    play ("16>C< ")
    delay (380)
    play ("16>C< ")
    play ("16b ")
    delay (150)
    play ("16>C< ")
    delay (300)
    play ("16b ")
    play ("16>c< ")
    delay (400)
    play ("4C ")
    play ("c")
    var randx, randy, rdcolor : int
    const blue := 1
    const yellow := 14
    randomize
    var count8 := 0
    loop
	var c : string (1)
	exit when not hasch
	getch (c)
    end loop
    loop
	count8 := count8 + 1
	exit when hasch
	exit when count8 = 15000
	randint (randx, 0, maxx)
	randint (randy, 0, maxy)
	randint (rdcolor, blue, yellow)
	drawdot (randx, randy, rdcolor)
    end loop
    loop
	exit
    end loop
end intro
procedure player1 (Color : int)
    drawfilloval (p1x, p1y, 20, 6, Color)
    drawfilloval (p1x, p1y + 6, 5, 5, Color)
    drawline (p1x, p1y - 3, p1x, p1y + 6, 0)
    drawline (p1x, p1y + 6, p1x - 3, p1y + 3, 0)
    drawline (p1x - 3, p1y - 3, p1x + 3, p1y - 3, 0)
end player1
procedure player2 (Color : int)
    drawfilloval (p2x, p2y, 20, 6, Color)
    drawfilloval (p2x, p2y + 6, 5, 5, Color)
    drawline (p2x - 5, p2y + 4, p2x, p2y + 4, 0)
    drawline (p2x, p2y + 4, p2x, p2y + 1, 0)
    drawline (p2x, p2y + 1, p2x - 5, p2y + 1, 0)
    drawline (p2x - 5, p2y + 1, p2x - 5, p2y - 2, 0)
    drawline (p2x - 5, p2y - 2, p2x, p2y - 2, 0)
end player2
procedure shoot1 (Color : int)
    loop
	drawfilloval (s1x + 25, s1y, 2, 2, Color)
	drawfilloval (s1x + 25, s1y, 2, 2, 4)
	s1x := s1x + 5
	for timer : 1 .. rockspeed
	    var timer2 : int := 0
	    timer2 := timer2 + 1
	end for
	if s1x >= maxx then
	    cls
	    exit
	end if
	if player2hit then
	    p1point := p1point + 1
	    for i : 1 .. 10
		drawoval (p2x, p2y, i, i, 4)
		delay (0)
	    end for
	    for decreasing i : 10 .. 1
		drawoval (p2x, p2y, i, i, 0)
		delay (1)
	    end for
	    locate (10, 30)
	    play ("5>A<4<<G>>")
	    put "Player 1 anhialated Player 2"
	    p1y := maxy div 2
	    p2y := maxy div 2
	    if p1point = 3 then
		put "Player 1 Wins!!!!! Way to go!"
		play ("16>D<")
		play ("16>D<")
		play ("16>D<")
		play ("16>D<")
		play ("16>C<")
		play ("16B")
		delay (250)
		play ("16>C<")
		play ("16>D<")
		delay (250)
		play ("16G")
		play ("8G")
		play ("16G")
		play ("8G")
		play ("16B")
		delay (600)
		play ("16A")
		delay (700)
		play ("8G")
		play ("8G")
		if p2point = 0 then
		    put "Player 1 had a shut-out!!"
		end if
		delay (2500)
		cls
		exit
	    elsif p1point = 2 and p2point = 2 then
		put "OVERTIME!!!!!!!!"
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
	    end if
	    put "" ..
	    put "Score: Player 1 ", p1point
	    put "       Player 2 ", p2point
	    delay (2500)
	    cls
	    return
	end if
    end loop
end shoot1
procedure shoot2 (Color : int)
    loop
	drawfilloval (s2x - 25, s2y, 2, 2, Color)
	drawfilloval (s2x - 25, s2y, 2, 2, 4)
	s2x := s2x - 5
	for timer : 1 .. rockspeed
	    var timer2 : int := 0
	    timer2 := timer2 + 1
	end for
	if s2x < 0 then
	    cls
	    exit
	end if
	if player1hit then
	    p2point := p2point + 1
	    for i : 1 .. 10
		drawoval (p1x, p1y, i, i, 4)
		delay (0)
	    end for
	    for decreasing i : 10 .. 1
		drawoval (p1x, p1y, i, i, 0)
		delay (1)
	    end for
	    locate (10, 30)
	    play ("5>A<4<<G>>")
	    put "Player 2 anhialated Player 1"
	    p1y := maxy div 2
	    p2y := maxy div 2
	    if p2point = 3 then
		put "Player 2 Wins!!!!! Way to go!"
		play ("16>D<")
		play ("16>D<")
		play ("16>D<")
		play ("16>D<")
		play ("16>C<")
		play ("16B")
		delay (250)
		play ("16>C<")
		play ("16>D<")
		delay (250)
		play ("16G")
		play ("8G")
		play ("16G")
		play ("8G")
		play ("16B")
		delay (600)
		play ("16A")
		delay (700)
		play ("8G")
		play ("8G")
		if p1point = 0 then
		    put "Player 2 had a shut-out!!"
		end if
		delay (2500)
		exit
	    elsif p1point = 2 and p2point = 2 then
		put "OVERTIME!!!!!!!!"
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
		play ("16c")
		play ("16c+")
	    end if
	    put "Score: Player 1 ", p1point
	    put "       Player 2 ", p2point
	    delay (2500)
	    cls
	    return
	end if
    end loop
end shoot2
procedure controlplayer
    player1 (10)
    player2 (10)
    var move : string (1)
    getch (move)
    case ord (move (1)) of
	label 122 :
	    player1 (0)
	    p1y += playerspeed
	    s1y += playerspeed
	label 120 :
	    player1 (0)
	    p1y -= playerspeed
	    s1y -= playerspeed
	label 112 :
	    player2 (0)
	    p2y += playerspeed
	    s2y += playerspeed
	label 111 :
	    player2 (0)
	    p2y -= playerspeed
	    s2y -= playerspeed
	label 99 :
	    shoot1 (4)
	    s1x := p1x
	    s1y := p1y
	label 105 :
	    shoot2 (4)
	    s2x := p2x
	    s2y := p2y
	label :
    end case
    if p1y < 10 then
	p1y := 10
    elsif p1y > maxy - 10 then
	p1y := maxy - 10
    elsif p2y < 10 then
	p2y := 10
    elsif p2y > maxy then
	p2y := maxy - 10
    end if
end controlplayer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                  Menu                                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
colorback (7)
color (14)
locate (10, 30)
color (1)
put " MENU "
put ""
put "" : 15, " 1) Let me play the game!!"
put "" : 15, " 2) Whoa! Let's see some rules first"
put "" : 15, " 3) How can I play the game without"
put "" : 15, "    knowing the story behind it"
put "" : 15, " 4) I've played this game so many times"
put "" : 15, "    I might just want to see who created it"
put "" : 15, " 5) Quit"
put ""
var count := 0
loop
    var v : int := 4
    count := count + 1
    exit when hasch
    exit when count = 2
    locate (1, 1)
    color (v)
    put "-Please insert coin-"
    play ("6b")
    exit when hasch
    wait (100)
    locate (1, 1)
    color (7)
    put "-Please insert coin-"
    play ("6b")
    exit when hasch
    wait (100)
    locate (1, 1)
    color (v)
    put "-Please insert coin-"
    play ("6>c<")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (7)
    put "-Please insert coin-"
    play ("6>c<")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (v)
    put "-Please insert coin-"
    play ("6>c<")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (7)
    put "-Please insert coin-"
    play ("6>d<")
    exit when hasch
    wait (100)
    locate (1, 1)
    color (v)
    put "-Please insert coin-"
    play ("6>d<")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (7)
    put "-Please insert coin-"
    play ("6>d<")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (v)
    put "-Please insert coin-"
    play ("6>d<")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (7)
    put "-Please insert coin-"
    play ("6>c<")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (v)
    put "-Please insert coin-"
    play ("6>d<")
    wait (50)
    locate (1, 1)
    color (7)
    put "-Please insert coin-"
    play ("6>c<")
    exit when hasch
    wait (100)
    locate (1, 1)
    color (v)
    put "-Please insert coin-"
    play ("6b")
    exit when hasch
    wait (100)
    locate (1, 1)
    color (7)
    put "-Please insert coin-"
    play ("6b")
    exit when hasch
    wait (100)
    locate (1, 1)
    color (v)
    put "-Please insert coin-"
    play ("6>d<")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (7)
    put "-Please insert coin-"
    play ("6>d<")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (v)
    put "-Please insert coin-"
    play ("6>d<")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (7)
    put "-Please insert coin-"
    play ("6g")
    exit when hasch
    wait (50)
    locate (1, 1)
    color (v)
    put "-Please insert coin-"
    exit when hasch
end loop
color (1)
locate (20, 4)
put
    " Hello! Please enter a choice by number, then press enter to select it. "
    ..
var choice : int
get choice
var b := 0
loop
    b := b + 1
    exit when b = 2
    play ("16g")
    play (">16c<")
    play ("16a")
    play (">16c<")
end loop
cls
colorback (0)
case choice of
    label 1 :
	system ("main.bat", retcode)
	include "main"
    label 2 :
	system ("rules.bat", retcode)
	include "rules"
    label 3 :
	system ("story.bat", retcode)
	include "story"
    label 4 :
	system ("credits.bat", retcode)
	include "credits"
    label 5 :
    label :
	cls
	color (7)
	colorback (0)
	loop
	    exit
	end loop
end case


