DistantStar001 Posted December 1, 2021 Share Posted December 1, 2021 I tweaked this program from something I saw on the 8-bit Guy. Managed to get the wave to fill most of the screen, repeat, and end where it begins on the screen. However, I was wondering if I could get it to scroll horizontally across the screen? or draw from right to left? I don't know, I'm just playing with BASIC and wanted some pointers. Program listing: 5 HGR 10 HCOLOR=3 20 FOR X=0 TO 278 30 LET Y=INT(-65*SIN(X*3.14/28))+70 40 HPLOT X,Y 50 NEXT X 60 GOTO 5 Quote Link to comment Share on other sites More sharing options...
Iamgroot Posted December 1, 2021 Share Posted December 1, 2021 Use vertical plotting to erase each vertical column before plotting the next pixel. And instead of the screen scrolling left, which is cpu intensive, have the plotted sin wave start over at the left edge of the screen again but it should have a different X coordinate. The code basically looks like this then. - create first loop - create second loop - calculate Y - set HCOLOR to black - draw a vertical line using HPLOT X,0 TO X,191 - set HCOLOR to white - plot pixel - return to second loop - return to first loop - END change line #30 to this 30 LET Y=INT(-65*SIN((X+Z*M)*3.14/28))+70 where Z is the first loop variable and M is a multiplier (try 2,3,4 etc) Quote Link to comment Share on other sites More sharing options...
DistantStar001 Posted December 2, 2021 Author Share Posted December 2, 2021 (edited) Thanks for this! Although I'm still working out how to create separate loops (I'm not very good with programing, and I don't have a manual). But for the moment, I think I can set my bar a little lower to achieve a similar effect. Since "HPLOT X,0 TO X,191" draws a vertical line, is it possible to make that line thicker and black, and get it to move across my screen through the sine wave? Essentially, give the illusion that the computer is continuously redrawing the wave? Or am I getting into sprite territory that the Apple II doesn't have? Even if it only fills the screen, I could set another wave to dray through it. Whipe the screen white, then draw a black wave, whipe black, white wave, repeat? Edited December 2, 2021 by DistantStar001 Quote Link to comment Share on other sites More sharing options...
Iamgroot Posted December 5, 2021 Share Posted December 5, 2021 Better yet. You could make the SIN wave look like a heart monitor and just have a double wide plotted pixel follow the SIN wave pattern. Line #40 basically looks like this then 40 HCOLOR=3: HPLOT X,Y: HPLOT X+1,Y : HCOLOR=0: HPLOT OX,OY : HPLOT OX+1,OY then make Line #45 into this: 45 OX=X: OY=Y Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.