Loading...
Logo
Processing Forum
Copy code
    Why is this code throwing a "unexpected token: boolean" error?

    Copy code
    1. class Bullet{
    2.   float x,y;
    3.   
    4.   Bullet(int startX, int startY){
    5.     x = startX;
    6.     y = startY;
    7.   }

    8.   void move(){
    9.     y -= 3;
    10.   }

    11.   void put(){
    12.     rect(x, y, 5, 5);
    13.   }
    14. }

    15. class Player{
    16.    int x, y;
    17.    int dirx, diry;

    18.   Player(int startX, int startY){
    19.     x = startX;
    20.     y = startY;
    21.   }

    22.   void put(){
    23.     rect(x, y, 10, 10);
    24.   }
    25.   
    26.   void move(){
    27.     y = y +diry;
    28.     x = x+dirx;
    29.   }
    30. }

    31. class Enemy{
    32.     int x, y;
    33.     int dirx, diry;
    34.     
    35.     Enemy(int startX, int startY){
    36.       x=startX;
    37.       y=startY;
    38.     }
    39.     
    40.     void put(){
    41.       rect(x, y, 10, 10);
    42.   }
    43.   
    44.     void move(){
    45.       y = y +diry;
    46.       x = x+dirx;
    47.   }
    48. }

    Replies(4)

    The error is not in this code must be in some other part you have not posted.
    That's what I thought but the thing is when i run the code it focuses on this tab. I'll go look in the other tabs.
    Got it. There was a missing bracket in one of the tabs. Still don't know why it zoomed to the tab where the problem wasn't.
    See my answer in https://forum.processing.org/topic/trouble-finding-an-error (exactly the same problem...).