I'm struggling to understand why the following code not works (sprite is not moving) when I use a variable in the SPRITE instruction (s or THIS.spr instead of 0).
If you decomment the 2 lines commented below (and comment the next one), it works. Why?
Tested on latest version 3.1, no error or warning during compilation:
' This code doesn't work. If you decomment the 2 lines and comment the following one, it works. Why?
TYPE TSPRITE
spr AS BYTE
x AS INT
y AS BYTE
SUB setPosition() STATIC
'SPRITE 0 AT THIS.x, THIS.y
SPRITE THIS.spr AT THIS.x, THIS.y
END SUB
SUB move() STATIC
THIS.x = THIS.x + 1
CALL THIS.setPosition()
END SUB
SUB init(s as BYTE, px AS INT, py AS BYTE, c AS BYTE) STATIC
'SPRITE 0 ON COLOR 7
SPRITE s ON COLOR c
THIS.spr = s
THIS.x = px
THIS.y = py
CALL THIS.setPosition()
END SUB
END TYPE
DIM spr AS TSPRITE
CALL spr.init(0, 24, 100, 7)
FOR k as INT = 0 TO 320
CALL spr.move()
DO WHILE PEEK($D012) <> 240: LOOP
NEXT
Notice that if I put the variable s between parathesis, the compiler crash (not sure if it's related):
SPRITE (s) ON COLOR c
object.Exception@source\language\factor.d(118): Add case for XCBASIC.Factor
----------------
0x00007FF713015A37
0x00007FF712EDAEB1
0x00007FF712F16096
0x00007FF712ED8BEE
3
0x00007FF712ED8BF8
0x00007FF712EDA1B8
4
0x00007FF712ED8BF8
0x00007FF712F5F083
0x00007FF712EC2DFD
0x00007FF712EC3724
2
0x00007FF712EC376B
0x00007FF712D62E06
0x00007FF71302DFE3
0x00007FF71302DE3F
0x00007FF71302DF3F
0x00007FF71302DE3F
0x00007FF71302DD4A
0x00007FF713017F29
0x00007FF712D68422
0x00007FF71308A53C
0x00007FFE54F17614 in BaseThreadInitThunk
0x00007FFE551226F1 in RtlUserThreadStart
Hi again,
I'm struggling to understand why the following code not works (sprite is not moving) when I use a variable in the
SPRITE
instruction (s
orTHIS.spr
instead of0
). If you decomment the 2 lines commented below (and comment the next one), it works. Why? Tested on latest version 3.1, no error or warning during compilation:Notice that if I put the variable
s
between parathesis, the compiler crash (not sure if it's related):SPRITE (s) ON COLOR c