physicist 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/physicist/body.rb +2 -8
- data/lib/physicist/laboratory/app.rb +0 -5
- data/lib/physicist/laboratory/handlers/create_scientist_handler.rb +0 -3
- data/lib/physicist/laboratory/handlers/move_scientist_handler.rb +1 -1
- data/lib/physicist/laboratory/listeners/scientist_updated_event_listener.rb +0 -1
- data/lib/physicist/laboratory/models/scientist.rb +1 -4
- data/lib/physicist/laboratory/screen.rb +1 -1
- data/lib/physicist/laboratory/views/scientist_view.rb +1 -1
- data/lib/physicist/simple_body.rb +0 -2
- data/lib/physicist/version.rb +1 -1
- data/spec/physicist_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25ec556fd4d506229e77d77f8d449b1c3d0f54b1
|
4
|
+
data.tar.gz: 0c1a334ccf5cbf505e87606ab54fc484947f4c00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1925d82228e4c198913dd95e24a1884ffd3a1454300c1f00b771064054c795a6e667c154adf0326ac5a2eff264485c8078a0c406c85bb81b3e2a798e1bd8ec05
|
7
|
+
data.tar.gz: 4212d6b0ef66e42ca3018960b86949b7da0e6050136c7feb2e818231525819e47f6b5b80e98d46e03712a39053ba74f0577a40ae14b3e362f4dab859f62bd456
|
data/lib/physicist/body.rb
CHANGED
@@ -26,7 +26,6 @@ module Physicist
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def at(t, obstacles:[])
|
29
|
-
# p [ :body, at: t, pos: position, vel: velocity ]
|
30
29
|
x0, _ = *position
|
31
30
|
vx0,vy0 = *velocity
|
32
31
|
|
@@ -87,15 +86,10 @@ module Physicist
|
|
87
86
|
end
|
88
87
|
|
89
88
|
distance_travelled_in_x_axis_if_no_obstacles = vx * dt
|
90
|
-
p [ :next_x_obs, at: ox, distance: distance_to_next_x_obstacle, distance_without_obs: distance_travelled_in_x_axis_if_no_obstacles ]
|
91
|
-
# require 'pry'
|
92
|
-
# binding.pry
|
93
89
|
|
94
90
|
if distance_travelled_in_x_axis_if_no_obstacles.abs < distance_to_next_x_obstacle
|
95
|
-
p [ :travel_x_less_than_obs_x ]
|
96
91
|
yield [x0 + (vx*dt), vx]
|
97
92
|
else
|
98
|
-
p [ :travel_x_more_than_obs_x ]
|
99
93
|
if vx > 0
|
100
94
|
yield [next_x_obstacle.position[0]-width, 0]
|
101
95
|
else
|
@@ -126,8 +120,8 @@ module Physicist
|
|
126
120
|
yield [y0 + (vy * dt), vy ]
|
127
121
|
else
|
128
122
|
if vy > 0
|
129
|
-
yield [next_y_obstacle.position[1] -
|
130
|
-
else
|
123
|
+
yield [next_y_obstacle.position[1] - (height) - 0.001, 0]
|
124
|
+
else
|
131
125
|
yield [next_y_obstacle.position[1] + next_y_obstacle.dimensions[1] + 0.1, 0]
|
132
126
|
end
|
133
127
|
end
|
@@ -31,7 +31,6 @@ module Physicist
|
|
31
31
|
attr_accessor :scientist
|
32
32
|
|
33
33
|
def setup(*)
|
34
|
-
p [ :lab_setup! ]
|
35
34
|
fire(
|
36
35
|
create_scientist(
|
37
36
|
scientist_id: scientist_id,
|
@@ -55,12 +54,8 @@ module Physicist
|
|
55
54
|
end
|
56
55
|
|
57
56
|
# TODO
|
58
|
-
p [ :check_jump ]
|
59
57
|
if window.button_down?(Gosu::KbUp)
|
60
|
-
p [ :jump! ]
|
61
58
|
fire(jump)
|
62
|
-
else
|
63
|
-
p [ :no_jump! ]
|
64
59
|
end
|
65
60
|
end
|
66
61
|
|
@@ -2,8 +2,6 @@ module Physicist
|
|
2
2
|
module Laboratory
|
3
3
|
class CreateScientistHandler
|
4
4
|
def handle(scientist_id:, name:, title:, position:, velocity:)
|
5
|
-
p [ :creating_space ]
|
6
|
-
|
7
5
|
map_data = (
|
8
6
|
[
|
9
7
|
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ],
|
@@ -20,7 +18,6 @@ module Physicist
|
|
20
18
|
|
21
19
|
space = Space.create(grid_map: map_data)
|
22
20
|
|
23
|
-
p [ :creating_scientist, name: name ]
|
24
21
|
space.create_scientist(
|
25
22
|
id: scientist_id,
|
26
23
|
name: name,
|
@@ -2,7 +2,6 @@ module Physicist
|
|
2
2
|
module Laboratory
|
3
3
|
class ScientistUpdatedEventListener < Metacosm::EventListener
|
4
4
|
def receive(scientist_id:, position:, velocity:, updated_at:)
|
5
|
-
p [ :scientist_updated, pos: position, vel: velocity ]
|
6
5
|
scientist_view = ScientistView.find_by(scientist_id: scientist_id)
|
7
6
|
scientist_view.update(
|
8
7
|
position: position,
|
@@ -39,9 +39,7 @@ module Physicist
|
|
39
39
|
dvx = direction == :left ? -speed : speed
|
40
40
|
vxt = vx + dvx
|
41
41
|
return unless vxt.abs < max_ground_speed
|
42
|
-
p [ :move, dir: direction, current: current, dvx: dvx, vxt: vxt ]
|
43
42
|
|
44
|
-
# TODO more specific event?
|
45
43
|
update(
|
46
44
|
position: current.position,
|
47
45
|
velocity: [vxt, vy],
|
@@ -50,7 +48,6 @@ module Physicist
|
|
50
48
|
end
|
51
49
|
|
52
50
|
def jump
|
53
|
-
p [ :jump, current: current ]
|
54
51
|
vx, vy = *current.velocity
|
55
52
|
return if vy.abs > 0.0
|
56
53
|
|
@@ -76,7 +73,7 @@ module Physicist
|
|
76
73
|
position: position,
|
77
74
|
velocity: velocity,
|
78
75
|
t0: updated_at || Time.now,
|
79
|
-
dimensions: [
|
76
|
+
dimensions: [2,2]
|
80
77
|
)
|
81
78
|
end
|
82
79
|
end
|
@@ -8,7 +8,6 @@ module Physicist
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.collection_from_tiles(tile_grid)
|
11
|
-
# p [ :assembling_bodies_from_tiles, grid: tile_grid ]
|
12
11
|
simple_bodies = []
|
13
12
|
|
14
13
|
tile_grid.each_with_index do |row, y|
|
@@ -19,7 +18,6 @@ module Physicist
|
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
# p [ bodies: simple_bodies ]
|
23
21
|
simple_bodies
|
24
22
|
end
|
25
23
|
end
|
data/lib/physicist/version.rb
CHANGED
data/spec/physicist_spec.rb
CHANGED
@@ -96,7 +96,7 @@ describe Body do
|
|
96
96
|
_,vy = *body_at_t.velocity
|
97
97
|
_,y = *body_at_t.position
|
98
98
|
expect(vy).to eq(0)
|
99
|
-
expect(y0
|
99
|
+
expect(y0 - 0.001).to eq(y)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -113,7 +113,7 @@ describe Body do
|
|
113
113
|
it 'should stop vertical movement after 1s' do
|
114
114
|
_,vy = *body_at_t.velocity
|
115
115
|
_,y = *body_at_t.position
|
116
|
-
expect(y0 +
|
116
|
+
expect(y0 + 9.799).to eq(y)
|
117
117
|
expect(vy).to eq(0)
|
118
118
|
end
|
119
119
|
end
|