Author Topic: Naalaa wavy with important message  (Read 1158 times)

B+

  • Guest
Naalaa wavy with important message
« on: July 19, 2018, 12:06:35 AM »
Code: [Select]

' Much better wavy.txt
' written for Naalaa 6 by bplus 2018-07-18

radians

constant:
wW 512
wH 512

visible:
pi# = acos#(-1.0)

hidden:

set window 100, 20, wW, wH

wln "B+ "
wln "..."

p[21][ 21]
for y = 0 to 16
   for x = 0 to 16
       if pixeli(x, y) <> pixeli(0, 10) then p[x + 3][ y + 3] = 1
   next
next

'check array, good!
'for y = 0 to 19
'    for x = 0 to 19
'        if p[x][y] = 1
'            set color 0, 0, 255
'            draw rect 100 + x, 100 + y, 1, 1
'        endif
'    next
'next
'wait keydown

set redraw off
r = 1 ; phase# = 0.0; loopCount = 0; d = 1
while 1
   set color 0, 0, 0
   draw rect 0, 0, wW, wH, true
   loopCount = loopCount + 1
   if loopCount = 10
       loopCount = 0
       r = r + d
       if r > 15 or r < 2 then d = d * -1
   endif
   for y = 1 to 20
       for x = 1 to 20
           'this syncs all the string angles from the grid points
           phase# = phase# + pi# / 40.0

           ' Sorry the following is still pretty hairy looking: 18.0 = 360 / 20 ie the circle divided into 20 even sections.
           ' The following calculates the other end of all the strings which is the origin of the swinging balls (xs, ys).
           ' The points have a distance of 20 and the strings are also 20 pixels long.
           ' The 40 is an offset to provide a margin for the point grid.
           xs = 40 + 20 * x + int(20.0 * cos#(pi# / 180.0 * (phase# + (float(x) + float(y)) * 18.0)))
           ys = 40 + 20 * y + int(20.0 * sin#(pi# / 180.0 * (phase# + (float(x) + float(y)) * 18.0)))
           set color 255, 255, 255
           draw line 40 + 20 * x, 40 + 20 * y, xs, ys
           if p[x][y]
               set color 0, 0, 255
           else
               set color 255, 255, 255
           endif
           draw ellipse xs, ys, r, r, true
       next
   next
   redraw
   wait 100
wend