1 /***************************************************************************
2 shots.c - description
3 -------------------
4 begin : Sat Sep 8 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 #include "lbreakout.h"
19 #include "../game/game.h"
20
21 extern SDL_Surface *shot_pic;
22 extern SDL_Surface *shot_shadow;
23 extern int shot_w, shot_h;
24 extern float shot_v_y;
25 float shot_cur_fr = 0.0;
26 int shot_fr_num = 4;
27 float shot_fpms = 0.01;
28 int shot_alpha = 128;
29 extern SDL_Surface *offscreen;
30 extern SDL_Surface *stk_display;
31 extern SDL_Rect stk_drect;
32 extern int shadow_size;
33 extern Game *game;
34
35 /*
36 ====================================================================
37 Locals
38 ====================================================================
39 */
40
41 /*
42 ====================================================================
43 Publics
44 ====================================================================
45 */
46
47 /*
48 ====================================================================
49 Hide and show shots
50 ====================================================================
51 */
shots_hide()52 void shots_hide()
53 {
54 ListEntry *entry = game->shots->head->next;
55 Shot *shot;
56 while ( entry != game->shots->tail ) {
57 shot = entry->item;
58 entry = entry->next;
59 stk_surface_blit( offscreen,
60 (int)shot->x,(int)shot->y,
61 shot_w + shadow_size,shot_h + shadow_size,
62 stk_display, (int)shot->x,(int)shot->y );
63 stk_display_store_rect( &shot->update_rect );
64 }
65 }
shots_show()66 void shots_show()
67 {
68 ListEntry *entry = game->shots->head->next;
69 Shot *shot;
70 int x, y;
71 stk_surface_clip( stk_display, 0, 0,
72 stk_display->w - BRICK_WIDTH, stk_display->h );
73 while ( entry != game->shots->tail ) {
74 shot = entry->item;
75 entry = entry->next;
76 x = (int)shot->x; y = (int)shot->y;
77 stk_surface_alpha_blit( shot_shadow,
78 0, 0, shot_w, shot_h,
79 stk_display, x + shadow_size, y + shadow_size,
80 SHADOW_ALPHA );
81 stk_surface_alpha_blit( shot_pic, (int)shot->cur_fr * shot_w, 0,
82 shot_w, shot_h, stk_display, x, y, shot_alpha );
83
84 shot->update_rect.x = x;
85 shot->update_rect.y = y;
86 shot->update_rect.w = shot_w + shadow_size;
87 shot->update_rect.h = shot_h + shadow_size;
88 stk_display_store_rect( &shot->update_rect );
89 }
90 stk_surface_clip( stk_display, 0, 0, 0, 0 );
91 }
shots_alphashow(int alpha)92 void shots_alphashow( int alpha )
93 {
94 ListEntry *entry = game->shots->head->next;
95 Shot *shot;
96 while ( entry != game->shots->tail ) {
97 shot = entry->item;
98 stk_surface_alpha_blit( shot_pic, (int)shot->cur_fr * shot_w, 0,
99 shot_w, shot_h, stk_display, (int)shot->x, (int)shot->y,
100 alpha );
101 stk_display_store_rect( &shot->update_rect );
102 entry = entry->next;
103 }
104 }
105
106 /* update animation of shots */
client_shots_update(int ms)107 void client_shots_update( int ms )
108 {
109 Shot *shot;
110
111 shot_cur_fr += ms * shot_fpms;
112 if (shot_cur_fr >= shot_fr_num)
113 shot_cur_fr -= shot_fr_num;
114
115 list_reset( game->shots );
116 while ( (shot = list_next(game->shots)) )
117 shot->cur_fr = shot_cur_fr; /* else there would be no animation
118 as reset the list with each communicator
119 call */
120 }
121
122
123