September 2018
Intermediate to advanced
328 pages
9h 10m
English
Create a file named js-without-glue.cpp in your /chapter-06-interact-with-js folder and populate it with the following contents:
/* * This file interacts with the canvas through imported functions. * It moves a circle diagonally across the canvas. */#define BOUNDS 255#define CIRCLE_RADIUS 50#define BOUNCE_POINT (BOUNDS - CIRCLE_RADIUS)bool isRunning = true;typedef struct Circle { int x; int y; char direction;} Circle;struct Circle circle;/* * Updates the circle location by 1px in the x and y in a * direction based on its current position. */void updateCircleLocation() { // Since we want the circle to "bump" into the edge of the canvas, // we need to determine when the right edge of the circle // encounters the bounds of the canvas, ...Read now
Unlock full access