PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

SetSpriteOrigin / Matrix Questions

Hopefully there are two simple questions. How do I use SetSpriteOrigin?

SetSpriteFixed(var$, 50); does not have any effect - the sprite still can move freely past and ahead 50 pixels.

Also, I thought matrices are supposed to be rows/columns rather than just straight across? I can't seem to find a way to do 2 dimensional matrices in PPL, and if there is, can't determine how you would know what row you're on too.
For origins, you should use:

SetOrigin(X, Y); To move the screen around.

SetSpriteFixed(sprite$, true); The sprite won't move with the virtual screen, it will always stay at the X,Y position on the pda screen. This is very usefull for user interface sprites. They always stay on the screen even though the screen origin is changed.

Matrices in PPL can be used like this:

m$ = [10, 20, [30, 40]];
ShowMessage(m$[2][1]); // 30;
Aha, I didn't do the SetOrigin, although I may just have to end up writing my own in the end that's a little more versatile , it'll still be a great start. (The built in is a bit too rigid for my tastes)

Still don't quite understand matrices in PPL. I'm trying to store the entire level in one matrix, with rows and columns, and each number designating a tile ie:

Code:

a$ = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1, 1, 1, 1, 0, 1, 1, 1, 1, 1]


In that example, the top three tiles will all be blank, and the 4th one down will be all wall with a small gap in it.

The level lengths will not be static, so I can't just foreach and start a new line every x entries. Determining the column is easy - infact I can draw an infinite length level, and have each tile appear, but how would I find which row I'm on?
What's too rigid about the built in SetOrigin()? I am always open to suggestions! :wink:

You can probably make this matrice like this:

Code:
a$ = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 0, 1, 1, 1, 1, 1]];

ShowMessage(a$[3][0]); // 1
ShowMessage(a$[2][0]); // 0
Right now, I still can't get it to work. But anyway, it'd be nice to be able to move the origin after it reaches a certain amount, say you can move all you want left of 100 pixels, but the camera will start moving when you try to move to the 101st pixel. Probably a bit hard to explain.

I'm running into several bugs right now, let me PM you my latest code and see what you think.
You can check in the WM_TIMER if your sprite is at pixel 101 or more, to pan the camera a bit using SetOrigin(OriginX+10, OriginY), something like that. Same thing if sprite is 99 or lower.
kornalius: How would foreach handle the matrix like the above? It doesn't seem to even render the first row of tiles correctly.

I may just give up a little flexibility and go with a different array for each row, and hardcode a max height.