-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.cpp
More file actions
88 lines (76 loc) · 2.5 KB
/
Copy pathPlayer.cpp
File metadata and controls
88 lines (76 loc) · 2.5 KB
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
/*
* Player.cpp
* Allenroids
*
* Created by Allen Smith on Mon Jun 21 2004.
* Copyright (c) 2004 __MyCompanyName__. All rights reserved.
*
*/
#include "Player.h"
/****************************************************
* default constructor
***************************************************/
Player::Player(){
}
/****************************************************
* constructor
***************************************************/
Player::Player(int numberArg, int numberOfPlayers, GLubyte *colorsArg, int livesArg, int maxStrength){
number = numberArg;
totalNumberOfPlayers = numberOfPlayers;
colors = colorsArg;
lives = livesArg;
defaultMaxStrength = maxStrength;
spawnSpaceship(); //ship must be generated after maxStrength is assigned
score = 0;
highestLevelAttained = 0;
enabled = true;
};
/****************************************************
* spawnSpaceship
* creates a spaceship for this player
***************************************************/
void Player::spawnSpaceship() {
Spaceship alevin; //"alevin" is the term for a newly-hatched salmon. Hey, "spawned," "salmon," "alevin"--yeah...
alevin.playerNumber = number;
alevin.radius = 20;
alevin.mass = 16;
alevin.color[0] = colors[0];
alevin.color[1] = colors[1];
alevin.color[2] = colors[2];
alevin.rotationAngle = 0;
alevin.position.x = FRAMEWIDTH * number/(totalNumberOfPlayers + 1);
alevin.position.y = FRAMEHEIGHT * number/(totalNumberOfPlayers + 1);
alevin.direction.x = 0;
alevin.direction.y = 0;
alevin.invinciblityTimeToLive = INVINCIBLE_LENGTH;
alevin.drawShieldsTimeToLive = alevin.invinciblityTimeToLive + FADEOUTS/2;
alevin.strength = defaultMaxStrength;
alevin.maxStrength = defaultMaxStrength;
alevin.thrusting = false;
alevin.decelerating = false;
alevin.drawThrustUntil = 0;
alevin.rotating = NOT_ROTATING;
spaceship = alevin;
}
/****************************************************
* isEnabled
* returns true if the player is currently able to play
***************************************************/
bool Player::isEnabled() const{
return enabled;
}
/****************************************************
* getColors
* returns the RGB triplet for this player
***************************************************/
GLubyte * Player::getColors() const{
return colors;
}
/****************************************************
* setEnabled
* sets the enabled flag to the specified value
***************************************************/
void Player::setEnabled(bool newSetting){
enabled = newSetting;
}