PacMan help
in
Programming Questions
•
2 years ago
hi i am learning to use processing need to do a pacman-like game, where I paint thefood at random, I have not learned lessons or anything, not if the food in this way I paintrandomly varying the types of food and I get an error called "arrayindexoutofboundexception: #"
where # is the value we give to fix my code:
int types [] = new int [1];
void setup () {
for (int i = 0; i <posesX.length; i + +) {
posesX [i] = (int) random (-200, 200);
posesY [i] = (int) random (-100, 200);
types [i] = (int) random (2); <----****** this is wrong
}
void draw () {
for (int i = 0; i <posesX.length; i + +) {
pintarComida (posesX [i], posesY [i], types [i]); (not if I work.) ************
}
void pintarComida (int posX, posY int, int type) {
switch (type) {
case 0: image (thunder, posX, posY)
case 1: image (thief, posX, posY)
}
thanks
where # is the value we give to fix my code:
int types [] = new int [1];
void setup () {
for (int i = 0; i <posesX.length; i + +) {
posesX [i] = (int) random (-200, 200);
posesY [i] = (int) random (-100, 200);
types [i] = (int) random (2); <----****** this is wrong
}
void draw () {
for (int i = 0; i <posesX.length; i + +) {
pintarComida (posesX [i], posesY [i], types [i]); (not if I work.) ************
}
void pintarComida (int posX, posY int, int type) {
switch (type) {
case 0: image (thunder, posX, posY)
case 1: image (thief, posX, posY)
}
thanks
1