@@ -29,12 +29,12 @@ int main() {
2929 colors [LIGHT_GROUND ] = TCOD_color_RGB (200 , 180 , 50 );
3030
3131 struct entity_list * entities_list_head ;
32- struct entity_list * player ;
32+ struct entity * player ;
3333 entities_list_head = (struct entity_list * ) malloc (sizeof (struct entity_list ));
3434 entities_list_head -> next = NULL ;
35- player = entities_list_head ;
3635 struct fighter * fighter = create_fighter (30 , 2 , 5 );
37- player -> data = create_entity (screen_width / 2 , screen_height / 2 , '@' , TCOD_white , "Player" , true, fighter , NULL );
36+ entities_list_head -> data = create_entity (screen_width / 2 , screen_height / 2 , '@' , TCOD_white , "Player" , true, fighter , NULL );;
37+ player = entities_list_head -> data ;
3838 TCOD_console_set_custom_font ("terminal16x16_gs_ro.png" ,
3939 TCOD_FONT_TYPE_GRAYSCALE | TCOD_FONT_LAYOUT_ASCII_INROW ,
4040 16 ,
@@ -43,7 +43,7 @@ int main() {
4343 TCOD_console_t con = TCOD_console_new (screen_width , screen_height );
4444
4545 struct game_map * map = create_game_map (map_width , map_height );
46- make_map (map , max_rooms , room_min_size , room_max_size , map_width , map_height , player -> data , entities_list_head ,
46+ make_map (map , max_rooms , room_min_size , room_max_size , map_width , map_height , player , entities_list_head ,
4747 max_monsters_per_room );
4848
4949 TCOD_key_t * key ;
@@ -62,7 +62,7 @@ int main() {
6262 TCOD_sys_check_for_event (TCOD_EVENT_KEY_PRESS , key , mouse );
6363
6464 if (fov_recompute ) {
65- recompute_fov (fov_map , player -> data -> x , player -> data -> y , fov_radius , fov_light_walls , fov_algorithm );
65+ recompute_fov (fov_map , player -> x , player -> y , fov_radius , fov_light_walls , fov_algorithm );
6666 }
6767 render_all (con , entities_list_head , map , fov_map , fov_recompute , screen_width , screen_height , colors );
6868 fov_recompute = false;
@@ -73,20 +73,21 @@ int main() {
7373
7474 handle_keys (key , action );
7575 if (action -> type != NO_ACTION ) {
76+
7677#pragma clang diagnostic push
7778#pragma ide diagnostic ignored "OCDFAInspection"
7879 if (action -> type == MOVE && game_state == PLAYERS_TURN ) {
7980 int dx = action -> data .move .dx ;
8081 int dy = action -> data .move .dy ;
81- int destination_x = player -> data -> x + dx ;
82- int destination_y = player -> data -> y + dy ;
82+ int destination_x = player -> x + dx ;
83+ int destination_y = player -> y + dy ;
8384 if (!is_blocked (map , destination_x , destination_y )) {
8485 struct entity * target = get_blocking_entities_at_location (entities_list_head , destination_x ,
8586 destination_y );
8687 if (target ) {
87- printf ( "You kick the %s in the shins, much to its annoyance!\n" , target -> name );
88+ attack ( player , target );
8889 } else {
89- move (player -> data , dx , dy );
90+ move (player , dx , dy );
9091 fov_recompute = true;
9192 }
9293 }
@@ -102,7 +103,7 @@ int main() {
102103 struct entity_list * curr = entities_list_head ;
103104 while (curr != NULL ) {
104105 if (curr -> data -> ai_action ) {
105- (* curr -> data -> ai_action )(curr -> data , player -> data , fov_map , map , entities_list_head );
106+ (* curr -> data -> ai_action )(curr -> data , player , fov_map , map , entities_list_head );
106107 }
107108 curr = curr -> next ;
108109 }
0 commit comments