diff --git a/lib/Microidium/ClientRole.pm b/lib/Microidium/ClientRole.pm index f013c23..0a3ad76 100644 --- a/lib/Microidium/ClientRole.pm +++ b/lib/Microidium/ClientRole.pm @@ -427,9 +427,23 @@ sub play_sound { } sub render_ui { - my ( $self, $game_state ) = @_; + my ( $self, $game_state, $client_game_state ) = @_; my $player_actor = $self->local_player_actor; my @texts; + + my $cam_pos = $client_game_state->{camera}{pos}; + my $half_height = $self->height / 2; + my $half_width = $self->width / 2; + my %names = ( 1 => "Mithaldu", 2 => "burnersk" ); + + for my $flier ( grep { !$_->{is_bullet} and $_->{team} == 1 } values %{ $game_state->{actors} } ) { + my ( $x, $y ) = map { $flier->{$_} - $cam_pos->{$_} } qw( x y ); + $y = $half_height + $half_height * $y / $self->display_scale; + $x = $half_width + $half_width * $x / $self->display_scale / $self->aspect_ratio; + my $name = $flier->{player_name}; + push @texts, [ [ $x, $y ], $names{$name} || $name ]; + } + push @texts, [ [ 0, $self->height - 12 ], "Controls: left up right d - Quit: q - Connect to server: n - Zoom in/out: o l" ]; diff --git a/lib/Microidium/LogicRole.pm b/lib/Microidium/LogicRole.pm index 4d801ad..5c4ddb5 100644 --- a/lib/Microidium/LogicRole.pm +++ b/lib/Microidium/LogicRole.pm @@ -127,6 +127,7 @@ sub plan_player_respawns { team => 1, hp => 12, player_id => $player->{id}, + player_name => $player->{id}, is_thrusting => 1, is_turning_left => 0, is_turning_right => 0, diff --git a/lib/Microidium/SDLRole.pm b/lib/Microidium/SDLRole.pm index 7c38291..a97d5d4 100644 --- a/lib/Microidium/SDLRole.pm +++ b/lib/Microidium/SDLRole.pm @@ -292,7 +292,7 @@ sub render { $self->render_screen_target; push $self->timestamps, [ screen_render_end => time ]; - $self->render_ui( $game_state ); + $self->render_ui( $game_state, $self->client_game_state ); push $self->timestamps, [ ui_render_end => time ]; return;