-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameState.cpp
More file actions
730 lines (584 loc) · 18.2 KB
/
GameState.cpp
File metadata and controls
730 lines (584 loc) · 18.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
/*
* Licensed under GNU GPL v2
* Author(s): Christofer Oden
* Created on: 091031
*/
#include "GameState.h"
#include "Interface.h"
#include "World.h"
#include <vector>
#include <sstream>
void GameState::initialize( SDL_Surface *screen ) {
the_screen = screen;
printf( "---Loading game state data---\n" );
my_sprite_map = load_image( "sprites/sprite_map.png" );
my_font_map = load_image( "sprites/font_map.png" );
printf( "---Generating world---\n" );
my_world.generate( 30, 30 );
printf( "---Initializing players---\n" );
my_player_manager.initialize( &my_world, 3
);
printf( "---Setting up interface---\n" );
my_interface.initialize( the_screen, &my_camera, &my_world,
&my_player_manager );
printf( "---Creating camera---\n");
SDL_Rect camera_rect = { 0, 0,
SCREEN_WIDTH - my_interface.get_rect()->w, SCREEN_HEIGHT };
my_camera.initialize( &my_world, &camera_rect );
i_am_running = true;
}
void GameState::handle_events() {
SDL_Event event;
while( SDL_PollEvent( &event ) ) {
switch( event.type ) {
case SDL_KEYDOWN:
case SDL_KEYUP:
handle_keyboard_event( &event );
break;
case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
handle_mouse_event( &event );
break;
case SDL_QUIT:
set_is_running( false );
break;
// Unhandled events
}
}
}
void GameState::update() {
my_player_manager.update();
my_camera.update();
}
void GameState::draw() {
//printf("GameState: Drawing tiles\n");
draw_tiles();
//printf("GameState: Drawing statics\n");
draw_static_entities();
//printf("GameState: Drawing mobiles\n");
draw_mobile_entities();
//printf("GameState: Drawing interface\n");
draw_interface();
if( SDL_Flip( the_screen ) < 0 ) {
fprintf( stderr, "SDL_Flip: %s\n", SDL_GetError() );
}
}
void GameState::handle_keyboard_event( SDL_Event *event ) {
Player *current_player = my_player_manager.get_current_player();
Unit *unit = NULL;
switch( event->type ) {
case SDL_KEYDOWN:
switch( event->key.keysym.sym ) {
case SDLK_ESCAPE:
set_is_running( false );
break;
case SDLK_TAB:
if( SDL_GetModState() & KMOD_SHIFT ) {
current_player->select_prev_unit();
}
else {
current_player->select_next_unit();
}
unit = current_player->get_selected_unit();
if( unit != NULL ) {
printf("Centering camera\n");
my_camera.center_at_tile(
unit->get_row(), unit->get_col() );
}
break;
case SDLK_KP7:
current_player->move_selected_unit( NW );
break;
case SDLK_UP:
case SDLK_KP8:
printf( "Up pressed\n" );
current_player->move_selected_unit( N );
break;
case SDLK_KP9:
current_player->move_selected_unit( NE );
break;
case SDLK_LEFT:
case SDLK_KP4:
printf( "Left pressed\n" );
current_player->move_selected_unit( W );
break;
case SDLK_RIGHT:
case SDLK_KP6:
printf( "Right pressed\n" );
current_player->move_selected_unit( E );
break;
case SDLK_KP1:
current_player->move_selected_unit( SW );
break;
case SDLK_DOWN:
case SDLK_KP2:
printf( "Down pressed\n" );
current_player->move_selected_unit( S );
break;
case SDLK_KP3:
current_player->move_selected_unit( SE );
break;
case SDLK_a:
my_camera.set_movement_x( -5 );
break;
case SDLK_c:
if( SDL_GetModState() & KMOD_CTRL )
set_is_running( false );
break;
case SDLK_d:
my_camera.set_movement_x( 5 );
break;
case SDLK_e:
printf( "End turn\n" );
my_player_manager.end_turn();
printf( "Your turn player %d\n",
my_player_manager.get_current_player()->get_id() );
break;
case SDLK_n:
my_player_manager.get_current_player()->
create_unit(
rand() % my_world.get_row_count(),
rand() % my_world.get_col_count(),
UNIT_MGUNNERORC );
printf("Unit count: %d\n",
my_player_manager.get_current_player()->
get_unit_list()->size() );
break;
case SDLK_s:
my_camera.set_movement_y( 5 );
break;
case SDLK_w:
my_camera.set_movement_y( -5 );
break;
default:
break;
}
break;
case SDL_KEYUP:
switch( event->key.keysym.sym ) {
case SDLK_w:
case SDLK_s:
my_camera.stop_movement_y();
break;
case SDLK_a:
case SDLK_d:
my_camera.stop_movement_x();
break;
default:
break;
}
break;
default:
fprintf( stderr, "Unhandled keyboard event.type,\n"
" this shouldn't happen!\n" );
fprintf( stderr, "File: %s, line: %d\n", __FILE__, __LINE__ );
}
}
void GameState::handle_mouse_event( SDL_Event *event ) {
Player *current_player = my_player_manager.get_current_player();
switch( event->type ) {
case SDL_MOUSEBUTTONDOWN:
switch( event->button.button ) {
case SDL_BUTTON_LEFT:
if( my_interface.covers( event->button.x,
event->button.y ) )
{
my_interface.on_click( event->button.x,
event->button.y );
}
else {
current_player->select_unit_at_xy(
my_camera.get_rect()->x + event->button.x,
my_camera.get_rect()->y + event->button.y );
}
break;
case SDL_BUTTON_RIGHT:
my_camera.center_at_xy(
my_camera.get_rect()->x + event->button.x,
my_camera.get_rect()->y + event->button.y );
break;
}
break;
case SDL_MOUSEBUTTONUP:
break;
case SDL_MOUSEMOTION:
break;
default:
fprintf( stderr, "Unhandled mouse event.type,\n"
" this shouldn't happen!\n" );
fprintf( stderr, "File: %s, line: %d\n", __FILE__, __LINE__ );
}
}
void GameState::draw_tiles() {
int row_count = my_world.get_row_count();
int col_count = my_world.get_col_count();
Player *current_player = my_player_manager.get_current_player();
for( int row = 0; row < row_count; ++row ) {
for( int col = 0; col < col_count; ++col ) {
if( my_camera.tile_is_in_scope( row, col ) == false )
continue;
if ( current_player->has_discovered_tile( row, col ) == false ) {
SDL_Rect temp_rect = { col * TILE_SIZE - my_camera.get_x(),
row * TILE_SIZE - my_camera.get_y(),
TILE_SIZE, TILE_SIZE };
//printf( "Draw tiles: Drawing undiscovered tile\n");
SDL_FillRect( the_screen, &temp_rect,
SDL_MapRGB( the_screen->format, 0x00, 0x00, 0x00 ) );
continue;
}
//printf( "Draw tiles: Drawing terrain tile\n");
switch( my_world.get_tile_type( row, col ) ) {
case TILE_GRASS:
apply_surface( col * TILE_SIZE - my_camera.get_x(),
row * TILE_SIZE - my_camera.get_y(),
my_sprite_map, the_screen, &RECT_GRASS );
break;
case TILE_WATER:
draw_water_sprites( row, col );
break;
case TILE_TREES:
draw_tree_sprites( row, col );
break;
default:
break;
}
/*
if( !current_player->can_see_tile( row, col ) ) {
SDL_Rect temp_rect = { col * TILE_SIZE - my_camera.get_x(),
row * TILE_SIZE - my_camera.get_y(),
TILE_SIZE, TILE_SIZE };
SDL_FillRect( the_screen, &temp_rect,
SDL_MapRGBA( the_screen->format,
0x00, 0x00, 0x00, 0xff ) );
}
*/
if( !current_player->can_see_tile( row, col ) ) {
apply_surface(
col * TILE_SIZE - my_camera.get_x(),
row * TILE_SIZE - my_camera.get_y(),
my_sprite_map, the_screen, &RECT_SHROUD );
}
}
}
}
void GameState::draw_static_entities() {
/*
.
.
.
* empty *
.
.
.
*/
}
void GameState::draw_mobile_entities() {
std::vector<Player> *player_list = my_player_manager.get_player_list();
Player *current_player = my_player_manager.get_current_player();
for( PlayerIterator p_it = player_list->begin();
p_it < player_list->end(); ++p_it )
{
std::vector<Unit> *unit_list = p_it->get_unit_list();
for( UnitIterator u_it = unit_list->begin();
u_it < unit_list->end(); ++u_it )
{
int row = u_it->get_row();
int col = u_it->get_col();
if( !my_camera.tile_is_in_scope( row, col ) ) {
continue;
}
if( !current_player->can_see_tile( row, col ) ) {
continue;
}
draw_unit_sprite( col * TILE_SIZE - my_camera.get_x(),
row * TILE_SIZE - my_camera.get_y(),
u_it->get_type(), u_it->get_owner_id() );
}
}
for( PlayerIterator p_it = player_list->begin();
p_it < player_list->end(); ++p_it )
{
std::vector<Unit> *unit_list = p_it->get_unit_list();
for( UnitIterator u_it = unit_list->begin();
u_it < unit_list->end(); ++u_it )
{
int row = u_it->get_row();
int col = u_it->get_col();
if( !my_camera.tile_is_in_scope( row, col ) ) {
continue;
}
if( !current_player->can_see_tile( row, col ) ) {
continue;
}
SDL_Rect temp_bar = { col * TILE_SIZE - my_camera.get_x() + 4,
row * TILE_SIZE - my_camera.get_y() - 4,
24, 4 };
draw_health_bar( &temp_bar,
u_it->get_health(), u_it->get_maxhealth() );
}
}
}
void GameState::draw_unit_sprite( int x, int y,
UnitType unit_type, int player_id )
{
SDL_Rect rect;
switch ( unit_type ) {
case UNIT_DRAGON:
rectcpy( &rect, &RECT_DRAGON );
rect.y += rect.h * player_id;
apply_surface( x, y, my_sprite_map, the_screen, &rect );
break;
case UNIT_INFANTRY:
rectcpy( &rect, &RECT_INFANTRY );
rect.y += rect.h * player_id;
apply_surface( x, y, my_sprite_map, the_screen, &rect );
break;
case UNIT_ARMOR:
rectcpy( &rect, &RECT_ARMOR );
rect.y += rect.h * player_id;
apply_surface( x, y, my_sprite_map, the_screen, &rect );
break;
case UNIT_HOWITZER:
rectcpy( &rect, &RECT_HOWITZER );
rect.y += rect.h * player_id;
apply_surface( x, y, my_sprite_map, the_screen, &rect );
break;
case UNIT_MGUNNERORC:
rectcpy( &rect, &RECT_MGUNNERORC );
rect.y += rect.h * player_id;
apply_surface( x, y, my_sprite_map, the_screen, &rect );
break;
case UNIT_BEHOLDER:
rectcpy( &rect, &RECT_BEHOLDER );
apply_surface( x, y, my_sprite_map, the_screen, &rect );
break;
default:
fprintf( stderr, "I was told to draw an unrecognized unit type!\n"
" This shouldn't happen, fix it!\n");
fprintf( stderr, "File: %s, line: %d\n", __FILE__, __LINE__ );
}
}
void GameState::draw_health_bar( SDL_Rect *box, int health, int max_health )
{
if( box->y < 0 )
return;
double ratio = double(health) / double(max_health);
SDL_FillRect( the_screen, box,
SDL_MapRGB( the_screen->format, 0xc0, 0xb0, 0xb0 ) );
box->x += 1;
box->y += 1;
box->w -= 2;
box->h -= 2;
SDL_FillRect( the_screen, box,
SDL_MapRGB( the_screen->format, 0x20, 0x00, 0x00 ) );
box->w *= ratio;
SDL_FillRect( the_screen, box,
SDL_MapRGB( the_screen->format, 0x80, 0x00, 0x00 ) );
}
void GameState::draw_interface() {
Unit *unit = my_player_manager.get_current_player()->get_selected_unit();
if( unit != NULL ) {
int row = unit->get_row();
int col = unit->get_col();
if( my_camera.tile_is_in_scope( row, col ) == true ) {
apply_surface( col * TILE_SIZE - my_camera.get_x(),
row * TILE_SIZE - my_camera.get_y(),
my_sprite_map, the_screen, &RECT_MARKER );
}
}
my_interface.draw();
if( unit != NULL )
{
std::stringstream ss;
ss << "Health: " << unit->get_health() << " of "
<< unit->get_maxhealth();
blit_string( SCREEN_WIDTH - 90, 200, ss.str().c_str(),
the_screen, my_font_map );
ss.str("");
ss << "Moves: " << unit->get_moves();
blit_string( SCREEN_WIDTH - 90, 210, ss.str().c_str(),
the_screen, my_font_map );
}
}
void GameState::draw_water_sprites( int row, int col ) {
SDL_Rect rect;
// Draw NW tile
// Check northern and western tile
if( my_world.get_tile_type( row - 1, col ) == TILE_WATER &&
my_world.get_tile_type( row, col - 1 ) == TILE_WATER )
{
if( my_world.get_tile_type( row - 1, col - 1 ) != TILE_WATER )
rect = RECT_OUTER_CLIFF_NW;
else
rect = RECT_WATER;
}
else if( my_world.get_tile_type( row - 1, col ) != TILE_WATER &&
my_world.get_tile_type( row, col - 1 ) == TILE_WATER )
{
rect = RECT_CLIFF_N;
}
else if( my_world.get_tile_type( row - 1, col ) == TILE_WATER &&
my_world.get_tile_type( row, col - 1 ) != TILE_WATER )
{
rect = RECT_CLIFF_W;
}
else if( my_world.get_tile_type( row - 1, col ) != TILE_WATER &&
my_world.get_tile_type( row, col - 1 ) != TILE_WATER )
{
rect = RECT_CLIFF_NW;
}
// printf( "DEBUG: Drawing NW tile\n" );
apply_surface(
col * TILE_SIZE - my_camera.get_x(),
row * TILE_SIZE - my_camera.get_y(),
my_sprite_map, the_screen, &rect );
// Draw NE tile
// Check northern and eastern tile
if ( my_world.get_tile_type( row - 1, col ) == TILE_WATER &&
my_world.get_tile_type( row, col + 1 ) == TILE_WATER )
if ( my_world.get_tile_type( row - 1, col + 1 ) != TILE_WATER )
rect = RECT_OUTER_CLIFF_NE;
else
rect = RECT_WATER;
else if( my_world.get_tile_type( row - 1, col ) != TILE_WATER &&
my_world.get_tile_type( row, col + 1 ) == TILE_WATER )
rect = RECT_CLIFF_N;
else if( my_world.get_tile_type( row - 1, col ) == TILE_WATER &&
my_world.get_tile_type( row, col + 1 ) != TILE_WATER )
rect = RECT_CLIFF_E;
else if( my_world.get_tile_type( row - 1, col ) != TILE_WATER &&
my_world.get_tile_type( row, col + 1 ) != TILE_WATER )
rect = RECT_CLIFF_NE;
// printf( "DEBUG: Drawing NE tile\n" );
apply_surface(
col * TILE_SIZE + 16 - my_camera.get_x(),
row * TILE_SIZE - my_camera.get_y(),
my_sprite_map, the_screen, &rect );
// Draw SW tile
// Check southern and western tile
if ( my_world.get_tile_type( row + 1, col ) == TILE_WATER &&
my_world.get_tile_type( row, col - 1 ) == TILE_WATER )
if ( my_world.get_tile_type( row + 1, col - 1 ) != TILE_WATER )
rect = RECT_OUTER_CLIFF_SW;
else
rect = RECT_WATER;
else if( my_world.get_tile_type( row + 1, col ) != TILE_WATER &&
my_world.get_tile_type( row, col - 1 ) == TILE_WATER )
rect = RECT_CLIFF_S;
else if( my_world.get_tile_type( row + 1, col ) == TILE_WATER &&
my_world.get_tile_type( row, col - 1 ) != TILE_WATER )
rect = RECT_CLIFF_W;
else if( my_world.get_tile_type( row + 1, col ) != TILE_WATER &&
my_world.get_tile_type( row, col - 1 ) != TILE_WATER )
rect = RECT_CLIFF_SW;
// printf( "DEBUG: Drawing SW tile\n" );
apply_surface(
col * TILE_SIZE - my_camera.get_x(),
row * TILE_SIZE + 16 - my_camera.get_y(),
my_sprite_map, the_screen, &rect );
// Draw SE tile
// Check southern and eastern tile
if ( my_world.get_tile_type( row + 1, col ) == TILE_WATER &&
my_world.get_tile_type( row, col + 1 ) == TILE_WATER )
if ( my_world.get_tile_type( row + 1, col + 1 ) != TILE_WATER )
rect = RECT_OUTER_CLIFF_SE;
else
rect = RECT_WATER;
else if( my_world.get_tile_type( row + 1, col ) != TILE_WATER &&
my_world.get_tile_type( row, col + 1 ) == TILE_WATER )
rect = RECT_CLIFF_S;
else if( my_world.get_tile_type( row + 1, col ) == TILE_WATER &&
my_world.get_tile_type( row, col + 1 ) != TILE_WATER )
rect = RECT_CLIFF_E;
else if( my_world.get_tile_type( row + 1, col ) != TILE_WATER &&
my_world.get_tile_type( row, col + 1 ) != TILE_WATER )
rect = RECT_CLIFF_SE;
// printf( "DEBUG: Drawing SE tile\n" );
apply_surface(
col * TILE_SIZE + 16 - my_camera.get_x(),
row * TILE_SIZE + 16 - my_camera.get_y(),
my_sprite_map, the_screen, &rect );
}
void GameState::draw_tree_sprites( int row, int col ) {
SDL_Rect rect;
// Draw NW tile
// Check northern and western tile
if( my_world.get_tile_type( row - 1, col ) == TILE_TREES
&& my_world.get_tile_type( row, col - 1 ) == TILE_TREES )
{
rect = RECT_TREES;
}
else if( my_world.get_tile_type( row - 1, col ) != TILE_TREES
&& my_world.get_tile_type( row, col - 1 ) == TILE_TREES )
{
rect = RECT_TREES_N;
}
else if( my_world.get_tile_type( row - 1, col ) == TILE_TREES
&& my_world.get_tile_type( row, col - 1 ) != TILE_TREES )
{
rect = RECT_TREES_W;
}
else if( my_world.get_tile_type( row - 1, col ) != TILE_TREES
&& my_world.get_tile_type( row, col - 1 ) != TILE_TREES )
{
rect = RECT_TREES_NW;
}
apply_surface(col * TILE_SIZE - my_camera.get_x(),
row * TILE_SIZE - my_camera.get_y(),
my_sprite_map, the_screen, &rect );
// Draw NE tile
// Check northern and eastern tile
if ( my_world.get_tile_type( row - 1, col ) == TILE_TREES &&
my_world.get_tile_type( row, col + 1 ) == TILE_TREES )
rect = RECT_TREES;
else if( my_world.get_tile_type( row - 1, col ) != TILE_TREES &&
my_world.get_tile_type( row, col + 1 ) == TILE_TREES )
rect = RECT_TREES_N;
else if( my_world.get_tile_type( row - 1, col ) == TILE_TREES &&
my_world.get_tile_type( row, col + 1 ) != TILE_TREES )
rect = RECT_TREES_E;
else if( my_world.get_tile_type( row - 1, col ) != TILE_TREES &&
my_world.get_tile_type( row, col + 1 ) != TILE_TREES )
rect = RECT_TREES_NE;
apply_surface(
col * TILE_SIZE + 16 - my_camera.get_x(),
row * TILE_SIZE - my_camera.get_y(),
my_sprite_map, the_screen, &rect );
// Draw SW tile
// Check southern and western tile
if ( my_world.get_tile_type( row + 1, col ) == TILE_TREES &&
my_world.get_tile_type( row, col - 1 ) == TILE_TREES )
rect = RECT_TREES;
else if( my_world.get_tile_type( row + 1, col ) != TILE_TREES &&
my_world.get_tile_type( row, col - 1 ) == TILE_TREES )
rect = RECT_TREES_S;
else if( my_world.get_tile_type( row + 1, col ) == TILE_TREES &&
my_world.get_tile_type( row, col - 1 ) != TILE_TREES )
rect = RECT_TREES_W;
else if( my_world.get_tile_type( row + 1, col ) != TILE_TREES &&
my_world.get_tile_type( row, col - 1 ) != TILE_TREES )
rect = RECT_TREES_SW;
apply_surface(
col * TILE_SIZE - my_camera.get_x(),
row * TILE_SIZE + 16 - my_camera.get_y(),
my_sprite_map, the_screen, &rect );
// Draw SE tile
// Check southern and eastern tile
if ( my_world.get_tile_type( row + 1, col ) == TILE_TREES &&
my_world.get_tile_type( row, col + 1 ) == TILE_TREES )
rect = RECT_TREES;
else if( my_world.get_tile_type( row + 1, col ) != TILE_TREES &&
my_world.get_tile_type( row, col + 1 ) == TILE_TREES )
rect = RECT_TREES_S;
else if( my_world.get_tile_type( row + 1, col ) == TILE_TREES &&
my_world.get_tile_type( row, col + 1 ) != TILE_TREES )
rect = RECT_TREES_E;
else if( my_world.get_tile_type( row + 1, col ) != TILE_TREES &&
my_world.get_tile_type( row, col + 1 ) != TILE_TREES )
rect = RECT_TREES_SE;
apply_surface(
col * TILE_SIZE + 16 - my_camera.get_x(),
row * TILE_SIZE + 16 - my_camera.get_y(),
my_sprite_map, the_screen, &rect );
}