6

Performance The main reason for the slow down are the state changes you incur each time you change the color and transparency of the particle (which is each particle). Unless you are prepared to write some shaders (webGL) you are not going to get past this problem. You will need to sacrifice some features to get performance. The second reason for the ...


5

You are beginning to mix up the business logic with the user interface. You should (be able to) design a "game driver" class without regard to user interface. You want to keep your GUI code separate from your game logic code. And another OO paradigm is to create new objects separately and pass them into where they are used. I see a Game class ( "Dealer" ...


3

About point (1) If it's obviously copied from somewhere without changing anything then it's perfectly fine to not change anything to the code itself. Given that you also have the link to the (pseudo-)code. In this case I wouldn't even add comments other than: look at this page to know how it works. If however you want to integrate it better into your own ...


3

Formatting & look: Use proper access modifiers All you methods and fields use the default package level visibility. Decreasing the scope of items to the lowest possible scope is recommended for clearer code. This is as simple of marking you methods and fields private or public where needed. Start field/variable names with a lowercase letter ArrayList&...


3

Turns out I needed to normalize the normal first: n.normalize(); full code for reference: PVector[] face = new PVector[3]; float ai = TWO_PI/3;//angle increment float r = 300;//overall radius float ro = 150;//random offset PVector n;//normal Ray r1; void setup() { size(500, 500, P3D); for (int i = 0 ; i < 3; i++) face[i] = new PVector(cos(ai * i)...


3

(1). From the point of style I'd recommend you not to mix the level of details in a function. For example. Instead of writing something like this: void setup() { background(0); size(1000, 500); for (int i = 0; i < pAmt; i++) { // this is bad p[i] = new Particle(random(width), random(height), i); } } You should write something like this. ...


2

Something you need to learn about performance in java is that if performance is important to you, Java might not be the language for you. Your code is not directly translated into machine code; the compiler interprets your code, rewrites it with it's own optimization algorithms before translating it to machine code. Of course you can make minor changes to ...


2

if (mouseButton == LEFT) { toggle = false; spheres.get(0).addSphereItem("SmallHexagrammicHexecontahedron"); spheres.get(1).addSphereItem("SmallHexagrammicHexecontahedron"); spheres.get(2).addSphereItem("SmallHexagrammicHexecontahedron"); spheres.get(3).addSphereItem("SmallHexagrammicHexecontahedron"); spheres.get(4).addSphereItem("...


2

In general, I think the program is well readable, and demonstrates the idea correctly. I have some suggestions for further improving it. Constants Consider the following statement: drawDigit(hour/10, 20, 100); drawDigit(hour%10, 110, 100); Since the values are reused more than once, I would suggest introducing constants for them: final int ...


2

Great accomplishment. I have made some improvements, without doing a complete redesign. I assume that you will learn most out of it, if the program gets reshaped step by step. As said in the comments, it would be preferable to write the program in an object oriented style, which I will do in the next days and then update my answer. So here are the the ...


2

Break out of loops sooner This applies specifically to your spaceship and to a lesser extent to asteroids and torpedoes. Once the spaceship is destroyed, return. Any other collision checks are wasted processing time. For torpedoes and asteroids, once a torpedo has destroyed an asteroid, break out and move on to the next torpedo. This leaves a small edge ...


2

That looks really good! I just have a few improvements, nothing big. Wind.interplorateWindSpeed() A math function called signum could be used instead of if statements. float speedDiff = targetSpeed - speed; float speedChange = (float) (sqrt(abs(speedDiff))/15); speed += speedChange * signum(speedDiff); Wind You might consider moving all the private ...


2

You might be able to improve performance by removing particles once they have left the boundaries of the screen. This should reduce your particle count substantially. Another option to pursue would be to use getFrameRate to check your current frame rate against a target value and reduce the number of particles you generate based on that.


1

//Allows use of math functions on doubles import java.lang.*; I know nothing about Processing, but this looked suspicious to me, so I went looking for the maths functions in question. I presume it's e.g. double logZN = java.lang.Math.log(zReal * zReal + zImag * zImag) / 2; In Java the point of import java.lang.* (if it were necessary, which it isn't, ...


1

Nice code. Some points to consider: If I understand the code correctly, the void draw() function will be looped and redraw the image, if the update boolean evaluates to true. In order to check for this effortlessly, you have declared update a global variable. You should only declare as many global variables as needed to avoid name cluttering (especially ...


1

If the range of the visible image is always centered around zero (as indicated by your minX, minY etc. values), you might benefit from representing the coordinate axes as a rational number type instead of double. This gives you a greater range of non rounded numbers in that intervall which might lead to less round off errors when zooming, see https://...


1

Looks good to me. There's a little bit of copy-n-paste but nothing serious. Good commenting. Thanks for sharing!


1

First of all, something regarding usability: The player has to press space to start, space to play, but click to restart or continue. If you were using space for all of these actions the player wouldn't have to move the hand between mouse and keyboard. Also, you are telling the player to press space, but actually any key will work. Variables static boolean ...


1

Well, fine for good signals. Good signals means low noise level, absense of features like very slow volume change rates, etc. Otherwise, you need things like FIR filter(s) to average and diffifentiate signal and use an interpolation to increase precision of the detection.


1

Some small observations: //maybe it works here, but generally you should use Math.abs(a-b) < epsilon //with a very small epsilon instead a == b for double comparision if(maxAlph == .05) maxAlph = 1; else maxAlph = .05; --> maxAlph = (maxAlph == .05) ? 1 : 0.05; if(alphX > width) alphAccel *= -1; else if(alphX < 0) alphAccel *= -1; --> if(...


Only top voted, non community-wiki answers of a minimum length are eligible