1 /***************************************************************************
4 begin : Sat Dec 15 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"
22 StkFont
*help_caption_font
= 0;
23 StkFont
*help_font
= 0;
24 SDL_Surface
*help_bkgnd
= 0;
27 extern SDL_Surface
*stk_display
;
28 extern SDL_Surface
*extra_pic
;
29 extern SDL_Surface
*brick_pic
;
30 extern int stk_quit_request
;
34 ====================================================================
36 ====================================================================
40 ====================================================================
42 ====================================================================
46 help_caption_font
->align
= STK_FONT_ALIGN_CENTER_X
| STK_FONT_ALIGN_TOP
;
47 stk_font_write( help_caption_font
,
48 stk_display
, stk_display
->w
/ 2, 20, STK_OPAQUE
, _("Quick Help") );
51 ====================================================================
53 ====================================================================
55 void draw_footnote( int side
)
58 help_font
->align
= STK_FONT_ALIGN_RIGHT
| STK_FONT_ALIGN_BOTTOM
;
59 sprintf( buf
, "%i / %i", side
, side_count
);
60 stk_font_write( help_font
, stk_display
,
61 stk_display
->w
- 2, stk_display
->h
- 2, STK_OPAQUE
, buf
);
62 help_font
->align
= STK_FONT_ALIGN_LEFT
| STK_FONT_ALIGN_BOTTOM
;
63 sprintf( buf
, _("<ESCAPE>: Quit <LEFT BUTTON>: Next Page <RIGHT BUTTON>: Previous Page") );
64 stk_font_write( help_font
,
65 stk_display
, 2, stk_display
->h
- 2, STK_OPAQUE
, buf
);
69 ====================================================================
71 ====================================================================
73 void draw_bonus_info( int x
, int y
, int id
, char *text
)
76 extra_pic
, id
* BRICK_WIDTH
, 0, BRICK_WIDTH
, BRICK_HEIGHT
,
78 help_font
->align
= STK_FONT_ALIGN_LEFT
| STK_FONT_ALIGN_CENTER_Y
;
79 stk_font_write( help_font
, stk_display
,
80 x
+ BRICK_WIDTH
+ 10, y
+ BRICK_HEIGHT
/ 2, STK_OPAQUE
, text
);
84 ====================================================================
86 ====================================================================
88 void draw_brick_info( int x
, int y
, int id
, char *text
)
91 brick_pic
, id
* BRICK_WIDTH
, 0, BRICK_WIDTH
, BRICK_HEIGHT
,
93 help_font
->align
= STK_FONT_ALIGN_LEFT
| STK_FONT_ALIGN_CENTER_Y
;
94 stk_font_write( help_font
, stk_display
,
95 x
+ BRICK_WIDTH
+ 10, y
+ BRICK_HEIGHT
/ 2, STK_OPAQUE
, text
);
99 ====================================================================
100 Draw bonus info screen.
101 ====================================================================
103 void draw_bonus_screen()
105 int bonus_x
= 20, bonus_y
= 80, bonus_w
= 200, bonus_h
= 30;
106 int malus_x
= 20, malus_y
= 330, malus_w
= 200, malus_h
= 30;
108 stk_surface_blit( help_bkgnd
, 0,0,-1,-1, stk_display
, 0,0 );
112 help_caption_font
->align
= STK_FONT_ALIGN_LEFT
| STK_FONT_ALIGN_TOP
;
113 stk_font_write( help_caption_font
,
114 stk_display
, bonus_x
, bonus_y
- 30, STK_OPAQUE
, _("Bonuses:") );
115 draw_bonus_info( bonus_x
+ bonus_w
* 0, bonus_y
+ bonus_h
* 0, 8, _("Expand paddle") );
116 draw_bonus_info( bonus_x
+ bonus_w
* 1, bonus_y
+ bonus_h
* 0, 9, _("Extra life") );
117 draw_bonus_info( bonus_x
+ bonus_w
* 2, bonus_y
+ bonus_h
* 0, 10, _("Sticky paddle") );
118 draw_bonus_info( bonus_x
+ bonus_w
* 0, bonus_y
+ bonus_h
* 1, 15, _("Plasma weapon") );
119 draw_bonus_info( bonus_x
+ bonus_w
* 1, bonus_y
+ bonus_h
* 1, 2, _("200 - 10,000 points extra score") );
120 draw_bonus_info( bonus_x
+ bonus_w
* 0, bonus_y
+ bonus_h
* 2, 12, _("Extra ball") );
121 draw_bonus_info( bonus_x
+ bonus_w
* 1, bonus_y
+ bonus_h
* 2, 11, _("Energy balls (penetrate bricks)") );
122 draw_bonus_info( bonus_x
+ bonus_w
* 0, bonus_y
+ bonus_h
* 3, 13, _("Bonus floor") );
123 draw_bonus_info( bonus_x
+ bonus_w
* 1, bonus_y
+ bonus_h
* 3, 18, _("Deccelerate balls to minimum speed") );
124 draw_bonus_info( bonus_x
+ bonus_w
* 0, bonus_y
+ bonus_h
* 4, 6, _("1,000 points extra score from bricks with no bonus") );
125 draw_bonus_info( bonus_x
+ bonus_w
* 0, bonus_y
+ bonus_h
* 5, 19, _("Instantly collect all bonuses and destroy all penalties") );
126 draw_bonus_info( bonus_x
+ bonus_w
* 0, bonus_y
+ bonus_h
* 6, 25, _("Explosive balls") );
127 draw_bonus_info( bonus_x
+ bonus_w
* 1, bonus_y
+ bonus_h
* 6, 26, _("Paddle attracts bonuses") );
130 stk_font_write( help_caption_font
, stk_display
,
131 malus_x
, malus_y
- 30, STK_OPAQUE
, _("Penalties:") );
132 draw_bonus_info( malus_x
+ malus_w
* 0, malus_y
+ malus_h
* 0, 7, _("Shrink paddle") );
133 draw_bonus_info( malus_x
+ malus_w
* 0, malus_y
+ malus_h
* 3, 17, _("Accelerate balls") );
134 draw_bonus_info( malus_x
+ malus_w
* 0, malus_y
+ malus_h
* 1, 14, _("Freeze paddle") );
135 draw_bonus_info( malus_x
+ malus_w
* 1, malus_y
+ malus_h
* 1, 21, _("Random ball reflection at bricks") );
136 draw_bonus_info( malus_x
+ malus_w
* 0, malus_y
+ malus_h
* 2, 20, _("Darkness") );
137 draw_bonus_info( malus_x
+ malus_w
* 1, malus_y
+ malus_h
* 2, 27, _("Paddle attracts penalties") );
138 draw_bonus_info( malus_x
+ malus_w
* 1, malus_y
+ malus_h
* 0, 22, _("Paddle disappears when not moving") );
139 draw_bonus_info( malus_x
+ malus_w
* 1, malus_y
+ malus_h
* 3, 28, /* xgettext:no-c-format */ _("40% chance that a ball doesn't damage brick") );
143 stk_display_update( STK_UPDATE_ALL
);
146 ====================================================================
148 ====================================================================
150 void draw_hint( int x
, int y
, char *text
)
152 stk_font_write( help_font
, stk_display
,
153 x
, y
, STK_OPAQUE
, text
);
156 ====================================================================
158 ====================================================================
160 void draw_hints_screen()
162 int hint_x
= 20, hint_y
= 80, hint_h
= 20;
164 stk_surface_blit( help_bkgnd
, 0,0,-1,-1, stk_display
, 0,0 );
167 help_caption_font
->align
= STK_FONT_ALIGN_LEFT
| STK_FONT_ALIGN_TOP
;
168 stk_font_write( help_caption_font
, stk_display
,
169 hint_x
, hint_y
- 40, STK_OPAQUE
, _("Hints:") );
171 draw_hint( hint_x
, hint_y
+ hint_h
* 0, _("<<'In Game'-Keys>>") );
172 draw_hint( hint_x
, hint_y
+ hint_h
* 1, _(" p Pause game. (and enter chatroom in network game)") );
173 draw_hint( hint_x
, hint_y
+ hint_h
* 2, _(" s Enable/Disable sound.") );
174 draw_hint( hint_x
, hint_y
+ hint_h
* 3, _(" a Change animation level (off/low/high).") );
175 draw_hint( hint_x
, hint_y
+ hint_h
* 4, _(" f Switch fullscreen/windowed mode.") );
176 draw_hint( hint_x
, hint_y
+ hint_h
* 5, _(" NOTE: Changing resolution takes a while so this is done best") );
177 draw_hint( hint_x
, hint_y
+ hint_h
* 6, _(" when game's paused.") );
178 draw_hint( hint_x
, hint_y
+ hint_h
* 7, _(" r Restart level.") );
179 draw_hint( hint_x
, hint_y
+ hint_h
* 8, _(" d Disintegrate single bricks. (AddOn's only)") );
180 draw_hint( hint_x
, hint_y
+ hint_h
* 9, _(" w Warp to next level after enough bricks where cleared. (AddOn's only)") );
181 draw_hint( hint_x
, hint_y
+ hint_h
* 10, _(" Shift Shows highest score of set instead of your score as long as you") );
182 draw_hint( hint_x
, hint_y
+ hint_h
* 11, _(" hold it down.") );
183 draw_hint( hint_x
, hint_y
+ hint_h
* 12, _(" Tab Take a screenshot.") );
184 draw_hint( hint_x
, hint_y
+ hint_h
* 13, _(" Esc Quit game.") );
186 draw_hint( hint_x
, hint_y
+ hint_h
* 15, _("Pressing the left or right mouse button will fire attached balls either") );
187 draw_hint( hint_x
, hint_y
+ hint_h
* 16, _("to the left or right direction if 'Ball Fire Angle' in 'Advanced Options'") );
188 draw_hint( hint_x
, hint_y
+ hint_h
* 17, _("is not set to 'Random'.") );
192 stk_display_update( STK_UPDATE_ALL
);
195 ====================================================================
197 ====================================================================
199 void draw_ingame_hints_screen()
201 int brick_x
= 20, brick_y
= 210, brick_h
= 30;
202 int extra_x
= 20, extra_y
= 80, extra_h
= 30;
204 stk_surface_blit( help_bkgnd
, 0,0,-1,-1, stk_display
, 0,0 );
207 help_caption_font
->align
= STK_FONT_ALIGN_LEFT
| STK_FONT_ALIGN_TOP
;
208 stk_font_write( help_caption_font
, stk_display
,
209 extra_x
, extra_y
- 30, STK_OPAQUE
, _("Neutral Power-Ups:") );
211 draw_bonus_info( extra_x
, extra_y
+ extra_h
* 0, 16, _("Any of the listed bonuses/penalties.") );
212 draw_bonus_info( extra_x
, extra_y
+ extra_h
* 1, 23, _("Resets all active bonuses and penalties.") );
213 draw_bonus_info( extra_x
, extra_y
+ extra_h
* 2, 24, _("Adds 7 seconds to all active bonuses/penalties.") );
215 help_caption_font
->align
= STK_FONT_ALIGN_LEFT
| STK_FONT_ALIGN_TOP
;
216 stk_font_write( help_caption_font
, stk_display
,
217 brick_x
, brick_y
- 30, STK_OPAQUE
, _("Special Bricks:") );
219 draw_brick_info( brick_x
, brick_y
+ brick_h
* 0, 0, _("Indestructible.") );
220 draw_brick_info( brick_x
, brick_y
+ brick_h
* 1, 1, _("May only be destroyed by energy ball else it's indestructible.") );
221 draw_brick_info( brick_x
, brick_y
+ brick_h
* 2, 2, _("As above and balls are reflected randomly at this brick.") );
222 draw_brick_info( brick_x
, brick_y
+ brick_h
* 3, 5, _("Needs three hits to be destroyed.") );
223 draw_brick_info( brick_x
, brick_y
+ brick_h
* 4, 9, _("As above and regenerates durability every 4 seconds.") );
224 draw_brick_info( brick_x
, brick_y
+ brick_h
* 5, 18, _("Explodes and destroys all nearby bricks.") );
225 draw_brick_info( brick_x
, brick_y
+ brick_h
* 6, 19, _("Creates up to 8 bricks on destruction.") );
229 stk_display_update( STK_UPDATE_ALL
);
232 ====================================================================
233 Draw trouble shooting
234 ====================================================================
236 void draw_trouble( int x
, int y
, char *text
)
238 draw_hint( x
, y
, text
);
240 void draw_trouble_screen()
242 int trouble_x
= 20, trouble_y
= 90, trouble_h
= 20;
243 int manual_x
= 20, manual_y
= 310, manual_h
= 20;
244 stk_surface_blit( help_bkgnd
, 0,0,-1,-1, stk_display
, 0,0 );
247 help_caption_font
->align
= STK_FONT_ALIGN_LEFT
| STK_FONT_ALIGN_TOP
;
248 stk_font_write( help_caption_font
, stk_display
,
249 trouble_x
, trouble_y
- 40, STK_OPAQUE
, _("Troubleshooting:") );
251 draw_trouble( trouble_x
, trouble_y
+ trouble_h
* 0, _("* In fullscreen mode the window keeps it size just adding a black frame?") );
252 draw_trouble( trouble_x
, trouble_y
+ trouble_h
* 1, _(" - Maybe you do not have 640x480 as resolution available? Check your") );
253 draw_trouble( trouble_x
, trouble_y
+ trouble_h
* 2, _(" X configuration.") );
254 draw_trouble( trouble_x
, trouble_y
+ trouble_h
* 3, _("* Sounds seem to be out of sync and are played with some delay?") );
255 draw_trouble( trouble_x
, trouble_y
+ trouble_h
* 4, _(" - Set SDL_AUDIODRIVER to dma (export SDL_AUDIODRIVER=dma). If this results") );
256 draw_trouble( trouble_x
, trouble_y
+ trouble_h
* 5, _(" in a lot of errors killing artsd (or esd) may help.") );
257 draw_trouble( trouble_x
, trouble_y
+ trouble_h
* 6, _("* LBreakout2 gets mute while playing when switching on/off sounds?") );
258 draw_trouble( trouble_x
, trouble_y
+ trouble_h
* 7, _(" - SDL_mixer seems to mute active channels. You shouldn't enable/disable") );
259 draw_trouble( trouble_x
, trouble_y
+ trouble_h
* 8, _(" sounds to often as you'll propably loose all channels then.") );
261 help_caption_font
->align
= STK_FONT_ALIGN_LEFT
| STK_FONT_ALIGN_TOP
;
262 stk_font_write( help_caption_font
, stk_display
,
263 manual_x
, manual_y
- 40, STK_OPAQUE
, _("Manual:"));
264 draw_trouble( manual_x
, manual_y
+ manual_h
* 0, _("This is just a quick help with the most important facts about LBreakout2.") );
265 draw_trouble( manual_x
, manual_y
+ manual_h
* 1, _("If you want more and better information check out the manual installed to") );
266 draw_trouble( manual_x
, manual_y
+ manual_h
* 2, _("/usr/doc/lbreakout2 or the online version at http://lgames.sf.net.") );
267 draw_trouble( manual_x
, manual_y
+ manual_h
* 3, _("And if you have questions (not answered by the manual) or you found a bug") );
268 draw_trouble( manual_x
, manual_y
+ manual_h
* 4, _("or you just want to drop a general note about LBreakout2 just mail to:") );
269 draw_trouble( manual_x
, manual_y
+ manual_h
* 5, _(" kulkanie@gmx.net") );
270 draw_trouble( manual_x
, manual_y
+ manual_h
* 6, _(" Enjoy the game!") );
271 draw_trouble( manual_x
, manual_y
+ manual_h
* 6 + 10, _(" Michael Speck") );
275 stk_display_update( STK_UPDATE_ALL
);
279 ====================================================================
281 ====================================================================
285 ====================================================================
286 Load/delete help resources.
287 ====================================================================
291 help_font
= stk_font_load( SDL_SWSURFACE
, "f_small_yellow.png" );
292 SDL_SetColorKey( help_font
->surface
, SDL_SRCCOLORKEY
,
293 stk_surface_get_pixel( help_font
->surface
, 0,0 ) );
294 help_caption_font
= stk_font_load( SDL_SWSURFACE
, "f_yellow.png" );
295 SDL_SetColorKey( help_caption_font
->surface
, SDL_SRCCOLORKEY
,
296 stk_surface_get_pixel( help_caption_font
->surface
, 0,0 ) );
297 /* background -- will be filled when running help */
298 help_bkgnd
= stk_surface_create( SDL_SWSURFACE
, stk_display
->w
, stk_display
->h
);
299 SDL_SetColorKey( help_bkgnd
, 0, 0 );
303 stk_font_free( &help_font
);
304 stk_font_free( &help_caption_font
);
305 stk_surface_free( &help_bkgnd
);
309 ====================================================================
311 ====================================================================
313 static void help_draw_side( int side_id
)
316 case 0: draw_bonus_screen(); break;
317 case 2: draw_hints_screen(); break;
318 case 1: draw_ingame_hints_screen(); break;
319 case 3: draw_trouble_screen(); break;
327 SDL_Surface
*buffer
=
328 stk_surface_create(SDL_SWSURFACE
,stk_display
->w
, stk_display
->h
);
331 stk_surface_blit( stk_display
, 0,0,-1,-1, buffer
, 0,0 );
332 SDL_SetColorKey(buffer
, 0, 0);
334 /* gray screen and use as background */
335 stk_surface_gray( stk_display
, 0,0,-1,-1, 1 );
336 stk_surface_blit( stk_display
, 0,0,-1,-1, help_bkgnd
, 0,0 );
339 while ( !leave
&& !stk_quit_request
) {
340 SDL_WaitEvent( &event
);
341 switch ( event
.type
) {
342 case SDL_QUIT
: stk_quit_request
= 1; break;
344 switch ( event
.key
.keysym
.sym
) {
345 case SDLK_ESCAPE
: leave
= 1; break;
348 if ( event
.key
.keysym
.sym
== SDLK_RIGHT
) {
350 if ( cur_side
== side_count
) cur_side
= 0;
354 if ( cur_side
< 0 ) cur_side
= side_count
- 1;
356 help_draw_side(cur_side
);
359 config
.fullscreen
= !config
.fullscreen
;
360 stk_display_apply_fullscreen( config
.fullscreen
);
361 help_draw_side(cur_side
);
366 case SDL_MOUSEBUTTONUP
:
367 if ( event
.button
.button
== STK_BUTTON_LEFT
) {
369 if ( cur_side
== side_count
) cur_side
= 0;
373 if ( cur_side
< 0 ) cur_side
= side_count
- 1;
375 help_draw_side(cur_side
);
382 stk_surface_blit( buffer
, 0,0,-1,-1, stk_display
, 0,0 );
383 stk_display_update( STK_UPDATE_ALL
);
384 SDL_FreeSurface( buffer
);
386 /* reset the relative position so paddle wont jump */
387 SDL_GetRelativeMouseState(0,0);