Difference between revisions of "CSC111 Homework 11 solution program"

From dftwiki3
Jump to: navigation, search
(Source)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
--[[User:Thiebaut|D. Thiebaut]] 12:22, 28 April 2010 (UTC)
 
--[[User:Thiebaut|D. Thiebaut]] 12:22, 28 April 2010 (UTC)
 
----
 
----
 
+
<onlydft>
 
==Zip file==
 
==Zip file==
 
The program and all the gif files associated with it can be found in this [[Media:CSC111_hw11_solution.zip | zip file]].
 
The program and all the gif files associated with it can be found in this [[Media:CSC111_hw11_solution.zip | zip file]].
Line 29: Line 29:
 
import time
 
import time
  
 +
# ------------------------------------------------------------------------
 +
#                                    CONSTANTS
 +
# ------------------------------------------------------------------------
 
# size of the window:
 
# size of the window:
 
H = 481
 
H = 481
 
W = 605
 
W = 605
 +
n    = 7  # number of fish:
 +
fRad = 45  # half width of the fish:
  
 +
 +
# ------------------------------------------------------------------------
 +
#                                  GLOBAL VARIABLE
 +
# ------------------------------------------------------------------------
 
bubbles = []
 
bubbles = []
  
  
 
 
n    = 7  # number of fish:
 
fRad = 45  # half width of the fish:
 
  
  
 
# ------------------------------------------------------------------------
 
# ------------------------------------------------------------------------
#                               CLASSES                                       
+
#                                     CLASSES                                       
 
# ------------------------------------------------------------------------
 
# ------------------------------------------------------------------------
#                             --BUBBLE--
+
#                                   --BUBBLE--
 
class bubble:
 
class bubble:
 
     """A class defining a bubble"""
 
     """A class defining a bubble"""
Line 127: Line 132:
 
     def swim(self):
 
     def swim(self):
 
         """moves the fish horizontally and randomly up and down"""
 
         """moves the fish horizontally and randomly up and down"""
         ddy = [-3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3]
+
         ddy = [-3, -2, -1, 1, 2, 3] + 15*[0]
 
         index = randrange(len(ddy))
 
         index = randrange(len(ddy))
 
         if self.d:
 
         if self.d:
Line 227: Line 232:
  
 
</source>
 
</source>
 
+
</onlydft>
 
<br />
 
<br />
 
<br />
 
<br />

Latest revision as of 08:42, 7 September 2011

--D. Thiebaut 12:22, 28 April 2010 (UTC)



...