SlideShare a Scribd company logo
ARTDM 170, Week 14:
Scripting Mechanical and
     Organic Motion
          Gilbert Guerrero
         gguerrero@dvc.edu
gilbertguerrero.com/blog/artdm-170/
Keyboard input

• If your ActionScript game class is
  called by a Movie symbol, the user
  input may not be recognized until the
  user clicks the screen!
• To fix this, add a line of code before
  your keyboard event listeners:

  stage.focus = stage;
Processing
Download Processing
    http://processing.org
Open Processing
Exporting

• Sketches run as Java Applets
• Sketches can be exported to several
  formats:
 ‣ Java applet with index.html page for
   web borwsers


 ‣ Windows, Mac, and Linux
   applications (use menus)
Sine wave
             1                                 1
sin(angle)




                                  sin(angle)
             0                                 0




             -1                                -1
               90   180     270
                    angle
Mechanical Ball Sketch
float angle = 0.0;     //current angle
float speed = 0.1;     //speed of motion
float radius = 50.0;   //range of motion

void setup() {
  size(200, 200);
  noStroke();
  smooth();
}

void draw() {
  fill(0,12);
  rect(0,0,width,height);
  fill(255);
  angle += speed;
  float sinval = sin(angle);
  float y = 100 + (sinval*radius);
  ellipse(100, y, 80, 80);
}
Add cosine
float   cosval = cos(angle);
float   sinval = sin(angle);
float   x = 100 + (cosval*radius);
float   y = 100 + (sinval*radius);

ellipse(x, y, 80, 80);
Warp it
float sx = 1.0;
float sy = 0.5;

float x = 100 + (cosval*radius);
float y = 100 + (sinval*radius);

float x2 = x + cos(angle*sx) * radius/2;
float y2 = y + sin(angle*sy) * radius/2;
ellipse(x2, y2, 6, 6);
Organic motion
angle += random(-0.2,0.2);

 x += cos(angle) * speed;

 y += sin(angle) * speed;

 print("x="+x+", y="+y+"n");

 translate(x,y);

 rotate(angle);

 line (0, -20, 0, 20);
Final Projects
November                        December
11            18        25         2            9           16
                                                                 Last day
                                                                 of class
     Design background and
     game elements. Embed
     in game symbol
                                                    Present final projects
                                                    (two days)
                Script user interaction and
                movement of game elements


                                       Add scoring and
                                       game over trigger
Work on your final
    projects
Homework, due Nov 25

• Work on your final projects
 ‣ Script user interaction and
   movement of game elements
Thank You

More Related Content

KEY
ARTDM 170, Week 14: Introduction to Processing
PPTX
The Business of Blogging
PPT
So, you created a blog. Now what?
PPT
Blog or Die: The Essential Guide to Blogging
PPT
Blogging and Podcasting for Writers
KEY
ARTDM 170, Week 7: Scripting Interactivity
KEY
Artdm170 week12 user_interaction
PPT
ARTDM 170, Week13: Processing
ARTDM 170, Week 14: Introduction to Processing
The Business of Blogging
So, you created a blog. Now what?
Blog or Die: The Essential Guide to Blogging
Blogging and Podcasting for Writers
ARTDM 170, Week 7: Scripting Interactivity
Artdm170 week12 user_interaction
ARTDM 170, Week13: Processing

Similar to ARTDM 170, Week 14: Organic (20)

PDF
Sketching in Code
KEY
Artdm 170 week15 publishing
PDF
ICS3211 Lecture 08 2020
PDF
Prototyping in code
PDF
Scratch Animation
PDF
Bootcamp Code Notes - Akshansh Chaudhary
PPTX
Design & technology assess 2 pp
PPTX
Scratch Lesson 5
PPT
CS 354 Interaction
PDF
A graphic library and an application for simple curve manipolation
PDF
Exemplar: Designing Sensor-based interactions by demonstration... (a CHI2007 ...
PDF
Scratch referenceguide14
PDF
OP: A Novel Programming Model for Integrated Design and Prototyping of Mixed...
PPTX
Electromania updated
PPTX
PPT
2D Plotter Presentation
PDF
Luke Steel's Portfolio
PDF
BGC2011Scratch-Rev1.pdf
PDF
COMP 4026 Lecture3 Prototyping and Evaluation
PDF
Sketching in Code
Artdm 170 week15 publishing
ICS3211 Lecture 08 2020
Prototyping in code
Scratch Animation
Bootcamp Code Notes - Akshansh Chaudhary
Design & technology assess 2 pp
Scratch Lesson 5
CS 354 Interaction
A graphic library and an application for simple curve manipolation
Exemplar: Designing Sensor-based interactions by demonstration... (a CHI2007 ...
Scratch referenceguide14
OP: A Novel Programming Model for Integrated Design and Prototyping of Mixed...
Electromania updated
2D Plotter Presentation
Luke Steel's Portfolio
BGC2011Scratch-Rev1.pdf
COMP 4026 Lecture3 Prototyping and Evaluation
Ad

More from Gilbert Guerrero (20)

PPTX
Designing for Skepticism and Bright Sunlight
KEY
ARTDM 171, Week 17: Usability Testing and QA
KEY
Artdm 171 week15 seo
KEY
ARTDM 171, Week 14: Forms
KEY
ARTDM 170, Week 13: Text Elements + Arrays
KEY
ARTDM 171, Week 13: Navigation Schemes
KEY
Artdm 171 Week12 Templates
KEY
ARTDM 171, Week 10: Mood Boards + Page Comps
KEY
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
KEY
ARTDM 171, Week 9: User Experience
KEY
ARTDM 171, Week 7: Remapping Cyberspace
KEY
Artdm170 week6 scripting_motion
KEY
Artdm170 Week6 Scripting Motion
KEY
Artdm170 Week6 Scripting Motion
KEY
Artdm170 Week6 Scripting Motion
KEY
Artdm171 Week6 Images
KEY
Artdm170 Week6 Scripting Motion
KEY
Artdm170 Week5 Intro To Flash
KEY
Artdm171 Week5 Css
KEY
Artdm171 Week4 Tags
Designing for Skepticism and Bright Sunlight
ARTDM 171, Week 17: Usability Testing and QA
Artdm 171 week15 seo
ARTDM 171, Week 14: Forms
ARTDM 170, Week 13: Text Elements + Arrays
ARTDM 171, Week 13: Navigation Schemes
Artdm 171 Week12 Templates
ARTDM 171, Week 10: Mood Boards + Page Comps
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
ARTDM 171, Week 9: User Experience
ARTDM 171, Week 7: Remapping Cyberspace
Artdm170 week6 scripting_motion
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
Artdm171 Week6 Images
Artdm170 Week6 Scripting Motion
Artdm170 Week5 Intro To Flash
Artdm171 Week5 Css
Artdm171 Week4 Tags
Ad

Recently uploaded (20)

PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PPTX
An introduction to Prepositions for beginners.pptx
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
PPTX
Congenital Hypothyroidism pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PDF
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
PDF
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PPTX
Software Engineering BSC DS UNIT 1 .pptx
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PPTX
Strengthening open access through collaboration: building connections with OP...
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Open Quiz Monsoon Mind Game Prelims.pptx
An introduction to Prepositions for beginners.pptx
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Information Texts_Infographic on Forgetting Curve.pptx
Congenital Hypothyroidism pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
How to Manage Loyalty Points in Odoo 18 Sales
Skill Development Program For Physiotherapy Students by SRY.pptx
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
Software Engineering BSC DS UNIT 1 .pptx
The Final Stretch: How to Release a Game and Not Die in the Process.
Module 3: Health Systems Tutorial Slides S2 2025
Strengthening open access through collaboration: building connections with OP...

ARTDM 170, Week 14: Organic

  • 1. ARTDM 170, Week 14: Scripting Mechanical and Organic Motion Gilbert Guerrero [email protected] gilbertguerrero.com/blog/artdm-170/
  • 2. Keyboard input • If your ActionScript game class is called by a Movie symbol, the user input may not be recognized until the user clicks the screen! • To fix this, add a line of code before your keyboard event listeners: stage.focus = stage;
  • 4. Download Processing http://processing.org
  • 6. Exporting • Sketches run as Java Applets • Sketches can be exported to several formats: ‣ Java applet with index.html page for web borwsers ‣ Windows, Mac, and Linux applications (use menus)
  • 7. Sine wave 1 1 sin(angle) sin(angle) 0 0 -1 -1 90 180 270 angle
  • 8. Mechanical Ball Sketch float angle = 0.0; //current angle float speed = 0.1; //speed of motion float radius = 50.0; //range of motion void setup() { size(200, 200); noStroke(); smooth(); } void draw() { fill(0,12); rect(0,0,width,height); fill(255); angle += speed; float sinval = sin(angle); float y = 100 + (sinval*radius); ellipse(100, y, 80, 80); }
  • 9. Add cosine float cosval = cos(angle); float sinval = sin(angle); float x = 100 + (cosval*radius); float y = 100 + (sinval*radius); ellipse(x, y, 80, 80);
  • 10. Warp it float sx = 1.0; float sy = 0.5; float x = 100 + (cosval*radius); float y = 100 + (sinval*radius); float x2 = x + cos(angle*sx) * radius/2; float y2 = y + sin(angle*sy) * radius/2; ellipse(x2, y2, 6, 6);
  • 11. Organic motion angle += random(-0.2,0.2); x += cos(angle) * speed; y += sin(angle) * speed; print("x="+x+", y="+y+"n"); translate(x,y); rotate(angle); line (0, -20, 0, 20);
  • 12. Final Projects November December 11 18 25 2 9 16 Last day of class Design background and game elements. Embed in game symbol Present final projects (two days) Script user interaction and movement of game elements Add scoring and game over trigger
  • 13. Work on your final projects
  • 14. Homework, due Nov 25 • Work on your final projects ‣ Script user interaction and movement of game elements