New fire code.
parent
f4a74ec7dc
commit
dab79a6a80
|
@ -30,31 +30,36 @@ cannon = None
|
|||
@app.route("/left/<int:amount>", methods=["POST"])
|
||||
def move_left(amount):
|
||||
cannon.move_left(amount)
|
||||
cannon.send_data()
|
||||
return "OK"
|
||||
|
||||
@app.route("/right/<int:amount>", methods=["POST"])
|
||||
def move_right(amount):
|
||||
cannon.move_right(amount)
|
||||
cannon.send_data()
|
||||
return "OK"
|
||||
|
||||
@app.route("/up/<int:amount>", methods=["POST"])
|
||||
def move_up(amount):
|
||||
cannon.move_up(amount)
|
||||
cannon.send_data()
|
||||
return "OK"
|
||||
|
||||
@app.route("/down/<int:amount>", methods=["POST"])
|
||||
def move_down(amount):
|
||||
cannon.move_down(amount)
|
||||
cannon.send_data()
|
||||
return "OK"
|
||||
|
||||
@app.route("/fire/", methods=["POST"])
|
||||
@app.route("/fire", methods=["POST"])
|
||||
def fire():
|
||||
cannon.fire();
|
||||
cannon.fire()
|
||||
cannon.send_data()
|
||||
|
||||
@app.route("/stop_fire/", methods=["POST"])
|
||||
def stop_fire():
|
||||
cannon.fired = False;
|
||||
|
||||
pass
|
||||
|
||||
@app.route("/status")
|
||||
def status():
|
||||
return json.dumps(cannon.get_data())
|
||||
|
@ -66,8 +71,11 @@ def root():
|
|||
|
||||
#Camera stuff
|
||||
|
||||
camera = pygame.camera.Camera("/dev/video0", (640, 480))
|
||||
camera.start()
|
||||
try:
|
||||
camera = pygame.camera.Camera("/dev/video0", (640, 480))
|
||||
camera.start()
|
||||
except:
|
||||
camera = None
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -226,8 +234,9 @@ class Screen:
|
|||
self.print_text(text, 20, 20 + i*20, (0, 0, 0), 30, self.window)
|
||||
|
||||
self.print_text([str(x) for x in cannon.get_data()].__str__(), 20, 300, (0, 0, 0), 30, self.window)
|
||||
image = camera.get_image()
|
||||
self.window.blit(image, (CAMERA_X, CAMERA_Y))
|
||||
if camera:
|
||||
image = camera.get_image()
|
||||
self.window.blit(image, (CAMERA_X, CAMERA_Y))
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
|
|
Loading…
Reference in New Issue