Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Change velocity and acceleration constants.

  • Loading branch information...
commit 6cae2288594fec88d37e8556574c4a0771adb12c 1 parent d8b6736
Jeffrey T. Palmer authored
2  lib/Games/Maze/SDL.pm
@@ -41,7 +41,7 @@ sub run {
41 41 my $height = $cell_height * $cells_y;
42 42 my $player_width = 24;
43 43 my $player_height = 24;
44   - my $dt = 25;
  44 + my $dt = 0.025;
45 45
46 46 my $maze_model = Games::Maze::SDL::Model::Maze->new(
47 47 cells_x => $cells_x,
12 lib/Games/Maze/SDL/Model/Player.pm
@@ -64,7 +64,7 @@ has 'velocity_y' => (
64 64 has 'max_velocity' => (
65 65 is => 'ro',
66 66 isa => 'Num',
67   - default => 0.1,
  67 + default => 100,
68 68 );
69 69
70 70 has 'acceleration_y' => (
@@ -106,18 +106,18 @@ after 'direction' => sub {
106 106 my $d = shift;
107 107 if ( $d eq 'north' ) {
108 108 $self->acceleration_x(0);
109   - $self->acceleration_y(-0.0001);
  109 + $self->acceleration_y(-100);
110 110 }
111 111 if ( $d eq 'south' ) {
112 112 $self->acceleration_x(0);
113   - $self->acceleration_y(0.0001);
  113 + $self->acceleration_y(100);
114 114 }
115 115 if ( $d eq 'west' ) {
116   - $self->acceleration_x(-0.0001);
  116 + $self->acceleration_x(-100);
117 117 $self->acceleration_y(0);
118 118 }
119 119 if ( $d eq 'east' ) {
120   - $self->acceleration_x(0.0001);
  120 + $self->acceleration_x(100);
121 121 $self->acceleration_y(0);
122 122 }
123 123
@@ -163,7 +163,7 @@ sub move {
163 163 }
164 164 }
165 165
166   - if (abs($v{$dim}) < 1.0e-3) {
  166 + if ( abs( $v{$dim} ) < 1.0 ) {
167 167 $v{$dim} = 0;
168 168 }
169 169
2  lib/Games/Maze/SDL/View/Player.pm
@@ -69,7 +69,7 @@ sub handle_event {
69 69 $self->sprite->x( $self->model->x );
70 70 $self->sprite->y( $self->model->y );
71 71 $self->sprite->ticks_per_frame(
72   - floor( 0.2 / $self->model->velocity ) + 5 );
  72 + floor( 200 / $self->model->velocity ) + 5 );
73 73 }
74 74 elsif ( $event->{type} eq 'turned' ) {
75 75 $self->sprite->sequence( $self->model->direction );

0 comments on commit 6cae228

Please sign in to comment.
Something went wrong with that request. Please try again.