Here's a simple, fairly optimized way to do what you are trying to achieve. I have detailed most of the optimizations in comments in the code, but I did not comment about the biggest optimization. This optimization is to draw sprites from a variable pointer, instead of requiring four different copies of the whole loop just for facing in different directions. For instance, here's the line I used to initialize the player sprite to the right-facing sprite:
:2*8+Pic1→SIf you're familiar with how this works, then go ahead and skip to looking at the code to see the final product with the rest of my suggested simple optimizations. If you're not familiar with how this works, I'll give a quick explanation. Because of how Axe includes data like sprites, the order in which you list data (like sprites) is exactly the order it will assume in the compiled program. Since each sprite is 8 bytes, that means that each successive sprite is found in memory 8 bytes after the previous sprite.
Pic1 points to the start of the block of 4 sprites, so it points to the first one, the down-facing sprite.
2*8+Pic1 would point to the data 16 bytes after the down-facing sprite, which we know is the right-facing sprite because it's 2 sprites (remember, a sprite is 8 bytes) after the down-facing sprite. This offset from
Pic1 logic is used to draw the proper sprite for facing in all 4 directions.
So here's my suggested fairly optimized and hopefully easy-to-understand solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| :.AXETEST :identity(3FFC3FFC30CF30CF300C300C0C300C303FFC3FFC330C330C3FFC3FFCF00FF00F) : :[]→Pic1 :[7E665A247EC37EC3] .DOWN :[7ED242247E4A7EC3] .LEFT :[7E4B42247E527EC3] .RIGHT :[7E7E42247EC37EC3] .UP : :.START FACING RIGHT AT (0,56): :2*8+Pic1→S :0→X :56→Y :.THIS DOESN'T NEED TO BE INSIDE THE LOOP: :StorePic : :While 1 : Pt-On(X,Y,S) : DispGraph : .ERASING WITH Pt-Change() UNNECESSARY BECAUSE: : RecallPic : If getKey(1) : Y+2→Y : 0*8+Pic1→S : End : If getKey(2) : X-2→X : 1*8+Pic1→S : End : If getKey(3) : X+2→X : 2*8+Pic1→S : End : If getKey(4) : Y-2→Y : 3*8+Pic1→S : End :.OPTIMIZED POST-CHECK LOOP: :End!If getKey(15)
|
Now, if you want
really optimized code... That can be arranged.

I'll leave figuring out how it works as an exercise.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| :.AXETEST :identity(3FFC3FFC30CF30CF300C300C0C300C303FFC3FFC330C330C3FFC3FFCF00FF00F) : :[]→Pic1 :[7ED242247E4A7EC3] .LEFT :[7E7E42247EC37EC3] .UP :[7E4B42247E527EC3] .RIGHT :[7E665A247EC37EC3] .DOWN : :56→Y : and 0→X :→S : :While 1 : ClrDraw : Pt-On(X,Y,S*8+16+Pic1) : DispGraph : If getKey(1)-getKey(4) : →S : *2+Y→Y : End : If getKey(3)-getKey(2) : -1→S+1 : *2+X→X : End :EndIf getKey(15)
|