I have a bit of code that adds instances of a class to a list. I get a 'local variable may not have been initialized error' when I try to add one item to an ArrayList. I can fix the problem easily by doing this in the declaration:
Point tempPoint1, tempPoint2=null;
...as I'm not a fan of making things point to nothing (seems as bad as not being initialized to me!), is there a 'proper' way to do this or is it a case of refactoring?
Incidentally, the code works properly and, so far as I can tell, there is no possibility of tempPoint2
not being assigned a value before it is added to the list.
I have a number of image files that I'd like to rename (or copy each to a new file with a new name leaving the original in place). Can anyone tell me how to do this reliably with Processing on Windows - from what I've read it seems that this can be a bit of a hack even in Java proper.
Simple string physics, click to grab/un-grab or leave it to move around.
final int NUMPOINTS=50; // number of points final int SEGLENGTH=2; // distance between points final int BORDER=10; // 'rebound' when this close to the edge
I'm trying to revamp an ugly old finite state machine that has lots of if/then and switch statements and I'd like to make it more object oriented. This is what I'm trying to achieve...
"...A more extendible approach is to set up a basic State class, and a set of specific states which inherit
their structure from the basic State class. At any time an AI agent has a state attached to it, when a
transition occurs, the state is replaced with the new state."
In C I would imagine function pointers would do the trick nicely; how can I emulate that using classes in Processing? Any help appreciated (especially in simplest terms
)
Assuming I have something like the code below, and I'm updating point[10] I'd like to be able to access other instances of point[], eg. point[6]. Can I /should I do this by passing the index of the object to the update() method or should I just move update() out of the class altogether (which seems self-defeating)? What if I need access to an unkown number of instances so can't define the parameters in advance?
TIA for helping me improve my OOP
class MyClass{
float fX, fY;
float update(){
//access other instances here
//eg updating point[10] but need to access point[6] and possibly others!
}
}
I have a very simple program that draws a bunch of lines and grabs part of the screen into a newly created image (around 200x200 pixels).
When exported to Javascript it works the same except the image seems to be of reduced quality.
I've tried the 'crisp' directive to see if that has any effect but it doesn't. No other drawing primitives are used except line (along with stroke() and strokeWeight() ) .
The image is created thus:
minipatt=createImage(16 * CELLSIZE, 16 * CELLSIZE, RGB);
This code doesn't seem to work in the latest Beta (released today), I think it did in the old version. I've tried in latest Win 32 and 64 bit versions....can anyone confirm this please?