Upcoming SlideShare
×

# Artdm170 week12 user_interaction

722 views

Published on

Published in: Design
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
722
On SlideShare
0
From Embeds
0
Number of Embeds
30
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide

• ### Artdm170 week12 user_interaction

1. 1. ARTDM 170, Week 12: User Interaction Gilbert Guerrero gguerrero@dvc.edu gilbertguerrero.com/blog/artdm-170
2. 2. Turn in Homework • Please put your ﬁles in a folder with your last name and ﬁrst initial • Put the folder in my dropbox • Example: smith-h design.jpg
3. 3. Timeline March April May Last day of class 9 16 23 30 6* 13 20 27 4 11 18 25 Create a project title and description Present ﬁnal projects Paper prototypes (two days) Design background, characters, and other game elements Embed game elements in game symbol Add movement and keyboard interaction Add Start and Game Over screens Add scoring and game over trigger
4. 4. Paper Prototypes
5. 5. Collision Detection
6. 6. hitTestObject sprite1 sprite1.hitTestObject(sprite2) sprite2 • When the bounding box of one object overlaps with the bounding box of another object, a collision is detected • Use an if() statement to do something with the collision if( sprite1.hitTestObject(sprite2) ) { // collision happened }
7. 7. hitTestPoint sprite1 sprite1.hitTestPoint(x1, y1, true) • Check if the edge of a shape is near a point • Cannot be used with two shapes, only a shape and a point • Can be used with the mouse, using mouseX and mouseY
8. 8. Collision based on distance • Detect when two objects are near each other sprite1 • Collide when the sprite2 distance between their registration points is less than half their sprite1 combined sizes sprite2
9. 9. Pythagorean Theorem C A B • To ﬁnd the distance between two points we need the Pythagorean Theorem • A2 + B2 = C2
10. 10. Pythagorean Theorem (x1,y1) dist dy (x1,y2) dx (x2,y2) • In ActionScript: dx = x2 - x1; dy = y2 - y1; dist = Math.sqrt(dx*dx + dy*dy);
11. 11. Collision based on distance sprite1 sprite2 var sizeBetween = sprite1.width/2 + sprite2.width/2; if(dist < sizeBetween) { // collision detected }
12. 12. Point.distance • Thereʼs a function for this! var sizeBetween = sprite1.width/2 + sprite2.width/2; if( Point.distance( new Point(sprite1.x, sprite1.y), new Point(sprite2.x, sprite2.y) ) < sizeBetween ) { // collision detected }
13. 13. Hit the Brick example
14. 14. Pop the Balloon example
15. 15. User Interaction keys and spacebar