The SparkFun Guide to Processing by Derek Runberg
Author:Derek Runberg [Runberg, Derek]
Language: eng
Format: epub
ISBN: 9781593276126
Publisher: No Starch Press
Published: 2015-09-15T05:00:00+00:00
Driving Shapes
Making something move on the screen in response to the keyboard or mouse is a basic building block of video game development. Letâs start simple and use the arrow keys to send an ellipse zooming around the sketch window.
Since you want to move the ellipse, you need to be able to change its x- and y-coordinates. First, in the code window, create global variables for those values:
int x = 300;
int y = 300;
Start your ellipse in the middle of the sketch window. In my example, the center is (300,300). Yours may be different, if you change the size of your sketch window.
Now write the setup() and draw() calls:
void setup()
{
size(600,600);
}
void draw()
{
background(150);
fill(255,0,0);
noStroke();
ellipse(x,y,50,50);
}
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Linux Device Driver Development Cookbook by Rodolfo Giometti(3952)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3723)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3648)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3486)
TinyML Cookbook by Gian Marco Iodice(3410)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2852)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2617)
Fusion 360 for Makers by Lydia Sloan Cline(2228)
Networking A Beginner's Guide by Bruce Hallberg(2223)
Hands-On Linux for Architects by Denis Salamanca(2065)
But How Do It Know? by J. Clark Scott(2039)
Computers For Seniors For Dummies by Nancy C. Muir(2020)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1975)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1958)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1914)
Hack and HHVM by Owen Yamauchi(1895)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1873)
MicroPython Projects by Jacob Beningo(1756)
Hands-On Internet of Things with MQTT by Tim Pulver(1723)
