Modify a text file: $/bam-tiles.01a.pde
$/bam-tiles.01a.pde
//// Tile puzzle. //// Move tiles to get solution. String title="Move tiles to answer the question."; String author="ProfessorBAM"; String question="What color is the sun?"; String answer="YELLOW"; char[] letters={ 'W', 'O', 'L', 'L', 'E', 'Y' }; int many=6, pick=-1, drop=-1; Tile[] tiles = new Tile[many]; int left=50, spacing=100, top=300; int tileWidth=80, tileHeight=80; color BLACK=0, WHITE=#FFFFFF, GRAY=#999999, RED=#FF0000, GREEN=#00FF00, BLUE=#0000FF, YELLOW=#FFFF00, CYAN=#00FFFF, MAGENTA=#FF00FF; void setup() { size( 750, 600 ); int x=left, y=top; // ++ Calculate positions based on many ++ for (int i=0; i
x+w) return false; if (y2
y+h) return false; return true; } boolean hover( float x2, float y2 ) { if (x2>x-w/2 && x2
=0 && drop != pick) { // Swap tiles[drop] with tiles[pick]; char what= tiles[pick].c; tiles[pick].c = tiles[drop].c; tiles[drop].c = what; } pick = -1; // (No more picked tile.) }