Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Mystery Logo Animation

# writes a frame to a file with the frame number in the filename
def writeFrame(frame, num):
  strNum = str(num)
  if num < 10:
    strNum = "00" + strNum
  elif num < 100:
    strNum = "0" + strNum
  filename = "frame" + strNum + ".jpg"
  writePictureTo(frame, getMediaPath(filename))

# main function: makes the frames of the movie
def makeFrames():
  # constants
  b = makeColor(0, 0, 0)
  numberOfFrames = 150
  speed = 1
  width = 100
  height = 100
  x1 = 7
  x2 = 14
  x3 = 21
  x4 = 28
  x5 = 35
  y1 = 10
  y2 = 20
  y3 = 30
  y4 = 40
  # initial settings (go left)
  x = x3
  y = y1
  dx = speed * -1
  dy = 0
  canvas = makeEmptyPicture(width, height)
  # loop through all of the frames in the movie
  for frameNum in range(1, numberOfFrames + 1):
    # make frame
    setColor(getPixel(canvas, x, y), b)
    writeFrame(canvas, frameNum)
    # update math for next frame
    x = x + dx
    y = y + dy
    # if at a turning point, change direction
    if x == x1 and y == y1:
      # go down
      dx = 0
      dy = speed
    elif x == x1 and y == y3:
      # go right
      dx = speed
      dy = 0
    elif x == x3 and y == y3:
      # go up
      dx = 0
      dy = speed * -1
    elif x == x3 and y == y2 and dx == 0:
      # go left
      dx = speed * -1
      dy = 0
    elif x == x2 and y == y2:
      # go right
      dx = speed
      dy = 0
    elif x == x5 and y == y2:
      # go left
      dx = speed * -1
      dy = 0
    elif x == x4 and y == y2 and dx == (speed * -1):
      dx = 0
      dy = speed
    elif x == x4 and y == y4:
      dx = 0
      dy = 0


Link to this Page