Microsoft Word - Document4 Assignment Instructions All code must be written in processing software, free software download on processing.org Write code for the flip tile game; here is how the game is...

1 answer below »
Attached are instructions for the assignment as well as a video example of the desired outcome. All code must be done in processing software, free software download on proccessing.org


Microsoft Word - Document4 Assignment Instructions All code must be written in processing software, free software download on processing.org Write code for the flip tile game; here is how the game is played : Basically there are 2 images... 1. To begin with, one of the 2 images are randomly displayed in each cell of the grid. 2. The user clicks on a cell to toggle between the 2 images. 3. Game comes to an end when all the cells in the grid show the same image. Watch the video to recall how the game is played. (It has been loaded inside hw7 folder in the box). You will need a 2D array board that stores either a 1 or 2 to let us know what image is being currently shown in a cell. Inside setup : 1. Randomly populate board with either 1 or 2. 2. Do the visual representation of what is inside board (1 means show your first image on that tile in the canvas & 2 means show your second image on that tile in the canvas ) Inside mousePressed: 1. Find clickedRow & clickedCol - both of that put together gives the user selected tile. 2. Check what is being currently displayed in the user selected tile (check the content of board at location determined by step 1). 3. Refer to activity_alternate_images inside BOX in the folder 11_09_29_images_intro_finish_ascending activity_toggle_image inside BOX folder 11_09_30_image_intro_descending puzzle for step 4 - first understand what has been done there; then try applying that concept here. 4. If it is showing image1(ie. board has a 1 in that position) then a. change the board content at that position to 2 b. write code to reflect this change visually by showing image2 in that cell on the canvas 5. else // means that tile is showing image2. a. change the board content at that position to 1 b. write code to reflect this change visually by showing image1 in that cell on the canvas 6. If game is over, a. close the game Game over condition : 1. Find how many tiles display image1 - giving 2 ways to do this. a. Maintain a variable that keeps count of # of image1 being displayed. (involves a couple of steps in mousePressed - I have not included that.) b. OR Count the number of 1 occurs inside the 2D array board (involves searching in the 2D array board ) 2. If the number determined in step 1 is same as number of tiles in the whole canvas (ie. all tiles are showing image1) OR that count is 0 (ie. all tiles are showing image2) then a. game has come to an end. 3. else a. game needs to continue. Lavf58.12.100
Answered Same DayOct 13, 2021

Answer To: Microsoft Word - Document4 Assignment Instructions All code must be written in processing software,...

Ramachandran answered on Oct 14 2021
130 Votes
Order-93652/game/data/img1.jpg
Order-93652/game/data/img2.jpg
Order-93652/game/game.pde
import ja
va.util.Random;
PImage img1;
PImage img2;
//total rows in grid
int n = 4;
//total cols in grid
int m = 4;
int wCell;
int hCell;
//initialize the grid
int[][] grid = new int[n][m];
int countImg1 = 0;
//calculate totalCells
int totalCells = n*m;
void setup() {
//set the size of the canvas
size(800, 800);
//load the images from the data folder
img1 = loadImage("img1.jpg");
img2 = loadImage("img2.jpg");
// calculate the...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here