> Quite BASIC
>
Welcome to the clubhouse!
User login
Username:
*
Password:
*
Create new account
Request new password
Navigation
Quite BASIC
Blog
Projects
Help
Forums
Snake Skin
Posted
July 7th, 2007
by
Anna Conda
in
Games
Your vote:
Current rating:
1
2
3
4
5
Category
Games
Description
A variant of the Snake game but with a snake skin that moves.
>> See More projects by Anna Conda
Level
>> Open this project at the main Quite BASIC Page
1000 REM Snake and Dots 1010 REM Quite BASIC Game Project 1020 REM ------------------------ 1030 CLS 1040 PRINT "== Snake and Dots ==" 1050 PRINT "UP: W" 1060 PRINT "DOWN: Z" 1070 PRINT "LEFT: A" 1080 PRINT "RIGHT: S" 2000 REM The array G holds one entry for each pixel 2010 REM (X, Y) maps to G[X + Y*25] 2020 REM A non-zero value in G means either the snake occupies the pixel or there is a dot on the pixel 2030 REM A dot is encoded by the value 5 2040 REM If the snake occupies the pixel, the value in G indicates the direction of the snake's motion 2050 REM 1=up, 2=down, 3=left, 4=right 2060 REM The Subroutines 9100, 9200, 9300, 9400 can be selected by adding 100 * D + 9000, where D is one of the directions 1, 2, 3, or 4 2070 ARRAY G 2080 REM === Initialize === 2090 LET P = 12 2100 LET Q = 12 2110 LET G[P + Q *25] = 1 2120 PLOT P, Q, "green" 2130 LET R = 12 2140 LET S = 11 2150 LET G[R + S*25] = 1 2160 PLOT R, S, "green" 2170 LET G[20 + 20*25] = 5 2171 ARRAY W 2172 LET W[0] = "orange" 2173 LET W[1] = "black" 2173 LET W[2] = "red" 2173 LET W[3] = "black" 2174 LET W[4] = "orange" 2175 LET W[5] = "green" 2176 LET W[6] = "green" 2180 PLOT 20, 20, W[0] 2300 REM === Keyboard input === 2310 LET C = UPPERCASE(GETCHAR()) 2320 IF C = "W" THEN LET G[P + Q*25] = 1 2330 IF C = "Z" THEN LET G[P + Q*25] = 2 2340 IF C = "A" THEN LET G[P + Q*25] = 3 2350 IF C = "S" THEN LET G[P + Q*25] = 4 2500 REM === Move the snake === 2510 LET D = G[P + Q*25] 2520 GOSUB 9000 + 100*D 2530 LET P = P + U 2540 LET Q = Q + V 2550 IF P > 24 OR P < 0 OR Q > 24 OR Q < 0 THEN GOTO 7000 2560 IF G[P + Q*25] THEN GOTO 3000 2565 LET G[P + Q*25] = D 2571 LET N = COLOR(R, S) 2571 PLOT R, S, "gray" 2572 LET D = G[R + S*25] 2573 LET G[R + S*25] = 0 2573 GOSUB 9000 + 100*D 2574 LET R = R + U 2575 LET S = S + V 2576 LET A = R 2577 LET B = S 2578 LET D = G[A + B*25] 2580 GOSUB 9000 + 100*D 2584 LET M = COLOR(A, B) 2581 PLOT A, B, N 2585 LET N = M 2582 LET A = A + U 2583 LET B = B + V 2586 IF A <> P OR B <> Q THEN GOTO 2578 2587 PLOT A, B, N 2650 PAUSE (6 - LEVEL) / (F/4 + 1) * 75 + 10 * (5 - LEVEL) 2660 GOTO 2300 3000 REM Collision detection 3010 IF G[P + Q *25] <= 4 THEN GOTO 7000 3020 LET F = F + 1 3030 CLT 3040 PRINT "== Snake and Dots ==" 3050 PRINT "Dots: " + F 3060 LET G[P + Q *25] = D 3080 REM Add a new dot 3090 LET A = FLOOR(RAND(24)) 3100 LET B = FLOOR(RAND(24)) 3110 IF G[A + B *25] THEN GOTO 3060 3120 PLOT A, B, W[F%7] 3130 LET G[A + B *25] = 5 3140 GOTO 2320 7000 REM === Game Over === 7010 CLT 7010 PRINT "== Snake and Dots ==" 7020 PRINT " Game Over" 7030 PRINT "Total dots: " + F 7040 IF F < 5 THEN PRINT "- Ouch!" 7050 IF F >= 5 AND F < 15 THEN PRINT "- Nice Try!" 7060 IF F >= 15 AND F < 50 THEN PRINT "- Way to go!" 7070 IF F >= 50 AND F < 250 THEN PRINT "- Great score!" 7080 IF F >= 250 THEN PRINT "-- Amazing score!" 7090 PRINT "==========" 7100 END 9000 REM Subroutines mapping the direction number in D (1, 2, 3, or 4) to a vector (U, V) 9100 LET U = 0 9110 LET V = 1 9120 RETURN 9200 LET U = 0 9210 LET V = -1 9220 RETURN 9300 LET U = -1 9310 LET V = 0 9320 RETURN 9400 LET U = 1 9410 LET V = 0 9420 RETURN
Login
or
register
to post comments
Popular Projects
Trebuchet II
New version with a mini story plus the popups are gone (yay!). And watch out for the dragon! The popup is replaced by pressing +/- to change the angle and pressing 1-9 to set the force.
Pong with Scoring
A version of the Ping Pong game that keeps the score
Snake Skin
A variant of the Snake game but with a snake skin that moves.
Countries Hangman
A version of the Hangman game where the words are all countries
Tool Name Hangman
A version of the Hangman game for tools.
more
Who's online
There are currently
0 users
and
0 guests
online.
Who's new
darylroy
sage sklar
masonsd
ace
JavaAnders
Active forum topics
Members
more
New forum topics
Members
more