Loading...
Logo
Processing Forum
cheezcoder's Profile
8 Posts
8 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    I'm making a game thing, but when I try to compile my code, the preprocessor gives me this error:
    1. 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 have this code, which is supposed to create a fuzzy-looking circle.

    1.     for (float i = 10; i > 0; i--) {
    2.       fill(255, 0, 0, i / 10 * life);
    3.       noStroke();
    4.       ellipse(pos.x, pos.y, i, i);
    5.     }
    life is a float from 1 to 255 and pos is a PVector.

    When I run this code (not standalone, obviously), it simply creates a solid red circle.

    What's wrong with my code?


    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?):

    1.     String[] toSave = new String[rows];
    2.     for (int i = 0; i < rows; i++) {
    3.       for (int j = 0; j < cols; j++) {
    4.         String[] toAppend = new String[2];
    5.         toAppend[0] = toSave[i];
    6.         toAppend[1] = nf(cells[i][j], 1);
    7.         toSave[i] = join(toAppend, ',');
    8.       }
    9.     }
    10.     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:

    null,0,0,0,0,1,0,0,0
    null,0,1,0,1,0,1,0,1
    null,0,0,1,1,1,1,1,0
    null,0,0,0,1,0,0,1,1
    null,0,1,1,0,0,1,1,0
    null,0,1,0,1,1,0,1,1
    null,0,0,1,0,0,1,0,0
    null,0,0,0,0,1,0,1,0

    What is going on?

    Thanks,
          Cheezey
    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:

    1. boolean cells[][];
    2. boolean newCells[][];
    3. int rows, cols;
    4. void setup() {
    5.   size(400, 400);
    6.   rows = height / 10;
    7.   cols = width / 10;
    8.   cells = new boolean[cols][rows];
    9.   newCells = new boolean[cols][rows];
    10.   for (int i = 0; i < cols; i++) {
    11.     for (int j = 0; j < rows; j++) {
    12.       if (int(random(0, 3)) == 1)
    13.         cells[i][j] = true;
    14.       else
    15.         cells[i][j] = false;
    16.     }
    17.   }
    18.   frameRate(30);
    19. }
    20. void draw() {
    21.   background(0);
    22.   for (int i = 0; i < cols; i++) { //loop through x of array
    23.     for (int j = 0; j < rows; j++) { //loop through y of array
    24.       if (cells[i][j])
    25.         rect(i * 10, j * 10, 10, 10); //draw a cell if it's active
    26.       int adjacent = 0; //the number of adjacent cells
    27.       for (int k = i - 1; k <= i + 1; k++) { //Loop through adjacent cells on the x axis
    28.         if (k < cols && k >= 0) { //no arrayIndexOutOfBoundsExceptions
    29.           for (int l = j - 1; l <= j + 1; l++) { //Loop through adjacent cells on the y axis
    30.             if (l < rows && l >= 0) {
    31.               if (cells[k][l])
    32.                 adjacent++; //that's one more adjacent cell! Yay!
    33.             }
    34.           }
    35.         }
    36.       }
    37.       //now for rule calculation...
    38.       if (cells[i][j]) {
    39.         if (adjacent < 2 || adjacent > 3) //lonely or overcrowded?
    40.           newCells[i][j] = false;
    41.         else
    42.           newCells[i][j] = true; //two or three friends is good :D
    43.       } else { //dead :(
    44.         if (adjacent == 3)
    45.           newCells[i][j] = true; //reincarnation! :D
    46.         else
    47.           newCells[i][j] = false; //still dead. :(
    48.       }
    49.     }
    50.   }
    51.   arrayCopy(newCells, cells);
    52. }

    Thanks in advance.

    I'm trying to use Processing to display sensor values from my Arduino.

    The serial monitor gives the correct values, but Processing gives two (sometimes three) incorrect digits.

    Here's my Arduino code:

    1. void setup() {
    2.   Serial.begin(9600);
    3.  
    4. }
    5. void loop() {
    6.   float brightness = analogRead(A0);
    7.   brightness = brightness / 1023 * 255; //make sure that it's under 255 so it's only one byte...
    8.                                                          //maybe it's a stupid idea, but I'm no expert.
    9.   Serial.println(byte(round(brightness)));
    10. }
    Processing code:

    1. import processing.serial.*;
    2. Serial bob; //I've named my robot bob... so sue me.
    3. int light;
    4. void setup() {
    5.   bob = new Serial(this, "COM3", 9600);
    6. }
    7. void draw() {
    8.   if (bob.available() > 0) {
    9.     light = int(bob.read());
    10.     println(light);
    11.   }
    12. }
    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.

    Thanks in advance,
    cheezcoder