game_machine 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99584a580fcb46287f1510e15f5eeb6c31a0a02d
|
4
|
+
data.tar.gz: 3969eb2639475bdcd43849b159eb3725a708f862
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f37531bd3d9207336ecaa0685523ce0be204f3a573b99edb6d1f7e708c7bd269b505f2759f30d0e8a08334757449c6059e14fae7ada16954ea9cb4990776f3cf
|
7
|
+
data.tar.gz: 5339212baf3d33ecad28a39063359748b5ba94121801330846294e065b83841ffa6803f2e9aa6a2d5e5d4b82931c46575407ec4e146fd9bba7cbb6155e13c5e0
|
data/config/config.example.yml
CHANGED
@@ -23,7 +23,7 @@ development:
|
|
23
23
|
# router size for the udp actor that handles all incoming upd messages
|
24
24
|
udp_routers: 10
|
25
25
|
# What data store the object database will use (one of memory, mapdb, or couchbase)
|
26
|
-
data_store:
|
26
|
+
data_store: mapdb
|
27
27
|
# Advanced settings for write behind cache. -1 disables. This is fine for
|
28
28
|
# all but large games with high traffic (hundreds of writes per second)
|
29
29
|
cache_write_interval: -1
|
@@ -66,7 +66,7 @@ development:
|
|
66
66
|
game_handler_routers: 10
|
67
67
|
request_handler_routers: 10
|
68
68
|
udp_routers: 10
|
69
|
-
data_store:
|
69
|
+
data_store: mapdb
|
70
70
|
cache_write_interval: -1
|
71
71
|
cache_writes_per_second: -1
|
72
72
|
grids:
|
data/games/example/lib/npc.rb
CHANGED
@@ -73,7 +73,7 @@ module Example
|
|
73
73
|
if @players[player.id]
|
74
74
|
@players[player.id][:vector].x = player.x
|
75
75
|
@players[player.id][:vector].y = player.y
|
76
|
-
@players[player.id][:vector].z =
|
76
|
+
@players[player.id][:vector].z = player.z
|
77
77
|
else
|
78
78
|
@players[player.id] = {:id => player.id, :vector => GameMachine::Vector.from(player)}
|
79
79
|
end
|
@@ -35,7 +35,7 @@ module Example
|
|
35
35
|
|
36
36
|
# Only update position if we moved
|
37
37
|
if position_changed
|
38
|
-
commands.grid.track(id,position.x,position.y,
|
38
|
+
commands.grid.track(id,position.x,position.y,position.z)
|
39
39
|
@position_changed = false
|
40
40
|
end
|
41
41
|
|
@@ -90,25 +90,19 @@ module Example
|
|
90
90
|
# Save object creation by not using methods that return new vector
|
91
91
|
x = current_target.x - position.x
|
92
92
|
y = current_target.y - position.y
|
93
|
-
dirx = GameMachine::Vector.norm(x)
|
94
|
-
diry = GameMachine::Vector.norm(y)
|
93
|
+
dirx,diry = GameMachine::Vector.norm(x,y)
|
95
94
|
position.x += dirx * speed_scale * delta_time
|
96
95
|
position.y += diry * speed_scale * delta_time
|
97
96
|
|
98
|
-
#
|
99
|
-
#position.x +=
|
100
|
-
#position.y +=
|
97
|
+
#dir = (current_target - position).normalize
|
98
|
+
#position.x += dir.x * speed_scale * delta_time
|
99
|
+
#position.y += dir.y * speed_scale * delta_time
|
101
100
|
|
102
|
-
# Not really what we want
|
103
|
-
#position.interpolate(current_target, speed_scale * delta_time)
|
104
101
|
|
105
102
|
if position.distance(current_target) > current_distance_to_target
|
106
103
|
set_reached_target
|
107
104
|
end
|
108
105
|
|
109
|
-
#if id.match(/viking_499/) || id.match(/worm/)
|
110
|
-
# puts "#{id}: old_distance :#{current_distance_to_target} new_distance: #{position.distance(current_target)} time: #{delta_time}"
|
111
|
-
#end
|
112
106
|
@last_move = Time.now.to_f
|
113
107
|
@position_changed = true
|
114
108
|
end
|
@@ -77,9 +77,9 @@ module GameMachine
|
|
77
77
|
|
78
78
|
entity.set_vector3(
|
79
79
|
MessageLib::Vector3.new.
|
80
|
-
set_x(grid_value.x).
|
81
|
-
set_y(grid_value.y).
|
82
|
-
set_z(grid_value.z)
|
80
|
+
set_x(grid_value.x.round(4)).
|
81
|
+
set_y(grid_value.y.round(4)).
|
82
|
+
set_z(grid_value.z.round(4))
|
83
83
|
)
|
84
84
|
|
85
85
|
if EXTRA.has_key?(grid_value.id)
|
data/lib/game_machine/vector.rb
CHANGED
@@ -69,13 +69,15 @@ module GameMachine
|
|
69
69
|
self.class.new( @x - v1.x, @y - v1.y )
|
70
70
|
end
|
71
71
|
|
72
|
-
def self.norm(
|
73
|
-
|
74
|
-
|
72
|
+
def self.norm(x,y)
|
73
|
+
dx = 0.0
|
74
|
+
dy = 0.0
|
75
|
+
length = Math.sqrt(x*x + y*y)
|
75
76
|
if length != 0
|
76
|
-
|
77
|
+
dx = x * (1/length)
|
78
|
+
dy = y * (1/length)
|
77
79
|
end
|
78
|
-
|
80
|
+
[dx,dy]
|
79
81
|
end
|
80
82
|
|
81
83
|
def normalize
|
data/lib/game_machine/version.rb
CHANGED