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