Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: tehalynn on November 30, 2010, 02:00:50 am
-
What's a good method for making a list of sprites in Axe?
I tried Data(Pic1, Pic2), but it wasn't working the way I thought it would.
-
I guess I could store put all the sprites into one block of memory, then do Pic1+8, Pic1+16, etc.
I'm still would like to hear what other people have to say though.
-
Double posting isn't well looked upon on these forums. You should edit your post.
By the way, the Data( command takes numbers as arguments and the value has to be stored to the variable.
For example, an easy way to use the Bitmap command is to do:
:Data(Columns,Rows)->Pic1
:[0123456789ABCDEF]
:Bitmap(X,Y,Pic1)
-
Double posting isn't well looked upon on these forums. You should edit your post.
My apologies. Will do in the future.
What I tried was:
[FFFF000000000000]->Pic1
[FFFFFFFFFFFFFFFF]->Pic2
Data(Pic1,Pic2)->GDB1
Pt-On(0, 0, {GDB1})
Pt-On(10, 0, {GDB1+1})
But {GDB1} and {GDB1+1} didn't seem to be pointers to Pic1 and Pic2.
-
do this instead
[FFFF000000000000FFFFFFFFFFFFFFFF->Pic1
Pt-On(0, 0, {Pic1})
Pt-On(10, 0, {Pic1+8})
-
As shmibs suggested, the most basic way to access an array of sprites is to simply put the data for the sprites all in succession and then access the sprite you want by adding an offset to the base pointer. For example:
[FFFF000000000000]→Pic1
[FFFFFFFFFFFFFFFF]
... Lots of sprites formatted like above and below
[A5229EFF667DCB00]
.Draw sprite 0
Pt-On(0,0,Pic1)
.Draw sprite 1
Pt-On(10,0,8+Pic1)
.Draw sprite 8
Pt-On(20,0,64+Pic1)
.Draw sprite N (0-indexed)
Pt-On(30,0,N*8+Pic1)
What I demonstrated above is probably the preferable method for displaying sprites from an array of sprites. However, if there's no way you can have the sprites occupy a contiguous array in memory and you require a list of pointers, you would do something like this:
.For this example, you have sprites at Pic1, L₁, and 64+L₁
[FFFF000000000000]→Pic1
Data(Pic1ʳ,L1ʳ,64+L1ʳ)→GDB1
.Draw sprite 0
Pt-On(0,0,{GDB1}ʳ)
.Draw sprite 1
Pt-On(10,0,{2+GDB1}ʳ)
.Draw sprite N (0-indexed)
Pt-On(20,0,{N*2+GDB1}ʳ)
-
Double posting isn't well looked upon on these forums. You should edit your post.
My apologies. Will do in the future.
What I tried was:
[FFFF000000000000]->Pic1
[FFFFFFFFFFFFFFFF]->Pic2
Data(Pic1,Pic2)->GDB1
Pt-On(0, 0, {GDB1})
Pt-On(10, 0, {GDB1+1})
But {GDB1} and {GDB1+1} didn't seem to be pointers to Pic1 and Pic2.
That's because pointers are two-byte numbers. Use Data(Pic1r,Pic2r) instead of Data(Pic1,Pic2) and it should work. Remember to count in multiples of two when you're accessing it, though, since they're now stored two bytes each sprite.
-
Double posting isn't well looked upon on these forums. You should edit your post.
My apologies. Will do in the future.
What I tried was:
[FFFF000000000000]->Pic1
[FFFFFFFFFFFFFFFF]->Pic2
Data(Pic1,Pic2)->GDB1
Pt-On(0, 0, {GDB1})
Pt-On(10, 0, {GDB1+1})
But {GDB1} and {GDB1+1} didn't seem to be pointers to Pic1 and Pic2.
That's because pointers are two-byte numbers. Use Data(Pic1r,Pic2r) instead of Data(Pic1,Pic2) and it should work. Remember to count in multiples of two when you're accessing it, though, since they're now stored two bytes each sprite.
You'll also have to read the bytes using the r symbol, by the way. {GDB1}r and {GDB1+2}r
-
Thanks everyone, that was very helpful.
I think I should be able to get the sprites in contiguous memory. I like this method, because it makes it easy to see where sprites begin and end in the code.
[FFFF000000000000]→Pic1
[FFFFFFFFFFFFFFFF]
It's good to also know the method for non-continiguous sprites too.
-
Thanks everyone, that was very helpful.
I think I should be able to get the sprites in contiguous memory. I like this method, because it makes it easy to see where sprites begin and end in the code.
[FFFF000000000000]→Pic1
[FFFFFFFFFFFFFFFF]
It's good to also know the method for non-continiguous sprites too.
That code can be optimized, right?
[FFFF000000000000→Pic1
[FFFFFFFFFFFFFFFF]
Not sure if it works in listed sprites, though
-
Closing a bracket in Axe does not save any space. It just makes the parser become confused.
-
Thanks everyone, that was very helpful.
I think I should be able to get the sprites in contiguous memory. I like this method, because it makes it easy to see where sprites begin and end in the code.
[FFFF000000000000]→Pic1
[FFFFFFFFFFFFFFFF]
It's good to also know the method for non-continiguous sprites too.
That code can be optimized, right?
[FFFF000000000000→Pic1
[FFFFFFFFFFFFFFFF]
Not sure if it works in listed sprites, though
Always close parenthese, quotes, and brackets in Axe unless you know what you're doing. It's not like in BASIC, where taking off the closing bracket saves space. And also unlike in BASIC, parentheses, braces, and brackets don't get closed at a store symbol. For example,
:3*(1+2→A
in BASIC stores 3*(1+2) to A (so A is 9), whereas
:3*(1+2→A
in Axe stores 1+2 to A, then multiplies it by 3 (so A is 3).
-
Can't you use the following instead?
[FFFF000000000000FFFFFFFFFFFFFFFF]->Str1 With extremely large amount of sprites it might be easier to read without all those brackets, although it's a bit risky since you can accidentally press CLEAR and delete everything at once.
Also even in BASIC there's one place where not closing parenthesizes can cause some issues, although it's minor (a slow down).