Posted: Thu Jun 05, 2003 10:01 am Post subject: CONNECT FOUR GAME
code:
setscreen ("graphics:vga")
var brd : array 1 .. 8, 1 .. 8 of string (25)
var name : array 1 .. 2 of string (15)
var matt : array 1 .. 2 of string (5)
var n : array 1 .. 8 of int
var pl, r, c, ct, mc, d1, d2, ht, k, blah : int
var p : array 1 .. 8 of int
var gameover, ok : boolean
procedure setup
for j : 1 .. 8
for k : 1 .. 8
brd (j, k) := " "
end for
end for
for j : 1 .. 8
n (j) := 8
end for
pl := 1
color (red)
matt (1) := " X "
color (black)
matt (2) := " O "
end setup
procedure intro
for j : 1 .. 2
put "please input name ", j
get name (j)
end for
end intro
procedure display
cls
for j : 1 .. 8
for k : 1 .. 8
if k < 8 then
put brd (j, k), "|" ..
else
put brd (j, k)
end if
end for
if j < 8 then
put "-----------------------------------------------"
end if
end for
end display
procedure switch
if pl = 1 then
pl := 2
else
pl := 1
end if
end switch
procedure check
ok := true
if c > 8 or c < 1 then
ok := false
put name (pl), "please input numbers between 1->8 ONLY"
end if
if ok and n (c) > 0 then
brd (n (c), c) := matt (pl)
n (c) := n (c) - 1
else
ok := false
put "pick a column that has room"
end if
end check
procedure gamedone
for j : 1 .. 8
ht := 0
for k : 1 .. 8
if brd (j, k) = matt (pl) then
ht := ht + 1
if ht = 4 then
gameover := true
end if
else
ht := 0
end if
end for
end for
for j : 1 .. 8
ht := 0
for k : 1 .. 8
if brd (k, j) = matt (pl) then
ht := ht + 1
if ht = 4 then
gameover := true
end if
else
ht := 0
end if
end for
end for
ct := 0
ht := 0
for d : 1 .. 5
ct := ct + 1
k := 0
for j : ct .. 8
k := k + 1
if brd (j, k) = matt (pl) then
ht := ht + 1
if ht = 4 then
gameover := true
end if
else
ht := 0
end if
end for
end for
ht := 0
ct := 9
for d : 1 .. 5
ct := ct - 1
k := 9
for decreasing j : ct .. 1
k := k - 1
if brd (j, k) = matt (pl) then
ht := ht + 1
if ht = 4 then
gameover := true
end if
else
ht := 0
end if
end for
end for
ct := 0
ht := 0
for d : 1 .. 5
ct := ct + 1
k := 9
for j : ct .. 8
k := k - 1
if brd (k, j) = matt (pl) then
ht := ht + 1
if ht = 4 then
gameover := true
end if
else
ht := 0
end if
end for
end for
ht := 0
ct := 9
for d : 1 .. 5
ct := ct - 1
k := 0
for decreasing j : ct .. 1
k := k + 1
if brd (j, k) = matt (pl) then
ht := ht + 1
if ht = 4 then
gameover := true
end if
else
ht := 0
end if
end for
end for
end gamedone
gameover := false
setup
intro
display
loop
loop
put " 1 2 3 4 5 6 7 8"
put name (pl), " input a col number"
get c
check
exit when ok
end loop
display
gamedone
exit when gameover
switch
end loop
Sponsor Sponsor
Prince
Posted: Thu Jun 05, 2003 10:16 am Post subject: (No subject)
pretty cool game... not bein a mod i dont hav unlimited bits to give away but if i could i would giv u 10 bits
Tony
Posted: Thu Jun 05, 2003 1:04 pm Post subject: (No subject)
simple, but works
Next step would be to use some graphics and move away from typing controls... Have players use mouse instead. Then perhaps even an animation of falling piece 8)
Posted: Thu Jun 05, 2003 3:26 pm Post subject: (No subject)
mine's posted in this thread with AI and stuff it was my final project for grade 11 computer science
The Stuff
Posted: Mon Jan 12, 2004 10:28 pm Post subject: (No subject)
what does the n in the proram do?
Thuged_Out_G
Posted: Tue Jan 13, 2004 3:13 pm Post subject: (No subject)
whats the point of having a submissions and a source code forum...if people are just going to post their source code in the submissions forum
Cervantes
Posted: Tue Jan 13, 2004 4:18 pm Post subject: (No subject)
submissions can be for either... source code = pure code
GJ i like it..
btw tony, those graphics own
shorthair
Posted: Tue Jan 13, 2004 7:02 pm Post subject: (No subject)
What does taht guy mean he cant give 10 bits HE HAS 400 , give him some bits dude ,
+ bits for an awsome program
Sponsor Sponsor
the_short1
Posted: Tue Jan 20, 2004 8:35 pm Post subject: (No subject)
Great job.... play it when my teacher is talking endlessly about stuff i already know... +1 Bit.. i saving for title glow... so icant give more...
kalin
Posted: Wed Jan 21, 2004 4:06 pm Post subject: (No subject)
Cool. Its cool. And question, what is the point of bits anyway??? I"m lost on that..
shorthair
Posted: Wed Jan 21, 2004 4:12 pm Post subject: (No subject)
Its in the FAQ , but a brief overview would be , you get them for good programs , 2 for posting a message ,and 1 for a thread , you can use them to buy name effects ( colors ) and you can buy tech stuff aswell , i bought an email at compsci , also you can give the m to people for good programs , the more you give the more you recieve ( its true ive seen it in action)
kalin
Posted: Wed Jan 21, 2004 4:14 pm Post subject: (No subject)
Well, alright.....I kinda get what you're saying....I think the FaQ will cover it better...well more...umm, I'll shut up
romper
Posted: Tue Jun 15, 2004 11:49 pm Post subject: (No subject)
Posted: Wed Jun 16, 2004 9:57 pm Post subject: (No subject)
for one ... u brought up a realy old post..... once its past the first 2 pages.... read and download the progs... but norm us compsciers dont like seing it come back up..
second... please
dont 'plug' your programs is other's threads...
i used to get bitched at for that... *when i was new to compsci...
.so i thought i would pass on that before the others (Asian s, Mazer, otherS) get mad....
Thanks
king_boby
Posted: Mon Jun 21, 2004 3:11 pm Post subject: (No subject)