IAT 167 Lecture Notes - Lecture 8: Presentation Layer, Ellipse, Side-Scrolling Video Game

41 views6 pages

Document Summary

Rotates a vector by the specified angle. Set x, y components of the vector. Returns a new unit vector from the specified angle. Static : class method (not an object method) Angle based linear motion: float angle = -pi/8; vel. rotate(angle); Use data source (timer/mouse positon) to change the angle for motion fill(timer*6); timer++; if (timer >40) { E. g. int timer = 0; vel. rotate (pi/2); timer = 0; Using cos and sin to affect the x and y positions using the same angle. E. g. int radius = 40; ellipse (radius * cos (angle), radius * sin (angle), 20, 20); angle + = 0. 04; Dir (value 1/-1) is used to change the travel direction. Pi/4 and 3* pi/4 are used to control angle range angle += 0. 04 * dir; if (angle 3 * pi/4) { Location keeps changing (adding random for direction)

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents