'=========================================================================== ' Subject: TRON LIKE GAME Date: 03-17-97 (12:30) ' Author: Angelo Ken Pesce Code: QB, QBasic, PDS ' Origin: us0082@uniserv.uniplan.it Packet: GAMES.ABC '=========================================================================== DECLARE SUB upd () DECLARE SUB harder () DECLARE SUB initpl1 () DECLARE SUB initsc () DECLARE SUB updpal () DECLARE SUB er (i%) DECLARE SUB dodel (i%) DECLARE SUB update (i%, a$) DECLARE SUB initpl () DEFINT A-Z TYPE ply xp AS INTEGER yp AS INTEGER xd AS INTEGER yd AS INTEGER up AS STRING * 1 down AS STRING * 1 left AS STRING * 1 right AS STRING * 1 col AS INTEGER END TYPE '------------------------------------------------------------------------- CLS COLOR 4 PRINT "TRON "; : COLOR 6: PRINT " v1.2 "; : COLOR 4: PRINT " By Angelo KEN Pesce||ken at uniserv.uniplan.it" COLOR 6 PRINT "Players (min 2-max 3)"; : COLOR 14: INPUT i$ in = VAL(i$) DIM SHARED players AS INTEGER IF in > 3 OR in < 2 THEN players = 2 ELSE players = in DIM SHARED p(players) AS ply DIM SHARED plist(players) AS INTEGER DIM SHARED dec1, dec2, dec3 AS INTEGER DIM SHARED test, delay AS INTEGER DIM SHARED keyp AS STRING COLOR 6 PRINT "Delay (100 = Pentium 75 using Qbasic 1.1)"; : COLOR 14: INPUT ii$ delay = VAL(ii$) IF ii$ = "" THEN delay = 100 COLOR 6 PRINT "Level (1-2)"; : COLOR 14: INPUT lv$ CLS initpl strt: initsc IF VAL(lv$) = 2 THEN CALL harder initpl1 ' ----------------------------------------------------------------------- DO test = 2 keyp = INKEY$ CALL upd LOOP WHILE test > 1 FOR i = 1 TO players IF plist(i) = 0 THEN CLS : SCREEN 0: WIDTH 80: COLOR 4: PRINT "The winner is player"; i: EXIT FOR NEXT INPUT "Another Game (y/n)"; y$ IF y$ = "y" THEN GOTO strt END SUB dodel (i) FOR ddel = 1 TO i FOR ddel1 = 1 TO i NEXT 'keyp = INKEY$: IF keyp <> "" THEN CALL upd NEXT END SUB SUB er (i) FOR x = 0 TO 319 FOR y = 0 TO 199 IF POINT(x, y) = i THEN PSET (x, y), 0 NEXT NEXT END SUB SUB harder LINE (160, 40)-(160, 159), 4 END SUB SUB initpl FOR i = 1 TO players COLOR 4 PRINT "Player"; i COLOR 6 PRINT "UP "; DO: a$ = INKEY$: LOOP WHILE a$ = "" COLOR 14 p(i).up = a$: PRINT a$ COLOR 6 PRINT "DOWN "; DO: a$ = INKEY$: LOOP WHILE a$ = "" COLOR 14 p(i).down = a$: PRINT a$ COLOR 6 PRINT "LEFT "; DO: a$ = INKEY$: LOOP WHILE a$ = "" COLOR 14 p(i).left = a$: PRINT a$ COLOR 6 PRINT "RIGHT "; DO: a$ = INKEY$: LOOP WHILE a$ = "" COLOR 14 p(i).right = a$: PRINT a$ PRINT NEXT CLS END SUB SUB initpl1 FOR i = 1 TO players p(i).xp = 130 + (i * 10) p(i).yp = 70 + (i * 10) p(i).xd = 0 p(i).yd = 1 p(i).col = i plist(i) = 0 NEXT END SUB SUB initsc SCREEN 13 PALETTE 1, 63 PALETTE 2, 256 * 32 + 32 PALETTE 3, 256 * 63 + 63 PALETTE 4, 65536 * 63 PALETTE 5, 65536 * 40 LINE (0, 16)-(319, 16), 4 LINE (0, 15)-(319, 15), 5 LINE (0, 17)-(319, 17), 5 FOR i = 0 TO 3 LINE (0, i)-(319, i), 1 NEXT FOR i = 5 TO 8 LINE (0, i)-(319, i), 2 NEXT FOR i = 10 TO 13 LINE (0, i)-(319, i), 3 NEXT LINE (0, 199)-(319, 199), 4 LINE (0, 0)-(0, 199), 4 LINE (319, 0)-(319, 199), 4 END SUB SUB upd test = 0 FOR i = 1 TO players IF plist(i) = 0 THEN CALL update(i, keyp): test = test + 1 NEXT CALL dodel(delay) END SUB SUB update (i, a$) SELECT CASE a$ CASE IS = "" ' do nothing CASE IS = p(i).up p(i).yd = -1 p(i).xd = 0 CASE IS = p(i).down p(i).yd = 1 p(i).xd = 0 CASE IS = p(i).left p(i).xd = -1 p(i).yd = 0 CASE IS = p(i).right p(i).xd = 1 p(i).yd = 0 END SELECT p(i).yp = p(i).yp + p(i).yd p(i).xp = p(i).xp + p(i).xd IF POINT(p(i).xp, p(i).yp) <> 0 THEN CALL er(i): plist(i) = 1: EXIT SUB PSET (p(i).xp, p(i).yp), p(i).col END SUB