Slide 78
Slide 78 text
def update
begin
move_tank
px, py = @me.x, @me.y
@me.move
@me.warp_to(px, py) if @me.hit_wall? or @me.outside_battlefield?
@other_tanks.each do |player, tank|
@me.warp_to(px, py) if tank.alive? and @me.collide_with?(tank, 30)
end
add_to_message_queue('obj', @me)
@other_shots.each_value do |shot|
if @me.alive? and @me.collide_with?(shot, 16)
@me.hit
add_to_message_queue('obj', @me)
end
end
@me_shots.each do |shot|
shot.move # move the bullet
if shot.hit_wall? or shot.outside_battlefield?
@me_shots.delete shot
add_to_message_queue('del', shot)
else
add_to_message_queue('obj', shot)
end
end
@client.send_message @messages.join("\n")
@messages.clear
check the other shots
on screen to see if it
hits me, if it does, tell
the server I was hit
Sunday, 9 June, 13