Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Munchor on February 20, 2011, 09:36:05 am

Title: Axe Greyscale Tutorial
Post by: Munchor on February 20, 2011, 09:36:05 am
Introduction
When I was new to Axe programming, I thought greyscale was reserved for extreme coders. I thought that making a greyscale game was really hard and I couldn't possibly do it. However, I noticed most games were greyscale and decided to try to make my first greyscale program. This is a quick guide and tutorial to help you with Axe greyscale.

The first think you need to know is that there are two types of greyscale in Axe. You can have three levels greyscale and four levels greyscale. The first one has three colours: Black, Grey and White. The second one has four colours: Black, Dark Grey, Light Grey and White.

Note: When I say white, I mean nothing, empty, the LCD colour.

We're starting off with three level greyscale since it is more simple and easy to understand.

I assume you've had previous experience in Axe programming, otherwise it will be difficult for you to understand the tutorial from now on.

The basics

Let's start by making your first greyscale program.

I'll post the code right here and then explain:

Code: [Select]
.GRS
[FFFFFFFFFFFFFFFF]->Pic1
5->Y
40->X
Repeat getKey(15)
Pt-On(X,Y,Pic1)r
Line(0,63,95,63
If Y<55
Y+1->Y
End
DispGraphr
ClrDrawr
End

This is what this program will create:

(http://img.removedfromgame.com/imgs/FirstProgram.gif)

It's a simple program that has greyscale and a gravity engine. It's a small grey square falling until it reaches the black line.

How did I achieve this?

3 Level Greyscale
Most drawing commands in Axe have a similar command followed by an 'r'. This 'r' can be found in 2ND+APPS+3.

The calculator can be divided in two parts, the main buffer (or front buffer) and the back buffer. It's a bit like layers, the back buffer's images will be displayed behind the main buffer's images. The back buffer is also a way to draw greyscale images.

If you had already drawn images on Axe, you probably did something like this:

Pt-On(X,Y,Pic

This draws pictures in the front buffer. The next one draws them in the back buffer:

Pt-On(X,Y,Pic)r

To display mono (black and white) images, you'd use:

DispGraph

For greyscale images you use:

DispGraphr

This is very simple, but where's the greyscale?

Code: [Select]
-----           Black         Grey         White
Main Buffer      X                               
Back Buffer      X             X

If I draw something to the back buffer only it will be grey, if I don't draw nothing, it'll be white.

If I draw something in the main buffer, it will be black. If I draw something both in the main and the back buffer it'll be black too (example):

Code: [Select]
Pt-On(10,30,Pic1)r
Pt-On(10,30,Pic1

In three level greyscale, we always use DispGraphr to display images..


Now let's make a four level greyscale program.

4 Level Greyscale

Now that I've thought you the basics, four level greyscale is very easy to understand.

First of all, we use DispGraphrr to display images.

Now, how do we make black, light grey or dark grey images?

Code: [Select]
DispGraphrr:
Buffer        BackBuffer        Color

                              White
               X              Light Grey
X                             Dark Grey
X              X              Black

Here's an example of a black sprite, a light grey sprite and a dark grey sprite in order:

Code: [Select]
Pt-On(50,40,Pic1)r
Pt-On(50,40,Pic1

Pt-On(0,0,Pic2)r

Pt-On(0,40,Pic3

More Information

When you want to clear the back buffer, you also need to use the r:

ClrDrawr

Conclusion

I want to thank BuilderBoy who taught me greyscale originally (he doesn't know he did, but he did).

If you have any doubts, you can PM me or respond to the topic, someone or me will help you out.

Attachments

Attached is Zip File with the source and executable program we made here in the first place and the screenshot.
Title: Re: Axe Greyscale Tutorial
Post by: Happybobjr on February 20, 2011, 10:27:16 am
wow, that is a simple gravity engine ;)
Looks, nice (still reading)
Title: Re: Axe Greyscale Tutorial
Post by: Munchor on February 20, 2011, 11:07:36 am
wow, that is a simple gravity engine ;)
Looks, nice (still reading)

Thanks ;D

I should make a .pdf too.
Title: Mistake in Tutoreal?
Post by: p2 on June 21, 2011, 12:57:36 pm
http://www.omnimaga.org/index.php?action=articles;sa=view;article=55 (http://www.omnimaga.org/index.php?action=articles;sa=view;article=55)
That's the Tutoreal for Greyscale


Code: [Select]
.GRS
[FFFFFFFFFFFFFFFF]->Pic1
5->Y
40->X
Repeat getKey(15)
[size=12pt][font=Verdana][b]Pt-On(X,Y,Pic1)r[/b][/font][/size]
Line(0,63,95,63
If Y<55
Y+1->Y
End
DispGraphr
ClrDrawr
End
That's what it should do:
(http://img.removedfromgame.com/imgs/FirstProgram.gif)

But I thought Pkt-on( isn't possible in Axe and that it must be Pxl-On(   ???
What's correct, now?


And what's the r in  Pt-On(X,Y,Pic1)r ??
Is it a special command, and if it is, where can I find it?


Title: Re: Axe Greyscale Tutorial
Post by: ztrumpet on June 21, 2011, 12:58:48 pm
New topic merged with "official" discussion topic. :)
Title: Re: Axe Greyscale Tutorial
Post by: Michael_Lee on June 21, 2011, 01:01:20 pm
Nope, it's correct.

Pxl-On turns on a single pixel on the screen.

Pt-On draws an 8x8 sprite (basically, a small image) on the screen.

Also, the 'r' is the small r that floats in the air.  You can find it by pressing [2ND] [ANGLE] [3].
(You can find the [ANGLE] button in blue over [APPS]).
Title: Re: Axe Greyscale Tutorial
Post by: Munchor on June 21, 2011, 01:04:12 pm
The tutorial in the tutorial page has a few errors with the BB Code, like lack of code tags and has a huge space below tutorial.

Thanks for your attention :)
Title: Re: Axe Greyscale Tutorial
Post by: Jonius7 on October 14, 2011, 07:23:44 am
I read it the first time a few months ago when this tutorial was kinda new and didn't really get it. Now I read it properly and it actually sounds really simple! This is a great tutorial for Axe and a pretty important one too.
Title: Re: Axe Greyscale Tutorial
Post by: Stefan Bauwens on October 18, 2011, 05:37:53 am
Quote
Code: [Select]
Pt-On(50,40,Pic1)r
Pt-On(50,40,Pic1

Pt-On(0,0,Pic2)r

Pt-On(0,40,Pic3
Very nice tutorial and very easy to understand! But what I don't understand on the above is why we have different pics(pic1,pic2 and pic3). If they do have different values what are they?
Title: Re: Axe Greyscale Tutorial
Post by: Yeong on October 18, 2011, 06:19:15 am
Pic1 is meant to be a monochrome data,so you put same sprite data at both buffer. The other one is meant to be a greyscale, so different sprite data at both buffer.
Title: Re: Axe Greyscale Tutorial
Post by: Munchor on October 18, 2011, 10:17:25 am
Thanks Stefan and Yeong too, your answer is just perfect.
Title: Re: Axe Greyscale Tutorial
Post by: turiqwalrus on October 18, 2011, 10:37:26 am
But I thought Pkt-on( isn't possible in Axe and that it must be Pxl-On(   ???
What's correct, now?
And what's the r in  Pt-On(X,Y,Pic1)r ??
Is it a special command, and if it is, where can I find it?
Pt-On(Xlocation,Ylocation,sprite data in hexadecimal) is the format, I believe(it's for drawing sprites.)
the r means to draw the sprite in the 'backbuffer', and it is found in the angle menu([2nd][APPS][3])
let me know if that helps ;)
Title: Re: Axe Greyscale Tutorial
Post by: Jonius7 on October 20, 2011, 09:39:25 am
The r is also used to display 3 colour greyscale: DispGraphr. rr which is used to show 4 colour greyscale: DispGraphrr
Title: Re: Axe Greyscale Tutorial
Post by: p2 on October 20, 2011, 11:54:54 am
How many "r"s can you max. use?
DispGraphrrrrrrrrrrrrrrrrrrrrr isn't possible, right?
Title: Re: Axe Greyscale Tutorial
Post by: Yeong on October 20, 2011, 11:55:23 am
2
Title: Re: Axe Greyscale Tutorial
Post by: p2 on October 20, 2011, 11:57:35 am
:(
It would have been funny to read a code with more than 2 - counting how many "r"s  are in it to get known what it'll do... :)
Title: Re: Axe Greyscale Tutorial
Post by: C0deH4cker on October 20, 2011, 12:10:58 pm
That would be annoying. Anyway, the 2 rs are for the two buffers: the main buffer and the back buffer.
Title: Re: Axe Greyscale Tutorial
Post by: Stefan Bauwens on October 20, 2011, 12:13:49 pm
That would be annoying. Anyway, the 2 rs are for the two buffers: the main buffer and the back buffer.
Isn't it actually frontbuffer, buffer and backbuffer? Since no 'r' should be the main buffer, right?
Title: Re: Axe Greyscale Tutorial
Post by: C0deH4cker on October 20, 2011, 12:17:36 pm
I think that the two rs just tell axe to take the data from the two buffers and display it in grayscale, but i could be wrong.
Title: Re: Axe Greyscale Tutorial
Post by: chattahippie on October 20, 2011, 12:28:24 pm
I think that Dispgraphrr just tells Axe to display in 4 scale greyscale, and ClrDrawrr tells it to clear both buffers.
And by the way, Pt-On() can only have a max of one r
Title: Re: Axe Greyscale Tutorial
Post by: C0deH4cker on October 20, 2011, 12:35:43 pm
Pretty much. I have the readme html file printed out for reference.
Title: Re: Axe Greyscale Tutorial
Post by: Jonius7 on October 21, 2011, 12:37:36 am
its quite simple actually. its whether a buffer is turned on or off (1 or 0). And Dispgraph, Dispgraphr, Dispgraphrr, will show 2 scale, 3 colour greyscale and 4 colour greyscale respectively.
Title: Re: Axe Greyscale Tutorial
Post by: dunrite321 on October 23, 2011, 05:35:22 pm
I have a question...

Is there a shorter way to make black text work on 4-level grayscale?  I don't want to constantly have to exchange buffers when drawing text.
Title: Re: Axe Greyscale Tutorial
Post by: chattahippie on October 23, 2011, 06:35:31 pm
If you are not using Fix 5, then just use Text(X,Y,stuff to display) after your DispGraph, it should flicker a little, but it will be black
Or, just use Text():Text()r if you are using Fix 5, with the correct arguments of course.
Title: Re: Axe Greyscale Tutorial
Post by: dunrite321 on October 23, 2011, 07:26:43 pm
Yeah, but Text()r isn't a valid command...