## getting bulky sprite to move

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

qbasicisfun
Newbie
Posts: 1
Joined: Wed Nov 14, 2012 3:02 am

### getting bulky sprite to move

Hello, new to these forums but have been lurking for a few days now. I'm new to coding in BASIC and have been learning the functions slowly but surely. I feel pretty comfortable with all the basic concepts so far (Do/loop, For/next, If/then, While/Wend, AND vs OR vs NOT, arrays, etc.), but I've been struggling greatly with trying to move a sprite. I was able move a circle with ease using similar code (granted I didn't store it in an array), but moving the sprite is defeating me.

I have tried many methods, and this is my most recent. My other code (which I can post later), would draw the sprite in question, but when moving, it would simply give me an OUT OF DATA error. This most recent code, now tells me Subscript range. So it has to be something I am doing with the array and not understanding the concept.

I really appreciate any help given as it's driving me crazy!

(Shout out to Ted Felix for the bird sprite):

DIM xst AS INTEGER
DIM yst AS INTEGER
DIM count AS INTEGER
DIM count2 AS INTEGER
DIM bird(14, 14) REM honestly unsure of the bounds at this point
DIM letter AS STRING
REM variables dimmed early to avoid confusion

SCREEN 13

LET xst = 0
LET yst = 0
LET count = xst + 14
LET count2 = yst + 14
REM set them equal to a value to avoid confusion

DATA 00,00,00,00,00,00,00,00,00,00,12,12,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,15,15,00,00,00
DATA 00,00,00,00,00,00,00,00,00,15,15,15,15,00,00
DATA 00,00,00,00,00,00,00,00,00,15,15,00,15,00,00
DATA 00,00,00,00,00,00,00,00,15,15,15,15,15,14,00
DATA 00,00,00,00,15,15,15,15,15,15,15,15,15,14,14
DATA 15,00,15,15,15,15,00,15,15,15,15,15,00,00,00
DATA 00,15,15,15,15,00,15,15,15,15,15,00,00,00,00
DATA 15,00,15,15,00,15,15,15,15,15,15,00,00,00,00
DATA 00,15,15,15,15,00,00,15,15,15,15,00,00,00,00
DATA 15,00,15,15,15,15,15,15,15,15,00,00,00,00,00
DATA 00,00,00,00,00,00,15,15,15,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,14,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,14,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,14,14,14,00,00,00,00,00,00
REM pixel from Ted Felix

FOR y = 0 TO 14
FOR x = 0 TO 14
NEXT x
NEXT y
REM stores the data read into an array of bird(x,y)

DO
letter = INKEY\$
IF letter = "d" THEN
FOR y = yst TO count2
FOR x = xst TO count
PSET (x, y), bird(x, y)
NEXT x
NEXT y
LET xst = xst + 10
LET count = xst + 14
END IF
LOOP UNTIL INKEY\$ = ""
REM unless esc is pressed, will continue in an idle state
REM or if d is pressed, object should theoretically move right