Paddle Ball! We will begin creating, in steps, a video game similar to ‘brick breaker’ or ‘pong’, were we can move paddles to hit a bouncing ball. I hope.

Slides:



Advertisements
Similar presentations
Graphics Shapes. Setup for using graphics You have to import the graphics library You can use either “import graphics” or “from graphics import *” or.
Advertisements

Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
1. Tuesday: Halloween Shoot due TOMORROW. You must make a contact sheet of your photos and print it from my computer tomorrow. -5 pts for every day I don’t.
First things first – open SketchUp. You may be asked to choose a ‘Template’ For everyday use, choose the Simple Template – Meters Do not choose the Template.
A Simple Applet. Applets and applications An applet is a Java program that runs on a web page –Applets can be run from: Internet Explorer Netscape Navigator.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
1 Python Programming: An Introduction to Computer Science Chapter 3 Objects and Graphics.
Back to Table of Contents Advanced PowerPoint Techniques Prepared by Pat Samuel WS 445/545 - Feb
PowerPoint: Tables Computer Information Technology Section 5-11 Some text and examples used with permission from: Note: We are.
Created in 2011 at Liberty High School. Getting Started Overview on Magnet Tool – Graphics – Text – Image – Video – Sound – Wall A Sample Glog How to.
Human Geography for Teachers: GCU673 Arizona State University Valerie Mervine.
Introduction to Scratch!
World Cities PowerPoint Tutorial Mrs. Bushman. Take Flight In iMovie Choose Your Path Movies in PowerPointAction Buttons.
POWERPOINT REVIEW Computer Technology. After reading the definition, think of the answer. Then, click to reveal the answer and see if you are correct.
Graphics Concepts CS 2302, Fall /3/20142 Drawing Paths.
Microsoft ® Office Excel ® 2007 Training Create a chart.
1. Press the New Layer Button 3. Double click names to re-name Ball & Shadow layers 2. Click to change to 12 fps Step 1.
Introduction to Using the Notebook 10 Software for SMART Board Day 2 LIVINGSTON PARISH PUBLIC SCHOOLS Facilitated by S. Waltman.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
PowerPoint Basics Tutorial 1: Objects These tutorials will introduce you to the most basic and useful functions of Microsoft PowerPoint We’re going.
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
Preset and custom animation
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Utilizing Your Class Site Class Website Guide by Kimberlee Fulbright.
PowerPoint: Animation Randy Graff HSC IT Center Training
“FEATURES OF THE PROGRAM” MICROSOFT PAINT TUTORIAL.
CRE Programming Club - Class 5 Robert Eckstein and Robert Heard.
Our desktop looks similar to what we see here normally. The pictures on the left are called icons. On the next few slides, we’ll play around with the icons.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
Steps on making a Powerpoint. There are steps you have to take to be able to get your powerpoint done for example if you want to get a new slide and layout.
Adding, editing, and deleting items using CONTENTdm Administration.
Here is a small example of the puzzle you will be completing today. You will start in the top left corner, and end at the bottom right using 3 different.
Using TKINTER For Better Graphic Tkinter module offers more functions: Button Widget: from tkinter import * tk =Tk() btn=Button(tk, text=‘Click me’) btn.pack()
INTRO to PIXLR.com.
CSS Box Model.
Weebly Elements, Continued
CSS Box Model.
MOM! Phineas and Ferb are … Aims:
Pixels, Colors and Shapes
Going Green By Ima Librarian
How to Make a PowerPoint Presentation (Using PowerPoint)
Flash Interface, Commands and Functions
Creating Vector Graphics
How Many Ways Can 945 Be Written as the Difference of Squares?
Microsoft Office PowerPoint 2010 INSERTING GRAPHIC OBJECTS
What? Learn how to program at FIU Register for: COP 1000 – #59660
MS PowerPoint 2010 Week 2.
Learning to program with Logo
به نام مهربانترین In the name of the most compassionate
CS 100: Roadmap to Computing
Adobe illustrator.
The Canvas.
Let’s make a shape…. Move!
NOTES for S1. Start by drawing a LINE. Move MOUSE POINTER (MP) over INSERT TAB of TOP MENU and Left.
CSS Box Model.
Presentations are a powerful communication medium.
Design Studies “Show Off” Project
A few tricks to take you beyond the basics of Microsoft Office 2007
A few tricks to take you beyond the basics of Microsoft Office
Whatcha doin'? Aims: Begin to create GUI applications. Objectives:
Let’s begin our game!.
How to Start This PowerPoint® Tutorial
CSS Box Model.
Introduction to PowerPoint
Directions are in slide notes. You can view them in two ways
Chapter 1 Introducing Small Basic
Add some WordArt to your cover slide
JavaScript – Let’s Draw!
Presentation transcript:

Paddle Ball! We will begin creating, in steps, a video game similar to ‘brick breaker’ or ‘pong’, were we can move paddles to hit a bouncing ball. I hope creating this game will be a fun activity for you, and a way for you to take what you have learned in programming to the next level. Once our game is completed, you will modify it to create a custom version of your own.

We are going to make a “paddle ball” game Before we do, we need to learn a few concepts. One of the biggest new concepts we will learn is called Object Orientation I have typed in the notes section of these slides, so for more information, please read the notes. Either View tab Notes page or… select the notes button at the bottom of the slide (if not in a slideshow) The previous PowerPoint went into detail about classes and objects – “Object Oriented Programming”. If you are still unclear, that is fine. Feel free to go back and review the video and the notes. Understanding this new concept will help us understand why we are doing what we are doing in this activity.

Making shapes using tkinter Drawing Shapes Making shapes using tkinter

Using tkinter Tkinter is a graphics module (like time, turtle, random…) It is designed to work faster and better than the turtle module, which is designed to teach and practice using graphics (it’s basic). Just like the time, random, and turtle modules, we have to import it before using. Brand new, just go with it. We will import it just like we did with the time module and turtle modules.

We need a canvas! Import tkinter: from tkinter import * tk = Tk( ) canvas = Canvas(tk, width=500, height = 500) canvas.pack( ) In order to draw a shape, we need to first have something to draw on. We create a ‘canvas’ to draw on. Just like an artist would. Yes, Brie and Skye, I know that not all artists have to paint on canvases, one could use any variety of mediums.  Our parameters for our canvas are setting the width and height. The canvas.pack function just tells the canvas to “show up”. Without this, the canvas won’t appear and thus neither will our shapes we are drawing! If you were to read this code from top to bottom (how else would one read it???) It would go something like this: Hey, I’m going to use the tkinter graphics tool! I’m going to use all that it has to offer (the * means “import everything”) again, thinking of a library like a suitcase, you would here unpack everything instead of only taking out a pair of jeans or one item at a time. I’m going to create a shortcut variable for the function Tk(), so I don’t have to type that out each time. Imma make a 500x 500 canvas I want that canvas to show up on my screen [the canvas.pack just tells it to display on our screen]

Let’s make a box We are going to begin by making a box ( a rectangle) Now that we have a canvas, we will use a create_polygon function which will draw a shape using parameters. If a triangle uses 6 parameters: canvas.create_polygon(10, 10, 10, 60, 50, 35) How many parameters do you think a rectangle will use? Creating a triangle, we used the create_polygon function. The parameters of the function are pairs of coordinates. Beginning with bottom left we have 10, 10 (x and y values), then bottom right (10,60), and then the top (50, 35). You could plot this yourself on a Cartesian plane, but here the program is doing it for us. For a rectangle, one might think our rectangle should use 4 sets of coordinates, which would be 8 numbers all separated by commas. However, since a rectangle is a square, we only need the top right and bottom left coordinates, so two sets of coordinates.

Get rect[angle] newb  from tkinter import * That was for Cole & Dustin Begin by creating a canvas to draw our rectangle on: from tkinter import * tk = Tk( ) canvas = Canvas(tk, width = 500, height = 500) canvas.pack( ) canvas.create_rectangle(10, 10, 50, 300) Sorry for the bad pun. Hey, teachers have to have fun too you know. I would be a very dry teacher if I didn’t enjoy my job! Remember: Our parameters for our canvas are setting the width and height. The canvas.pack function just tells the canvas to “show up”. Without this, the canvas won’t appear and thus neither will our shapes we are drawing! If you were to read this code from top to bottom : Hey, I’m going to use the tkinter graphics tool! I’m going to use all that it has to offer (the * means “import everything”) again, thinking of a library like a suitcase, you would here unpack everything instead of only taking out a pair of jeans or one item at a time. I’m going to create a shortcut variable for the function Tk(), so I don’t have to type that out each time. I am going to make a 500x 500 canvas. I want that canvas to show up on my screen I'm going to create a rectangle the top left corner is at coordinates 10, 10 and the bottom right corner is at corner 50, 300 Coordinates for top left and bottom right corners

Plain rectangles are boring Let’s add some color by filling them in. Same code as before, but with one modification: canvas.create_rectangle(10, 10, 50, 300. fill = ‘green’) Now what has happened? Yes! A green rectangle. We have included a new parameter or argument for our function. When we create our functions, we can add a parameter to alter or change what we have created. Now, we should have a green rectangle. Cool, huh?

Pick a color, any color colorchooser.askcolor( ) We can use the color selector (just like in Word) to select a color to fill our rectangle with. This is called the colorchooser Add to your code: (before the create rectangle) colorchooser.askcolor( ) Adding this function allows us to first, set up our function that will allow us to choose a color, then we will include this as a parameter in our create_polygon function.

Use the color chooser in fill c = colorchooser.askcolor( ) canvas.create_rectangle(10, 10, 50, 300, fill=c[1]) * When the color is selected, a tuple is created with the red, green, and blue value amounts as well as the hexadecimal value for all three. The [1] index selects the hexadecimal value. A tuple (pronounced: ‘too-pull’) is a list that cannot be changed (unmutable). Remember when we created our lists before: Example: listofnames = [‘Robert’, ‘Jessica’, ‘Brinay’, ‘Dre’, ‘Ed’, ‘Shelly’] in this list, we could rearrange, add, delete or change the elements of our list. A tuple would look like this: listofnames = (‘Robert’, ‘Jessica’, ‘Brinay’, ‘Dre’, ‘Ed’, ‘Shelly’) The tuple is set the same way, but has parentheses rather than brackets. Just know that a tuple is a list that can’t be changed…

More color options! We can change the color of our object by configuring it. canvas.itemconfig(object, fill = ‘color’) Our object is 1, because it is the object ID We could give our shape a variable name and use that as well. Notice that in the canvas.itemconfig(object, fill = ‘color’) line, Object  which is what we are creating, is listed as one of the arguments, or parameters of the function itemconfig. This is done because we are configuring our object [it is naming itself]. Think of it this way, if you were to create a function called “Comb hair” (yes, imagining that we were living in a computer program… just stay with me for a bit here…) you would want to know who’s hair to comb. In this example, you would have something like combHair(self, time). Meaning you will comb (your) hair for (x time). Many object oriented programs for Python will name themselves as a parameter. Its just a personality quirk of Python. Don’t worry about it too much, just know that is what it does. This is just a way for a function to call another function.

What we can also change: fill = ‘color’ outline = ‘color’ * The outline and fill color do not have to be the same colors

Arcs Arc – a segment of the circumference of a circle tkinter actually draws an arc inside of a rectangle. When we create an arc, we use coordinates just like a rectangle. We also use style and extent arguments Now that we know how to draw a shape and fill in the color, we can also draw an arc (Curved line)

Noah’s Arc Joakim Noah – Chicago Bulls Another pun. Sorry again.

Extent – the degrees of the angle of the arc 1st set of coordinates (10, 10) 2nd set of coordinates (200, 100) Extent – the degrees of the angle of the arc Style – its an arc

Creating an arc Canvas.create_arc(10, 10, 200, 100, extent = 180, style = ARC

Arc angle measurements tkinter considers 360o as the same as 0o, For a full circle, we’ll use 359o