I want to make a game in axe. I covered some basic concepts like moving a sprite, set it's trajectory, it's speed etc. Now let's say I have 3 sprites : one is stationary, the second is moving along X (Y-const) and the third is supposed to leave the at the first sprite's coordinates and move towards the second one, according to it's current location, faster than it. Is it hard to do? Because I've seen only tutorials on how to move a sprite infinitely in one direction.
I don't even know what's supposed to be complicated.
Here's some ultra-clear code, with useless variables (X1, Y1 and Y2 are constant) so that you understand better what's happening. Note that 3's movement is not a straight line, it moves diagonally then straight to 2.


Code:
.AA
[]->°Sprites
[1878781818187E7E]
[3C7E660C18307E7E]
[3C7E461C1E467E3C]

L1+00->°X1
L1+02->°Y1
L1+04->°X2
L1+06->°Y2
L1+08->°X3
L1+10->°Y3

ClrDraw(L1)
ClrDraw(L6)
5->X2
53->Y2
While 1
 Pt-On(X1/2,Y1/2,°Sprites)
 Pt-On(X2++/2,Y2/2,°Sprites+8)
 Pt-On(X3+(<X2-(X3>X2)*2)→X3/2,Y3+(<Y2-(Y3>Y2)*2)→Y3/2,°Sprites+16)
 DispGraphClrDraw
 Pause 100
EndIf getKey(15)
ClrHome


And here's a screenshot to prove I am not lying.
Thank you for the answer. I've also tweaked it a bit to fit my needs. It takes a harder learning curve than ti-basic as axe is more low-level than ti-b and I don't have much time to learn it.

This will be my last question, still: what this does? I don't understand it.

Code:
X3+(<X2-(X3>X2)*2)
It is functionnally equivalent to ((X3<X2)-(X3>X2))*2+X3.
I know I've put too much parentheses here, but this way it is really understandable. In Axe, every calculation goes into hl and evey calculation is done with hl (you'll say "how do you do an addition with only one register ?", and the answer is that of course there is another one, but I am making things simple). So X3+(<X2-(X3>X2)*2) is basically that X3→hl+(hl<X2-(X3>X2)*2).

And the reason why I wrote X3+(<X2-(X3>X2)*2) is because I find it funny to have "+(<", I don't even know if it is more optimized than writing it in the natural order X3<X2-(X3>X2)*2+X3.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement