ARTDM 170, Week 14: Organic

567 views

Published on

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
567
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • ARTDM 170, Week 14: Organic

    1. 1. ARTDM 170, Week 14: Scripting Mechanical and Organic Motion Gilbert Guerrero gguerrero@dvc.edu gilbertguerrero.com/blog/artdm-170/
    2. 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;
    3. 3. Processing
    4. 4. Download Processing http://processing.org
    5. 5. Open Processing
    6. 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. 7. Sine wave 1 1 sin(angle) sin(angle) 0 0 -1 -1 90 180 270 angle
    8. 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. 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. 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. 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. 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. 13. Work on your final projects
    14. 14. Homework, due Nov 25 • Work on your final projects ‣ Script user interaction and movement of game elements
    15. 15. Thank You

    ×