Computer Science Canada Snake |
Author: | equs [ Tue May 18, 2004 9:40 pm ] |
Post subject: | Snake |
hi i need some help with my program. The snake only grows when you clikc in the opposite direction its going in and i also want to make food grow afteryou collect good food, and this food is that when you collect it you die. PLease help me thx. var choice : string (1) var chars : array char of boolean var cellsize := 16 var lsnake := 3 var count := 1 var limit := 400 div cellsize var delaytime := 80 var points := 0 var ate := false var colorfood := black var colorsnake := 7 var temprow, tempcol := 0 var leftright, updown := 0 var trigger := false var trig3 := false type coor : record row, col : int end record var snake : flexible array 1 .. lsnake of coor proc drawboard drawbox (0, 0, maxx, maxy, 7) for i : 1 .. limit drawline (i * cellsize, 0, i * cellsize, maxy, 7) drawline (0, i * cellsize, maxx, i * cellsize, 7) end for end drawboard proc drawcell (col, row, clr : int) var temprow1 := row - 1 var tempcol1 := col - 1 drawfillbox (temprow1 * cellsize, tempcol1 * cellsize, row * cellsize, col * cellsize, clr) end drawcell proc clear updown := 0 leftright := 0 end clear proc checkfood (rownum, colnum : int) var center := cellsize div 2 if View.WhatDotColor (colnum * cellsize - center, rownum * cellsize - center) = colorfood then points += 1 ate := false trig3 := true elsif View.WhatDotColor (colnum * cellsize - center, rownum * cellsize - center) = colorsnake then trigger := true end if end checkfood proc movement if updown = 1 then checkfood (snake (lsnake).row + 1, snake (lsnake).col) snake (lsnake).row += 1 elsif updown = 2 then checkfood (snake (lsnake).row - 1, snake (lsnake).col) snake (lsnake).row -= 1 elsif leftright = 1 then checkfood (snake (lsnake).row, snake (lsnake).col - 1) snake (lsnake).col -= 1 elsif leftright = 2 then checkfood (snake (lsnake).row, snake (lsnake).col + 1) snake (lsnake).col += 1 end if end movement proc food var count := 0 if ate = false then loop loop tempcol := Rand.Int (1, limit) for i : 1 .. lsnake if tempcol not= snake (i).col then count += 1 end if end for exit when count = lsnake count := 0 end loop temprow := Rand.Int (1, limit) count := 0 for i : 1 .. lsnake if temprow not= snake (i).row then count += 1 end if end for exit when count = lsnake end loop ate := true end if end food var tlen, trow, tcol := 0 for i : 1 .. lsnake snake (i).row := limit div 2 snake (i).col := limit div 2 end for var trig2 := true loop tlen := lsnake trow := snake (lsnake).row tcol := snake (lsnake).col if points mod 5 = 0 and points not= 0 then if trig2 = false then lsnake += 1 new snake, lsnake trig2 := true elsif trig3 = true then trig2 := false trig3 := false end if end if snake (lsnake).row := trow snake (lsnake).col := tcol Input.Flush Input.KeyDown (chars) for i : 1 .. lsnake - 1 snake (i).row := snake (i + 1).row snake (i).col := snake (i + 1).col end for if snake (lsnake).row >= 0 and snake (lsnake).row <= limit and snake (lsnake).col >= 0 and snake (lsnake).col <= limit then if chars (KEY_UP_ARROW) then clear updown := 1 elsif chars (KEY_DOWN_ARROW) then clear updown := 2 elsif chars (KEY_LEFT_ARROW) then clear leftright := 1 elsif chars (KEY_RIGHT_ARROW) then clear leftright := 2 elsif chars (chr (ORD_SPACE)) then clear end if else exit end if exit when trigger = true for i : 1 .. lsnake drawcell (snake (i).row, snake (i).col, colorsnake) end for drawcell (temprow, tempcol, colorfood) movement drawcell (snake (lsnake).row, snake (lsnake).col, colorsnake) food drawboard delay (delaytime) View.Update cls if count = lsnake then count := 1 end if end loop View.Update put "your score is:", points |
Author: | McKenzie [ Wed May 19, 2004 1:59 pm ] |
Post subject: | |
SHAME ON YOU!!! http://www.compsci.ca/v2/viewtopic.php?t=3625&highlight=snake You asked for help to do snake on April 9th. Paul Bian told you to look at SantaBruzer's code. You copy it almost exactly then ask for help to fix it, and claim it is your own. SHAME ON YOU!!! |
Author: | SuperGenius [ Wed May 19, 2004 3:49 pm ] |
Post subject: | |
palagurism is bad. you should lose bits. |
Author: | LiquidDragon [ Wed May 19, 2004 5:17 pm ] |
Post subject: | |
Why don't you take a look at my snake game? It may answer some of your questions. I am almost done. So far im just polishing it up. Right now I am adding lives, speed, and other stuff which will remain a secret It will be ssoo good. Everyone will donate all their bits to me and i will be the king of all. MUAHAHAHAHA |
Author: | equs [ Wed May 19, 2004 8:15 pm ] |
Post subject: | |
im trying to fix it becuase i want to see how to fix it. |