Jump to content
IGNORED

Pretty pattern


Vorticon

Recommended Posts

So I came across this video by 8-bit Show and Tell on Youtube and I thought it would be interesting to recreate that on the TI, so I did :) I could not get the pattern to work initially, until I figured out that the line length had to be Odd, not Even, for reasons that are unclear to me. That said, I'm not terribly happy with my code, and I was wondering if there is a way to optimize it somehow...

 

 

 

 

10 CALL CLEAR :: RANDOMIZE
20 CALL SCREEN(10)
30 CALL COLOR(1,7,10,2,9,10)
40 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF")
50 CALL CHAR(40,"FFFEFCF8F0E0C0800103070F1F3F7FFF")
60 B=B=0
70 FOR I=1 TO 27 :: B=B=0
80 Z=INT(RND+0.5)
90 IF Z=0 THEN CH=33 ELSE CH=40
100 IF B=-1 THEN IF Z=0 THEN CH=34 ELSE CH=41
110 IF I=27 THEN PRINT CHR$(CH)ELSE PRINT CHR$(CH);
120 NEXT I
130 GOTO 70

 

  • Like 5
Link to comment
Share on other sites

I was intrigued too and had a go with green instead of red 🙂:

 

100 CALL CLEAR
110 CALL SCREEN(3)
120 CALL COLOR(9,4,13)
130 CALL CHAR(96,"FFFEFCF8F0E0C080")
140 CALL CHAR(97,"0103070F1F3F7FFF")
160 CALL CHAR(98,"80C0E0F0F8FCFEFF")
165 CALL CHAR(99,"FF7F3F1F0F070301")
170 RV=INT(RND*4)
180 PRINT CHR$(96+RV);
190 GOTO 170

 

Definitely needs work ;-)

 

Edited by JJB
clatification
Link to comment
Share on other sites

Give this a go.

 

10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10)
20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF")
30 FOR I=1 TO 27 :: B=B=0 :: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30

 

  • Like 2
Link to comment
Share on other sites

15 minutes ago, OLD CS1 said:

Give this a go.

 

10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10)
20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF")
30 FOR I=1 TO 27 :: B=B=0 :: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30

 

Oh, and to reverse the effect of B, change line 30:

 

30 FOR I=1 TO 27 :: B=B=0 :: PRINT CHR$(33+INT(RND+.5)*7-B);:: NEXT I :: PRINT :: GOTO 30

 

Lastly, you can move B=B=0 to between the PRINT and NEXT statements to have it start at 0 rather than -1.

  • Like 1
Link to comment
Share on other sites

16 minutes ago, OLD CS1 said:

Give this a go.

 

10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10)
20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF")
30 FOR I=1 TO 27 :: B=B=0 :: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30

 

Yes that looks great. Shame the TI doesn't have several shades of gray ;-)

Link to comment
Share on other sites

1 hour ago, Retrospect said:

@oddemann for example, this particular line won't go down too well with the compiler, it would have to be amended somehow.

I had used RND*2 before, but I am not certain how RND returns.  @senior_falcon has some details on the best way to use RND when compiled.

  • Like 2
Link to comment
Share on other sites

Just now, OLD CS1 said:

I had used RND*2 before, but I am not certain how RND returns.  @senior_falcon has some details on the best way to use RND when compiled.

I must say those patterns are very pretty and would make a good "transition" effect between levels on an arcade game.  Not that I want to derail the thread or anything but still, they're nice. :)

  • Like 3
Link to comment
Share on other sites

2 hours ago, OLD CS1 said:

Also, this is from my back-library of schtuff.

 

5 RANDOMIZE
10 PRINT CHR$(47+INT(RND*2)*45);:: GOTO 10

 

Surprisingly, a little slower than its TI BASIC equivalent.

XB random number generator sucks from what Rich has seen. Could be that. 

  • Like 3
Link to comment
Share on other sites

14 hours ago, OLD CS1 said:

Give this a go.

 

10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10)
20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF")
30 FOR I=1 TO 27 :: B=B=0 :: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30

 

That's what I'm talking about! 

Link to comment
Share on other sites

B=B=0   I don't understand the purpose of this? It sets B=0 and I see no place where B is ever changed

 

PRINT CHR$(34+INT(RND+.5)*7+B)

RND+.5 will be a value from .5 to 1.4999.....

so INT(RND+.5) will be 0 or 1 with an equal chance of either one.

so INT(RND+.5)*7 will be either 0 or 7

 

You could replace that with PRINT CHR$(34+INT(RND*2)*7); and since B=0 I left it out.

 

And with those changes I think this could be compiled.

Edited by senior_falcon
Link to comment
Share on other sites

27 minutes ago, senior_falcon said:

B=B=0   I don't understand the purpose of this? It sets B=0 and I see no place where B is ever changed

 

That is not what happens. B is set to -1 (TRUE) if B=0 going into the expression or 0 (FALSE), otherwise. The first '=' is an assignment operator and the second '=' is a relational operator. The expression is treated the same as though it were stated

B=(B=0)

...lee

Link to comment
Share on other sites

27 minutes ago, Lee Stewart said:

 

That is not what happens. B is set to -1 (TRUE) if B=0 going into the expression or 0 (FALSE), otherwise. The first '=' is an assignment operator and the second '=' is a relational operator. The expression is treated the same as though it were stated

B=(B=0)

...lee

You are right! I thought that is what would happen and tested this in the immediate mode:

B=B=0

PRINT B

and it prints 0

 

It must be that B was set to some value other than zero, because if you enter

B=0

B=B=0

PRINT B

then -1 is printed. 

 

And of course, the program 10 B=B=0::PRINT B 

will print -1 as you say. 

Link to comment
Share on other sites

7 minutes ago, senior_falcon said:

You are right! I thought that is what would happen and tested this in the immediate mode:

B=B=0

PRINT B

and it prints 0

 

It must be that B was set to some value other than zero, because if you enter

B=0

B=B=0

PRINT B

then -1 is printed. 

 

And of course, the program 10 B=B=0::PRINT B 

will print -1 as you say. 

 

Yeah, in Walid’s program, B will alternate between 0 and -1 as the loop containing it executes.

 

...lee

Link to comment
Share on other sites

52 minutes ago, Lee Stewart said:

 

Yeah, in Walid’s program, B will alternate between 0 and -1 as the loop containing it executes.

 

...lee

I changed the program to see what was going on in B and it was just -1 0 over and over and over?

10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10)
20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF")
30 FOR I=1 TO 27 :: B=B=0 :: S$=S$&STR$(B):: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30

Yea I know it crashes with string full but just FCTN 4 and type PRINT S$ to see result.

Link to comment
Share on other sites

20 hours ago, Vorticon said:

I could not get the pattern to work initially, until I figured out that the line length had to be Odd, not Even, for reasons that are unclear to me.

 

30 FOR I=1 TO 27 :: B=B=0 :: S$=S$&STR$(B):: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30

i'm guessing the B=(B=0) is getting out of sync when the line is even. I bet if you added B=(B=0) after NEXT I it would work properly with an even line length. (and improperly with an odd line length)

 

  • Like 1
Link to comment
Share on other sites

55 minutes ago, senior_falcon said:

i'm guessing the B=(B=0) is getting out of sync when the line is even. I bet if you added B=(B=0) after NEXT I it would work properly with an even line length. (and improperly with an odd line length)

The line length is controlled by I, hence 27 characters and thus odd.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...