Author Topic: Homescreen Invaders Bug!!! Matrix rendering system broken  (Read 6795 times)

0 Members and 1 Guest are viewing this topic.

Offline boot2490

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 607
  • Rating: +54/-36
    • View Profile
    • Boot2490's Stuff
Homescreen Invaders Bug!!! Matrix rendering system broken
« on: September 25, 2011, 06:06:22 pm »
So, in homescreen invaders, the alien fleet is rendered by the program reading from a 3X5 matrix and drawing a V in the appropriate position.
Howver, it doesn't draw anything.
Also, the matrix is appropriately filled with 1's for the example.
Here is the code:
Code: [Select]
1→M
1→X
1→Y
While M≤15
If X≤5
Then
If Y≤3
Then
If [I](Y,X)=1
Output(Y+3,X+3,"V"
If [I](Y,X)=0
Output(Y+3,X+3," "
Else
Goto Z
End
Else
X+1→X
Y+1→Y
End
M+1→M
End
I'm not worried about SOPA creating censorship, that will not stand for long. I'm worried that they'll succeed in stopping piracy!

Spoiler For Signature, updated march 23, 11:28 PM EST:















An useful tool!

PM me if you need some help. I am glad to be of assistance and part of the TI Communnity.

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #1 on: September 25, 2011, 06:20:05 pm »
Nevermind whatever I had here at first. I was being stupid. Um... I'm going to use my own method (but retain some of the same things of yours) because I despise while loops unless I'm reading from a file on the computer... This method will also allow you to change the size of the matrix at any time.

Code: [Select]
dim([I]→L1
Ans(1→H
L1(2→W
For(Y,1,H)
For(X,1,W)
If [I](Y,X)=1
Output(Y+3,X+3,"V
If not([I](Y,X
Output(Y+3,X+3," "
End
End
DelVar L1
« Last Edit: September 25, 2011, 08:04:21 pm by BlakPilar »

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: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #2 on: September 25, 2011, 06:47:23 pm »
Please don't put a loop after a DelVar.  It will then be skipped if something like an if statement surrounds it. ;)
Also, if you close the parenthesis on the For loops, it'll run faster (because TI fails).

Offline boot2490

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 607
  • Rating: +54/-36
    • View Profile
    • Boot2490's Stuff
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #3 on: September 25, 2011, 06:48:17 pm »
That is a lot of less lines. How does it work? Must know...
I'm not worried about SOPA creating censorship, that will not stand for long. I'm worried that they'll succeed in stopping piracy!

Spoiler For Signature, updated march 23, 11:28 PM EST:















An useful tool!

PM me if you need some help. I am glad to be of assistance and part of the TI Communnity.

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #4 on: September 25, 2011, 06:49:17 pm »
@ztrumpet, Ahh. I haven't really done anything with TI-BASIC in a looong time, so sorry about that lol. I just did it the way Is do it on the computer.
« Last Edit: September 25, 2011, 06:59:31 pm by BlakPilar »

Offline Broseph Radson

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 295
  • Rating: +20/-1
  • Its 0x1A4 somewhere
    • View Profile
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #5 on: October 03, 2011, 04:27:17 pm »
Woo I'm late to this thread. That code works like this:
the outer for increments once each time the inner for finishes, so it reads the matrix row by row. The conditionals use the values in the for loops to correspond to coordinates in the matrix, and the outputs use those coordinates to place the characters where they belong on screen in relation to the current y,x of the loops.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #6 on: October 06, 2011, 03:15:20 pm »
Code: (BlakPilar's Code Optimized) [Select]
dim([I]
For(Y,1,Ans(1
For(X,1,Ans(2
If [I](Y,X
Then
Output(Y+3,X+3,"V
Else
Output(Y+3,X+3,"_
End
End
End
DelVar L1
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #7 on: October 06, 2011, 04:15:53 pm »
Perhaps you can clarify for me then, meishe. Does the calculator pre-determine the min and max values for for loops?

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #8 on: October 06, 2011, 04:27:54 pm »
Do you mean it that it determines the variables then store them somewhere?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #9 on: October 06, 2011, 04:51:03 pm »
Basically, yeah. Like, if I do
Code: [Select]
5
For(A,1,Ans
2
End
will it use 5 as the max instead of 2?

Offline Broseph Radson

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 295
  • Rating: +20/-1
  • Its 0x1A4 somewhere
    • View Profile
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #10 on: October 06, 2011, 04:51:41 pm »
Code: [Select]
Dim([I]
Returns the dimensions of matrix I in ans in list format so the length and width can be recalled as ans(#

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #11 on: October 06, 2011, 05:00:29 pm »
I know that (if that was meant for me), but my question was if the calculator remembers that as Ans for the for loop instead of something inside of the loop.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #12 on: October 06, 2011, 05:06:38 pm »
Ya, I believe it will. I mean it works in my example anyways :P I believe the only way to effect how the For() counts is if you modify the variable it uses. So say you have For(A,1,100):A+1→A:End, I believe it will actually be counting by two instead of by one. (Note: I haven't actually tested that, so I could be wrong. But the principle remains the same.)
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

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: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #13 on: October 06, 2011, 05:57:14 pm »
Perhaps you can clarify for me then, meishe. Does the calculator pre-determine the min and max values for for loops?
I'm actually not sure.  Meishe's example works because Ans is never changed during the loops.

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Homescreen Invaders Bug!!! Matrix rendering system broken
« Reply #14 on: October 06, 2011, 06:10:02 pm »
Quick Wabbit test shows that
Code: [Select]
5
For(A,1,Ans
2
Disp Ans
End
Displays "2" five times. So maybe? :D