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
#2
Looks like a good start for a simple screen saver. Have you had any experience opening and saving data into sequential data files? I would recommend setting it up so that you can build the sprite in some sort of simple editor, save it into a file, and then open it with this program. Then people could make their own little screen saver.

If you need any help getting started with that I could show you how it could work.
-yah
Reply
#3
I thought of it not as a screen saver but as a distraction at the command prompt. sort of like the windows E-Sheep
http://www.montagar.com/~patj/esheep.exe
WHILE RPG$ <> "complete" : make up silly excuses :WEND
Reply
#4
That's a good idea, but the problem is that while the program is running you wont be able to type commands.

One thing that you could do is have the sheep program pass any commands typed to the command prompt:

Code:
DO
    Random1% = 'random number gen
    Random2% = 'random number gen
    Random3% = 'random number gen
    IF Random1% = 32 THEN 'Decides if sheep should be moved based on random num.
        LOCATE Random2%, Random3%: PRINT "Sheep" 'Prints random sheep.
    END IF
    INPUT CMD$ 'Waits for user command.
    SHELL CMD$ 'Sends users command to the command prompt.
LOOP

This is a very simple example, but each time the user enters a command there is a probability that the sheep moves to a new random location. The old sheep will still exist.
-yah
Reply
#5
When you run the sheep program as an EXE it leaves the sheep on the screen after the program terminates. the grass infront of the sheep flashes because screen 0 supports blinking colours.
WHILE RPG$ <> "complete" : make up silly excuses :WEND
Reply
#6
Ah ok, I was thinking you wanted it to randomly move around while the person is typing commands and whatnot, because it will disappear once the screen is cleared or other text pushes it up.
-yah
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)