Computer Science A 11: 24/3. Animation - Dubble buffering - Transformations - Sprites and textures - Sound.

Slides:



Advertisements
Similar presentations
COMP 110: Introduction to Programming Tyler Johnson Apr 20, 2009 MWF 11:00AM-12:15PM Sitterson 014.
Advertisements

Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Microsoft® Small Basic
Web Design & Development Lecture 19. Java Graphics 2.
CSE 1341 Honors Professor Mark Fontenot Southern Methodist University Note Set 21.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
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?
Multithreading : animation. slide 5.2 Animation Animation shows different objects moving or changing as time progresses. Thread programming is useful.
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
User Interface Programming in C#: Graphics
Datalogi A 7: 20/10. Event driven programs Many things may happen: Pressing a button Selecting values with sliders, lists etc. Type text in fields Mouse.
Lab 10: Creating a Presentation
Computer Science 5 Fall 2004 Module 3 10/1/2004 7:57 AM.
Computer Science A 11: 20/2. Java and swing Graphics programming: Windows with menus Buttons, textfields, scroll panels etc Animations, images, Events.
Datalogi A 6: 13/10. Java and swing Graphics programming: Windows with menus Buttons, textfields, scroll panels etc Animations, images, Events from mouse.
Slide Transitions Slide Show, Slide Transition opens Slide Transition task pane Practice each option setting to select the transition style, its speed,
Computer Science 5 Fall 2004 Module 3 6/28/2015 8:59:45 PM6/28/2015 8:59:45 PM6/28/2015 8:59:45 PM.
Computer Science 5 Spring 2007 Module 3 7/12/2015 1:55:57 PM7/12/2015 1:55:57 PM7/12/2015 1:55:57 PM.
Computer Science A 8: 6/3. Group data in an object class PlayerData{ String name; int score; }.. PlayerData d=new PlayerData(); d.name=“Mads”; d.score=100;
Back to Table of Contents Advanced PowerPoint Techniques Prepared by Pat Samuel WS 445/545 - Feb
PowerPoint Lesson 3 Working with Visual Elements
Excel Working with Charts and Graphics Microsoft Office 2010 Fundamentals 1.
Computer Information Technology – Section 4-13 Some text and examples used with permission from: Note: We not endorsing or promoting.
Chapter 3 Working with Symbols and Interactivity.
Creating Special Effects
Lesson 5: Graphics Spotlight on Word ProcessingLesson 51.
Working with Symbols and Interactivity
XP Tutorial 1 Introduction to Macromedia Flash MX 2004.
Java Graphics. Review 3 kinds of elements in components API? Layout managers Events Extend vs. Implement.
COMP 110: Spring Announcements Quiz Wednesday No Class Friday Assignment 5 Due next Monday Q&A Review Session Monday.
Introduction to Java Simple Graphics. Objects and Methods Recall that a method is an action which can be performed by an object. –The action takes place.
Laboratory Exercise # 9 – Inserting Graphics to Documents Office Productivity Tools 1 Laboratory Exercise # 9 Inserting Graphics to Documents Objectives:
CS177 RECITATION WEEK 7 Input and Output (Text & Graphical)
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 21.1 Test-Driving the Painter Application.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
MICROSOFT POWERPOINT (MICROSOFT POWERPOINT)
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
Power Point Tutor. Table of Contents Starting from Scratch Opening an old presentation Inserting an new slide Choosing a background color Fill Effects.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
Ch. 14: Presentations with Graphics and Multimedia – Lesson 87 © 2010, 2006 South-Western, Cengage Learning.
Months and Numbers to jazz up your classroom calendar.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
Computer Programming with Scratch JAOIT 8. Scratch Scratch is a programming language that makes it easy to create your own interactive stories, animations,
Microsoft PowerPoint Prepared by the Academic Faculty Members of IT.
>>0 >>1 >> 2 >> 3 >> 4 >>
Enhancing a Presentation with Pictures, Shapes, and WordArt
PowerPoint Basics Technology Summit University of Denver February 27, 2004.
Creating cast members  Using tool palette window that can be selected from window menu.  The following objects can be created: Push buttons, Radio buttons,
Chapter 7 Introduction to High-Level Language Programming.
PowerPoint Project 1 These instructions will tell you what TAB you need to go to, but will not give you pictures of the COMMAND buttons you need. 1.Go.
Chapter 4 Drawing and Painting with Color
PowerPoint Grades 3-5.
Lisette Elby Scratch E-Safety Quiz Evaluation
What? Learn how to program at FIU Register for: COP 1000 – #59660
How To Use This Template:
Economist Report (Advanced)
First line of text Second line of text Third line of text here
Україніські народні інструменти.
Power Point Tutor.
Sample heading First line of text Second line of text
Sample statement or caption goes here
POWER POINT WHY HAVE WE USE THIS PROGRAM? TO SHOW YOUR STUDY..
May 14, 2015 Ferris Wheel 3-D transition effect and pictures (Basic)
Power Point 101.
对 话 无 界 限 “对话是两个集合出现交集的一个刹那。” “对话是发现共同点的捷径。”.
Paleolithic Mesolithic Neolithic Bronze Age
Divide Whole Numbers by Decimal Numbers
TEXT FORMAT Textured and layered background with title - Advanced
Picture with watercolor overlay background (Advanced)
Presentation transcript:

Computer Science A 11: 24/3

Animation - Dubble buffering - Transformations - Sprites and textures - Sound

Dubble buffering Basic pinciple of animation: use two display areas: one to draw in and one to display while(true){ canvas.startBuffer(); canvas.clear(); … draw image canvas.endBuffer(); canvas.sleep(20); // display image }

Bouncing ball while(true){ int mx=canvas.getWidth(); int my=canvas.getHeight(); canvas.startBuffer(); canvas.clear(); canvas.setPaint(Color.green); x+=vx; y+=vy; if(x<0){x=0;vx=-vx;} if(y<0){y=0;vy=-vy;} if(x+d>mx){x=mx-d;vx=-vx;} if(y+d>my){y=my-d;vy=-vy;} canvas.fillOval(x,y,d,d); canvas.endBuffer(); canvas.sleep(20); }

Coordinate transformations You want to draw some model (chair, box, house,..) This will often involve several transformations: -Coordinates of parts of model in own system -Coordinates of model in world coordinates -Transform coordinates so view point is on z-axis -Make 3d projection: multiply size with the inverse of distance to view point -Transform to window coordinates -Draw model: furthest away first, nearest last

Textures, sprites A texture is a tileable image A sprites is a small (often partially transparant) image drawn on top of a background

JEventQueue JEventQueue events = new JEventQueue(); events.listenTo(button1,"button1"); events.listenTo(button2,"button2");... while(true){ EventObject event = events.waitEvent(); String name=events.getName(event); if(name.equals("button1")){... }else if(name.equals("button2")){... }else... }

Selections: RadioButton: isSelected() CheckBox: isSelected() Spinner: getValue() Slider. getValue() ComboBox: getSelectedItem() List: getSelectedValue()

Mouse events Draw circles where you click and lines where you drag. int x0=0,y0=0; while(true){ EventObject event=events.waitEvent(); if(events.isMouseEvent(event)){ int x=events.getMouseX(event); int y=events.getMouseY(event); if(events.isMousePressed(event)){x0=x;y0=y;} if(events.isMouseClicked(event)) canvas.drawOval(x0-5,y0-5,10,10); if(events.isMouseReleased(event)) canvas.drawLine(x0,y0,x,y); }

Timers startTimer(miliseconds,name) stopTimer(name)

Window events Events when closing or resizing a window Bring up a dialog when you close a window so that the user can confirm whether the user wants to exit the program.

More on graphics: -Transparent shapes -Blending paints -Outline of fonts, font metrics -Gradient paint -Curves -Coordinate transfomations (when writing text) -Timers

Sound import javax.sound.sampled.Clip; public class PlaySound{ public static void main(String args[]){ Clip crash = JCanvas.loadClip("crash.au"); JCanvas.playClip(crash); JCanvas.sleep(4000); }

Sound playClip(Clip clip) starts the sound, and returns loadClip(String filename) format:.au,.wav,.aiff stopClip(Clip clip) loopClip(Clip clip,int n)