Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Munchor on January 01, 2011, 02:51:25 pm
-
Hey there, here is a GIF and the code of how to move a smilie, just change the code to whatever you want to get a moving mouse, a moving dog, or whatever you want.
.SMILIE
.The Sprite, change the Hex to whatever you want
[004466000000817E]->Pic1
.Do everything below until CLEAR is pressed
Repeat getKey(15)
StorePic
.Display Sprite
Pt-On(X,Y,Pic1
DispGraph
Pt-Change(X,Y,Pic1
RecallPic
ClrDraw
.Right Key
If getKey(3) and (X<92)
X+1->X
End
.Left Key
If getKey(2) and (X>2)
X-1->X
End
.Down Key
If getKey(1) and (Y<60)
Y+1->Y
End
.Up Key
If getKey(4) and (Y>2)
Y-1->Y
End
. End of the game loop
End
-
icwutudidther.... :P
-
Forgot to add comments:
.SMILIE
.The Sprite, change the Hex to whatever you want
[004466000000817E]->Pic1
.Do everything below until CLEAR is pressed
Repeat getKey(15)
StorePic
.Display Sprite
Pt-On(X,Y,Pic1
DispGraph
Pt-Change(X,Y,Pic1
RecallPic
ClrDraw
.Right Key
If getKey(3) and (X<92)
X+1->X
End
.Left Key
If getKey(2) and (X>2)
X-1->X
End
.Down Key
If getKey(1) and (Y<60)
Y+1->Y
End
.Up Key
If getKey(4) and (Y>2)
Y-1->Y
End
. End of the game loop
End
Also, optimized unneeded stuff.
-
I just wanted to optimize that... ;)
:.SMILE
:[004466000000817E]->Pic1
:DiagnosticOff
:0->X->Y
:Repeat getkey(15)
:Pt-Off(X,Y,[0000000000000000]
:X+getkey(3)-getkey(2)->X
:Y+getkey(1)-getkey(4)->Y
:Pt-On(X,Y,Pic1
:DispGraph
:End
oh, wait, you want boundaries...
:.SMILE
:[004466000000817E]->Pic1
:DiagnosticOff
:0->X->Y
:Repeat getkey(15)
:Pt-Off(X,Y,[0000000000000000]
:X+(getkey(3) and (X<88))-(getkey(2) and (X>0))->X
:Y+(getkey(1) and (Y<56))-(getkey(4) and (Y>0))->Y
:Pt-On(X,Y,Pic1
:DispGraph
:End
-
Optimizations like Runer112 does!
/me runs
I know everything I do can be optimized, and people always optimize my stuff xD But thanks ;D
-
As small as I could get it, 345 bytes of executable code. ;)
:.SMILE
:[004466000000817E]->Pic1
:DiagnosticOff
:0->X->Y
:Repeat getkey(15)
:ClrDraw
:getKey(3)-getKey(2)+X
:!If +1
:+1
:End
:-1
:Pt-On(min(,88)→X,getKey(1)-getKey(4)+Y+(=⁻1)min(,56)→Y,Pic1)
:DispGraph
:End
-
O.o
It took me about 2 straight minutes staring at the screen before I finally understood what that did.
-
I always go :crazy: and :w00t: when I see Runer's optimizations...
-
As small as I could get it, 345 bytes of executable code. ;)
<snip>
As cool as that optimization is, Runer, it ignores a major part of Scout's code. Notice the "Storepic." That's there to store the screen so that it can be replaced later, when the sprite is erased. Likewise, the "Recallpic" replaces it.
-
I think I just made it a wee bit smaller :D (now it's 362 bytes :o with .4.6)
never mind lol
:.SMILE
:[004466000000817E]->Pic1
:DiagnosticOff
:0->X->Y
:Repeat getkey(15)
:ClrDraw
:getKey(3)-getKey(2)+X
:!If +1
:1
:End
:-1
:Pt-On(min(,88)→X,getKey(1)-getKey(4)+Y+(=⁻1)min(,56)→Y,Pic1)
:DispGraph
:End
You could use the DispgGraphClrDraw at the end as well to save speed (idk about size) but I don't have .4.7 :P
Also @qwerty, I think that since this code serves the same purpose (moving around a sprite) its ok :P
-
I opted out of that optimization because I assumed that if somebody wanted to use this code in their program, they would probably have more than just that one sprite in the buffer and wouldn't want to clear it every time they updated the screen.
-
Actually the main one that I was talking about was changing !If +1:+1:End to !If +1:1:End (or are you talking to qwerty?)
-
+1 is smaller and faster than 1 :P
-
oh really?
...
fail >.<
-
+1 is smaller and faster than 1 :P
O.O what?
-
Yes I think it's because adding one to hl is faster than loading one into hl.
Did someone accidentally sticky this? I unstickied it :P (actually could have been me, I never know quite what I'm pressing while on a itouch lol)
-
Maybe someone accidentally clicked the button X.x