Bruce Chang - Problem Set #2
 
Part 1
p1.dbn
//PRODUCES A PSEUDO-INTERLACED .GIF
//EFFECT
pen 75
repeat x 5 0
{
   repeat y 20 0
   {
      line 0 (y*5+x) 100 (y*5+x)
   }
}




Choose a single shade of a paper and render that shade.
 
Part 2
p2.dbn
// "SQUISHY STRESS BALL"
// rebound takes longer than the
// compression
paper 0
repeat z 1 3
{
   repeat x 0 5
   {
      paper (x*20)
   }
   repeat y 20 0
   {
      paper (y*5)
   }
}
// z loops block of code 3 times
// x fades to black step 20
// y fades to white step 5


Create a sequence of shaded papers using the Repeat command as a short animation of brightness. For example
Repeat a 0 100
{
Paper a
}

 
Part 3
p3.dbn
// HEARTBEAT IN (ALMOST) DUPLE-TRIPLE METER
paper 100
//REPEAT BLOCK OF CODE 10 TIMES
repeat z 1 10
{
   //lub (white fade to black)
   repeat x 0 3
   {
      paper (x*30)
   }
   //dub (white fade to black + pause)
   repeat x 0 6
   {
      paper (x*17)
   }
   //delay program 1/2 sec. or so
   repeat w 0 100
   {
      set [1 1] 100
   }
}




Create an animation of a sequence of shaded papers that evokes a sense of rhythm.
 
Part 4
p4.dbn
// NODDING OFF IN CLASS:
// exponential fading symbolizes drooping
// head
// awake = white
// passed out = black
paper 100
// BEGIN DROOPING
repeat x 0 65
{
   paper (x*x/60)
}
// LOOP "DOZING" BLOCK OF CODE
repeat z 1 3
{
   //CATCH YOURSELF DROOPING AND WAKE UP
   //SOMEWHAT
   repeat x 10 3
   {
      paper (x*7)
   }
   //DROOPING ONCE AGAIN
   repeat x 20 85
   {
      paper (x*x/70)
   }
}


Create an animation of a sequence of shaded papers that evokes a tranquil, sleepy image.
 
Part 5
p5.dbn
//GRADUAL INCREASE IN BRIGHTNESS WITH
//CHECKPOINT FLASHES EVERY 20%
paper 0
set x 240
repeat y 1 5
{
   set x (x-40)
   //INCREASE BRIGHTNESS 20%
   repeat x x (x-40)
   {
      paper (x/2)
   }
   
   //CHECKPOINT FLASH
   paper 0
}


Create an animation of a sequence of shaded papers that evokes a gradually increasing/heightening feeling.
 
Part 6
p6.dbn
// FALLING LINE SEGMENT
// SET TO THE BACKGROUND OF PART 5
// a shifts line horizontally
// x shifts line downwards
paper 0
set b 120
repeat x 0 5
{
   //FALL TO LEFT
   set a 6
   repeat y 0 10
   {
      set b (b-1)
      set a (a-3)
      paper (b-20)
      line (35+a) (100-(x*20)) (75+a) (110-y*2-(x*20))
   }
   //FALL TO RIGHT
   set a 6
   repeat y 0 10
   {
      set b (b-1)
      set a (a+3)
      paper (b-20)
      line (0+a) (100-y*2-(x*20)) (40+a) (90-(x*20))
   }
// paper 0  (TOOK OUT THE CHECKPOINT FLASH
//           FROM PART 5 CAUSE IT LOOKED
//           STUPID)
}





Add a single line to the sequence, and let it fly in time. For instance
Repeat a 0 100
{
Paper 0
Line a 0 a 100
}

 
Part 7
p7.dbn
// RADAR DETECTING APPROACHING BOGIE
paper 0
pen 100
set a (-1)
set b (-10)
set c (-1)
set d (-10)
set e 0
// HARMONIC MOTION IN X & Y DIRECTIONS
// 90 DEGREE ROTATIONS IN 4 QUADRANTS
// RADAR SCANS 3 TIMES
repeat g 1 3
{
   set e (e+15)
   repeat y (-10) 0
   {
      set a (a+1)
      paper 0
      line (a*a/2) (y*y/(-2)+100) 50 50
   }
   repeat y 0 9
   {
      set b (b+1)
      paper 0
      line (b*b/(-2)+100) (y*y/(-2)+100) 50 50
      //APPROACHING BOGIE
      pen (b*(-15))
      line 47 (110-b/2-e) 54 (100-b/2-e)
      pen 100
   }
   repeat y (-10) 0
   {
      set c (c+1)
      paper 0
      line (c*c/(-2)+100) (y*y/2) 50 50
   }
   repeat y 0 9
   {
      set d (d+1)
      paper 0
      line (d*d/2) (y*y/2) 50 50
   }
   set a (-1)
   set b (-10)
   set c (-1)
   set d (-10)
}
// BOOM!  BOGIE DESTROYS BASE
paper 0
paper 100
paper 0
paper 100
repeat x 0 20
{
   paper (x*5)
}
// a,b,c,d DEFINE x-COORDINATES FOR
// HARMONIC MOTION
// b,e CONTROL BOGIE: b FADES BOGIE, e
// LOWERS BOGIE


Add another line and let two lines fly in contrasting styles.
 
Part 8
p8.dbn
//2 LINES "FLY" COOPERATIVELY TO DRAW
//OPPOSITE EDGES OF A CUBE
//
//VERY INEFFICIENT CODE, BUT I CAN'T
//FIGURE OUT HOW TO UTILIZE SPRITES
//OR LAYERS
paper 0
//-----------------------------------
repeat x 0 2
{
   pen 100
   line (x*20) 55 (x*20+10) 55
   line 45 (x*20) 45 (x*20+10)
   paper 0
}
pen 20
line 45 55 75 55
line 45 25 45 55
repeat x 3 5
{
   pen 20
   line 45 55 75 55
   line 45 25 45 55
   pen 100
   line (x*20) 55 (x*20+10) 55
   line 45 (x*20) 45 (x*20+10)
   paper 0
}
pen 20
line 45 55 75 55
line 45 25 45 55
//-----------------------------------
repeat x 0 2
{
   pen 20
   line 45 55 75 55
   line 45 25 45 55
   pen 100
   line (x*20) 45 (x*20+10) 45
   line 55 (x*20) 55 (x*20+10)
   paper 0
}
pen 20
line 45 55 75 55
line 45 25 45 55
line 25 45 55 45
line 55 45 55 75
repeat x 3 5
{
   pen 20
   line 45 55 75 55
   line 45 25 45 55
   line 25 45 55 45
   line 55 45 55 75
   pen 100
   line (x*20) 45 (x*20+10) 45
   line 55 (x*20) 55 (x*20+10)
   paper 0
}
pen 20
line 45 55 75 55
line 45 25 45 55
line 25 45 55 45
line 55 45 55 75
//-----------------------------------
repeat x 0 2
{
   pen 20
   line 45 55 75 55
   line 45 25 45 55
   line 25 45 55 45
   line 55 45 55 75
   pen 100
   line (x*20) ((-1)*x*20+100) (x*20+10) ((-1)*x*20+90)
   line ((-1)*x*20+100) (x*20) ((-1)*x*20+90) (x*20+10)
   paper 0
}
pen 20
line 25 75 45 55
line 45 55 75 55
line 45 25 45 55
line 25 45 55 45
line 55 45 55 75
repeat x 3 5
{
   pen 20
   line 25 75 45 55
   line 55 45 75 25
   line 45 55 75 55
   line 45 25 45 55
   line 25 45 55 45
   line 55 45 55 75
   pen 100
   line (x*20) ((-1)*x*20+100) (x*20+10) ((-1)*x*20+90)
   line ((-1)*x*20+100) (x*20) ((-1)*x*20+90) (x*20+10)
   paper 0
}
pen 20
line 25 75 45 55
line 55 45 75 25
line 45 55 75 55
line 45 25 45 55
line 25 45 55 45
line 55 45 55 75
//-----------------------------------
//REMAINING EDGES FADE IN
repeat x 0 20
{
   pen x
   line 25 75 55 75
   line 45 25 75 25
   line 25 75 25 45
   line 75 25 75 55
   line 25 45 45 25
   line 55 75 75 55
}


Let two lines fly in cooperative styles.
 
Part 9
p9.dbn
//// // a carefully chosen line
//// paper 50
//// pen 100
//// line 0 50 100 50
//
// Comments on Nick's Code for Part 1 PS1:
//
// Nick noted in a commented line that it
// was "a carefully chosen line,"
// therefore the line he created was
// ideal for his purposes.  I see the 
// image as the top of a cardboard box
// with a horizonal seam where the flaps
// meet.
//
//I'd brighten the background a bit to
//give more contrast to the line:
//
paper 20
pen 100
line 0 50 100 50


Using Part 1 of Problem Set 1, you are asked to comment and improve on a colleague's work. The person you will choose is determined by your order in the pulldown menu of the main page. For example, Ben should comment on Bruce, Bruce on Nick, and all the way down to Hoeteck commenting on Ben (wrapped around). We don't have a form mechanism setup, so for now just put it inside your DBN buffer as a comment, and include a modified version of your colleague's program that reflects your suggestions.
 
Part 10
p10.dbn
////paper = 0
////pen = 100
////set y 2
////set z 0
////set q 5
////repeat x 1 9
////{
////set h q
////set q (q+10)
////set y (x*10)
////set z (x*15)
////repeat a y z
////{
////   repeat B 10 (a-1)
////   {
////      set [a b] (h+5)
////   }
////}
////}
//
//Comments on Nick's part 10 PS1:
//
// Nick's code produces a triangle with
// vertical gradient stripes.  The code
// can be cleaned up a bit:
// e.g. "q" can be eliminated
// completely and "h" can be
// independent: "set h 5" replaces
// "set q 5"; "set h (h+10)" replaces
// "set q (q+10)" and can be placed
// after the internal "repeat a y z" loop
// to prevent the initial increment of
// "h." Also, initial declarations of "y"
// and "z" are unnecessary because both are
// later redefined as functions of "x."
// In terms of aesthetics, the missing
// chunk at the left corner of the triangle
// can be removed.  As a technicality
// issue, the problem statement requires
// the "Line" command to render the
// object.  Optimized code for similar
// output:
//
paper 0
repeat a 1 9
{
   pen (a*10)
   repeat b 1 10
   {
      line (a*10+b) 10 (a*10+b) (a*10+b)
   }
}

Do the same as above for Part 10 of Problem Set 1.