예제 #1
0
//--------------------------------------------------------------
void ofApp::update(){
    
    //target.set(ofGetMouseX(),ofGetMouseY());
    point.set(0,0);
    
    for(int i = 0; i < flock.size(); i++){
        flock[i].update();
        flock[i].applyForce(force);
        flock[i].seek(target);
        flock[i].arrive(target);
        flock[i].avoid(point);
        
    }
    
    lookForFood();
    
    predatorBirth();
        
    checkForDeath();
    

    
    
}
예제 #2
0
파일: chicken.c 프로젝트: polluks/edgar
static void wander()
{
	float dirX;

	self->thinkTime--;

	if (self->thinkTime <= 0)
	{
		if (self->dirX == 0)
		{
			self->dirX = self->speed * (prand() % 2 == 0 ? -1 : 1);

			setEntityAnimation(self, "WALK");
		}

		else
		{
			self->dirX = 0;

			setEntityAnimation(self, "STAND");
		}

		self->thinkTime = 180 + prand() % 120;
	}

	if (prand() % 2400 == 0)
	{
		playSoundToMap("sound/enemy/chicken/cluck", -1, self->x, self->y, 0);
	}

	if (prand() % 30 == 0)
	{
		lookForFood();
	}

	if (self->dirX < 0)
	{
		self->face = LEFT;
	}

	else if (self->dirX > 0)
	{
		self->face = RIGHT;
	}

	dirX = self->dirX;

	if (self->dirX != 0 && isAtEdge(self) == 1)
	{
		self->dirX = 0;
	}

	checkToMap(self);

	if (self->dirX == 0 && dirX != 0)
	{
		self->face = (self->face == RIGHT ? LEFT : RIGHT);

		self->dirX = -dirX;
	}
}