
Need help on SUB in fishtank.bas
With some examples from the book and from this group, I have proceeded
to use a SUB for the plant in the fishtank program.
However, I am not completely in control of the plant generated in the
SUB sea (col%, row%)
I thought naming it that would allow me to move the plant that gets
generated by changing the numbers in the CALL statement.
Is this not correct?
My entire FISHTANK program (text version of .bas file) is below
(minus the fish sprites).
If you can clue me in to how the SUB can be made to move to different
pos left and right on screen, I would appreciate it.
Thanks,
Glo
' ======================fishtank.bas=====================================
DECLARE SUB sea (col%, row%)
SCREEN 13
PALETTE 255, 63 * 65536 + 63 * 256 + 63
DEFINT A-Z
READ n
READ f$
OPEN f$ FOR INPUT AS 1: CLOSE 1
OPEN f$ FOR BINARY AS 1
t$ = SPACE$(4)
GET #1, 1, t$
tx = ASC(MID$(t$, 1, 1))
ty = ASC(MID$(t$, 2, 1))
u = INT(tx * ty / 2) + 1 + 2 'the size of one sprite
DIM sprite(1 TO u * n) AS INTEGER 'create the arrays
DIM mask(1 TO u * n) AS INTEGER
CLOSE 1
RESTORE: READ n
FOR i = 1 TO n
READ f$
OPEN f$ FOR INPUT AS 1: CLOSE 1
OPEN f$ FOR BINARY AS 1
sprite((i - 1) * u + 1) = tx * 8: sprite((i - 1) * u + 2) = ty
mask((i - 1) * u + 1) = tx * 8: mask((i - 1) * u + 2) = ty
s$ = SPACE$((LOF(1) - 4) / 2)
m$ = s$
GET #1, 5, s$
GET #1, , m$
FOR j = 1 TO LEN(s$)
DEF SEG = VARSEG(sprite(1))
POKE j + 3 + (i - 1) * u * 2, ASC(MID$(s$, j, 1))
DEF SEG = VARSEG(mask(1))
POKE j + 3 + (i - 1) * u * 2, NOT ASC(MID$(m$, j, 1))
NEXT j
CLOSE 1
NEXT i
DEF SEG
' ****Background colors of tank ****
LINE (0, 200)-(320, 0), 1, BF
LINE (1, 130)-(320, 200), 119, BF
'**** attempts at making plants ****
'***Calling a SUB for seaweed as shown in RevQB book ***
CALL sea(150, 110)
DIM Back(1 TO u) AS INTEGER
px = INT(RND * (320 - tx))
py = INT(RND * (200 - ty))
GET (px, py)-(px + tx - 1, py + ty - 1), Back
DO
FOR i = 1 TO n
PUT (px, py), Back, PSET
px = px + 1
px = px MOD (320 - tx)
py = py + 1
py = py MOD (200 - tx)
GET (px, py)-(px + tx - 1, py + ty - 1), Back
PUT (px, py), mask((i - 1) * u + 1), AND
PUT (px, py), sprite((i - 1) * u + 1), OR
FOR zz& = 1 TO 24000: NEXT zz& ' controls speed of sprite's motion
IF INKEY$ <> "" THEN END
NEXT i
LOOP
DATA 7: 'the number of sprite per animation
DATA "c:\sprt5\fish1.spr": 'first sprite
DATA "c:\sprt5\fish2.spr": '2nd sprite
DATA "c:\sprt5\fish3.spr":
DATA "c:\sprt5\fish4.spr":
DATA "c:\sprt5\fish3.spr":
DATA "c:\sprt5\fish2.spr":
DATA "c:\sprt5\fish1.spr":
SUB sea (col%, row%)
FOR i = 0 TO 2
seaweed$ = "c10 e3 u5 h3 u4 e3 u5 e3 u4 h3 l4 g3 d4 f3 r4"
DRAW "X" + VARPTR$(seaweed$)
seaweed$ = "c10 ta15 e3 u5 h3 u4 e3 u5 e3 u4 h3 l4 g3 d4 f3 r4"
DRAW "X" + VARPTR$(seaweed$)
NEXT i
END SUB