1 /***************************************************************************
2                           balls.h  -  description
3                              -------------------
4     begin                : Sun Sep 9 2001
5     copyright            : (C) 2001 by Michael Speck
6     email                : kulkanie@gmx.net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
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.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef __BALLS_H
19 #define __BALLS_H
20 
21 /*
22 ====================================================================
23 Load/delete ball graphics
24 ====================================================================
25 */
26 void ball_load();
27 void ball_delete();
28 /*
29 ====================================================================
30 Create ball at position
31 ====================================================================
32 */
33 Ball* ball_create( int x, int y );
34 /*
35 ====================================================================
36 Set a special ball property like metal ball.
37 ====================================================================
38 */
39 void balls_set_type( int type );
40 /*
41 ====================================================================
42 Set chaotic behaviour (random relfection)
43 ====================================================================
44 */
45 void balls_set_chaos( int chaos );
46 /*
47 ====================================================================
48 Clear ball list and attach one ball to paddle
49 ====================================================================
50 */
51 void balls_reset();
52 /*
53 ====================================================================
54 Show/hide all balls
55 ====================================================================
56 */
57 void balls_hide();
58 void balls_show_shadow();
59 void balls_show();
60 void balls_alphashow( int alpha );
61 /*
62 ====================================================================
63 Update balls and detach attached balls if fire was pressed.
64 ====================================================================
65 */
66 void balls_update( int ms );
67 /*
68 ====================================================================
69 All balls with target mx,my will have there 'get_target' flag
70 set True so they compute a new target next time balls_update()
71 is called. If 'mx' is -1 all balls will set their flag.
72 ====================================================================
73 */
74 void balls_check_targets(int mx, int my);
75 /*
76 ====================================================================
77 Adjust velocity of ball to spare out any illegal values.
78 Add a little entropy to the vector if 'entropy' is True.
79 ====================================================================
80 */
81 void ball_mask_vel(Ball *b, float old_vx, int entropy );
82 /*
83 ====================================================================
84 Get target for a ball.
85 input :
86     Ball* b
87 function :
88     -check if ball b hits a brick and if so:
89     -compute the hitten brick in lev_map (int mx, my)
90     -the reset position of the ball after destroying the brick (float x, y)
91     -the time in milliseconds it takes the ball to hit the brick from its current position
92     by using ball_v as velocity (int time)
93     -the side at which the ball hits; might be LEFT, RIGHT, TOP, BOTTOM (int side)
94     -the reflection vector (float a); if reflecting at an horizontal wall it's a = {0, 1} else a = {1, 0}
95 ====================================================================
96 */
97 void ball_get_target( Ball *b );
98 /*
99 ====================================================================
100 Increase velocity acording to vel_change
101 ====================================================================
102 */
103 void balls_inc_vel( int ms );
104 /*
105 ====================================================================
106 Return all balls that have ball->return_allowed True to the paddle
107 (if they touched this one as last).
108 ====================================================================
109 */
110 void balls_return( Paddle *paddle );
111 
112 /* set random starting angle for ball according to its paddle */
113 void ball_set_random_angle( Ball *ball, double ball_v );
114 
115 /*
116 ====================================================================
117 Check if the ball is on paddle's level and an reflect is
118 possible.
119 ====================================================================
120 */
121 int ball_paddle_contact_possible( Ball *ball, Paddle *paddle, Vector old );
122 
123 /*
124 ====================================================================
125 Check reflection of ball at paddle. 'old' is the position of
126 the ball before update. Used to compute direction.
127 ====================================================================
128 */
129 void ball_check_paddle_reflection( Ball *ball, Paddle *paddle );
130 
131 /*
132 ====================================================================
133 Set velocity of all balls and get new targets if any.
134 ====================================================================
135 */
136 void balls_set_velocity( List *balls, double vel );
137 
138 /*
139 ====================================================================
140 Detach all balls to the passed direction (-1 or 1) and return True
141 if there were any balls detached. As balls within walls are not
142 fired the result may differ from paddle::attached_ball_count!
143 ====================================================================
144 */
145 int balls_detach_from_paddle( Paddle *paddle, int dir );
146 
147 /*
148 ====================================================================
149 Clear contents of target.
150 ====================================================================
151 */
152 void ball_clear_target( Target *t );
153 
154 #endif
155 
156