Animation CSC 161: The Art of Programming Prof. Henry Kautz 10/14/2009.

Slides:



Advertisements
Similar presentations
Numerical Methods or Two Recipes for Pi CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
Advertisements

Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
Graphics Shapes. Setup for using graphics You have to import the graphics library You can use either “import graphics” or “from graphics import *” or.
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
Graphics Chapter 16.  If you want to draw shapes such as a bar chart, a clock, or a stop sign, how do you do it?
Programming Patterns CSC 161: The Art of Programming Prof. Henry Kautz 9/30/2009.
Python Programming, 2/e1 CS177: Programming in Multimedia Objects Recitation Topic: Graphics Library.
Chapter 5 Creating an Image Map.
Using MS Publisher to develop a movie proposal! English 10-1 Ms. Tobin, Room 432 Othello.
Ms. Blain’s 4 th grade!. -Round - Never Ending -Any point on the circle is the same distance from the center. Diameter = A line segment drawn from any.
Intro to Robots 8 Sights & Sounds. Intro to Robots Computing is more than Computation So many devices – iPod, digital cameras, etc – use computers to.
Intro to Robots Lab 8. Intro to Robots Exercise 1: Follow the text’s suggestion and Google “color names list” Collect from the list a set of 25 colors.
1 Python Programming: An Introduction to Computer Science Chapter 3 Objects and Graphics.
Computing with Strings CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
Chapter 4 Objects and Graphics
Python: Graphics
Please open your laptops, log in to the MyMathLab course web site, and open Quiz 3.6B. IMPORTANT NOTE: If you have time left after you finish the problems.
CSC 110 Objects and Graphics [Reading: chapter 4] CSC 110 E 1.
Computing with Numbers CSC 161: The Art of Programming Prof. Henry Kautz 9/14/2009.
Chapter 5 Graphics.  We’ve been doing command line programming, but now it’s time to try GUI programming—programming in a graphical user interface, using.
Chapter 5 Creating an Image Map.
An Overview of Programming in Python CSC 161: The Art of Programming Prof. Henry Kautz 9/9/2009 Slides stolen shamelessly from Dr. Mark Goadrich, Centenary.
Introduction to Flash. Topics What is Flash? What can you do with it? Simple animation Complex interactive web application, such as an online store. Starting.
60 Questions (review for final exam) CSC 161: The Art of Programming Prof. Henry Kautz 12/7/
Please CLOSE YOUR LAPTOPS, and turn off and put away your cell phones, and get out your note- taking materials.
CSCE 121: Introduction to Program Design and Concepts Dr. J. Michael Moore Spring 2015 Set 12: A Display Model 1 Based on slides created by Bjarne.
Introduction to Computer Science – Chapter 8 CSc 2010 Spring 2011 Marco Valero.
Java course. Assignment #2, due: Feb. 27, (20) (a) Tell the difference between the abstract class and the interface. (b) Tell the difference between.
EVENTS Wiring together objects, code, and actions.
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
Drawing rectangles and ovals in the Applet window Displaying Text in the Java Console Window Demo of the HelloAgain program Arithmetic expressions Examples.
Some Graphics CS303E: Elements of Computers and Programming.
Python Programming, 1/e1 Programming Thinking and Method (5a) Zhao Hai 赵海 Department of Computer Science and Engineering Shanghai Jiao Tong University.
CSC 1010 Programming for All Lecture 7 Input, Output & Graphics.
Xiaojuan Cai Computational Thinking 1 Lecture 5 Objects and Graphics Xiaojuan Cai (蔡小娟) Fall, 2015.
$100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300.
LING 408/508: Programming for Linguists Lecture 23 November 25 th.
Animation II: Revenge of the Clones CSC 161: The Art of Programming Prof. Henry Kautz 10/16/2009.
Documenting a function. Documenting a function definition We have a template for information that we need you to put at the top of each function - if.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 4 Objects and Graphics.
How to Make a Power Point Go to Slide 2. (You can get there by clicking on slide 2 in Normal VIEW.)
10. MORE OBJECTS Rocky K. C. Chang October 18, 2015 (Based on from Charles Dierbach. Introduction to Computer Science Using Python and adapted from John.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 4 Objects and Graphics.
5. COMPUTING WITH GRAPHICS OBJECTS Dennis Y. W. Liu and Rocky K. C. Chang October 8, 2015 (Adapted from John Zelle’s slides)
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
Template by Bill Arcuri, WCSD Click Once to Begin JEOPARDY! Final Exam Review Journalism I.
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
CS 115 Lecture 7 Graphics – coordinate systems, Text, Entry, aliases Taken from notes by Dr. Neil Moore.
Vahé Karamian Python Programming CS-110 CHAPTER 4 Objects and Graphics.
CS 115 Lecture 6 Graphics Taken from notes by Dr. Neil Moore.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 4 Objects and Graphics Killer cars.
ENGINEERING 1D04 Tutorial 4. What are we doing today? Focus Functions Scope of Variables Returning Values Objects Graphics library Aliasing Events Mouse.
Graphics Taken from notes by Dr. Neil Moore & Dr. Debby Keen
GUI in Python Ismail Abumuhfouz.
Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
Graphics Part I Taken from notes by Dr. Neil Moore
Graphics Part I Taken from notes by Dr. Neil Moore
CS 115 Lecture Graphics II – coordinate systems, Text, Entry, aliases
About 45 questions / 50 points
Three major projects: There will be a midterm covering the material presented during the first half of the semester a final covering the material presented.
CS 115 Lecture Graphics II – coordinate systems, Text, Entry, aliases
CSc 110, Spring 2018 Lecture 9: Parameters, Graphics and Random
SSEA Computer Science: Track A
Graphics Part I Taken from notes by Dr. Neil Moore
Simple Graphics Package
Class 6 using the math library
Announcements DS-203 Fall 2008.
Presentation transcript:

Animation CSC 161: The Art of Programming Prof. Henry Kautz 10/14/2009

Status Programming assignment 6: Graphics Part I: Due 10:00am, Sat 24 October Part II: Due 10:00am, Sat 31 October To be completed in teams of two assigned by Lab TA Next workshop: telling a story through animation Homework: Read Zelle Chapter 5 Monday: bring at least one written question about something in the chapter that was mysterious or puzzling! Monday: Final graphics, plus introduction to functions (Ch ) Wednesday: In-class midterm exam on everything to date. Bring: Pencils Calculator 1 page of notes / crib sheet 2

Problems using Graphics Library? See detailed instructions for both PC and Macintosh – follow Programming Help link on Blackboard course home page Solution to "module not found" problem Solution to "console window" problem 3

Where We Were from graphics import * def main(): w = GraphWin('Test', 300, 300) for i in range(5): p = w.getMouse() label = Text(p, 'Ouch!') label.draw(w) main() 4

GraphWin Objects Graphwin(title, width, height) Constructor: creates and returns a window object w = GraphWin('hello', 300, 600) close() getMouse() Wait for click, return Point object p = w.getMouse() checkMouse() Like getMouse, but don't wait: if user does not click, then return None 5

Graphical Objects Point, Line, Circle, Oval, Rectangle, Polygon, Text All support setFill( ) setWidth( ) draw( ) undraw( ) move( dx, dy ) clone() Return a copy of the object Compare: x = y versus x = y.clone() 6

Points Point(x, y) Constructor getX() getY() Example: p = Point(99, 21) if (p.getX() == 99): print "yes" p.move(10,10) if (p.getX() == 99): print "no" 7

Lines Line(point1, point2) getP1() getP2() Line from (10, 20) to (30, 40) is: L = Line(Point(10,20), Point(30,40)) 8

2-Dimensional Shapes Circle( centerPoint, radius ) getCenter() getRadius() Rectangle( point1, point2 ) Points at opposite corners of the rectangle getP1() getP2() Polygon( point1, point2, point3,... ) Arbitrary polygon 9

Text Objects Text( anchorpoint, string) Anchor is center of text setText( string ) Change the text setSize( number ) 5 to 36 setTextColor( string ) 10

Uses of Graphics Displaying data See example in textbook: creating a bar chart of the amount of an investment Games! 11

Duck Shoot Goal: shoot a moving target 5 times Once the target it hit, it changes color from yellow to red You can shoot the target at most once until it reverses direction 12

from graphics import * def main(): w = GraphWin("duckhunt", 400,200) # THE PROGRAM w.getMouse() w.close() main() 13

w = GraphWin("duckhunt", 400,200) c = Circle(Point(100,100),20) c.setFill('yellow') c.draw(w) d = 1 # direction -1 = left, 1 = right p = 0 # number of hits alive = True # is duck alive right now? 14

while p<5: m = w.checkMouse() if m != None and alive: x = m.getX() y = m.getY() xc = c.getCenter().getX() yc = c.getCenter().getY() if ((x-xc)**2 + (y-yc)**2) < 400: c.setFill('red') p = p + 1 alive = False 15

elif c.getCenter().getX() >= 380: d = -1 c.setFill('yellow') alive = True elif c.getCenter().getX() <= 20: d = 1 c.setFill('yellow') alive = True c.move(d*4,0) 16

while p<5: m = w.checkMouse() if m != None and alive: x = m.getX() y = m.getY() xc = c.getCenter().getX() yc = c.getCenter().getY() if ((x-xc)**2 + (y-yc)**2) < 400: c.setFill('red') p = p + 1 alive = False elif c.getCenter().getX() >= 380: d = -1 c.setFill('yellow') alive = True elif c.getCenter().getX() <= 20: d = 1 c.setFill('yellow') alive = True c.move(d*4,0) 17

from graphics import * def main(): w = GraphWin("duckhunt", 400,200) c = Circle(Point(100,100),20) c.setFill('yellow') c.draw(w) d = 1 p = 0 alive = True while p<5: m = w.checkMouse() if m != None and alive: x = m.getX() y = m.getY() xc = c.getCenter().getX() yc = c.getCenter().getY() if ((x-xc)**2 + (y-yc)**2) < 400: c.setFill('red') p = p + 1 alive = False elif c.getCenter().getX() >= 380: d = -1 c.setFill('yellow') alive = True elif c.getCenter().getX() <= 20: d = 1 c.setFill('yellow') alive = True c.move(d*4,0) 18