04-29-2008, 10:40 AM
I am writing a heap of ascii sprites for dos and compiling them to *.exe . when you run it an ascii sprite appears at a random location. you can also specify the location through command line options. this is the code so far:
please post any suggestions, criticisms or comments
    LPG
Code:
'sheep.bas
'by LPG
RANDOMIZE TIMER
l = CSRLIN - 2Â Â Â 'save line number
' O###Â ascii sheep
'^^| |
w = 5 'width of sheep
h = 2 'height of sheep
c$ = COMMAND$Â 'get command line options
IF COMMAND$ = "" THEN GOSUB ranx: GOSUB rany: GOTO friend 'if there are no command specs create random locations
x = VAL(LEFT$(c$, 2))Â 'cut x out of c$
IF x < 1 OR x > 80 - w THEN GOSUB ranx 'check x
y = VAL(RIGHT$(c$, 2))Â 'cut y out of c$
IF y < 1 OR y > 25 - h OR y = l THEN GOSUB rany 'check y
friend:Â 'draw sprite at x,y
IF y = l THEN GOSUB rany 'check y
'draw sheep
LOCATE y, x
COLOR 8
PRINT " O";
COLOR 7
PRINT "###"
LOCATE y + 1, x
COLOR 2
PRINT "^";
COLOR 18
PRINT "^";
COLOR 8
PRINT "| |"
COLOR 7
'put the prompt where it started
LOCATE l, 1
PRINT "Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "
LOCATE l, 1
END
ranx:
x = INT(RND * (80 - w)) + 1Â 'make random x
RETURN
rany:
y = INT(RND * (25 - h)) + 1Â 'make random y
RETURN
please post any suggestions, criticisms or comments
    LPG
WHILE RPG$ <> "complete" : make up silly excuses :WEND