elks-enhanced
public
Read
Owner: themaster
Branch: master
Commits: 6893
Updated: 2026-04-19 00:15
Git CLI clone URL
git clone https://www.xt-emporium.com/git/elks-enhanced.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
elks-enhanced
/
elkscmd
/
basic
/
snakecga.bas
File editor
100 REM port from www.quitebasic.com/prj/games/snake This version below is for CGA video mode and IBM PC 200 MODE 0 300 CLS 400 PRINT "=== Snake and Dots ===" 500 PRINT "UP: W" 600 PRINT "DOWN: Z" 700 PRINT "LEFT: A" 800 PRINT "RIGHT: S" 805 PRINT "=== Eat Red dot ===" 810 PRINT "=== Press Enter ===" 820 INPUT A$ 850 DIM G(325) 900 REM === Initialize === 905 MODE 4 910 COLOR 3,0 920 PLOT 0,0 930 DRAW 240,0 935 DRAW 240,120 940 DRAW 0,120 945 DRAW 0,0 950 F=0 1000 P=12 1010 Q=6 1020 G(P+Q*25+1)=1 1030 COLOR 1,0 1040 PLOT P*10,Q*10 1050 R=12 1060 S=5 1070 G(R+S*25+1)=1 1080 PLOT R*10,S*10 1085 COLOR 2,0 1090 G(20+10*25+1)=5 1100 PLOT 20*10,10*10 1110 REM === Keyboard input === 1120 C$=INKEY$ 1130 IF C$="W" OR C$="w" THEN G(P+Q*25+1)=1 1140 IF C$="Z" OR C$="z" THEN G(P+Q*25+1)=2 1150 IF C$="A" OR C$="a" THEN G(P+Q*25+1)=3 1160 IF C$="S" OR C$="s" THEN G(P+Q*25+1)=4 1170 REM === Move the snake === 1180 D=G(P+Q*25+1) 1190 GOSUB 9000+100*G(P+Q*25+1) 1200 P=P+U 1210 Q=Q+V 1220 IF P>24 OR P<0 OR Q>12 OR Q<0 THEN GOTO 7000 1230 IF G(P+Q*25+1) THEN GOTO 3000 1240 G(P+Q*25+1)=D 1250 COLOR 1,0 1260 PLOT P*10,Q*10 1280 GOSUB 9000+100*G(R+S*25+1) 1290 G(R+S*25+1)=0 1300 COLOR 0,0 1310 PLOT R*10,S*10 1320 R=R+U 1330 S=S+V 1340 PAUSE 300 1350 GOTO 1110 3000 REM Collision detection 3010 IF G(P+Q*25+1)<=4 THEN GOTO 7000 3020 F=F+1 3025 REM POSITION 0,6 3040 REM PRINT "=== Snake and Dots ===" 3050 REM PRINT "Score: ",F 3060 G(P+Q*25+1)=D 3070 COLOR 1,0 3080 PLOT P*10,Q*10 3090 REM Add a new dot 3100 A=INT(RND*23)+1 3110 B=INT(RND*11)+1 3120 IF G(A+B*25+1) THEN GOTO 3060 3130 COLOR 2,0 3140 PLOT A*10,B*10 3150 G(A+B*25+1)=5 3160 GOTO 1130 7000 REM === Game Over === 7002 MODE 0 7005 POSITION 0,6 7010 PRINT "=== Snake and Dots ===" 7020 PRINT " Game Over" 7030 PRINT "Total score: ",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 STOP 9000 REM Subroutines mapping the direction number 9100 U=0 9110 V=1 9120 RETURN 9200 U=0 9210 V=-1 9220 RETURN 9300 U=-1 9310 V=0 9320 RETURN 9400 U=1 9410 V=0 9420 RETURN
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
master
Visibility
public
Your access
Read
Remote
Configured
File activity
View file history