Thanks in advance, I am having some custom class object stored in an ArrayList. When I click any of them, it will fade away and when alpha reaches 0, it will remove itself from the ArrayList using remove(this).
However, if I click them in order, the moment when it is removed causing the rendering of the next object in ArrayList to flicker a bit. It almost seems like the ArrayList lost the next object for a brief moment so it wasn't updated and drawn to the screen. How do I go around and keep that flickering from happening?
In the code below, if you click starting with the bottom-right one and go clockwise, you will see the next object flicker. I am using Processing 2.0b8 on PC, and it happens with or without P2D
*just test it this on 1.5.1, also does it.
*just test it this on a Mac, also does it.
ArrayList<enemy> enemies;
void setup() {
size(300,300, P2D);
enemies= new ArrayList<enemy>();
float a = PI/4; //create four enemies, PI/2 away, starting bottom-right corner
for (int i=0; i<4; i++) {
enemy temp = new enemy(width/2+100*cos(a), height/2+100*sin(a));
enemies.add(temp);
a+=PI/2;
}
}
void draw() {
background(0);
if (!enemies.isEmpty()) {
for (int i=0; i<enemies.size(); i++) {
enemy temp= enemies.get(i);
temp.update();
}
}
}
class enemy {
PVector pos;
float size;
boolean death;
int alpha;//alpha for all the color in the drawing of the enemy
Hi, I am using the NXTComm library to run Lego NXT and it works great. However, there is one little thing that bothers me, every time when the program executes mynxt.motorForward(mynxt.MOTOR_A, -80) or other NXT related commands, the visual freezes for a brief moment. I was told to look into threading, is it possible to run the entire NXTComm class in a separate thread?
I am using the NXTcomm library in a project. It works nicely but there is one [considerably big] problem. When I send out commands, the animation I have on the screen will stuck for a brief sec and move on. Has anyone experienced this lag before? Is there a way to fix this problem?
Originally I set up my Android development with Galaxy Note 10.1 on my desktop that runs Windows 7. It was a breeze to set up just have to read the Android Processing Wiki carefully. However, moving the development environment to Window XP on my other machine with the exact steps, software, and drivers, has been a nightmare so far. I simply can't get Windows XP to recognize Galaxy Note 10.1. I got it to show up as an unknown device in the hardware manager, but none of the drivers (inc. the verizon one from Samsung website and Kies) worked...
Does anyone know a driver that works? Or is it just impossible to develop with Note 10.1 on Windows XP? I read it somewhere that Galaxy Note 10.1 only works on Windows 7, can anyone confirm this!?
I have a question about sending a sequence of bytes to the serial port. What is the right way to do this? I translated from this python sample code in order to control an USB device using Processing:
Is this is a correct way to send byte sequences? My USB device didn't response at all... (I have the baud rate and parity set up correctly) any hints will be really helpful, thanks in advance!
I am trying to convert 4 bytes into a float number. I was looking into Float.intBitsToFloat but I am stock at it. I have a byte[] data={ byte(154), byte(105), byte(19), byte(64)}; the float read out of this 4 bytes should be 2.3033204, when I put the byte manually it works fine:
Float.intBitsToFloat(0x4013699A) gives me 2.3033204
However, when I try to do it dynamic in the following way, it doesn't work correctly anymore. please help!
Float.intBitsToFloat( (data[3]>>24)|(data[2]>>16)|(data[1]>>8)|data[0]) this gives me NaN...
Question:
What is the equivalent of C# BitConverter in Processing? If there is none, is it possible to read 4-byte integers and 2-byte integers from the data[] with Processing?
Backstory:
I am trying to read the UDP packets coming from Optitrack (industrial 3D Motion tracking system) with Processing. I learned that pocket is made of multi-byte data, such as 4-byte integers and 2-byte integers. It won't work with the UDP library examples using -> new String(data[]). I have no problem receiving data from the port, I just can't parse the data[] correctly.
Tried and not working:
1. Converting each byte to a string equivalent with char() and then concatenating.
2. add byte together based on the byte syntax (e.g byte(data[0]+data[1]) )
2. new String(data[]);