Buttons & Boards CSE 120 Winter 2019

Slides:



Advertisements
Similar presentations
Variables Conditionals Boolean Expressions Conditional Statements How a program produces different results based on varying circumstances if, else if,
Advertisements

Introduction to Programming
Processing Lecture. 1 What is processing?
 Variables  What are they?  Declaring and initializing variables  Common uses for variables  Variables you get “for free” in Processing ▪ Aka: Built-in.
FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2011.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Geometers Sketch pad. Step 1: Open Sketch pad Use this to select items Use this to draw a point Use this to draw a circle Use this to draw a line Use.
CIS 3.5 Lecture 2.2 More programming with "Processing"
Variables Art &Technology, 3rd Semester Aalborg University Programming David Meredith
Lesson Two: Everything You Need to Know
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …
______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY [SIAT] |
G RAPHICS & I NTERACTIVE P ROGRAMMING Lecture 2 More Programming with Processing.
Programming for Art: Arrays – 2D ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 16 Fall 2010.
A Circle of radius 1. A Circle Note the Pythagorean form How does the Pythagorean theorem apply here? The x and y coordinates are also side lengths of.
Scratch Programming Cards
Nested Loops & Arrays CSE 120 Spring 2017
Unit 5: Canvas Painter.
MOM! Phineas and Ferb are … Aims:
Pixels, Colors and Shapes
Intro CS – Screens and Variables
Basic Input and Output CSE 120 Spring 2017
Scratch for Interactivity
p5.js mouse, keyboard and if’s
Keyboard Input.
USING THE GRAPHING TOOLS
Processing Introduction CSE 120 Spring 2017
Intro CS – Keyboard and mouse input
Developing an App CSE 120 Spring 2017
Lesson Two: Everything You Need to Know
Example: Card Game Create a class called “Card”
Computation as an Expressive Medium
Puzzle App II CSE 120 Winter 2018
Basic Input and Output CSE 120 Winter 2018
Variables & Datatypes CSE 120 Winter 2018
Matlab Class 6 Xiaotao Su, Ph. D
Processing and Drawing CSE 120 Winter 2018
Computer Application AutoCAD Program
Board: Objects, Arrays and Pedagogy
Developing an App II CSE 120 Spring 2017
Variables & Datatypes CSE 120 Spring 2017
For Net Art Lecture 2 J Parker
Mouse Inputs in Processing
Today in CS161 Week #5 **weekly visit D2L** Practicing…
Strings, Puzzle App I CSE 120 Winter 2018
Lec 5 Nested Control Structures
Chapter 5, Conditionals Brief Notes
Nested Loops, Arrays CSE 120 Winter 2018
More programming with "Processing"
Announcements How’s it going? My internet/power supply?
A Case Study: Space Invaders
Lecture 7: Introduction to Processing
Basic Input and Output CSE 120 Winter 2019
Inside a PMI Online Course
Variables & Datatypes CSE 120 Winter 2019
Arrays CSE 120 Winter 2019 Instructor: Teaching Assistants:
Today in CS161 Week #5 **go to Blackboard ** Practicing…
Processing and Drawing CSE 120 Winter 2019
LCC 6310 Computation as an Expressive Medium
Loops & Nested Loops CSE 120 Winter 2019
Catchup. Work on project.
Non-numeric Data Representation
Variables and Operators
The Iterative Design Recipe
Creating a Simple Game in Scratch
Working with images and scenes
Expressions & Conditionals CSE 120 Winter 2019
CAMP 1 – MODULE 3 INSIDE MATHEMATICS
Presentation transcript:

Buttons & Boards CSE 120 Winter 2019 Instructor: Teaching Assistants: Justin Hsia Ann Shan, Eunia Lee, Pei Lee Yap, Sam Wolfson, Travis McGaha Humans playing VR game Beat Saber move faster than what Steam thought was ‘humanly possible’ “Some people move so fast when they play the VR game Beat Saber, a rhythm game that’s basically Dance Dance Revolution with lightsabers, that Valve developers have had to issue a fix. People were moving so fast that Steam VR couldn’t track their movements. “[D]evelopers noted that they had to ‘Increase limits of what we thought was humanly possible for controller motion.’ ” https://www.theverge.com/platform/amp/2019/2/11/ 18220993/vr-valve-steam-beat-saber-fast-speeds

Administrivia Assignments: “Big Ideas” lecture: CS and Ethics Reading Check 7 due @ 3:30 pm tomorrow (2/21) Controlling Elli [submit] due tomorrow (2/21) Word Guessing [checkoff/submit] due Saturday (2/23) Living Computers Museum Report due Tuesday (2/26) “Big Ideas” lecture: CS and Ethics

Review: Rectangle Detection (x,y) h w if( (mouseX >= x) && (mouseX <= x + w) && (mouseY >= y) && (mouseY <= y + h) )

Review: Rectangle Detection if( (mouseX >= x) && (mouseX <= x + w) && (mouseY >= y) && (mouseY <= y + h) ) { // do something } Potential Uses: To detect on every frame, place in draw() or function called by draw() e.g. hover detection – change color when mouse is over rectangle To detect on a mouse click, place in mousePressed() e.g. a button that the user can click on

Circle Detection A circle is defined as all points in a 2-D plane that are equidistant from a center point In mathematical terms, the set of all points (x, y) that satisfy: (x - centerX)2 + (y - centerY)2 = radius2 To detect the mouse being inside the circle, this becomes an inequality (mouseX - centerX)2 + (mouseY - centerY)2 <= radius2 In Processing: if( (mouseX-x)*(mouseX-x)+(mouseY-y)*(mouseY-y) <= r*r ) { // do something } TODO: insert image of triangle inside a circle with Pythagorean Theorem

Creating a Button The button needs to be visible to the user Use rect() or ellipse() to draw on your canvas Generally, the user should know what the button is for Use text() to either label the button or put directions somewhere else on screen Often, textAlign(CENTER) makes finding appropriate coordinates easier

Button Demo Create a “Clear” button for phone or calculator Use a 500 x 500 canvas The button should be of size 46 x 46 and white at position (152, 302) Labeled button with a red “C” text roughly centered Hints: use textSize(40) and textAlign(CENTER) When the mouse is hovering over the button, it should turn yellow: color(255, 255, 98) Requires Active Mode When the button is clicked, it should print "Cleared!" to the console

Grids and Boards Grids can be created using nested for-loops Example: numeric keypad

Grid Demo Grids can be created using nested for-loops

Your Board “State” The state of your board indicates its current configuration In some applications, this never changes e.g. numeric keypad In other applications, this will change over time e.g. tic-tac-toe Board state is typically represented via an array Naturally ties a numeric location on your grid to the symbol/value currently associated with that cell Similar to pixels[] holding the color “state” of your drawing canvas

Labeling Our Grid For the numeric keypad, the board state is the set of (ordered) key labels: char[] keypad = {'1','2','3',…,'*','0','#'};

Grid Detection Detection of mouse location within a grid x_index and y_index must be of datatype int! int x_index, y_index; if( (mouseX >= x) && (mouseX <= x+w) && (mouseY >= y) && (mouseY <= y + h) ) { x_index = int( (mouseX-x)/(w/2) ); y_index = int( (mouseY-y)/(h/2) ); }

Keypad Grid Click Detection Clicking on the keypad should add to the phone number you are trying to dial Use a String to store and display on the canvas

Clear Functionality Our phone number should “reset” or “clear” when we click the clear button Currently, it prints "Cleared!" to the console

Summary Sketched the idea on paper Planned out coding representations Built on previous work by adding one function or idea at a time Ran the program after every improvement to make sure that it worked correctly Unit and integration testing!!!