Esempio n. 1
0
void ofxPolygonMask::checkWinding() {
	if(points.size()<3) return;
	ofVec2f a = points[1] - points[0];
	ofVec2f b = points[2] - points[0];
	float z = (a.x*b.y) - (a.y*b.x);
	
	// if the z of the cross product is negative, we need to reverse the winding
	if(z<0) {
		flipDirection();
	}
	
}
Esempio n. 2
0
void Enemy::patrol(float dt) {
	float delta_x = speed_x * dt;
	float delta_y = speed_y * dt;

	int check_pos = 12;
	if(facing_direction == Facing::Left) check_pos = -check_pos;
	if(move(delta_x, delta_y)) {
		// Turn around if you run into something.
		//cout << "obstructed\n";
		flipDirection();
	} /*else if(!game_map->isSolid(int(pos_x + check_pos), int(pos_y + yOrigin + 1))) {
		// Turn around if there's a pit up ahead.
		//cout << "pit\n";
		//debugPixel.SetPosition(
		//	0.5f + (int)(pos_x - game_map->cam_x),
		//											 0.5f + (int)(pos_y - game_map->cam_y));
		//checkGround = true;
		flipDirection();
	}*/
}