Hello! I've been working on this program in which a rectangle is directed about the screen using the WASD keys (or arrow keys... I'm not done yet) , and I'm working on having the "front" of the rectangle always be the front, so that moving "forward" causes it to travel forward, even if the rectangle is rotated. Is this possible, and if so, could someone direct me to where I could learn? Thanks!
Hello! I'm working on a program in which I need to rotate a 2D rectangle around it's centre using the "speed" displayed while running the following programme, which goes from -1 to +1 (I'll make it it's own variable eventually :P ). In addition, the rectangle may or may not be traveling while doing this (eventually, the rectangle will move about the screen using WASD keys, which I have already figured out, and take into account inertia and momentum), and I may end up needing to smooth the value so it doesn't decrease so abruptly. Those last two parts aren't actually part of my question, but I just wanted to fill you in. All I need to do is apply the rotation to a square. A few people I've talked to have told me that this is "easy", but I haven't seen this type of rotation in any of the examples I've found. Any help would be greatly appreciated!
Hello! I'm trying to make a 'joystick' using the mouse. I'm trying to get the mouse speed and map it to -1 to +1 for the 'x' and 'y' axis. I'm fairly certain that I can get the absolute mouse speed using
but I can't use that to tell the direction, and I don't know the values I'm using to map. In addition to figuring out the speed, I'm probably going to need to use the Robot library to keep the mouse on screen, which would mean that mouseX and pmouseX etc won't work... I'm sure I could figure it out if Processing was working for me, but part of it seems to be broken. The libraries are not communicating...I'm re-downloading, but I won't be here when it finishes (and it's DLing at 5kb/s). If anyone happens to have some time and/or knows how to do this, I would really appreciate if you could share some of your knowledge. Thanks!
Hello! I'm attempting to make a GUI for controlling a robot, and I need FPS style mouse controls. I thought I figured out how it's done in games, but it turns out I have no idea. This is what I have....
import processing.core.*; import java.awt.Robot;
public class FPSMouse extends PApplet { public static void main(String args[]) { PApplet.main(new String[] { "--present", "FPSMouse" }); }
public boolean sketchFullScreen() { return true; } }
It's unresponsive and slow and just disappointing. Is there a better way of doing this? Thanks!
p.s. I'm using Eclipse, not the Processing IDE, in case you were wondering...
Hello! I've been searching everywhere for this (including this forum) and haven't been able to figure it out. I'm attempting to use [W][A][S][D] and [SHIFT] to steer a square around the screen, but I can't seem to figure out the shift part. It should essentially steer in the standard holonomic FPS style, but I'm having problems. The [SHIFT] key
should toggle the variable which corresponds to the "speed". I don't currently have access to the modified version, but I can assure you it didn't work. This is what I've been trying to modify.
import processing.core.*;
public class Key_WASD extends PApplet { public static void main(String args[]) { PApplet.main(new String[] { "--present", "Key_WASD" }); }
final static int NORTH = 1; final static int EAST = 2; final static int SOUTH = 4; final static int WEST = 8; int result; float x,y,a;
public void setup() { size(displayWidth,displayHeight); frameRate(300); noCursor(); result = 0; x = width/2; y = height/2; a = 3; }
public void draw() { background(0); switch(result) { case NORTH: y-=a; break; case EAST: x+=a; break; case SOUTH: y+=a; break; case WEST: x-=a; break; case NORTH|EAST: y-=a; x+=a; break; case NORTH|WEST: y-=a; x-=a; break; case SOUTH|EAST: y+=a; x+=a; break; case SOUTH|WEST: y+=a; x-=a; break; case NORTH|SOUTH|EAST: x+=a; break; case NORTH|SOUTH|WEST: x-=a; break; case EAST|WEST|NORTH: y-=a; break; case EAST|WEST|SOUTH: y+=a; break; }
if (x>displayWidth){x=0;} if (x<0){x=displayWidth;} if (y>displayHeight){y=0;} if (y<0){y=displayHeight;}
A friend of mine (who is notoriously good at processing) tried this himself, but still had issues. The [SHIFT] key has to be pressed before moving, and can not be toggled on while moving. Here's that code (he told me to put it here).
public void keyPressed() { if (key == 'a') { left = true; SOOPASPEED = false; } else if (key == 'A') { left = true; SOOPASPEED = true; } if (key == 'd') { right = true; SOOPASPEED = false; } else if (key == 'D') { right = true; SOOPASPEED = true; } if (key == 's') { down = true; SOOPASPEED = false; } else if (key == 'S') { down = true; SOOPASPEED = true; } if (key == 'w') { up = true; SOOPASPEED = false; } else if (key == 'W') { up = true; SOOPASPEED = true; } }
public void keyReleased() { if (key == 'a' || key == 'A') { left = false; } if (key == 'd' || key == 'D') { right = false; } if (key == 's' || key == 'S') { down = false; } if (key == 'w' || key == 'W') { up = false; } } }
I apologize if I forgot anything. Also, if it wasn't apparent, we're both using Eclipse for compiling, which isn't our problem. Can anyone see what we're doing wrong? Thanks!
Hello! I'm REALLY new to Processing (first week or so) and myself and a few other people (who happen to be amazing at this language) are building a GUI for controlling a robot in Eclipse (that's not the problem). What we
want to do is use the mouse much in the same way as it would be used for a first-person-shooter. Our problem is getting the mouse to maintain it's position in the centre of the screen while still acquiring information such as the "speed" and direction (which should be two values from -1 to +1; x and y axis). I know there's a way to display in "presentation mode" which takes up the full screen, but I don't know if we can still acquire "speed" and directional data if the mouse is essentially trapped against the screen boarder. Is there a way to move the mouse itself and/or acquire data from the entire screen, not just the window? Like I said, I have no idea what I'm doing. Thanks!