Stubbed Connection, added #next_entity_id to Player, made Director store and pass to Player the current_tick

This commit is contained in:
2019-10-03 10:40:57 -05:00
parent 8be63d8ebe
commit 3dd067612a
6 changed files with 39 additions and 12 deletions

View File

@@ -1,13 +1,16 @@
class IMICRTS
class Director
attr_reader :current_tick
def initialize(map:, players:, networking_mode: :virtual, tick_rate: 10)
@map = map
@players = players
@connection = IMICRTS::Connection.new(director: self, mode: networking_mode)
@networking_mode = networking_mode
@tick_rate = tick_rate
@last_tick_at = Gosu.milliseconds
@tick_time = 1000.0 / @tick_rate
@current_tick = 0
end
def update
@@ -15,11 +18,14 @@ class IMICRTS
@last_tick_at = Gosu.milliseconds
tick
@connection.update
end
end
def tick
@players.each(&:tick)
@players.each { |player| player.tick(@current_tick) }
@current_tick += 1
end
def player(id)