-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLIYBoid.h
70 lines (62 loc) · 2.7 KB
/
LIYBoid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// LIYBoid.h
// Boids
//
// Created by Jason Cheladyn on 9/18/13.
// Copyright (c) 2013 Jason Cheladyn. All rights reserved.
//
#import <SpriteKit/SpriteKit.h>
#import "CGPointExtension.h"
#import "ccMacros.h"
#define EDGE_NONE -1
#define EDGE_WRAP 0
#define EDGE_BOUNCE 1
@interface LIYBoid : SKSpriteNode
{
@protected
float _maxForce;
float _maxSpeed;
int _edgeBehavior;
@public
float _maxForceSQ;
float _maxSpeedSQ;
bool _doRotation;
CGPoint _internalPosition;
CGPoint _oldInternalPosition;
CGPoint _velocity;
CGPoint _acceleration;
CGPoint _steeringForce;
float _radius;
float _wanderTheta;
float _wanderMaxTurnCircleRadius;
float _wanderTurningRadius;
float _wanderLookAheadDistance;
LIYBoid *_next;
}
@property (assign, nonatomic) float maxForce;
@property (assign, nonatomic) float maxSpeed;
@property (assign, nonatomic) bool doRotation;
@property (assign, nonatomic) int edgeBehavior;
- (void)setSpeedMax:(float)speed andSteeringForceMax:(float)force;
- (void)setSpeedMax:(float)speed withRandomRangeOf:(float)speedRange andSteeringForceMax:(float)force withRandomRangeOf:(float)forceRange;
- (void)setWanderingRadius:(float)radius lookAheadDistance:(float)distance andMaxTurningAngle:(float)turningAngle;
- (void)resetVectorsToZero;
- (void)setPos:(CGPoint)value;
- (void)update;
- (void)handleBorder;
- (void)brake:(float)breakingForce;
- (void)seek:(CGPoint)target usingMultiplier:(float)multiplier;
- (void)seek:(CGPoint)target withinRange:(float)range usingMultiplier:(float)multiplier;
- (void)arrive:(CGPoint)target withEaseDistance:(float)easeDistance usingMultiplier:(float)multiplier;
- (void)flee:(CGPoint)target panicAtDistance:(float)panicDistance usingMultiplier:(float)multiplier;
- (void)wander:(float)multiplier;
- (CGPoint)steer:(CGPoint)target easeAsApproaching:(BOOL)ease withEaseDistance:(float)easeDistance;
- (void)flock:(LIYBoid *)head withSeparationWeight:(float)separationWeight andAlignmentWight:(float)alignmentWeight andCohesionWeight:(float)coheasionWeight andSeparationDistance:(float)separationDistance andAlignmentDistance:(float)alignmentDistance andCoheasionDistance:(float)coheasionDistance;
- (void)separate:(LIYBoid *)head withSeparationDistance:(float)separationDistance usingMultiplier:(float)multiplier;
- (void)align:(LIYBoid *)head withAlignmentDistance:(float)neighborDistance usingMultiplier:(float)multiplier;
- (void)cohesion:(LIYBoid *)head withNeighborDistance:(float)neighborDistance uisingMultiplier:(float)multiplier;
float randRange(float min, float max);
CGPoint normalize(CGPoint point);
float getDistance(CGPoint pointA, CGPoint pointB);
float getDistanceSquared(CGPoint pointA, CGPoint pointB);
@end