diff --git a/app.py b/app.py index 2fbcc90..1bf4c55 100644 --- a/app.py +++ b/app.py @@ -163,7 +163,7 @@ def hello_world(): if request.method == 'GET': robot = players[player_id].robot if robot is not None: - robot_pos = (robot.x, robot.y) + robot_pos = (robot.x, robot.y, robot.orientation) else: robot_pos = None return render_template('drag_example.html', cmds=player_hand, player_id=player_id, robot_pos=robot_pos) diff --git a/static/orientation.png b/static/orientation.png new file mode 100644 index 0000000..830ffd6 Binary files /dev/null and b/static/orientation.png differ diff --git a/static/style.css b/static/style.css index 2601a3f..311d90e 100644 --- a/static/style.css +++ b/static/style.css @@ -18,6 +18,30 @@ cursor: move; } +.rotate90 { + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -o-transform: rotate(90deg); + -ms-transform: rotate(90deg); + transform: rotate(90deg); +} + +.rotate180 { + -webkit-transform: rotate(180deg); + -moz-transform: rotate(180deg); + -o-transform: rotate(180deg); + -ms-transform: rotate(180deg); + transform: rotate(180deg); +} + +.rotate270 { + -webkit-transform: rotate(270deg); + -moz-transform: rotate(270deg); + -o-transform: rotate(270deg); + -ms-transform: rotate(270deg); + transform: rotate(270deg); +} + .card0 { left: 0; top: 0; background-color: #E74C3C; } .card1 { left: 100px; top: 0; background-color: #8E44AD; } .card2 { left: 200px; top: 0; background-color: #5DADE2; } diff --git a/templates/drag_example.html b/templates/drag_example.html index b3e8184..8492c7b 100644 --- a/templates/drag_example.html +++ b/templates/drag_example.html @@ -26,23 +26,27 @@ - {% if robot_pos is none %}
+ {% if robot_pos is none %} -
+ + 0 {% else %} -
-
+ + + {% endif %} + + @@ -61,6 +65,23 @@ var box = $(".box"); var mainCanvas = $(".main-canvas"); + var orientation_icon = $("#orientation"); + + orientation_icon.click(function () { + if (this.alt === "0") { + this.alt = "90"; + } + else if (this.alt === "90") { + this.alt = "180"; + } + else if (this.alt === "180") { + this.alt = "270"; + } + else if (this.alt === "270") { + this.alt = "0"; + } + $(this).css({'transform' : 'rotate('+ this.alt +'deg)'}); + }); $("#btnSubmit").click(function () {