1 | |
---|
2 | |
---|
3 | /* |
---|
4 | orxonox - the future of 3D-vertical-scrollers |
---|
5 | |
---|
6 | Copyright (C) 2004 orx |
---|
7 | |
---|
8 | This program is free software; you can redistribute it and/or modify |
---|
9 | it under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 2, or (at your option) |
---|
11 | any later version. |
---|
12 | |
---|
13 | ### File Specific: |
---|
14 | main-programmer: Patrick Boenzli |
---|
15 | co-programmer: |
---|
16 | */ |
---|
17 | |
---|
18 | |
---|
19 | #include "player.h" |
---|
20 | #include <iostream> |
---|
21 | #include <stdlib.h> |
---|
22 | |
---|
23 | |
---|
24 | using namespace std; |
---|
25 | |
---|
26 | |
---|
27 | Player::Player () { |
---|
28 | // cout << "Player::Player" << endl; |
---|
29 | xCor = yCor = zCor = 0; |
---|
30 | shootLaser = new ShootLaser; |
---|
31 | shootRocket = new ShootRocket; |
---|
32 | } |
---|
33 | |
---|
34 | Player::~Player () |
---|
35 | { |
---|
36 | //delete shootLaser; |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | void Player::setPosition( float x, float y, float z) |
---|
41 | { |
---|
42 | xCor = x; yCor = y; zCor = z; |
---|
43 | } |
---|
44 | |
---|
45 | |
---|
46 | void Player::getPosition(float* x, float* y, float* z) |
---|
47 | { |
---|
48 | *x = xCor; *y = yCor; *z = zCor; |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | void Player::setCollisionRadius(float radius) |
---|
53 | { |
---|
54 | collisionRadius = radius; |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | void Player::goX(float x) |
---|
59 | { |
---|
60 | //cout << "Player::goX" << endl; |
---|
61 | xCor += x; |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | void Player::goY(float y) |
---|
66 | { |
---|
67 | yCor += y; |
---|
68 | } |
---|
69 | |
---|
70 | void Player::goZ(float z) |
---|
71 | { |
---|
72 | zCor += z; |
---|
73 | } |
---|
74 | |
---|
75 | void Player::shoot(int n) |
---|
76 | { |
---|
77 | shootLaser->addShoot(xCor,yCor+1.0,5); |
---|
78 | shootLaser->addShootExt(xCor,yCor,zCor,.1,.4,.0); |
---|
79 | shootLaser->addShootExt(xCor,yCor,zCor,-.1,.4,.0); |
---|
80 | //shootLaser->addShootdExt(xCor,yCor,zCor,-.1,.4,.0); |
---|
81 | //shootRocket->addBackParable(xCor,yCor,zCor); |
---|
82 | |
---|
83 | |
---|
84 | |
---|
85 | } |
---|
86 | |
---|
87 | //void Player::addIO(InputOutput *io) {} |
---|
88 | |
---|
89 | |
---|
90 | void Player::drawPlayer(float a, float b) |
---|
91 | { |
---|
92 | |
---|
93 | /*glPushMatrix(); |
---|
94 | glTranslatef(xCor, yCor, 3.0); |
---|
95 | glScalef(1.0, 3.0, 1.0); |
---|
96 | glutWireCube(1.0); |
---|
97 | glPopMatrix();*/ |
---|
98 | glPushMatrix(); |
---|
99 | glEnable(GL_NORMALIZE); |
---|
100 | glEnable(GL_COLOR_MATERIAL); |
---|
101 | glEnable(GL_LIGHTING); |
---|
102 | glEnable(GL_LIGHT0); |
---|
103 | GLfloat LPosition[4]={0,20,30,1}; |
---|
104 | glLightfv(GL_LIGHT0,GL_POSITION,&LPosition[0]); |
---|
105 | glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); |
---|
106 | |
---|
107 | glTranslatef(xCor,yCor,5.0); |
---|
108 | glRotatef(3*a,1.0,0.0,0.0); |
---|
109 | glRotatef(3*b,0.0,1.0,0.0); |
---|
110 | //glTranslatef(xCor,yCor,3.0); |
---|
111 | glBegin(GL_QUADS); |
---|
112 | glColor3f(.2,0.5,0.5); |
---|
113 | glNormal3f(-1.0,0.0,0.0); |
---|
114 | glVertex3f(-1.0,-1.0,-1.0); |
---|
115 | glVertex3f(-1.0,-1.0,1.0); |
---|
116 | glVertex3f(-1,1.0,0.4); |
---|
117 | glVertex3f(-1,1.0,-0.4); |
---|
118 | |
---|
119 | glNormal3f(1,0,0); |
---|
120 | glVertex3f(-.99,-1,-1); |
---|
121 | glVertex3f(-.99,-1,1); |
---|
122 | glVertex3f(-.99,1,.4); |
---|
123 | glVertex3f(-.99,1,-.4); |
---|
124 | |
---|
125 | glNormal3f(0.0,1.0,0.0); |
---|
126 | glVertex3f(-1,1.0,.4); |
---|
127 | glVertex3f(-1,1.0,-.4); |
---|
128 | glVertex3f(1,1.0,-.4); |
---|
129 | glVertex3f(1,1.0,.4); |
---|
130 | |
---|
131 | glNormal3f(0,-1,0); |
---|
132 | glVertex3f(-1,.99,.4); |
---|
133 | glVertex3f(-1,.99,-.4); |
---|
134 | glVertex3f(1,.99,-.4); |
---|
135 | glVertex3f(1,.99,.4); |
---|
136 | |
---|
137 | glNormal3f(1.0,0.0,0.0); |
---|
138 | glVertex3f(1,1,.4); |
---|
139 | glVertex3f(1,1,-.4); |
---|
140 | glVertex3f(1.0,-1.0,-1.0); |
---|
141 | glVertex3f(1.0,-1.0,1.0); |
---|
142 | |
---|
143 | glNormal3f(-1,0,0); |
---|
144 | glVertex3f(.99,1,.4); |
---|
145 | glVertex3f(.99,1,-.4); |
---|
146 | glVertex3f(.99,-1,-1); |
---|
147 | glVertex3f(.99,-1,1); |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | glEnd(); |
---|
152 | glPopMatrix(); |
---|
153 | |
---|
154 | |
---|
155 | |
---|
156 | |
---|
157 | |
---|
158 | /* draw all the shoots additionaly */ |
---|
159 | glColor3f(0,0,1); |
---|
160 | shootLaser->drawShoot(); |
---|
161 | shootRocket->drawShoot(); |
---|
162 | //cout << "Player::drawPlayer" << endl; |
---|
163 | } |
---|
164 | |
---|
165 | |
---|
166 | |
---|
167 | |
---|
168 | |
---|
169 | |
---|
170 | |
---|
171 | |
---|
172 | |
---|
173 | |
---|
174 | |
---|
175 | |
---|
176 | |
---|
177 | |
---|
178 | |
---|
179 | |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | |
---|
184 | |
---|
185 | |
---|
186 | |
---|
187 | |
---|
188 | |
---|
189 | |
---|