LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Confused, need help.

Root / Programming Questions / [.]

KrondeloCreated:
I keep looking at the code, but it's not doing what I would expect. Am I missing something obvious?
T=30
P[T]
FOR I%=0 TO T-1
  SPSET P[I%],0,0
  PX[I%]=RND(5)+185
  PY[I%]=RND(2)+220
  SPOFS P[I%],PX[I%],PY[I%]
  VSYNC
NEXT
So I would expect to see each of these sprites be assigned their location and then they should stay there. However they don't, it looks like one sprite jumping around and then I am left with one sprite in one position.

Solved, someone can delete this post? and @PetNet, no you need SPSET to define the 30 sprites. The issue was the array P[] was full of zeroes.

Basically, this is supposed to define the 30 sprites, and assign each of them a somewhat random position and keep them there. SPOFS controls sprites but it also defines where they start. The next function (not shown) will control the movement.

No worries, thanks for trying to help at least!

I keep looking at the code, but it's not doing what I would expect. Am I missing something obvious?
T=30
P[T]
FOR I%=0 TO T-1
  SPSET P[I%],0,0
  PX[I%]=RND(5)+185
  PY[I%]=RND(2)+220
  SPOFS P[I%],PX[I%],PY[I%]
  VSYNC
NEXT
So I would expect to see each of these sprites be assigned their location and then they should stay there. However they don't, it looks like one sprite jumping around and then I am left with one sprite in one position.
I think you can do it differently:
FOR I=0 TO 5
  SPSET I, I                        'this sets the 5 sprites to be set and I happened to uses the same I variable to mean set sprite 0-5
  SPOFS I,RND(300),RND(200)   'if you want them all to be set in specific places, I suggest you place them individually.
NEXT
Hope that helped