Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
thanks, Souvik!
Hi, I just started out with axe. I programmed first a little tunnel game:

Code:
:.TUNNEL The tunnel game
:Full
:identity(07F003F801FC01FC03F807F00FE007F007F003F801FC01FC01FC01FC01DC018C)
:DiagnosticOff
:[E7C381FFFFFFFFFF]→Pic1
:20→B
:33→C
:30→D
:0→E
:ref(0,1,96,64
:DispGraph
:Repeat getKey(15) or (pxl-Test(C,59)=0) or (pxl-Test(C+8,59)=0
: rand/8192→A
: If A≥1 and (A≤3
: B-1→B
:End
:If A≥4 and (A≤6
:B+1→B
:End
:If B=1
:2→B
:End
:If B=66
:65→B
:End
:If getKey(2)
:C-1→C
:End
:If getKey(3)
:C+1→C
:End
:Line(B,1,B+D,1
:Line(B,2,B+D,2
:Vertical +
:Vertical +
:Pt-Off(C,60,Pic1
:If E=200 or (E=400) or (E=600) or (E=800) or (E=1000) or (E=1200) or (E=1400
:D-1→D
:End
:DispGraph
:E+1→E
:End
:Fix 1
:Text(1,1,E►Dec
:Repeat getKey(9)
:End

It works well, but I wanted to ask whether that code can be optimized.
Oh, and as further questions I wanted to ask how you do grayscale, tilemaps, screenmasks and I wanted to ask what the command #Axiom(NAME) does. Thatks for all awnsers! Smile
I'll answer your questions as best I can. #Axiom(NAME) is an advanced command that can add extra, 3rd party commands. If you ever need to use them, then I can address this in more detail, but there aren't enough Axioms out there to be worth it.
As for optimizations:

Code:
If E=200 or (E=400) or (E=600) or (E=800) or (E=1000) or (E=1200) or (E=1400

Might be this:

Code:
If E/100<15 and (E/100>1) and (E/100^2=0

Which can further change this:

Code:
:If E=200 or (E=400) or (E=600) or (E=800) or (E=1000) or (E=1200) or (E=1400
:D-1→D
:End

to this:

Code:
D-(E/100<15 and (E/100>1) and (E/100^2=0))→D


Code:
:If getKey(2)
:C-1→C
:End
:If getKey(3)
:C+1→C
:End

Can be:

Code:
C+getKey(3)-getKey(2)→C

Along similar lines of thought...

Code:
:If A≥4 and (A≤6
:B+1→B
:End

Can be...

Code:
B+(A≥4 and (A≤6))→B

Same idea:

Code:
: If A≥1 and (A≤3
: B-1→B
:End

Can be...

Code:
B-(A≥1 and (A≤3))→B


Code:
:If B=66
:65→B
:End

==

Code:
B-(B=66)→B

There's probably more, but I'm not really prepared to optimize a whole program right now.

Grayscale! This is pretty straightforward with Axe. You have two buffers: the back and front buffer. With three-level grayscale (black, gray, and white), you use DispGraphr to display a frame of grayscale. Generally, the more often you use DispGraphr, the better quality your grayscale will be. The colors are determined like this: if the pixel is present on both buffers, it will be black. If it is present on only one, it will be gray. If it is present on neither, it will be white.
You can use most of the draw commands on the back buffer by adding r to them.
Four-level grayscale is slightly different. It is displayed with DispGraphrr. The color is determined differently: If the pixel is present on both buffers, black. If it is present only on the front buffer, dark gray. If it is present only on the back buffer, light gray. If it is present on neither, white.

Tilemaps can be done a variety of ways. You have different size tiles, and smooth-scroll versus hard-scroll versus static, and grayscale versus black&white. It's a pretty broad topic. Here is a tutorial I've written on the subject, here is another. The latter covers smooth-scrolling, but it uses an inefficient method that I don't particularly like. It is, however, easier to understand. My preferred method is more complex, you can see it in use on Motherload.

What do you mean by "screenmasks?"
Ok, thanks a lot! Smile And I thought that screen masks were these things that you can make i.g. a background in a game that is always the same but just things in the front change.
SirCmpwn wrote:

As for optimizations:

Code:
If E=200 or (E=400) or (E=600) or (E=800) or (E=1000) or (E=1200) or (E=1400

Might be this:

Code:
If E/100<15 and (E/100>1) and (E/100^2=0


That doesn't work, it would return true for 200 to 299, 400 to 499, 600 to 699, etc. Also, I think the divisions make it slower than before.

Here's a nice optimization (requires Axe 1.0.3):

Code:
!If E-200?-200?-200?-200?-200?-200?-200
D-1->D
End
That was the only optimization I was unsure about.
As for a "screen mask", you can store a background to the back buffer and recall it every frame for black and white. For grayscale, there are more complex ways of doing it (see Motherload again), but generally you'd re-draw the scene every frame.
calc84maniac wrote:

Here's a nice optimization (requires Axe 1.0.3):

Code:
!If E-200?-200?-200?-200?-200?-200?-200
D-1->D
End

Darn! Axe 1.0.3 did want to go on my calc, neither with tilp nor with ticonnect, so i just have axe 1.0.2! Sad
Oh, well you can use this longer syntax on Axe 1.0.2 I'm pretty sure:

Code:
!If E-200?-200?-200?-200?-200?-200?-200,,,,,,
D-1->D
End
In axe 1.0.3 documentry it says that "?" is new, and it isn't in axe 1.0.2 doclumentry.... Sad
Sorunome wrote:
In axe 1.0.3 documentry it says that "?" is new, and it isn't in axe 1.0.2 doclumentry.... Sad
But the cond?expr1,expr2 operator is in Axe 1.0.2, which is what my last code uses ^^
ups, your right! Ok, I don't get really what cond?expr1,expr2 does
EDIT: I think I get it! Smile
EDIT2: What is Bitmap(X,Y,BITMAP) and Pt-Mask(X,Y,PIC)?
You can think of cond?expr1,expr2 as just another way to write if-else. Pt-Mask does the almost the same thing as Pt-On, but it is used on sprites with two layers, making it easier to write programs with grayscale.

I don't know what a bitmap is. I /think/ it's pretty much the same as a sprite, except it saves its own size. As in [height][width] and then the image data. The Bitmap command would then be used to print bitmaps, but this is just guesses from my part. Smile

Code:
.Width
[08→Pic1
.Height
[08
.Image
[FFFFFFFFFFFFFFFF

Bitmap(0,0,Pic1


Arbitrary size sprites.
ok, thanks, i think I get it. Smile
Just keep in mind that the Bitmap() type of sprites are very slow and don't support clipping. This is because it uses one of TI's official routines. Razz
Ok, thanks, but I just use 8x8 sprites usually. Smile
EDIT: Does Ans uses normally in axe?
Sorunome wrote:
Ok, thanks, but I just use 8x8 sprites usually. Smile
EDIT: Does Ans uses normally in axe?


Using Ans in Axe will access the TI-Basic variable Ans (which probably isn't what you want). You can usually get the same functionality by stringing together operations, for example:

Code:
TI-Basic:
A->B
2Ans->C

Axe:
A->B*2->C
oh, I didn't know that worked! Smile but I need Ans more often than once in a condition.... so i think i'll just add a new variable... -.-
No, Ans isn't used in Axe as it is used in BASIC.
However, there is a similar thing, called HL.
The HL register contains the last value or constant "loaded".


Code:
0→A:0→B
.Write this instead
0→A→B


Zero is loaded into HL, and saved to A. The value of HL is till zero, so you can load it right into B without first setting it. Here's another example:


Code:
Pt-On(8,8,Pic1)
.Write this instead
Pt-On(8,,Pic1)


Eight is loaded once into HL, we don't need to do it twice. This HL re-usage can be used in quite many places, but it can make the code harder to understand if one is not used to it. Smile

EDIT: Woah, way to slow. Got beaten twice. :p
I got a new question: How do you read/write data into a appvar?
  
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 3 of 11
» All times are GMT - 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