Omnimaga
Calculator Community => [FR] Section Francophone => [FR] Programmation Axe Parser => Topic started by: Jagang on October 23, 2010, 04:42:34 pm
-
(Re) bonjour,
J'ai de nouveau un problème pour mon jeu Mario Sokoban
Je charge mes cartes dans des GBD comme ceci :
Data(0,1,1,1,1,0,0,0,1,1,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,0,3,3,1,2,0,1,1,1,1,0,0,2,0,1,0,0,1,1,1,0,0,1,0,0,0,0,1,1,1,1)->GBD1
Étant donné qu'il y a plusieurs cartes, j'ai utilisé des condition, comma ça :
If L=1
Data(...)->GBD1
End
If L=2
Data(...)->GBD1
End
etc ...
Le problème, c'est que quand je lance la compilation, ça marche pas ...
Je ne peux pas utiliser un GBD par map puisque j'ai plus de 10 maps ...
Dans la version TI-Basic de mon programme, à chaque nouveau niveau, j'allais changer la valeur de la matrice [A].
En Axe, je pensais que c'était pareil ... dommage
Comment faire alors ?
Merci d'avance
Cordialement
Jagang
-
I don't speak French, but using Google Translate I can tell that you seem to be misunderstanding how "->GDB1" works.
(DJ or another French speaker, please translate my response.)
GDB1 etc. are not dynamic like in BASIC. Instead, when you use "->" with them, the data you store to them is placed in the compiled program. To use it like you would in BASIC, you have to use L1 or another place to store your data. However, this does bring up another problem; you still have to store the original data somewhere. You can use one GDB for each map, and you can add another digit to each. (You can use GDB10, GDB56, and so on, and maybe even another, like GDB623. However, I'm not sure about two extra digits.)
Another solution exists, though. If each set of data is the same size, rather than using GDB01 to access the first, GDB02 for the second, and so on, you can use GDB1 for the first, GDB1+56 for the second, GDB1+112 for the third, and so on, storing them like in the code box below. (assuming each set map is 56 bytes) (If you are using it with L like you were above, you could actually just use L-1*56+GDB1 to access the L'th set of data, indexed from 1.)
Data(...)->GDB1
.Data for map 1
Data(...)
.Data for map 2
Data(...)
.Data for map 3
.And so on
Thinking over it, I've realized that, if you're using maps, they are static and their content does not change. This means that you won't have to use L1 for that purpose. Rather, you can have a line like
L-1*56+GDB1->M
M now contains the address of the map data, and you can index from there. If, however, you would rather use L1 (perhaps for convenience?) you would have to copy the data to L1 like so: (You can use any free RAM area, not just L1)
Copy(L-1*56+GDB1,L1,56
Feel free to ask more if you are still confused; I doubt I've clarified everything.
-
Thank you, but, my maps are dynamics...
So, how load my maps in L1 ?
Data(0,2,2,2,3,1,4,1,..)->L1
?
Because, I need the same pointer/variable in the main program (where I test if an action is possible).
Sorry, I don't speak English very well (though I should), but it's always better than Google Translate (I think ...)
-
Okay. My suggestion was that, instead of, say, L1+5 you use M+5, where M is the pointer to the map created by the code I gave above.
To load the maps into L1, you can use Copy(. For example, to copy X bytes from GDB1 to L1, you can use Copy(GDB1,L1,X).
A more complete line of code was that which was given above:
Copy(L-1*56+GDB1,L1,56
This code assumes you store 56-byte maps in the way I suggested in my previous post.
-
Ok, I understand, thank you.
So, I create a Data like that :
Data([map 1],[map 2],[map 3] ...) ->GBD1
And to load one map I use :
Copy(L-1*128+GDB1,L1,128)
Where L is the level starting at 1 and 128 is the size of the map.
But my maps have different size.
Can I use an other GDB with the size of each map ?
For example :
Data([map 1, 56],[map 2, 42] ...)->GDB1
Data(56,42 ...)->GDB2
And to load :
0->A
For(I,0,L)
A+{I+GDB2}->A
End
Copy(A+GDB1,L1,{L+GDB2})
Does it work ?
How to access at the different case of L1 ?
Like GDB ?
If {D+L1}=3
2->{D+L1}
End
Thank you
Jagang
EDIT: Someone know an Axe editor for PC ? Actualy, I use TI-Graph Link 83+ and it hasn't the instruction of Axe.
Personne ne connaitrais un éditeur pour l'Axe sur ordi ? J'utilise TI-Graph Link 83+ en ce moment, mais il n'a pas les instruction d'Axe et en plus il est francisé (Str1 = Chaîne1 ...)
-
GDB2 wouldn't be the size of each map but rather the sum of the sizes of all the maps before it.
So instead of Data(56,42 ...)->GDB2 you would have Data(0,56,98 ...)->GDB2. 98 is 56+42, of course.
To map L indexed from 1 you would then use
Copy(GDB1+{L+GDB2-1},L1,{L+GDB2}-{L+GDB2-1})
Note that you'd have to add to the end of GDB2 an extra entry that is the sum of the sizes of all the maps.
You could use your method too, but L should be L-1 in both places where it appears. It will also be somewhat slower ;)
0->A
For(I,1,L
A+{I+GDB2-1}->A
End
Copy(A+GDB1,L1,{L+GDB2-1})
This is the fixed version of yours.
What do you mean by "How to access at the different case of L1. Like GDB?"
Edit: You can use TI-Graph Link, you just need to know to use conj( instead of Copy(, expr( instead of Exch(, and so on.
-
I prefer my method because I think to use GDB2 for the real size of the map, the size on X and on Y :
Data(7,8 |size of the first map| ...) ->GDB2
So, to load :
.Size of the map in X
{L+BDG2-1 }->U
.Size of the map in Y
{L+BDG2 }->V
0->A
For(I,1,L
A+{I+GDB2-1}*{I+GDB2}->A
.To add 2 on each loop
I+1->I
End
Copy(A+GDB1,L1,U*V)
No ? I can use a While loop too.
-
Hm... that code is almost good. I think it would be better to use a While loop, though.
Also, there is no "order of operations" and your data for each map is now two bytes.
0->A
L*2+(GDB2->I)->E
.E is the end of the size data which we're scanning
Repeat I=E
{I}*{I-1}+A->A
.No order of operations, so we have to make the multiplication come first.
I+2->I
.Add 2
End
Copy(A+GDB1,L1,{E-1}*{E-2})
.I would work too instead of E
-
I don't understand your code, sorry :(
Can you explain it please ?
-
[b]Edit:[/b] Annoying code tag bug. Try to ignore x.x
Okay :)
So, one line at a time:
[code]0->A
Initialize A, like we've been doing
L*2+(GDB2->I)->E
You can store to variable inside expressions. We need I to point to the beginning of the data containing the size, so it is stored.
Since the size data for each map is 2 bytes, we multiply L by 2, then add it to the beginning of the size data to get the end where we stop.
Repeat I=E
Just repeat until we reach the end.
{I}*{I+1}+A->A
I points to the X-size of the current map, and I+1 points to the Y-size of it. (I had had I-1, but I fixed it.)
We multiply these to get the total size of the current map, and add it to A. The multiplication comes first because otherwise it would evaluate as (A+{I})*{I+1} and not A+({I}*{I+1})
I+2->I
Add 2 to move on to the next set of data.
End/code]
Finish our loop
Copy(A+GDB1,L1,{E-1}*{E-2})[/code]
A is the correct offset, so we add it to GDB1 to get to the start of the map data.
Alternatively, we could have done GDB1->A at the beginning and just A on this line instead of A+GDB1.
L1 is the destination.
E is the end of the size data we've scanned. The data for the map you're loading is right before it. So {E-1} is the Y-size and {E-2} is the X-size. We multiply those to get the size of the map which we're copying.
-
Ok, thank you.
But I have an other problem, yet ...
0->A
L*2+(GDB2->I)->E
.E is the end of the size data which we're scanning
Repeat I=E
{I}*{I-1}+A->A
.No order of operations, so we have to make the multiplication come first.
I+2->I
.Add 2
End
Copy(A+GDB1,L1,{E-1}*{E-2})
.I would work too instead of E
.Size of the map in X
{E-2}->U
.Size of the map in Y
{E-1}->V
Fixe 5
0->O
For(A,0,U*V-1)
If {A+L1}=3
O+1->O
End
Text(45,40
Text AåDec,{A+L1}åDec
DispGraph
Pause 500
End
All case are 2 !!!
Data(0,1,1,1,1,0,0,0,1,1,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,0,3,3,1,2,0,1,1,1,1,0,0,2,1,1,0,0,1,1,1,0,0,1,0,0,0,0,1,1,1,1)->GDB1
Data(8,7)->GDB2
Why ?
-
Is L set to 1?
If so, that should work...
-
I add the total code in attachment.
-
{I}*{I-1}+A→A
You still have the unfixed code in your file. Could you fix it to {I}*{I+1}+A→A and try again? :)
Edit: Just tried it; it still says "2"... I'll keep looking.
Edit 2: There was a problem with my code. L*2+(GDB2→I)→E should be L-1*2+(GDB2→I)→E. Trying that now.
-
J'ai remplacé {I}*{I-1}+A->A par {I}*{I+1}+A->A mais ca ne change rien.
Puis j'ai remplacé L*2+(GDB2->I)->E par L-1*2+(GDB2->I)->E mais la ca ne fonctionne plus du tout, il n'y a plus qu'une seule case qui s'affiche...
Merci
Cordialement
Jagang
PS : je suis sur mon téléphone donc je suis obligé d'écrire en français.