unexpected char: '\' and another question.
in
Programming Questions
•
2 years ago
Just a couple of quick questions: First, I keep getting the error "unexpected char: '\'" when I try and run this piece of code:
- PVector position, velocity;
- int diameter;
- void setup(){
- size(500,500);
- background(0);
- smooth();
- position = new PVector(10,10,0);
- velocity = new PVector(3,5,0);
- diameter = 10;
- }
- void draw(){
- background(0);
- position.add(velocity);
- bounceWalls();
- noStroke();
- fill(255);
- ellipse(position.x,position.y,diameter,diameter);
- }
- void bounceWalls(){
- float leftLimit, rightLimit, upperLimit, lowerLimit;
- leftLimit = diameter*.5;
- rightLimit = width–diameter*.5;
- upperLimit = diameter*.5;
- lowerLimit = height – diameter*.5;
- if(position.x < leftLimit)
- {
- position.x = leftLimit;
- velocity.x = velocity.x*-1;
- }
- if(position.x > rightLimit)
- {
- position.x = rightLimit;
- velocity.x = velocity.x*-1;
- }
- if(position.y < upperLimit)
- {
- position.y = upperLimit;
- velocity.y = velocity.y*-1;
- }
- if(position.y > lowerLimit)
- {
- position.y = lowerLimit;
- velocity.y = velocity.y*-1;
- }
- }
Second question: Is there a way to resize the processing window or applet, without changing the pixels, as it were? Like a window 600x300 px, but processing drawing lines and all in a 300x150 grid of pixels at the 600x300 px window size? I want to try and make a pixel-ly game, but don't know if I have to introduce extra code to achieve this.
Thanks in advance!
1