How can I create a PImage of something without actually drawing it to the screen?
Say I have an empty PImage and I want to draw an ellipse or some text to it but I never want that to appear on the screen - and even if I did, I want to preserve transparency.
textDescent() seems to work very unreliably for the same character across different sizes, even when using a scalar as in the example. Is there a simpler way or a trick that I'm missing?
This runs very smoothly on its own, but it slaughters the framerates of other elements, like a simple player-controlled spaceship. Is there anything glaringly obvious to be done to optimize it? I'm hesitant to write it to a PImage since the "clouds" are not static, unlike the planet's surface, and even only drawing the clouds severely slows down anything else on the screen. Thanks in advance.
I have a class Object1 that has an object called obj2 as a property. Depending on the instantiation of Object1, obj2 might be an instance of Object3 or Object4, extensions of the Object5 class.
At the moment I'm doing it like this:
Object1 {
int type;
Object5 obj2;
Object1 (int typein) {
type = typein;
switch (type) {
case 0:
obj2 = new Object3();
break;
case 1:
ob2 = new Object4();
break;
}
}
void put(){
obj2.put();
}
}
class Object5 {
Object5(){
}
}
class Object3 extends Object5 {
int foo;
Object3 () {
foo = floor(random(10));
}
void put(){
text(foo,10,10);
}
}
class Object4 extends Object5 {
float bar;
Object4 () {
bar = random(10);
}
void put(){
text(round(bar),10,10);
}
}
However, it's not working. The code above doesn't work unless Object5 also has int foo or float bar, and a push method, and then what I get is an instantiation of Object5 followed by Object3 or Object4, and changes to obj.obj2.foo or obj.obj2.bar are reflected in the Object5 instantiation and not in obj2's put method.
I feel like I must just be drastically misunderstanding how to extend a class, how to implement an object that might be an instance of several different classes, or perhaps even how to accomplish this altogether.
How can I fix this, or what is a better way to do it?
I'm using booleans to track which keys are pressed. I had thought that this was the fix for multiple keypresses but am now finding that only the first two are tracked. Any additional keys are ignored. Furthermore, key releases are ignored until those additional keys are released also. How can I allow any number of keys to be pressed?
Maybe I'm just missing something in the code. It's probably worth noting that right and left are changing angle of rotation while up and down are moving forward and backward along that angle. It's not just a matter of:
{ right = x++; left = x--; up = y--; down = y++; }
I'm working on a game that is very expansive in terms of data, but graphically very simple - basically little more than Asteroids with an extensive plot and universe generator. I'm trying to figure out if I'm wasting my time writing it in Processing. I know other languages - C++, Python, and Javascript, to name a few - but it seems to me that either graphics are more difficult to manage than they need to be (C++ - in which I've never understood how to do graphics - and Python, which is tough by Pythonic standards), cross-platform compatibility is a problem (C++), or the scripted nature makes managing the large amounts of worldgen data difficult (Python and Javascript).
I feel like Processing is the most fun way to do it, and the easiest. It might not be the most efficient, but as long as it runs smoothly I'm not worried. The big problem I'm having with embarking on this is that it seems like my intentions here go against Processing's own identity. From the overview: "
The Processing project encourages a style of work that builds code quickly, understanding that either the code will be used as a quick sketch, or ideas are being tested before developing a final project." Is this saying that Processing is not intended for large-scale projects? Am I going to run into unforeseen problems halfway through? Is there a language I haven't considered that I should consider? Maybe it's time to learn Java. I dunno. Any advice would be very appreciated.
This runs smoothly on my computer except when large quanitites of raindrops are generated. Could anything be done to optimize performance or is this just the limitations of Java? mouseX controls wind, height - mouseY controls amount of rain.
Is there an easier way than .pixels[] to only show a selected part of an image? I see
this post but it seems to behave differently than described and I can't find any documentation to support it:
image(img, dx, dy, dw, dh, sx, sy, sw, sh); where dx, dy, dw, dh = the area of your display that you want to draw to. and sx, sy, sw, sh = the part of the image to draw (measured in pixels)