I have 30 ellipses that are moving in Z direction (think the rings in the film, Metropolis). They are intended to be looking like they are travelling towards the ground and just before they hit the ground they spread out (grow in size) and scale out along the ground, as if a shockwave that had been hurtling towards the ground then sends shockwaves out across the ground as it hits it. Though, in this case, it's not a right angle change in direction, it's a soft one just before it hits the ground.
At the moment I've been telling the ellipses that if they're at a certain Z distance, to start scaling in size. This gives the effect of them anticipating hitting the ground but doesn't allow them to then spread out along the ground. Any ideas?
(by the way, the ground is imaginary for now - just imagine it as the furthest Z distance the ellipses currently travel. Just before they reach the limit of Z they'll start to scale their X and Y size and once they reach Z, they'll stay at it but keep scaling X and Y up. Also, this code uses the peasycam library for testing but it can be commented out of needed).
I've an array of n coordinates that are drawn out and a path running through them. I need one of the coordinates to highlight when a mouse is within a given number of pixels to it. Using this formula:
It works close to perfect but not quite perfect. There's strange quirks like being able to select a point using MouseX alone (e.g. if I line up the mouse under a point, it'll select fine if mouseX is within the distance I specified as if ignoring the clause that mouseY also needs to be within a set distance).
I'm going to guess I'm misunderstanding how && works.
Interestingly, I tried adding a
} else {
selectedPoint = 0;
}
after it just to try. This had strange results also and seemed to only let one point out of 10 or so be highlighted and flick back to point 0 if I tried anything else.
The code for this is fairly lengthy and it's hard to isolate just the bit that's relevant here, so I'll hopefully be able to explain it clear enough without needing to post a page of code to wade through:
Basically, I'm drawing a train in 2d with several carriages. The train follows a path and this all works fine and the carriages do everything they're meant to. The only problem I'm having (and I've spent most of today getting a headache over trying variations to make it work) is that when the carriages are drawn one by one from a loop, they overlap the correct way in some directions but overlap wrong in other directions.
Each carriage has an integer ( 0 - 4) associated and each line on the path has a slope calculated at one of 8 angles.
My first way of tackling this problem was making a condition that if the carriages reached a line that I'd named as one where the carriages needed to be drawn in reverse order, I would draw them in reverse order. The simple formula for this was along the lines of:
for (int z=0; z< 5; z++) {
if (currentPathSlope == "reverse") {
i = abs(z-4);
} else {
i = z;
}
}
Which meant that instead of drawing the carriages in the order of 0, 1, 2.... , when it reached a flagged path it would draw them in the order of 4, 3, 2 .... etc.
This works perfect....
Except....
Imagine a carriage moving along a line flagged as reverse. Say it's the first carriage and so it's numbered 4 and it gets to the end of the line before moving onto the next that isn't flagged. It then gets numbered as carriage 0 so that it's drawn in the opposite order. It works fine except the last carriage in the train - still on the line flagged as reverse - has been numbered as 0 and so it disappears the moment carriage 5 moves onto the next line and becomes 0.
So I'm stuck!
My first line of thought was to keep each carriage numbered consistently throughout the whole path. I can't figure out how to get the loop to draw them in reverse order on command by doing this.