summaryrefslogtreecommitdiff
path: root/gaunt01/src/bird.h
blob: 967e7bd12e8ecac408d0b2a12f3de118c8fc826d (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef BIRD_H
#define BIRD_H

/*
    Hostile bird character for 'Run the gauntlet' game

    Tim Redfern April 2012

    ??how to manage visibility
    Bird should automatically stay within viewing volume of camera

    from the birds POV, The visible area is a frustrum extending down from the camera

    1) like opensteer, extend the birds heading and decide whether this will hit the edge
    2) have an actual model of the volume and work within it

    3) how do we make the bird aware of players in front of it

    --> this all implies being able to take a sightline from the bird and determine
        -visibility of objects
        -distance to obstructions

    -build basic of time/speed/heading update/draw
    -basic anim cycle



    MAKING THE BIRD CHASE THE PLAYERS

    find distance to edge of play - alter turn behaviour depending on how bird needs to head
    detect player in FOV
    turn & swoop
    pick player and remove

    planes frustrum belongs to camera
    bird checks ray dist to planes
    avoids nearest +ve

*/

#define sign(x) ((x > 0) - (x < 0))

#include "ofMain.h"
#include "morphmesh.h"
#include "normBindTexture.h"
#include "player.h"
#include "outsidePolygon.h"

#include "ofxRay.h"

#define DEBUG 1

#define SCANNING 1
#define SWOOPING 2
#define ATTACKING 3

class bird
{
    public:
        bird();
        virtual ~bird();
        void update(map<int,player>& players,float angle);
        void draw();
        void drawShadow();
	void drawDebug();

	void	setBounds(ofPlane* _bounds);
	void	setCentre(ofVec2f _centre);

        int state;
        morphmesh model;

	ofRay pointer;
	ofVec3f position;
	ofVec2f centrePoint; //2d coords of centre of screen

	ofVec3f edgepoint; //point where the bird will hit the edge of the screen
	float edgelength,edgeangle;

    	vector<float> playang;
	vector<float> playhead;
	vector<float> playdip;
	vector<float> playdist;
	vector<ofVec3f> playpos;

	ofPlane* bounds;
	ofVec2f centre;

	bool leaving;
	float centrehead;
	
	//animation speed
	void setSpeed(float speed);
	float getSpeed();

    float heading;

    protected:
    private:

	float fieldofview;

        ofVec3f direction;

        float velocity; //per second relative to ofGetHeight()
        float turnRate; //per second
        float diveRate; //per second relative to ofGetHeight()

        float lastTime;

	ofSoundPlayer*  sounds;
        ofImage texture;



};

#endif // BIRD_H