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

By Pineapple

Rookie (17)

Аватар пользователя 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

By chalky

Resident (56)

Аватар пользователя 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.)?

By pgimeno

Master (245)

Аватар пользователя 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.

By Dolphin101546015

Champion (282)

Аватар пользователя Dolphin101546015

19-05-2020, 03:15

Use X-Basic already. Cool

By Pineapple

Rookie (17)

Аватар пользователя Pineapple

21-05-2020, 03:45

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

By Dolphin101546015

Champion (282)

Аватар пользователя 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