crashtest-r0ket/tools/game/simpletest.py

24 lines
651 B
Python
Raw Normal View History

2011-12-15 18:09:05 +00:00
import r0ketrem0te.game
import r0ketrem0te.bridge
2011-12-14 16:59:32 +00:00
import r0ketrem0te.packets
2011-12-12 17:02:24 +00:00
import time
2011-12-14 16:59:32 +00:00
import Queue
2011-12-15 18:09:05 +00:00
def receivedPacket(packet):
if isinstance(packet, r0ketrem0te.packets.Join):
# flags = 1: join ok
# flags = 0: join not ok
ack = r0ketrem0te.packets.Ack(packet.id, packet.ctr, 1)
qp = r0ketrem0te.bridge.QueuePacket(game.channel, game.playermac, False, ack)
game.bridge.putInQueue(queue, qp)
2011-12-14 16:59:32 +00:00
2011-12-15 18:09:05 +00:00
game = r0ketrem0te.game.Game('/dev/ttyACM0', "testgame", 83, 81, (1,2,3,2,1))
2011-12-14 16:59:32 +00:00
2011-12-15 18:09:05 +00:00
queue = Queue.Queue()
game.bridge.registerQueue(queue)
game.bridge.registerCallback(receivedPacket)
2011-12-12 17:02:24 +00:00
while True:
2011-12-15 18:09:05 +00:00
time.sleep(1)
2011-12-12 17:02:24 +00:00