1 /*
2     C-Dogs SDL
3     A port of the legendary (and fun) action/arcade cdogs.
4     Copyright (c) 2015-2019 Cong Xu
5 
6     Redistribution and use in source and binary forms, with or without
7     modification, are permitted provided that the following conditions are met:
8 
9     Redistributions of source code must retain the above copyright notice, this
10     list of conditions and the following disclaimer.
11     Redistributions in binary form must reproduce the above copyright notice,
12     this list of conditions and the following disclaimer in the documentation
13     and/or other materials provided with the distribution.
14 
15     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18     ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25     POSSIBILITY OF SUCH DAMAGE.
26 */
27 #pragma once
28 
29 #include "draw/draw_buffer.h"
30 #include "hud/hud.h"
31 #include "screen_shake.h"
32 
33 #define CAMERA_SPLIT_PADDING 40
34 
35 typedef enum
36 {
37 	SPECTATE_NONE,
38 	SPECTATE_FOLLOW,
39 	SPECTATE_FREE
40 } SpectateMode;
41 
42 typedef struct
43 {
44 	DrawBuffer Buffer;
45 	struct vec2 lastPosition;
46 	HUD HUD;
47 	ScreenShake shake;
48 	SpectateMode spectateMode;
49 	// UID of actor to follow; only used if camera is in follow mode
50 	int FollowActorUID;
51 	// Immediately enter follow mode on the next player that joins the game
52 	// This is used for when the game has no players; all spectators should
53 	// immediately follow the next player to join
54 	bool FollowNextPlayer;
55 	int NumViews;
56 } Camera;
57 
58 void CameraInit(Camera *camera);
59 void CameraReset(Camera *camera);
60 void CameraTerminate(Camera *camera);
61 
62 void CameraInput(Camera *camera, const int cmd, const int lastCmd);
63 void CameraUpdate(Camera *camera, const int ticks, const int ms);
64 void CameraDraw(Camera *camera, const HUDDrawData drawData);
65 void CameraDrawMode(const Camera *camera);
66 
67 bool CameraIsSingleScreen(void);
68