Nibbler A Fun Snake Game
Author |
Message |
Codi
|
Posted: Tue May 09, 2006 9:08 am Post subject: Nibbler A Fun Snake Game |
|
|
% Codi
colorback (black)
cls
View.Set (" nocursor, noecho graphics maxx;maxy") % No Blinking thing, when you type somehting it dosent oput to screen and size of screen%
var ch, oldch : string (1) := " "
var row, col, face : int
color (brightgreen)
row := maxrow div 2 % start in middle of screen
col := maxcol div 2 % middle of screen
face := 1
var taillength : int := 1 % Variables
var hec : string
var count := 0
var Lives : int := 5
var lvl : string
proc menu
Draw.FillMapleLeaf( 25,25,100,100, brightgreen)
put " Welcome to The Worm Game"
put " Would you like to Play Type Yes or No"
get hec
if hec = "No" then
cls
put " JERK"
quit
else
put " Good i Knew you would now here are the rules"
put " Use the Directinal keys to move the snake around and try to get you tail as big as possible"
put " but beware you have to eat food food look like this * dont eat anyhting but them and you only have"
put " a certain amount of lives so give it a shot"
delay (1)
cls
end if
end menu
menu
var foodrow, pfoodrow : int % row and col for the food
var foodcol, pfoodcol : int
var food : int
var pfood : int
var tailrow, tailcol : array 1 .. 100 of int %varianbles for tail length
for i : 1 .. 100
tailrow (i) := row % inital values
tailcol (i) := col
end for
proc thetail
locate (tailrow (taillength), tailcol (taillength))
put " " .. % erases last tail
for decreasing i : taillength .. 2
tailrow (i) := tailrow (i - 1)
tailcol (i) := tailcol (i - 1)
end for
tailrow (1) := row
tailcol (1) := col
locate (tailrow (1), tailcol (1))
put "=" .. % draw snake tail inplace of snake
end thetail
proc putfood
foodrow := Rand.Int (1, 25)
foodcol := Rand.Int (1, 80)
food := 42
locate (foodrow, foodcol)
put chr (food) ..
end putfood
proc poisinfood
pfoodrow := Rand.Int (2, 24)
pfoodcol := Rand.Int (2, 79)
pfood := 177
locate (pfoodrow, pfoodcol)
put chr (pfood) ..
if row = pfoodrow and col = pfoodcol then
put " You eated Posin Food! now you have to start all over again!!"
menu
end if
end poisinfood
proc tailcheck
for i : 2 .. taillength
if row = tailrow (i) and col = tailcol (i) then
locate (maxrow div 2, maxcol div 2 - 10)
cls
put " You ate Your Tail ! You Loose a Life!"
delay (1000)
cls
Lives := Lives - 1
poisinfood
putfood
end if
end for
end tailcheck
proc foodandlivescount
color (brightgreen)
locate (1, 1)
put " You have ", count, " Food. You have ", Lives, " lives left"
if Lives = 0 then
put " You Died Please Play Again."
delay (1000)
cls
menu
end if
end foodandlivescount
poisinfood % Procedure
putfood
%main Line%
proc move
if hasch then
oldch := ch
getch (ch)
end if
%delay (50) % delays it for 50 milliseconds
% Up, Down, Left, Right Keys%
if ord (ch) = 200 then
row := row - 1 % Up
elsif ord (ch) = 208 then
row := row + 1 % Down
elsif ord (ch) = 205 then
col := col + 1 % right
elsif ord (ch) = 203 then
col := col - 1 % left
else
ch := oldch
end if
%locate (row, col)
%put chr (face) .. % puts my character i chosen to the screen%
end move
%food
loop
move
foodandlivescount
if foodrow = row and foodcol = col then
putfood
poisinfood
taillength := taillength + 1
count := count + 1
end if
if row = pfoodrow and col = pfoodcol then
poisinfood
putfood
cls
locate (maxrow div 2, maxcol div 2 - 12)
put "You Ate Posin Food Loose A Life!"
Lives := Lives - 1
delay (1000)
cls
putfood
poisinfood
if count = 20 then
if hasch then
oldch := ch
getch (ch)
end if
%delay (50) % delays it for 50 milliseconds
% Up, Down, Left, Right Keys%
if ord (ch) = 200 then
row := row - 2% Up
elsif ord (ch) = 208 then
row := row + 2 % Down
elsif ord (ch) = 205 then
col := col + 2 % right
elsif ord (ch) = 203 then
col := col - 2 % left
else
ch := oldch
end if
cls
put " 1 UP!"
Lives := Lives + 1
putfood
poisinfood
end if
if Lives = 0 then
locate (maxrow div 2, maxcol div 2 - 12)
cls
put " You Dies Please PLay Again"
delay (3000)
cls
menu
end if
locate (1, 1)
put " You Only Have ", Lives, " Lives Left!"
end if
% check boundries
if row = 0 then
row := maxrow % makes Nibbler apear on the oppisit side of the screen%
elsif col = 0 then
col := maxcol % makes Nibbler apear on the oppisit side of the screen%
elsif row = maxrow + 1 then
row := 1 % makes Nibbler apear on the oppisit side of the screen%
elsif col = maxcol + 1 then
col := 1 % makes Nibbler apear on the oppisit side of the screen%
else
locate (row, col)
put chr (face) .. % puts my character i chosen to the screen%
end if
delay (50)
thetail
tailcheck
end loop |
|
|
|
|
|
Sponsor Sponsor
|
|
|
jamonathin
|
Posted: Tue May 09, 2006 9:27 am Post subject: (No subject) |
|
|
First and foremost, please use these when showing code.
Secondly, nice little game. It something a little different then your ordinary snake, kind of. Maybe adjust the speed when going up and down so you're not flying at warp 8.
Also, i kept saying "no", i dont want to play, then it would loop back and insist that i play. When dealing with user inputed text, use Str.Upper - such as:
code: | get hec
if Str.Upper(hec) = "NO" then
cls
put " JERK"
end if
|
That way case wont matter. Good work on it. |
|
|
|
|
|
RedRogueXIII
|
Posted: Sun May 14, 2006 3:32 pm Post subject: (No subject) |
|
|
Pretty good, the only problems i had where the speed going up and down to fast, in proportion with left and right, and that the snake could eat itself and continue eating up its lives when you pressed the direction oppostie to where the snake is and collide with the body behind the head. eg if you were going left and pressed right then you'd die and respawn but go in the same direction again and die again, effectively eating up all your lives.
Anyways i like how it was done as text though. |
|
|
|
|
|
Isaac
|
Posted: Sun May 14, 2006 10:05 pm Post subject: (No subject) |
|
|
I'd have to agree with what red and jam said, but there is a bug I'd like to point out; the 'food' popped up off screen. So yeah I ended up eating all the posion food instead of the real food. Haha.
Cool game. |
|
|
|
|
|
Carey
|
Posted: Mon May 15, 2006 9:31 am Post subject: (No subject) |
|
|
another bug
when you eat the poison food that apperared with the last real food it does nothing
example:
level one : food1 appears, poison1 appears, you eat the food and the poison stays there
level two :food2 appears, poison2 appears, you eat poison1 it does nothing
you should erase the poison food from the last level or make it so you lose a life when you eat it
also minor bug:
you dont see the "JERK!" when you say you dont want to play because the window exits try putting and Input.Pause or a delay there |
|
|
|
|
|
[Gandalf]
|
Posted: Tue May 16, 2006 2:38 am Post subject: (No subject) |
|
|
Yep, the difference between poison and non-poisionous food is not very clear...
Other than that, just one comment:
You probably do not know this, but your game is very similar to the original Nibbles programmed in BASIC. Both were graphical, but they both used text characters as graphics. To create the snake and food, I believe they used the 219th character on the ASCII table which creates a ■.
Yes... Nibbles is an amazing game. |
|
|
|
|
|
War_Caymore
|
Posted: Thu May 18, 2006 12:49 pm Post subject: (No subject) |
|
|
Good game, a little fast paced but that makes it more difficult. Also, when you are asked to play again, your lives start at 0. This can be easily fixed.
After your entier program is finnised, put:
So that when you re-start the game after you lsot all your lives, you start with 5 lives again. Other than that, good job.
Bits for you |
|
|
|
|
|
Rocket
|
Posted: Thu May 18, 2006 5:36 pm Post subject: (No subject) |
|
|
allright, but you shouldnt be able to eat your own tail and i dont know why he goes faster up and down than side to side |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Codi
|
Posted: Wed May 24, 2006 1:03 pm Post subject: (No subject) |
|
|
heis suposted to be able to eat tail it makes it harder |
|
|
|
|
|
|
|