I'm making a game thing, but when I try to compile my code, the preprocessor gives me this error:
expecting IDENT, found ')'
An interesting thing about that is that it highlights the closing curly brace of my class.
I've searched and never found a direct answer explaining what an IDENT is, only answers talking about how they forgot to specify types or they need to wrap it in setup() or stuff like that.
I'm not going to post my code (there is a lot of it) unless I need to.
What could this error actually mean, and what is an IDENT?
I'm making a physics sandbox with a zoom in/zoom out button and camera panning. However, when the matrix is adjusted, the mouse position isn't and everything is off.
So is there a way to apply my transformation matrix to x/y coordinates to sync them up with shape drawing?
I'm working on a simulator and editor for the great cellular automaton
WireWorld.
There's a two-dimensional array called 'cells' which stores the states of the cells in the grid: 0 for off, 1 for wire, 2 for electron head, and 3 for electron tail.
Currently, it needs to save the states of each cell to a file. Here's my code (please pardon my sloppy, inefficient code... if there is a way to generate an array on the fly without a variable, could someone please tell me?):
String[] toSave = new String[rows];
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
String[] toAppend = new String[2];
toAppend[0] = toSave[i];
toAppend[1] = nf(cells[i][j], 1);
toSave[i] = join(toAppend, ',');
}
}
saveStrings("wireworld.txt", toSave);
That's in a keyPressed function, by the way.
My problem is that it adds "null" to the beginning of each line, like this:
My conway's game of life looks cool... but for some reason it doesn't act right.
As far as I know, these are the
correct rules...
So why isn't it acting correctly?
(it does look cool though)
My code:
boolean cells[][];
boolean newCells[][];
int rows, cols;
void setup() {
size(400, 400);
rows = height / 10;
cols = width / 10;
cells = new boolean[cols][rows];
newCells = new boolean[cols][rows];
for (int i = 0; i < cols; i++) {
for (int j = 0; j < rows; j++) {
if (int(random(0, 3)) == 1)
cells[i][j] = true;
else
cells[i][j] = false;
}
}
frameRate(30);
}
void draw() {
background(0);
for (int i = 0; i < cols; i++) { //loop through x of array
for (int j = 0; j < rows; j++) { //loop through y of array
if (cells[i][j])
rect(i * 10, j * 10, 10, 10); //draw a cell if it's active
int adjacent = 0; //the number of adjacent cells
for (int k = i - 1; k <= i + 1; k++) { //Loop through adjacent cells on the x axis
if (k < cols && k >= 0) { //no arrayIndexOutOfBoundsExceptions
for (int l = j - 1; l <= j + 1; l++) { //Loop through adjacent cells on the y axis
if (l < rows && l >= 0) {
if (cells[k][l])
adjacent++; //that's one more adjacent cell! Yay!
}
}
}
}
//now for rule calculation...
if (cells[i][j]) {
if (adjacent < 2 || adjacent > 3) //lonely or overcrowded?
newCells[i][j] = false;
else
newCells[i][j] = true; //two or three friends is good :D
I'm pretty new to processing (okay,
really new).
I was browsing through the learning section and found
this.
I thought, "well, this is awesome! maybe I could use this..."
I was thinking that it could be used in a game I was making to make little fluffy explosions whenever an enemy died. After experimenting with it (basically just changing the size, renderer [to P2D, which improved speed by a longshot] and the contents of the res variable), I got really, really confused. I have no idea what vbuffer is, and the code is not commented at all... I couldn't figure out which part generated the particles from the bottom of the screen.
So could anyone give me some pointers to:
removing rising of smoke
creating new smoke with specified position, direction, and velocity... if it works that way
I have already commented out random gusts and mouse control but I can get some portion of them back if I need.