Author Topic: Grammer Examples  (Read 6975 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Grammer Examples
« 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

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Grammer Examples
« Reply #1 on: February 05, 2012, 09:15:53 pm »
85 bytes!! Wow that is sweet!
« Last Edit: February 05, 2012, 09:17:32 pm by saintrunner »
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer Examples
« Reply #2 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 >.>

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Grammer Examples
« Reply #3 on: February 22, 2012, 04:02:06 pm »
Looks really great. :)

Offline Snake X

  • Ancient Veteran
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 810
  • Rating: +33/-8
    • View Profile
Re: Grammer Examples
« Reply #4 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
Loved this place, still the best producers of power metal, and sparked my dreams of coding.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer Examples
« Reply #5 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 :/

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Grammer Examples
« Reply #6 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. :)

Offline Spyro543

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1189
  • Rating: +74/-3
    • View Profile
Re: Grammer Examples
« Reply #7 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.
« Last Edit: February 22, 2012, 04:27:32 pm by Spyro543 »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Grammer Examples
« Reply #8 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.