On Sprite Gosub in basic - Is it supposed to be this slow?

Por Pineapple

Resident (45)

Imagen del Pineapple

17-05-2020, 19:21

10 SPRITE$(0)=CHR$(&H0)+CHR$(&H0)+CHR$(&H0)+CHR$(&HFF)+CHR$(&H0)+CHR$(&H0)+CHR$(&H0)+CHR$(&H0)
20 SPRITE$(1)=CHR$(&H1)+CHR$(&H1)+CHR$(&H1)+CHR$(&H1)+CHR$(&H1)+CHR$(&H1)+CHR$(&H1)+CHR$(&H1)
30 PUT SPRITE 1,(128,96),15,1
35 SPRITE ON
40 X=X+1
50 PUT SPRITE 0,(X,96),12,0
55 ON SPRITE GOSUB 90
60 GOTO 40
90 PRINT X:END

I seem to be getting consistent results with sprite collisions where the program registers the collision 2 frames late.
Am I doing something wrong, or does it just work like this?
Is there a better implementation?

I'm using screen1, BTW

Thanks.

Login sesión o register para postear comentarios

Por chalky

Expert (67)

Imagen del chalky

17-05-2020, 20:37

I think it's a little faster if you move line 55 to before line 35 (as you only need to set it up once rather than every pass)...

10 SPRITE$(0)=CHR$(&H0)+CHR$(&H0)+CHR$(&H0)+CHR$(&HFF)+CHR$(&H0)+CHR$(&H0)+CHR$(&H0)+CHR$(&H0)
20 SPRITE$(1)=CHR$(&H1)+CHR$(&H1)+CHR$(&H1)+CHR$(&H1)+CHR$(&H1)+CHR$(&H1)+CHR$(&H1)+CHR$(&H1)
30 PUT SPRITE 1,(128,96),15,1
32 ON SPRITE GOSUB 90
35 SPRITE ON
40 X=X+1
50 PUT SPRITE 0,(X,96),12,0
60 GOTO 40
90 PRINT X:END

...DEFINTX might help too - but either way the increase is not massive.

I'm not sure why the collision is late - maybe it's to do with the way the MSX BASIC handles hit-points in sprites (are they top left, middle, etc.)?

Por pgimeno

Champion (328)

Imagen del pgimeno

18-05-2020, 04:05

Your sprite is moving faster than 1 pixel per frame (128 pixels in about 1 second), but the VDP does not necessarily check sprite collisions immediately, only when it renders them, i.e. once per frame.

Por Dolphin101546015

Champion (336)

Imagen del Dolphin101546015

19-05-2020, 03:15

Use X-Basic already. Cool

Por Pineapple

Resident (45)

Imagen del Pineapple

21-05-2020, 03:45

Looks like I need to study up more on MSX programming.
Tongue

Por Dolphin101546015

Champion (336)

Imagen del Dolphin101546015

21-05-2020, 09:49

Pineapple wrote:

Looks like I need to study up more on MSX programming.
Tongue

No just use X-Basic extention, and your program Wink