1 /***************************************************************************
4 begin : Thu Sep 13 2001
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 "lbreakout.h"
21 extern SDL_Surface
*stk_display
;
23 extern SDL_Surface
*offscreen
;
24 extern SDL_Surface
*shine_pic
;
26 float shine_change
= 0.020; /* per ms */
27 int shine_frame
= 6; /* maximum frame */
28 float shine_cur
= 0; /* current frame */
29 int shine_x
, shine_y
; /* position where current shine is drawn */
30 int shine_recreate
= 1;
31 Delay shine_delay
; /* delay between shines */
34 ====================================================================
36 ====================================================================
40 delay_set( &shine_delay
, 200 );
46 ====================================================================
47 Recreate shine on a random but valid brick
48 ====================================================================
52 int x_add
, y_add
, x
, y
;
54 shine_x
= 0; shine_y
= 0;
56 if ( !config
.anim
) return;
58 x
= (rand() % (BRICK_WIDTH
- 2)) + 1;
59 y
= (rand() % (BRICK_HEIGHT
- 2)) + 1;
60 x_add
= rand() % 2 == 0 ? 1 : -1;
61 y_add
= rand() % 2 == 0 ? 1 : -1;
63 while (x
> 0 && x
< MAP_WIDTH
- 1 && y
> 0 && y
< MAP_HEIGHT
- 1) {
64 if (game
->bricks
[x
][y
].type
!= MAP_EMPTY
&& game
->bricks
[x
][y
].id
!= INVIS_BRICK_ID
) {
65 shine_x
= x
* BRICK_WIDTH
;
66 shine_y
= y
* BRICK_HEIGHT
;
69 x
+= x_add
; y
+= y_add
;
71 /* if creation succeeded don't create any more shines */
72 if ( shine_x
!= 0 && shine_y
!= 0 ) shine_recreate
= 0;
75 ====================================================================
77 ====================================================================
81 shine_x
= shine_y
= 0;
83 delay_reset( &shine_delay
);
86 ====================================================================
87 Show/hide current shine
88 ====================================================================
92 if (shine_x
== 0 && shine_y
== 0) return;
93 stk_surface_blit( offscreen
, shine_x
, shine_y
,
94 BRICK_WIDTH
, BRICK_HEIGHT
,
95 stk_display
, shine_x
, shine_y
);
96 stk_display_store_drect();
100 if (shine_x
== 0 && shine_y
== 0) return;
101 stk_surface_blit( shine_pic
, (int)shine_cur
* BRICK_WIDTH
, 0,
102 BRICK_WIDTH
, BRICK_HEIGHT
,
103 stk_display
, shine_x
, shine_y
);
106 ====================================================================
108 ====================================================================
110 void shine_update( int ms
)
112 /* recreate shine? */
113 if ( shine_recreate
) {
114 shine_x
= shine_y
= 0; /* if recreation is demanded delete old shine */
115 if ( delay_timed_out( &shine_delay
, ms
) ) shine_create();
118 shine_cur
+= shine_change
* ms
;
119 if (shine_cur
> shine_frame
) {
121 delay_reset( &shine_delay
);