29 Ball ball
= { GAME_X_MID
, GAME_Y_MID
, 2.0, 0.2 };
30 Player player1
= { GAME_X_MIN
-4, GAME_Y_MID
, 0, 0 };
31 Player player2
= { GAME_X_MAX
, GAME_Y_MID
, 0, 0 };
37 werbung
[w
] = rand()%SPONSOR_COUNT
;
46 show_bmp( "data/court.bmp", 0, 0, 255);
49 show_sprite( SPONSOR_BMP
, werbung
[w
], SPONSOR_COUNT
, 60+50*w
+5*(w
>1), 7, 255);
52 show_sprite( RACKET_BMP
, (!player1
.state
), 4, player1
.x
, player1
.y
, 255);
53 show_sprite( RACKET_BMP
, (!player2
.state
)+2, 4, player2
.x
, player2
.y
, 255);
55 show_bmp( "data/ball.bmp", ball
.x
, ball
.y
, 255);
57 show_bmp( "data/standings.bmp", 115, 160, 255);
58 show_digit( player1
.score
/10%10, 140, 180, 100);
59 show_digit( player1
.score
%10, 148, 180, 100);
60 show_digit( 10, 156, 180, 100);
61 show_digit( player2
.score
/10%10, 164, 180, 100);
62 show_digit( player2
.score
%10, 172, 180, 100);
67 if( IS_OUT_X(ball
.x
) || IS_OUT_Y(ball
.y
)) {
68 if( (IS_OUT_Y(ball
.y
) && ball
.move_y
> 0) || (!(player1
.state
&& IS_NEAR_Y(player1
.y
, ball
.y
)) && ball
.x
< GAME_X_MIN
)) {
72 ball
.move_x
= fabsf( ball
.move_x
);
77 if( (IS_OUT_Y(ball
.y
) && ball
.move_y
< 0) || (!(player2
.state
&& IS_NEAR_Y(player2
.y
, ball
.y
)) && ball
.x
> GAME_X_MAX
)) {
81 ball
.move_x
= -fabsf( ball
.move_x
);
86 if( IS_OUT_X(ball
.x
)) {
87 if( ball
.move_x
< 0) {
89 ball
.move_x
= (2.0+(2.0*(rand()%10))/10.0);
90 ball
.move_y
= GET_MOVE(player1
.y
,ball
.y
);
93 ball
.move_x
= -(2.0+(2.0*(rand()%10))/10.0);
94 ball
.move_y
= GET_MOVE(player2
.y
,ball
.y
);
99 ball
.x
+= ball
.move_x
;
100 ball
.y
+= ball
.move_y
;
102 if( player1
.state
) player1
.state
--;
103 if( player2
.state
) player2
.state
--;
106 limit_value( &player1
.y
, GAME_Y_MIN
, GAME_Y_MAX
);
107 limit_value( &player2
.y
, GAME_Y_MIN
, GAME_Y_MAX
);
110 keys
= SDL_GetKeyState( NULL
);
112 if( keys
['2']) player1
.y
-=3;
113 if( keys
['w']) player1
.y
-=2;
114 if( keys
['s']) player1
.y
+=2;
115 if( keys
['x']) player1
.y
+=3;
116 if( keys
['d']) player1
.state
= 10;
118 if( keys
['9']) player2
.y
-=3;
119 if( keys
['o']) player2
.y
-=2;
120 if( keys
['l']) player2
.y
+=2;
121 if( keys
['.']) player2
.y
+=3;
122 if( keys
['k']) player2
.state
= 10;
124 if( keys
['f']) SDL_WM_ToggleFullScreen( screen
);
126 if( keys
[SDLK_ESCAPE
] || keys
['q']) break;
135 void limit_value( float* value
, float min
, float max
) {
138 } else if( *value
> max
) {