Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ASCII sprites
#1
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:
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
Reply


Messages In This Thread
ASCII sprites - by LPG - 04-29-2008, 10:40 AM
Re: ASCII sprites - by zoasterboy - 04-30-2008, 09:51 PM
Re: ASCII sprites - by LPG - 05-01-2008, 07:44 AM
Re: ASCII sprites - by zoasterboy - 05-02-2008, 09:39 PM
Re: ASCII sprites - by LPG - 05-03-2008, 10:02 AM
Re: ASCII sprites - by zoasterboy - 05-07-2008, 09:16 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)