COMP 1005 Lecture Notes - Frame Rate, Global Variable, Ellipse

66 views7 pages

Document Summary

The draw function: unusual function which introduces a time element into the code. Called automatically from after setup() and is like an infinite loop. It executes the code inside the function perpetually. Can be stopped by stopping the program or calling the noloop() function from within the function. The number of times n the draw() function executes in each second may be controlled with the framerate() function. The default frame rate is 60 frames per second but you can e. g. make it say 30 frames per second as follows: framerate(30) // make these variables global int x= 20; int y =250; int radius=20; void setup(){ size(500,500); framerate (60); // the draw function void draw(){ drawcircle( ); void drawcircle(){ background(0); // set background to zero wipes out previous circle ellipse(x, y, radius, radius); //when circle gets to the right hand side reset it to the left hand side if(x>480){ x=20;} else.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents