We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm doing a homework assignment in which we need to make our own puzzle game with the coding the professor gave us. I want to replace the numbers with images but seems I have am having trouble putting replacing the images since it keeps on giving me certain errors
gemArray[i][j].posX - 25 && mouseX < gemArray[i][j].posX + 25) { if (mouseY > gemArray[i][j].posY -25 && mouseY < gemArray[i][j].posY + 25) { gemArray[i][j].marked = true; } } } } } void MarkedTest() { oneMarked = false; for ( int i = 0; i < gemArray.length; i++) { for (int j = 0; j < gemArray[i].length; j++) { if (gemArray[i][j].marked == true) { if (oneMarked == false) { oneMarked = true; markedOneColumn = i; markedOneRow = j; } else { SwitchGems(markedOneColumn, markedOneRow, i, j); } } } } } void SwitchGems(int oneColumn, int oneRow, int twoColumn, int twoRow) { holdNumber = gemArray[oneColumn][oneRow].myNumber; gemArray[oneColumn][oneRow].myNumber = gemArray[twoColumn][twoRow].myNumber; gemArray[twoColumn][twoRow].myNumber = holdNumber; gemArray[oneColumn][oneRow].marked = false; gemArray[twoColumn][twoRow].marked = false; } void CheckMatch() { for ( int i = 0; i < gemArray.length; i++) { for (int j = 0; j < gemArray[i].length; j++) { tileNumber = gemArray[i][j].myNumber; if (i < gemArray.length - 2) { if (gemArray[i+1][j].myNumber == tileNumber) { if (gemArray[i+2][j].myNumber == tileNumber) { gemArray[i][j].alive = false; gemArray[i+1][j].alive = false; gemArray[i+2][j].alive = false; } } // Shaan hugs trees // a lot } if (j < gemArray[i].length - 2) { if (gemArray[i][j+1].myNumber == tileNumber) { if (gemArray[i][j+2].myNumber == tileNumber) { gemArray[i][j].alive = false; gemArray[i][j+1].alive = false; gemArray[i][j+2].alive = false; } } } } } }
class Gem{ int column, row, posX, posY, myNumber; boolean marked; boolean alive; int aliveTimer; Gem(int myColumn, int myRow){ column = myColumn; row = myRow; posX = 50 + column * 100; posY = 50 + row * 100; myNumber = (int)random(1, 10); alive = true; } void update(){ SetNewNumber(); if (marked == true) { strokeWeight(7); } else { strokeWeight(3); } ellipse(posX, posY, 50, 50); if (alive == true) { text(myNumber, posX - 10, posY + 14); } } void SetNewNumber(){ if(alive == false){ if(aliveTimer < 120){ aliveTimer++; } else{ myNumber = (int)random(1, 10); aliveTimer = 0; alive = true; } } } }
Is there anyway I can get images like this one as a number?
Answers
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
"it keeps on giving me certain errors"
What errors? Obviously, we cannot run the code you gave, so we can't reproduce these errors.
Apparently, the shown code is cut in the middle of a function, and there is no setup() nor draw().
Beside, in this code, I don't see any reference to an image.
If you can display the numbers 0 to N in your sketch, you can have an array of N images, and use the numbers as an index for that array instead. Here's an example that uses an array of colors instead of images.