Skip to content

Commit

Permalink
horrible hack to display names for actual players
Browse files Browse the repository at this point in the history
  • Loading branch information
wchristian committed May 7, 2015
1 parent c32bb7b commit 35e7843
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
16 changes: 15 additions & 1 deletion lib/Microidium/ClientRole.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];

Expand Down
1 change: 1 addition & 0 deletions lib/Microidium/LogicRole.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/Microidium/SDLRole.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 35e7843

Please sign in to comment.