1 /***************************************************************************
5 copyright : (C) 2001 by Michael Speck
6 email : kulkanie@gmx.net
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #include "../client/lbreakout.h"
19 #include "../game/levels.h"
22 int current_player
= 0;
24 Player players
[MAX_PLAYERS
];
27 ====================================================================
28 Add this player to the list and increase the counter until
29 MAX_PLAYERS is reached.
30 Return Value: True if successful
31 ====================================================================
33 int player_add( char *name
, int lives
, Level
*level
)
35 if ( player_count
== MAX_PLAYERS
) return 0;
36 memset( &players
[player_count
], 0, sizeof( Player
) );
37 strcpy( players
[player_count
].name
, name
);
38 players
[player_count
].lives
= lives
;
39 player_init_level( &players
[player_count
], level
, 0 );
44 ====================================================================
46 Return Value: first player in list
47 ====================================================================
49 Player
* players_get_first()
52 return players_get_next();
55 ====================================================================
56 Get next player in list (cycle: return first player after
58 Return Value: current player
59 ====================================================================
61 Player
* players_get_next()
63 if ( players_count() == 0 ) return 0;
66 if ( current_player
== player_count
) current_player
= 0;
68 while ( players
[current_player
].lives
== 0 );
69 return &players
[current_player
];
72 ====================================================================
73 player_count players give id's 0,1,...,player_count-1. Select
74 the player with id 'current' as current player. The id used is
75 the absolute one, not the relative one resulting from dead players.
76 Return Value: current player
77 ====================================================================
79 Player
* players_set_current( int current
)
81 if ( current
< 0 || current
>= player_count
) return 0;
82 current_player
= current
;
83 return &players
[current_player
];
86 ====================================================================
88 ====================================================================
95 ====================================================================
96 Return number of players still in game (lives > 0)
97 ====================================================================
103 for ( i
= 0; i
< player_count
; i
++ )
104 if ( players
[i
].lives
> 0 )
109 /* set level_id and init snapshot with the new leveldata */
110 void player_init_level( Player
*player
, Level
*level
, int id
)
112 player
->level_id
= id
;
113 player
->snapshot
= *level
;