### Author Topic: Flickering Text (and collision?)  (Read 983 times)

0 Members and 1 Guest are viewing this topic.

#### Joey H.

• LV1 Newcomer (Next: 20)
• Posts: 5
• Rating: +0/-0
• Take Care!
##### Flickering Text (and collision?)
« on: June 04, 2021, 07:53:51 pm »
Hello!
I am new here on this Forum and hope to learn a thing or two sooner or later about Axe Parser!
Call me Joey.
Since I'm new here, this may be a rather dumb question, because I cannot seem to find anyone else with the same problem here...
Anyway, my very first question to ask is as follows: The Text in my game displaying the score to the player is flickering and really lagging up the game...
This is what loops every frame:
Code: [Select]
ClrDraw.Text(1,0,"SCORE:").Text(32,0,D►Dec)Pt-On(X,Y,Pic1)Pt-On(A,B,Pic2)DispGraphIt's pretty clear that this would flicker the text, but I do not know how to fix it...
How might I go about making this issue stop? (Thanks in advance)
« Last Edit: June 04, 2021, 09:18:05 pm by Joey H. »

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4678
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do.
##### Re: Flickering Text
« Reply #1 on: June 04, 2021, 08:22:17 pm »
If that is your loop then it shouldn't be flickering as far as I can tell. Can you post the rest of the code? It'll only be flickering of there is another DispGraph between the ClrDraw and DispGraph (or of course if the text is changing )

Also, if you only draw the text and update the screen (DispGraph) when something changes, then you'll get a significant speed-up.

EDIT: Ooohhh, I know the issue. At the start of your program (not in the loop), use Fix 5 and before you exit, run Fix 4.
The default behavior of Text( is to draw directly to the LCD and not the graphics buffer (this is what TI-OS expects when your program is finished). Fix 5 switches it to draw to the buffer and not the LCD.

So you would draw the text, and then when DispGraph, the text isn't drawn to the buffer and so it gets erased.
« Last Edit: June 04, 2021, 08:37:17 pm by Xeda112358 »

#### Joey H.

• LV1 Newcomer (Next: 20)
• Posts: 5
• Rating: +0/-0
• Take Care!
##### Re: Flickering Text
« Reply #2 on: June 04, 2021, 08:38:13 pm »
The entirety of my code:

It is a tad shaky, but here it is!

When I add the Fixes it does the same thing, same issue...:
Code: [Select]
.DODGEB2 Dodge Da Blocks![3C42A5A581BD423C]→Pic1[FF81A5A581BD81FF]→Pic2DiagnosticOffClrHome48→X52→Y0→Brand/745→A1→C0→DFix 0Fix 5Repeat getKey(15)Pause 5If getKey(2) and (X≠0X-1→XEndIf getKey(3) and (X≠88X+1→XEnd!If B≥64B+C→BElseD+1→D0→Brand/745→AEndClrDrawText(1,0,"DODGED:")Text(32,0,DDec)Pt-On(X,Y,Pic1)Pt-On(A,B,Pic2)DispGraphLbl BFix 4End

Oh. Wait!!!!
It works when I do it now! Where do I put the Fix 4 Recovery line of code now?
Code: [Select]
.DODGEB2 Dodge Da Blocks![3C42A5A581BD423C]→Pic1[FF81A5A581BD81FF]→Pic2DiagnosticOffClrHome48→X52→Y0→Brand/745→A1→C0→DFix 0Fix 5Repeat getKey(15)Pause 5If getKey(2) and (X≠0X-1→XEndIf getKey(3) and (X≠88X+1→XEnd!If B≥64B+C→BElseD+1→D0→Brand/745→AEndClrDrawText(1,0,"DODGED:")Text(32,0,DDec)Pt-On(X,Y,Pic1)Pt-On(A,B,Pic2)DispGraphLbl BEndEDIT: (Zeda) Merged double-posts.
« Last Edit: June 04, 2021, 08:53:38 pm by Xeda112358 »

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4678
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do.
##### Re: Flickering Text
« Reply #3 on: June 04, 2021, 08:50:10 pm »
You have the Fix 4 inside the loop so after the first iteration, it starts drawing directly to the LCD again. If you move it outside the loop (after the End), then it should work.

Also as general forum etiquette, you can Modify your post instead of double- (or triple-) posting (Double posting is when you post twice in a row. General rule of thumb is that after a day since the last post it is okay to double-post.)

#### Joey H.

• LV1 Newcomer (Next: 20)
• Posts: 5
• Rating: +0/-0
• Take Care!
##### Re: Flickering Text
« Reply #4 on: June 04, 2021, 08:54:06 pm »
All right!
That seems to work now!
One last look:
Code: [Select]
.DODGEB2 Dodge Da Blocks![3C42A5A581BD423C]→Pic1[FF81A5A581BD81FF]→Pic2DiagnosticOffClrHome48→X52→Y0→Brand/745→A1→C0→DFix 0Fix 5Repeat getKey(15)Pause 5If getKey(2) and (X≠0X-1→XEndIf getKey(3) and (X≠88X+1→XEnd!If B≥64B+C→BElseD+1→D0→Brand/745→AEndClrDrawText(1,0,"DODGED:")Text(32,0,DDec)Pt-On(X,Y,Pic1)Pt-On(A,B,Pic2)DispGraphLbl BEndFix 4
Thank you very much!
But my apologies about the double (or triple) posting... I was a bit confused with myself; and also, I had a feeling already that it wasn't polite, but thank you for confirming it!

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4678
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do.
##### Re: Flickering Text
« Reply #5 on: June 04, 2021, 09:00:09 pm »
Haha, no problem, and I merged those posts together.

The code looks like it should work. So for an optimization, if you draw the sprite with XOR logic, then DispGraph, then re-draw with XOR logic, then you won't have to ClrDraw to remove the sprites. (It's like doing a pxl-change/DispGraph/pxl-change)

So what about the text? You can draw the initial score before the loop, and after that, only re-draw the score when you increment D.

Drawing text can be slow, so only drawing it when needed will save a lot of time in your loop.

EDIT: clarified what xor/disp/xor was doing

#### Joey H.

• LV1 Newcomer (Next: 20)
• Posts: 5
• Rating: +0/-0
• Take Care!
##### Re: Flickering Text
« Reply #6 on: June 04, 2021, 09:17:08 pm »
I'm certainly learning a lot here!
Among all of this, how might I add a system which responds when there is a collision between this "block" (what you have to dodge) and the character doing the dodging?
Will this slow it down a lot or is there a better way than how I'm approaching it?:
Code: [Select]
If B>44If A>(X-8) and A<(X+8)Pt-Off(X,Y,Pic3)Goto DEndEndB is the Y coord. of the block, X is the X of the character, A is the X of the block

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4678
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do.
##### Re: Flickering Text (and collision?)
« Reply #7 on: June 04, 2021, 09:25:57 pm »
That is probably the simplest and fastest method and shouldn't slow it down much, but there might be order-of-operations issues, so you might need:
Code: [Select]
If (A>(X-8)) and (A<(X+8))Alternatively:
Code: [Select]
If (A-X>-8) and (A-X<8)But for Axe, that can probably be optimized to:
Code: [Select]
If A-X+7 < 15(This is taking advantage of "negative" numbers actually being really large, so you don't need to make sure A-X+7>=0. If it was "smaller" than zero, it would actually be around 65000 which is not less than 15 )

#### Joey H.

• LV1 Newcomer (Next: 20)
• Posts: 5
• Rating: +0/-0
• Take Care!
##### Re: Flickering Text (and collision?)
« Reply #8 on: June 04, 2021, 09:37:47 pm »
Whoa! You're good!
Well, Thank you very much, that's all for now!
Thanks!!!