We are about to switch to a new forum software. Until then we have removed the registration on this forum.
//Thermal Diffusion between fire particles.
class BThermalDiffusion implements BehaviorInterface {
float effD; //effective distance of diffusion
float b; //coeffient
float squaredEffD; // square of effD
float squaredHalfEffD; // square of half effD
BThermalDiffusion() {
this(25.0, 0.2);
}
BThermalDiffusion(float x, float y) {
effD = x;
b = y;
squaredEffD = effD*effD;
squaredHalfEffD = squaredEffD/4;
}
void apply(VParticle p) {
float temp=0.0;
for(VParticle neighbor : p.neighbors) {
if(neighbor == p)
continue;
float squaredDis = p.distSq(neighbor);
if(squaredDis <= squaredEffD)
temp += neighbor.getTemperature()*b*(1.0-squaredDis/squaredEffD)*exp(-1.0*squaredDis/squaredHalfEffD);
}
p.addHeat(temp);
}
}
Unexpect token : ;. Highlighted the last line. The sketch includes 5 files written by me. Error reported in this file.
Answers
but that's no real guarantee that it's in this file, especially if it's something like a missing {} or ()
i can't see anything in there myself
Above should be the whole picture. 3 files(unfinished) to simulate fire effect by particle systems. I made some tiny changes, so some code in BThermalDiffusion are a little different from previous edition. And, I still get "Unexpected token" error. Have been checking this the hole night. Plz help!
nope, i pasted it into a decent java editor and reformatted it and still can't see anything wrong with it.
are any of the files java files rather than processing files? if so you might need to follow proper java conventions like not using the color type or defining floats with a trailing f, ie 0.0f
also, it's good practice to put {}s around even single line blocks, makes it more readable. the seconds you save with the typing aren't worth the extra debugging time in my experience...
fwiw, i get a different error:
unexpected token: (
on line 100
but i don't have those libraries
I got error on line 120;--super(f);
and call for ps.run() ? why? ps [object of firesystem class]
The super() syntax is usable only in constructors.
Otherwise, you have to use the syntax:
No idea for ps.run(), because you don't tell us what error you have, and we don't know what the ParticleSystem class looks like.
or he might be not writing super(param) method in the super class. or forget written that. he had the method, super(param1,param2); in the ps object, there is no run(). may be he wish to run a thread?
Thx all! guys! problem solved aly. It turns out some of my other files containing logic error.