Basics of motion. Fluid motion Fluid motion is best achieved with floats, try and work out why: floats have decimal places, which provide more resolution,

Slides:



Advertisements
Similar presentations
Circle Theorems Bingo!. Use any 9 of these numbers 105 o 240 o 55 o 14 o 65 o 50 o 90 o 45 o 60 o 40 o 110 o 155 o 15 o 74 o 120 o 12 o.
Advertisements

I recommend writing down items in these yellow boxes
Freefall Motion for which the only force acting is the force of gravity. It can be moving up or down. (Air friction is negligible) Negligible – So insignificant.
Creative Computing. \\ aims By the end of the session you will be able to: 1.Move objects around 2.Write simple interactive programs 3.Use the mouse position.
Variables Conditionals Boolean Expressions Conditional Statements How a program produces different results based on varying circumstances if, else if,
Motion.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
physics engine + graphics
Motion in Two and Three Dimensions
© John Parkinson 1 © John Parkinson 2 Distance travelled - s Time taken - t Velocity - v v= s t v s / t Velocity = Speed in a Specified Direction Constant.
Graphical Analysis of Motion
Lesson One: The Beginning
Frame Windows A frame object is used to create a graphical frame window. This frame is used to show information in a graphical application. The JFrame.
Introduction to Programming
Game with US Beginner Tutorial. Welcome!! Who I am What is Processing? Basic Coding Input Methods Images Classes Arrays.
A Quick Introduction to Processing
Variables and Operators
Recursion October 5, Reading Read pp in the text.
Emerging Platform#5: Processing 2 B. Ramamurthy 6/13/2014B. Ramamurthy, CS6511.
Processing Processing is a simple programming environment that was created to make it easier to develop visually oriented applications with an emphasis.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
Review Blocks of code {.. A bunch of ‘statements’; } Structured programming Learning Processing: Slides by Don Smith 1.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Click your mouse for next slide Flash – Introduction and Startup Many times on websites you will see animations of various sorts Many of these are created.
MOTION. Chapter Four: MotionMotion  4.1 Position, Speed and Velocity  4.2 Graphs of Motion  4.3 Acceleration.
Motion  1 Position, Speed and Velocity  2 Graphs of Motion  3 Acceleration.
Continuous February 16, Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?
Processing Lecture.2 Mouse and Keyboard
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 2 Graphics Programming with C++ and the Dark GDK Library Starting.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
B. RAMAMURTHY Simulating Motion and Implementing Animation.
PREVIOUS QUIT NEXT START SLIDE Quiz by Dr. John Dayton Physics Quiz MOTION IN ONE DIMENSION Each question is multiple choice. Select the best response.
CIS 3.5 Lecture 2.2 More programming with "Processing"
2-D Shapes, Color, and simple animation. 7 Basic Shapes Ellipse :: ellipse() Arc :: arc() Line :: line() Point :: point() Rectangle :: rect() Triangle.
Variables Art &Technology, 3rd Semester Aalborg University Programming David Meredith
Objects. The Heart of the Matter - The "Black Box" Object-oriented software is all about objects. An object is a "black box" which receives and sends.
Strategy Using Strategy1. Scan Path / Strategy It is important to visualize the scan path you want for a feature before you begin taking points on your.
Mouse Inputs in Processing. Interacting with the Mouse mouseX and mouseY: pg mouseXmouseY –The position of the mouse in the canvas pmouseX and.
Processing TYWu. Where can I download? 2.0b9 Windows 32-bit.
Creating visual interfaces in python
Computer Science I Recap: variables & functions. Images. Pseudo-random processing.
Continuous. Flow of Control Programs can broadly be classified as being –Procedural Programs are executed once in the order specified by the code varied.
Processing TYWu. Where can I download? 2.0b9 Windows 32-bit.
 Advancing from moving premade primitives to making our own models  Two different approaches: ◦ Direct mesh editing: A more traditional approach commonly.
Acceleration: a change in Velocity!. An object traveling at the same rate in the same direction, is in uniform motion. NON uniform motion - there must.
Midterm: Question 1 (35%) (30 minutes) Write an assembly program to draw a rectangle. – (5%) Show a message to ask for information of the rectangle – (5%)
Test Review. General Info. All tests will be comprehensive. You will be tested more on your understanding of code as opposed to your ability to write.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
Programming in Processing Taught by Ms. Madsen Assistants: Ms. Fischer and Ms. Yen Winsor School, 2/20/08.
CPCS 391 Computer Graphics Lab One. Computer Graphics Using Java What is Computer Graphics: Computer graphics are graphics created using computers and,
Collision testing. learning targets Increase awareness of the struggles that of game development; Recognize computer science elements for game logic;
Variables. Something to mention… void setup(){ size(200, 200); background(255); smooth(); } void draw() { stroke(0); strokeWeight(abs(mouseX-pmouseX));
PROCESSING A computer screen is a grid of small light elements called pixels.
Introduction to Processing David Meredith Aalborg University Art &Technology, 3rd Semester Programming.
Game development.
9.1 Describing Acceleration
MOTION.
Chapter Four: Motion 4.1 Position, Speed and Velocity
Lesson One: The Beginning Chapter 1: Pixels Learning Processing Daniel Shiffman Presentation by Donald W. Smith Graphics from
9.1 Describing Acceleration
Mouse Inputs in Processing
9.1 Describing Acceleration
Chapter 5, Conditionals Brief Notes
MOTION.
More programming with "Processing"
9.1 Describing Acceleration
Lecture 7: Introduction to Processing
Graphing Uniform Motion
Continuous & Random September 21, 2009.
Presentation transcript:

Basics of motion

Fluid motion Fluid motion is best achieved with floats, try and work out why: floats have decimal places, which provide more resolution, the slowest int could be 1 pixel per frame, whereas the slowest float could be....as slow as you want.

Speed and direction (Animation) Animation is typically produced by declaring a variable, such as float x = 0; And then another variable, often called speed: float speed = 0.5; Speed is typically added to x with each frame, or taken away if we want to go 'backwards' See overleaf:

Go forward adding speed to x float x = 0; float speed = 0.5; void setup() { size(240, 120); smooth(); } void draw() { background(0); x += speed; // Increase the value of x ellipse(x, 40, 30, 30); //could be a, criiter, or a rect etc, with x as its x co-orddinate }

Go forward and backward float x = 0.0; float speed; int obSiz = 30; void setup(){ //set size of window: size(240, 120); } void draw() { background(0); if (x > width) //check x is not greater than the width of window { speed = -0.5; //if it is, decrement speed variable which is added to our x variable to make it go backwards and forwards } else if (x < 1) //if it reaches left edge go forward { speed = +0.5; } //draw our shapes: ellipse(x, 30, obSiz,obSiz); //draw ellipse going up and down x += speed; // keep adding x tospeed //(this will be a minus number if we are going backwards) }

Clever stuff tiamtowodt

// Example from "Getting Started with Processing" // by Reas & Fry. O'Reilly / Make 2010 int radius = 40; float x = 110; float speed = 0.5; int direction = 1; void setup() { size(240, 120); smooth(); ellipseMode(RADIUS);//explained on next slide } void draw() { background(0); x += speed * direction; if ((x > width-radius) || (x < radius)) { direction = -direction; // Flip direction } if (direction == 1) { arc(x, 60, radius, radius, 0.52, 5.76); // Face right } else { arc(x, 60, radius, radius, 3.67, 8.9); // Face left }

ellipseMode() The origin of the ellipse is modified by the ellipseMode() function. The default configuration is ellipseMode(CENTER), which specifies the location of the ellipse as the center of the shape. The RADIUS mode is the same, but the width and height parameters to ellipse() specify the radius of the ellipse, rather than the diameter. The CORNER mode draws the shape from the upper-left corner of its bounding box. The CORNERS mode uses the four parameters to ellipse() to set two opposing corners of the ellipse's bounding box. The parameter must be written in "ALL CAPS" because Processing is a case sensitive language. See the Processing reference

Tweening - going from one point to another Set up a start position and an end position Then clalculate the tween (inbetween) positions at each frame, run the code and then change the various positions (code overleaf)

// Example from "Getting Started with Processing" // by Reas & Fry. O'Reilly / Make 2010 int startX = 20; // Initial x-coordinate int stopX = 160; // Final x-coordinate int startY = 30; // Initial y-coordinate int stopY = 80; // Final y-coordinate float x = startX; // Current x-coordinate float y = startY; // Current y-coordinate float step = 0.005; // Size of each step (0.0 to 1.0) float pct = 0.0; // Percentage traveled (0.0 to 1.0) void setup() { size(240, 120); smooth(); } void draw() { background(0); if (pct < 1.0) { x = startX + ((stopX-startX) * pct); y = startY + ((stopY-startY) * pct); pct += step; } ellipse(x, y, 20, 20); }

Friction: we multiply speed by friction to slow the ellipse down /* Model realsitic movement that is subject to friction and therefore non-uniform acceleration/deceleration. */ float velocity = 50.0; //added to y coordinate float friction = 0.99; /*velocity is multiplied by friction, because friction is less than 1, friction decreases the velocity with each frame so the 'ball' slows down, until we re-boost it with a mouse press */ float y =0; void setup() { size(400, 400); } void draw() { background(255); fill(255, 0, 0); ellipse(55, y, 45, 45); velocity*=friction; //this decreases velocity with every frame. y +=velocity;//add this to y; //check for edges: if ((y>height) ||(y<0)) { velocity=-velocity;/clever flip between plus and minus values } println(velocity); } //reboost the 'ball' void mousePressed() { velocity =10; }

We'll look at circular, trigonometric movements after readng week – moving on sine waves and in circles, see page 100 Getting Started with Processing and examples 7-12 and 7-13.