Author Topic: One letter at a time...  (Read 3180 times)

0 Members and 1 Guest are viewing this topic.

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
One letter at a time...
« on: October 23, 2011, 12:16:46 am »
Ok, using the "Text(" Command, how would I display text on the screen one letter at a time for dramitization?
Also... How would I make a menu? I've tried adding and subtracting the Y value but it wont do anything, i need maybe an example...  :banghead:

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: One letter at a time...
« Reply #1 on: October 23, 2011, 03:09:48 am »
Okay, this isn't tested + I'm writing this up while half-incoherent with sleep, but here's something that _might_ work to display letters one at a time:

Edit: Okay, it works now.

Assuming Axe 1.0.5 for function coolness.

Code: [Select]
.TEST

. Use 'Fix 5' to draw all text to the buffer.
Fix 5


.Text you want to display:
"HELLO WORLD"->Str1

.Display the text
SLTXT(10,10,8,1000,Str1)

.Wait until you press [CLEAR] to quit.
Repeat getKey(15)
    DispGraph
End

. End program
Fix 4
Return


.Function:
.r1 = X coordinate
.r2 = Y coordinate
.r3 = Distance between letters
.r4 = Delay between each letter
.r5 = Pointer to string
Lbl SLTXT
    0->r6
    While {r5+r6}
        .X1T is from the parametric variable section.
        .I just needed another variable -- you could have done
        .r5+r6->A
        .and used A instead if you needed to.
        r5+r6->X1T

        .'o^^' is the degrees symbol
        Text(r6*r3+r5,r2,o^^X1T)

        Pause r4
        r6+1->r6
    End
Return


.Basically:
.While the character isn't [00] (null byte),
.keep going and display the character.


What kind of menu?  There are so many...

Here's basically pseudocode for what I would do for a basic menu:
Code: [Select]
.TEST

Fix 5

Draw basic stuff
Write all the text
Draw a sprite next to the first item
Repeat until I press [2nd] or [Enter]
    If getkey up or down
        erase the sprite
        If getkey up
            Subtract 1 from the sprite's Y value
        End
        If getkey down
            Add 1 to the sprite's Y value
        End
        Draw the sprite (multiply the Y value by whatever and add an offset)
        DispGraph
    End
End

The sprite's Y coordinate is the menu item number
If Y=0
    .Do something
ElseIf Y=1
    .Do something
ElseIf (etc....)
    .Blah
End

(Either wrap the entire menu in a loop, or add a Goto here.)

« Last Edit: October 23, 2011, 11:41:49 am by Michael_Lee »
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 hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: One letter at a time...
« Reply #2 on: October 23, 2011, 05:53:54 pm »
Ok, What are the Fixes? I only know what Fix 5 does...

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: One letter at a time...
« Reply #3 on: October 23, 2011, 06:02:13 pm »
the explanation of what all the fixes do is in the commands list

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: One letter at a time...
« Reply #4 on: October 23, 2011, 06:04:17 pm »
What they all do are in the commands list: http://ourl.ca/8409
(see the 'Text' section)

I like to think of them as 'switches': you do Fix 5, the program 'switches' so that all text is drawn to the buffer, not directly to the screen, and you do Fix 4 to revert it back (which is good practice, otherwise things will look a little funny temporarily after you end the program.)
« Last Edit: October 23, 2011, 06:04:27 pm by Michael_Lee »
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 hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: One letter at a time...
« Reply #5 on: October 24, 2011, 02:45:26 pm »
Thanks!

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: One letter at a time...
« Reply #6 on: October 24, 2011, 03:21:50 pm »
By one letter at a time do you mean like in RPG text boxes where the text appears like if it was typed? I always had troubles trying to figure that out myself in Axe too.

Also when this topic was started, I thought somebody started a forum game where each member posts one letter per post lol. Glad it wasn't the case.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: One letter at a time...
« Reply #7 on: October 25, 2011, 09:28:05 am »
I know somebody made a substring routine. (I think it's Runer) use his routine to display one letter and put some pause.. repeat..
That would work.
Sig wipe!

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: One letter at a time...
« Reply #8 on: October 25, 2011, 10:54:34 am »
Its not really hard or so.
I'm not a nerd but I pretend: