Skip to content

Instantly share code, notes, and snippets.

@shirriff
Created February 10, 2014 01:52
Show Gist options
  • Save shirriff/17185e37cd45257636aa to your computer and use it in GitHub Desktop.
Save shirriff/17185e37cd45257636aa to your computer and use it in GitHub Desktop.
QBASIC game found in Bitcoin transaction 3a1c1cc760bffad4041cbfde56fbb5e29ea58fda416e9f4c4615becd65576fe7
10 REM The variables in life
20 ' life the lifespan of a creature
30 ' mates the number of mates a creature needs to breed
40 'move the type of land a creature can be on (1=earth 2=water 3=all)
50 'foodtype the type of food a creature can eat
60 'f2breed the amount of food a creature needs to breed
70 'a2breed the age a creature needs to breed
80 'cy(i) the y location of a creature
90 'cx(i) the x location of a creature
100 'cf(i) the amount of food a creature has
110 'ca(i) the age of a creature
120 CLS
130 COLOR 14, 0, 0
140 CLS
150 LOCATE 2, 30
160 PRINT "Life"
170 COLOR 7, 0, 0
180 LOCATE 20, 20
190 INPUT "Do you want to start (y/n) ? ", START$
200 IF START$ = "n" THEN END 'it will be gosub
210 REM
220 REM Setting attributes
230 LIFE = 5
240 MATES = 0
250 MOVE = 1
260 FOODTYPE = 1
270 F2BREED = 10
280 A2BREED = 1
290 F# = 10
300 C# = 5
305 CMUTA = 5
310 EPERYEAR = 1
320 REM
330 GOSUB 360
350 REM
360 REM placing creatures
370 COLOR 5, 6, 0
380 CLS
390 COLOR 14, 0, 0
400 FOR I = 1 TO C#
410 RANDOMIZE TIMER
420 Y = INT(RND * 21)
430 IF Y < 15 THEN GOTO 420
440 X = INT(RND * 61)
450 IF X < 15 THEN GOTO 440
460 LOCATE Y, X
470 CY(I) = Y 'This saves the creatures y
480 CX(I) = X 'This saves the creatures x
490 CF(I) = 10
500 CA(I) = 0
510 PRINT CHR$(2)
520 NEXT I
'530 RETURN
540 REM
550 REM This places the food
560 COLOR 2, 0, 0
570 FOR I = 1 TO F#
580 RANDOMIZE TIMER
590 Y = INT(RND * 21)
600 IF Y < 15 THEN GOTO 590
610 X = INT(RND * 61)
620 IF X < 15 THEN GOTO 610
630 LOCATE Y, X
640 FY(I) = Y 'This saves the foods y
650 FX(I) = X 'This saves the foods x
660 PRINT CHR$(5)
670 NEXT I
680 REM
690 REM Starts trapping
700 ON KEY(1) GOSUB 1480
710 KEY(1) ON
720 REM prompts to start
730 LOCATE 1, 1
740 PRINT "Press F1 to pause. "
750 REM
760 REM checks the creatures
770 REM can it breed
780 FOR I = 1 TO C#
790 IF CA(I) > A2BREED THEN GOTO 810
800 GOTO 960
810 IF CF(I) > F2BREED THEN GOTO 830
820 GOTO 960
830 FOOD# = FOOD# - F2BREED
840 RANDOMIZE 'TIMER
850 MUTA = INT(RND * CMUTA)
860 IF MUTA <> 1 THEN GOTO 920 'Checks to see if it mutates
870 LIFE = INT(RND * 101)
880 MATES = INT(RND * 3)
890 MOVE = INT(RND * 4)
900 FOOD = INT(RND * 4)
910 A = C#
920 C# = 1
930 GOSUB 360
940 C# = A
950 NEXT I
960 REM
970 REM moves the creatures
980 FOR I = 1 TO C#
990 RANDOMIZE TIMER
1000 A = INT(RND * 5)
1010 IF A = 1 THEN CY(I) = CY(I) + 1
1020 IF A = 2 THEN CY(I) = CY(I) - 1
1030 IF A = 3 THEN CX(I) = CX(I) + 1
1040 IF A = 4 THEN CX(I) = CX(I) - 1
1050 GOSUB 1380
1060 NEXT I
1070 REM **********
1080 REM is the creature on food
1090 FOR I = 1 TO C#
1100 FOR A = 1 TO F#
1110 IF CY(I) = FY(A) THEN YES = 1
1120 IF CX(I) = FX(A) THEN YES = YES + 1
1130 IF YES = 2 THEN GOSUB 1180
1140 NEXT A
1150 NEXT I
1160 GOSUB 1170
1165 GOTO 1250
1170 REM giving the creature food
1180 CF(I) = CF(I) + 1
1190 COLOR 2, 0, 0
1200 LOCATE FY(A), FX(A)
1210 PRINT " "
1220 FY(A) = 0 'DELETEs the foods y
1230 FX(A) = 0 'DELETEs the foods x
1240 RETURN
1250 REM dos it die
1260 FOR I = 1 TO C#
1270 IF CF(I) < 9 THEN GOSUB 1300
1280 NEXT I
1290 GOTO 1340
1300 COLOR 14, 0, 0
1310 LOCATE CY(I), CX(I)
1320 PRINT " "
1330 RETURN
1340 REM this takes away x food from a creature
1350 FOR I = 1 TO C#
1360 IF CA(I) MOD EPERYEAR > 0 THEN CF(I) = CF(I) - 1
1370 NEXT I
1380 REM this redraws the SCREEN
1385 COLOR 14, 6, 0
1390 CLS
1400 FOR I = 1 TO C#
1410 COLOR 14, 6, 0
1420 LOCATE CY(I), CX(I)
1430 PRINT CHR$(2)
1460 NEXT I
1464 LOCATE 1, 1
1465 INPUT "gsf", A
1470 GOTO 760
1480 COLOR 7, 0, 0
1490 END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment