🔥
CS1334
  • Introduction to Programming
  • Algorithm
  • RGB Colormode
  • HSB Colormode
  • Animation
  • Contrasting Concepts - Art
  • Geometric Transform Functions
    • Animation Using Transforms
  • Functions to Draw Characters
  • Functions to Draw Flowers
  • Bounding Box Conditional Branching
  • Canvas Border Constraints
  • Loops Using Math Formulas for Position
  • Finite State Machine
  • Arrays
  • KeyPress Logic
  • Time
  • Collision between objects
  • Buttons
  • Scene Management - State Variables
  • Project 3 - Animation Specification - FSM
  • Project 4 - Animation Logic
  • Project 5
  • Javascript Syntax
    • Variables
    • Indentifiers
    • Functions
    • Variable Scope: Global or Local
    • Logical Operators
    • Numerical Operator Shortcuts
    • Repetition - Loops
Powered by GitBook
On this page

Was this helpful?

Time

Processing has several different functions that can be used in programs.

millis( ) // gives time elapsed since the program started in milliseconds where there are 1000 milliseconds  in 1 second.

seconds( ), minutes(), hours(), etc //provides actual time according to the computer's clock

Timer

To create a timer, you can use an elapsed time calculation where you create a variable at the beginning of the program and initialize it with one of the time functions, then check to see the difference between current time and the startTime variable, reset the startTime variable when the timer has reset.

    var initialTime = millis(); //called once at beginning

    var draw=function(){
    var elapsedTime = millis() - initialTime;
    if (elapsedTime > 3000){ // 3 seconds has passed
       println("3 seconds");
    initialTime = millis(); //reset initial time
    }
};
PreviousKeyPress LogicNextCollision between objects

Last updated 5 years ago

Was this helpful?