by Pixer and Didney Animation Studios

Slides:



Advertisements
Similar presentations
Using Thread for Animation. Threads When we are doing multiple things at once we say we are multitasking Computers multitask when they run several programs.
Advertisements

Games and Simulations O-O Programming in Java The Walker School
Slides 4/22 COP Topics Final Exam Review Final Exam The final exam is Friday, April 29 th at 10:00 AM in the usual room No notes, books, calculators,
Unit 141 Threads What is a Thread? Multithreading Creating Threads – Subclassing java.lang.Thread Example 1 Creating Threads – Implementing java.lang.Runnable.
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
CS 280 Data Structures Professor John Peterson. Quiz 4 Recap Consider the following array: {2, 6, 7, 3, 4, 1, 5, 9}. Draw this in tree form and then show.
1 Applets Chapter 1 To understand:  why applets are used to extend the capabilities of Web pages  how an applet is executed and know about the restrictions.
Building Memory… Day 3 – November 17, Two options to make Game graphical Game should extend some graphical component to allow us to put it on the.
ObjectDraw and Objects Early Chris Nevison Barbara Wells.
Slides prepared by Rose Williams, Binghamton University ICS201 Lectures 18 : Threads King Fahd University of Petroleum & Minerals College of Computer Science.
Programming What is a program? –A set of instructions –Understood by a computer.
Lecture 17: Animation Yoni Fridman 7/27/01 7/27/01.
Java: Animation Chris North cs3724: HCI. Animation? Changing graphics over time Examples: cartoons Clippy, agents/assistants Hour glass Save dohicky Progress.
Chapter 5 - Making Music: An On-Screen Piano
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
REPETITION STRUCTURES. Topics Introduction to Repetition Structures The while Loop: a Condition- Controlled Loop The for Loop: a Count-Controlled Loop.
Using a Debugger. SWC What is ”debugging”? An error in a computer program is often called a ”bug”… …so, to ”debug” is to find and get rid of errors in.
Programming Languages and Paradigms Object-Oriented Programming.
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
Overview of our Approach Program Structure –Data, variables, and parameters –Basic control structures (conditionals, loops and Threads) –Class definitions.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
Java Programming, Second Edition Chapter Seventeen Multithreading and Animation.
11 Chapter 5 METHODS CONT’D. 22 MORE ON PASSING ARGUMENTS TO A METHOD Passing an Object Reference as an Argument to a Method Objects are passed by reference.
Chapter 10 Fireworks: Part II The Web Warrior Guide to Web Design Technologies.
The process concept (section 3.1, 3.3 and demos)  Process: An entity capable of requesting and using computer resources (memory, CPU cycles, files, etc).
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
JMP Example 2 Say you take 5 measurements for the yield from a granulator and find the mean measurement. You repeat this process 50 times, to generate.
Unit 1: Java and Eclipse The Eclipse Development Environment.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
Concurrent Programming and Threads Threads Blocking a User Interface.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
1 GUIs, Layout, Drawing Rick Mercer. 2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces (GUIs)
Graphics Tools and Parameters Chris Nevison Barbara Wells.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 5 Repetition Structures.
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
Compiling and running Java programs with BlueJ. Successfully compiled files program files in BlueJ You can tell from the shade of a program icon in BlueJ.
Creating a Java Application and Applet
Martin T. Press.  Main Method and Class Name  Printing To Screen  Scanner.
Chapter 9 Active Objects + Boxball Project Design Animations! What are they? –Snapshots of objects i n different positions –When viewed quickly appear.
Slides prepared by Rose Williams, Binghamton University Chapter 20 Java Never Ends.
Lesson 28: More on the GUI button, frame and actions.
Teaching Control Structures, using objectdraw Chris Nevison Barbara Wells.
Learning Plan 6 Java Programming Intro to Object Oriented Programming.
Software Development Languages and Environments. Computer Languages Just as there are many human languages, there are many computer programming languages.
Greenfoot.
Chapter 4 - Finishing the Crab Game
Multithreading Lec 23.
Broadcasting (Adding a new level)
Topics Introduction to Repetition Structures
Chapter 19 Java Never Ends
Topics Introduction to Repetition Structures
Ellen Walker Hiram College
Computation as an Expressive Medium
BBC Microbit.
Concepts From Alice Switching to Java Copyright © Curt Hill.
Threads and Multithreading
Objective of the lesson
Game Loop Update & Draw.
Nested Loops & The Step Parameter
Concurrency, Processes and Threads
Tonga Institute of Higher Education IT 141: Information Systems
Topics Introduction to Repetition Structures
Tonga Institute of Higher Education IT 141: Information Systems
Threads.
The Step Parameter & Nested For … To … Next loops
Mobile Computing With Android ACST 4550 Android Animation
Presentation transcript:

by Pixer and Didney Animation Studios How to Animate 101 by Pixer and Didney Animation Studios

Compiling, Running, and Quitting To compile (this will compile any .java files Animate uses): javac -cp objectdraw.jar:. Animate.java To run (this will require all the .class files Animate uses): java -cp objectdraw.jar:. Animate To quit (because the X11 window does not have a close button): Ctrl-C (entered into the terminal)

The Basics of Animation Animation is a series of still images that are shown very quickly To animate something on a computer: Move object to new location Pause for a very short time Repeat steps 1 and 2 The shorter the pause and the smaller the movement, the smoother the animation will be Longer pauses will make the animation seem jerky Making movements bigger or pauses shorter will make the animation faster

The Structure of Objectdraw Animation Two major components: WindowController and Thread Both must be EXTENDED by another class public class Animate extends WindowController {...} public class DrawArc extends Thread {...} The WindowController will create new Threads in the begin() method The animation logic is written in the Thread’s run() method In the files we gave you, Animate is the WindowController, and it creates a new Thread, DrawArc

WindowController The driver for all the threads - where all new Threads are created Requires a begin() method, and inside it you want to: Inherit a canvas so the objects know what to draw themselves on DrawingCanvas myCanvas = canvas; Create a new thread and start it, giving them the canvas that we have Thread t1 = new DrawArc(0, 0, myCanvas); t1.start();

Animate.java In addition to the standard WindowController methods, Animate has two additional methods catchSleep(): a static function that pauses the program for a few millisections call this in Thread.run() after every movement, otherwise you won’t see the animation because movements happen instantly main(): where the program starts - this is a little confusing because inside of it you create an instance of Animate See slide 8 for clarification of program flow

Thread (aka DrawArc.java) Where the animation actually happens Requires a constructor and a run() method Constructor sets up variables and objects (FilledArc, FilledRect, etc) arc = new FilledArc(..., canvas); //give this the canvas! run() does two things in a loop: Moves your object arc.move(x, y); Pauses the animation so the user can see the progress of the object Animate.catchSleep(milliseconds); You DO NOT call run() anywhere! Run is automatically called by Thread.start(), which you called in Animate

ANIMATION.JAVA DRAWARC.JAVA FILLEDARC.JAVA 1. Animation.main() creates a new Animation and runs 3. DrawArc(), which creates other objects by calling 4. FilledArc(), which is the object being moved in DrawArc 2. Animation.begin() creates multiple threads, calling 5. Then starts these threads calling Thread.start(), which automatically calls 6. DrawArc.run(), which loops between first moving the object by calling 8. and then calling 7. FilledArc.move(), which moves this specific object TO PROGRAM YOUR OWN ANIMATIONS, swap out DrawArc.java and FilledArc.java with your own classes and program your own animation logic Ex. MoveSquareUpAndDown.java which uses FilledRect.java 9. Animation.catchSleep() to pause the thread

TL;DR Do NOT change Animate.main() or Animate.catchSleep() Create instances of animations (threads) in Animate.begin(); These are your own animations that EXTEND Thread These require a constructor and a run() method Creation of objects like squares/circles/lines is in constructor Movement/pausing loop happens in run() For a summary of objects you can use - aka circles/squares/lines, look at the left column of this library: http://eventfuljava.cs.williams.edu/library/objectdrawJavadocV1.1.1/

GOOD LUCK Albert