creature interface and super classe
This commit is contained in:
parent
ac498092a9
commit
f389f9473c
36
micro/creature_creature_behavior/Creature.pde
Normal file
36
micro/creature_creature_behavior/Creature.pde
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import teilchen.BehaviorParticle;
|
||||||
|
import mathematik.Vector3f;
|
||||||
|
|
||||||
|
class Creature extends BehaviorParticle {
|
||||||
|
|
||||||
|
float _scale;
|
||||||
|
|
||||||
|
public Creature(int x, int y, int r) {
|
||||||
|
super();
|
||||||
|
position().set(x, y);
|
||||||
|
maximumInnerForce(100);
|
||||||
|
radius(r);
|
||||||
|
_scale = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display() {
|
||||||
|
pushMatrix();
|
||||||
|
translate(position().x, position().y);
|
||||||
|
rotate(getRotation());
|
||||||
|
scale(_scale);
|
||||||
|
draw_shape();
|
||||||
|
popMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getRotation() {
|
||||||
|
if(velocity().isNaN() || velocity().magnitude() == 0) return 0;
|
||||||
|
Vector3f v = new Vector3f(-1, 0, 0);
|
||||||
|
return velocity().angle(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw_shape() {}
|
||||||
|
|
||||||
|
public boolean inside(int mx, int my){return false;}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
11
micro/creature_creature_behavior/CreatureBehavior.pde
Normal file
11
micro/creature_creature_behavior/CreatureBehavior.pde
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
interface CreatureBehavior {
|
||||||
|
|
||||||
|
public void event(int x, int y);
|
||||||
|
|
||||||
|
public void event(int c);
|
||||||
|
|
||||||
|
public void update(float dt);
|
||||||
|
|
||||||
|
public void add(Creature c);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
|
||||||
2
micro/creature_creature_behavior/sketch.properties
Normal file
2
micro/creature_creature_behavior/sketch.properties
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
mode.id=processing.mode.java.JavaMode
|
||||||
|
mode=Java
|
||||||
Loading…
x
Reference in New Issue
Block a user