Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: meishe91 on March 12, 2010, 03:15:58 pm

Title: Pxl-On troubles
Post by: meishe91 on March 12, 2010, 03:15:58 pm
Ok, so I know I'm doing something dumb in these line of code but I can't figure out what it is.

Code: [Select]
If sub(Str1,AW-W+C,1)≠Str2
Pxl-On(A-1,B

That's not all the code but I'm pretty sure my error is happening there. (It isn't turning on the right pixels.) I can provide more if nothing is seen wrong. Thanks for any help :)
Title: Re: Pxl-On troubles
Post by: trevmeister66 on March 12, 2010, 03:22:00 pm
Is A your X or your Y Variable? Because Pxl is (X,Y) I believe, while Pt is (Y,X). or vice versa, i can't remember exactly
Title: Re: Pxl-On troubles
Post by: meishe91 on March 12, 2010, 03:23:52 pm
Well it isn't that it is displaying in the wrong place, is that it is recognizing everything as being true (therefore turning all pixels on and not skipping any). Sorry for not specifying.
Title: Re: Pxl-On troubles
Post by: Radical Pi on March 12, 2010, 03:24:38 pm
Pt is (X,Y), like how normal points are written.
Pxl is (Y,X) like Output( is for the homescreen.

It would help to know what the variables represent (although I have a good idea already ;)) and what the strings are.
Title: Re: Pxl-On troubles
Post by: trevmeister66 on March 12, 2010, 03:26:15 pm
Well what ever you're getting out of Str1 is going to only be 1 character long, so if Str2 is longer than 1 character, then it will never be true
Title: Re: Pxl-On troubles
Post by: meishe91 on March 12, 2010, 03:41:32 pm
Haha ya, Nyrax you probably do. It has to do with a String►Pic program. I'm just trying not to release to much...yet :P
Str1 is your map.
Str2 is your the character you can move over (space for example).
W is the width of the map.
A is the y-value.
B is the x-value.
C helps locate the location in the String.
Title: Re: Pxl-On troubles
Post by: Radical Pi on March 12, 2010, 04:06:11 pm
Like trevmeister said, are you sure that length(Str2)=1? If it is then all I can think of is to double check that A, W, and C are all still the right values when that piece of code executes.
Title: Re: Pxl-On troubles
Post by: meishe91 on March 12, 2010, 04:10:56 pm
Ya because you enter it manually. It's not something that is preset. But thanks you guys. I'll go over it and see what I come up with.
Title: Re: Pxl-On troubles
Post by: trevmeister66 on March 12, 2010, 04:14:12 pm
Hmm yeah it probably has to do with your variables then. Maybe the algebra is wrong or something, although from what it looks like, it seems fine. Good luck with finding out the bug
Title: Re: Pxl-On troubles
Post by: meishe91 on March 12, 2010, 04:22:10 pm
Grrr, I can't figure it out! I keep coming up with the same things :P
I'm just gonna show all the code and see what you guys see. Maybe that will shed some light on it.

Code: [Select]
PROGRAM:CNVRTSP
ClrDraw
AxesOff
FnOff
Input "WIDTH: ",W
Input "HEIGHT: ",H
Input "SPACE CHARACTER:",Str2
For(A,1,H
1→C
For(B,1,W
If sub(Str1,AW-W+C,1)≠Str2
Pxl-On(A-1,B-1
End
End
StorePic Pic1

I realize this is probably not optimized, I'm just getting the programs so they work and then going from there.
Title: Re: Pxl-On troubles
Post by: Radical Pi on March 12, 2010, 04:59:11 pm
You don't even need C. Take the substring at AW-W+B like so:

Code: [Select]
PROGRAM:CNVRTSP
ClrDraw
AxesOff
FnOff
Input "WIDTH: ",W
Input "HEIGHT: ",H
Input "SPACE CHARACTER:",Str2
For(A,1,H
For(B,1,W
If sub(Str1,AW-W+B,1)≠Str2
Pxl-On(A-1,B-1
End
End
StorePic Pic1
Title: Re: Pxl-On troubles
Post by: meishe91 on March 12, 2010, 05:06:35 pm
Ooooooooooook, I see what I did now. I wasn't increasing C by one each time like it should have been. But ya, you're right, C isn't needed. Thanks :D