Sha256: 202f645917bc2668d35a7d06a51708b55d829d6d5202b6b4f9fbd0c1fcb9c1c6
Contents?: true
Size: 968 Bytes
Versions: 5
Compression:
Stored size: 968 Bytes
Contents
# Simple 3D Bird # by Ira Greenberg. # # Using a box and 2 rects to simulate a flying bird. # Trig functions handle the flapping and sinuous movement. attr_reader :ang, :ang2, :ang3, :ang4, :flap_speed def setup size 640, 360, P3D no_stroke @ang, @ang2, @ang3, @ang4 = 0.0, 0.0, 0.0, 0.0 @flap_speed = 0.2 end def draw background 0 lights px = sin(ang3.radians) * 170 py = cos(ang3.radians) * 300 pz = sin(ang4.radians) * 500 translate width/2 + px, height/2 + py, -700 + pz rotate_x sin(ang2.radians) * 120 rotate_y sin(ang2.radians) * 50 rotate_z sin(ang2.radians) * 65 fill 153 box 20, 100, 20 fill 204 push_matrix rotate_y sin(ang.radians) * -20 rect -75, -50, 75, 100 pop_matrix push_matrix rotate_y sin(ang.radians) * 20 rect 0, -50, 75, 100 pop_matrix @ang += flap_speed @flap_speed *= -1 if ang.abs > PI @ang2 += 0.01 @ang3 += 2.0 @ang4 += 0.75 end
Version data entries
5 entries across 5 versions & 1 rubygems