• Axe Greyscale Tutorial 5 1
Currently:  

Author Topic: Axe Greyscale Tutorial  (Read 18884 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Axe Greyscale Tutorial
« 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:



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.
« Last Edit: February 20, 2011, 09:46:36 am by Scout »

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Axe Greyscale Tutorial
« Reply #1 on: February 20, 2011, 10:27:16 am »
wow, that is a simple gravity engine ;)
Looks, nice (still reading)
« Last Edit: February 20, 2011, 10:27:32 am by Happybobjr »
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Greyscale Tutorial
« Reply #2 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.

Offline p2

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 849
  • Rating: +51/-11
  • I'm back :)
    • View Profile
Mistake in Tutoreal?
« Reply #3 on: June 21, 2011, 12:57:36 pm »
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:


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?


*insert supercool signature*

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Axe Greyscale Tutorial
« Reply #4 on: June 21, 2011, 12:58:48 pm »
New topic merged with "official" discussion topic. :)
« Last Edit: June 21, 2011, 01:00:45 pm by ztrumpet »

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Axe Greyscale Tutorial
« Reply #5 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]).
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Greyscale Tutorial
« Reply #6 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 :)

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Axe Greyscale Tutorial
« Reply #7 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.
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Stefan Bauwens

  • Creator of Myst 89 - סטיבן
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1799
  • Rating: +162/-24
  • 68k programmer
    • View Profile
    • Portfolio
Re: Axe Greyscale Tutorial
« Reply #8 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?


Very proud Ticalc.org POTY winner (2011 68k) with Myst 89!
Very proud TI-Planet.org DBZ winner(2013)

Interview with me

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Axe Greyscale Tutorial
« Reply #9 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.
Sig wipe!

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Greyscale Tutorial
« Reply #10 on: October 18, 2011, 10:17:25 am »
Thanks Stefan and Yeong too, your answer is just perfect.

Offline turiqwalrus

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 840
  • Rating: +51/-2
  • Wheeeeeee~!
    • View Profile
Re: Axe Greyscale Tutorial
« Reply #11 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 ;)
« Last Edit: October 18, 2011, 10:37:52 am by turiqwalrus »

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Axe Greyscale Tutorial
« Reply #12 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
« Last Edit: October 21, 2011, 12:33:52 am by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline p2

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 849
  • Rating: +51/-11
  • I'm back :)
    • View Profile
Re: Axe Greyscale Tutorial
« Reply #13 on: October 20, 2011, 11:54:54 am »
How many "r"s can you max. use?
DispGraphrrrrrrrrrrrrrrrrrrrrr isn't possible, right?
*insert supercool signature*

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Axe Greyscale Tutorial
« Reply #14 on: October 20, 2011, 11:55:23 am »
2
Sig wipe!