1 #ifndef __SPACEDOTS_H__
2 #define __SPACEDOTS_H__
3 #include <SDL/SDL.h>
4 #include "config.h"
5 #include "globals.h"
6 #include "u-iff.h"
7 
8 /*! \brief Star background
9  *
10  * Space dots are harmless background items All are active. When one
11  * falls off the edge, another is created at the start.
12  */
13 struct spacedot {
14   float x, dx;
15   int y;
16   RD_VIDEO_TYPE color;
17 };
18 
19 /*! \brief cicade spacedots data structure
20  *
21  * Contains all the information needed for displaying a nice star
22  * background.
23  */
24 struct cicada_spacedots_playfield {
25   SDL_Surface *playfield;
26   float speed;
27   float pos;
28 };
29 
30 typedef struct {
31   short type;
32   union {
33     struct {
34       struct spacedot *spacedots;
35       unsigned int num_spacedots;
36     };
37     struct {
38       struct cicada_spacedots_playfield *cicadadots;
39       unsigned short num_cicada_playfields;
40     };
41   };
42 } spacedots_t;
43 
44 
45 /*! \brief Initialise space dots.
46  *
47  * The space dots engine is initialised and the information is written
48  * into the spacedots_t union.
49  *
50  * \param surf_screen The surface which is displayed.
51  * \param type 0 = normal spacedots, 1 = cicada spacedots
52  * \param iff iff context for rockdodger data-file
53  * \return 0 = failure, 1 = OK
54  */
55 spacedots_t *init_space_dots_engine(SDL_Surface *surf_screen, short type, uiff_ctx_t iff);
56 
57 
58 /*! \brief Draw the background
59  *
60  * This draws the background space dots and updates the coordinates at
61  * the same time. It will chose the right function automatically.
62  *
63  * \param spacedots Spacedots engine
64  * \param surf_screen The surface to draw on
65  * \param s Surface to draw on.
66  */
67 void draw_space_dots(spacedots_t *spacedots, SDL_Surface *surf_screen);
68 
69 
70 /*! \brief Cicada star background
71  *
72  * This function takes its parameters from the global variables xsize
73  * and ysize. The returned function is actually
74  * draw_cicada_spacedots().
75  *
76  * \param surf_screen The surface which is displayed.
77  * \param spacedots Structure to be initialised.
78  * \return 0 = failure, 1 = OK
79  */
80 int init_cicada_spacedots(spacedots_t *spacedots, SDL_Surface *surf_screen);
81 
82 
83 /*! \brief Draw cicada spacedots.
84  *
85  * Draw different layers of spacedots into the surface.
86  *
87  * \param spacedots Spacedots engine
88  * \param surf_screen surface to draw on
89  */
90 void draw_cicada_dots(spacedots_t *spacedots, SDL_Surface *surf_screen);
91 
92 
93 /*! \brief Destroy cicada spacedots engine.
94  *
95  * Destroy the spacedots engine and free the memory. It will also set
96  * the type field to -1. A NULL pointer is just ignored.
97  *
98  * \param spacedots Spacedots engine
99  */
100 void destroy_space_dots(spacedots_t *spacedots);
101 
102 #endif
103