Omnimaga

Calculator Community => TI Calculators => Grammer => Topic started by: Xeda112358 on February 05, 2012, 09:13:36 pm

Title: Grammer Examples
Post by: Xeda112358 on February 05, 2012, 09:13:36 pm
Okay, so at request, I started this topic for example codes :) I will try to post a link in this post when I add new codes. The first one is a bouncing circle:
Code: [Select]
.0:Return
1→X→Y→B→C
Repeat getKey(15
Circle(Y,X,12,1   ;Draws a circle of radius 12 using pxl-On
DispGraph
ClrDraw
X+B→X
If >95            ;Since negative numbers are really big (>32768), this tests if it is negative, too
-B→B
Y+C→Y
If >63
-C→C
End
Stop
Title: Re: Grammer Examples
Post by: saintrunner on February 05, 2012, 09:15:53 pm
85 bytes!! Wow that is sweet!
Title: Re: Grammer Examples
Post by: Xeda112358 on February 22, 2012, 03:58:43 pm
Okay, here is an example using the latest Grammer features for grayscale-- a grayscale cursor!
Code: [Select]

π9872→P            ;This sets P equal to 9872h. This will be the location of the other buffer.
ClrDrawP           ;Clears the buffer at P
Disp ºP            ;Sets the buffer at P as the gray buffer
Lbl ".→Z           ;Locates label named "." and stores that to Z. Better to search once than every loop!
0→X→Y
Repeat getKey(15   ;repeats the loop until clear is pressed
Repeat 1           ;repeats until 1 is not zero (so it only cycles once). This is a great trick.
..                 ;This is a label. Sub routines use the End statement to end and so does Repeat >.>
Line(X,Y,6,6,2,P   ;Draws an inverted filled rectangle at X,Y of size 6x6 on the buffer P (the gray buffer)
Line(X,Y,6,6,2     ;This inverts the same region on the main buffer.
End                ;Ends the repeat loop/subroutine
DispGraph          ;Updates the LCD (in grayscale)
prgmZ              ;executes the sub routine pointed to by Z
getKey(56          ;tests the delete key
If +getKey(9       ;tests if Ans or getKey(9 is valid
Line(X,Y,6,6,1-getKey(56   ;draws a white rectangle if delete is pressed, black otherwise
X+getKey(3
-getKey(2→X
Y+getKey(1
-getKey(4→Y
End
Stop

CRSRGRAY is 143 bytes on calc >.>
Title: Re: Grammer Examples
Post by: DJ Omnimaga on February 22, 2012, 04:02:06 pm
Looks really great. :)
Title: Re: Grammer Examples
Post by: Snake X on February 22, 2012, 04:06:12 pm
danggit guys lol you make me want to get back into calc programming XD

But that's pretty awesome though that you can do that with such little coding
Title: Re: Grammer Examples
Post by: Xeda112358 on February 22, 2012, 04:13:27 pm
Thanks :] My goal is to make it easier for folks to make use of great graphics :) Although, I still think that Grammer has a higher learning curve than BASIC :/
Title: Re: Grammer Examples
Post by: DJ Omnimaga on February 22, 2012, 04:14:30 pm
danggit guys lol you make me want to get back into calc programming XD

But that's pretty awesome though that you can do that with such little coding
It would be nice :D. If you do so, don't hesitate to ask questions in the help section if you can find anything on the forums or tutorials. :)
Title: Re: Grammer Examples
Post by: Spyro543 on February 22, 2012, 04:26:43 pm
Okay, so at request, I started this topic for example codes :) I will try to post a link in this post when I add new codes. The first one is a bouncing circle:
Code: [Select]
.0:Return
1→X→Y→B→C
Repeat getKey(15
Circle(Y,X,12,1   ;Draws a circle of radius 12 using pxl-On
DispGraph
ClrDraw
X+B→X
If >83          ;Changed by Spyro
-B→B
Y+C→Y
If >51          ;Changed by Spyro
-C→C
End
Stop
Those two small additions should make the circle bounce on its edge.
Title: Re: Grammer Examples
Post by: Xeda112358 on February 22, 2012, 05:07:57 pm
Nice :D Another trick is you can store the radius to R and use 96-R and 64-R. That way, you can add stuff to change the radius of the circle.