I'm coding a game where you're a spider and you're trying to avoid fire. I'm coding the fire and when it hits the right edge it returns to the left edge and goes up and down it ad infinitum. I'm using the code from school free software as a base with some modification "bouncing ball animation".
test1.xdest and test1.ydest aren't being called anywhere else but in sub bounce and in the main do loop. I'm not sure why it's doing it.
SCREEN _NEWIMAGE(640, 480, 32)
RANDOMIZE TIMER
TYPE test 'player info
x AS INTEGER
y AS INTEGER
END TYPE
TYPE test1 'fire info
x AS INTEGER
y AS INTEGER
xdest AS INTEGER
ydest AS INTEGER
number AS INTEGER
fire AS LONG
END TYPE
DIM SHARED spider AS test
DIM SHARED test1 AS test1
test1.x = 0 'fire x chord
test1.y = 0 'fire y chord
test1.xdest = 1 '1 if fire is moving right 0 left
test1.ydest = 0 '1 up 0 down
test1.fire = _LOADIMAGE("./fire.png")
DO
PCOPY 1, _DISPLAY
CLS
IF _KEYDOWN(18432) THEN spider.y = spider.y - 5
IF _KEYDOWN(20480) THEN spider.y = spider.y + 5
IF _KEYDOWN(19200) THEN spider.x = spider.x - 5
IF _KEYDOWN(19712) THEN spider.x = spider.x + 5
CIRCLE (spider.x, spider.y), 5, _RGB(177, 83, 127)
_PUTIMAGE (test1.x, test1.y), test1.fire
IF test1.xdest = 1 THEN test1.x = test1.x + 5
IF test1.xdest = 0 THEN test1.x = text1.x - 5
IF test1.ydest = 1 THEN test1.y = test1.y - 5
IF test1.ydest = 0 THEN test1.y = test1.y + 5
bounce
border
WAIT &H3DA, &H3DA
WAIT &H3DA, &H3DA, 8
_DISPLAY
PCOPY _DISPLAY, 1
LOOP
SUB bounce 'makes the fire bounce
IF test1.x >= 628 THEN
test1.xdest = 0
END IF
IF test1.x <= 0 THEN
text1.xdest = 1
END IF
IF test1.y >= 468 THEN
test1.ydest = 1
END IF
IF test1.y <= 0 THEN
test1.ydest = 0
END IF
END SUB
SUB border 'prevents palyer from going OOB
IF spider.x > 630 THEN spider.x = spider.x - 5
IF spider.x < 0 THEN spider.x = spider.x + 5
IF spider.y > 470 THEN spider.y = spider.y - 5
IF spider.y < 0 THEN spider.y = spider.y + 5
END SUB
i figured it out, on line 37, i misspelled one of my variables, i put
text1.xinstead oftest1.x