Commit ab170164 authored by Hubert Denkmair's avatar Hubert Denkmair
Browse files

follow message / unfollow feature

parent 5f40dc21
......@@ -48,6 +48,7 @@ ul.nav li a, .footer a {
ul.nav li:hover {
background-color: #804600;
}
a:hover {
text-decoration: underline;
}
......@@ -153,4 +154,18 @@ table.snake-list {
#bot_stats tbody {
cursor:pointer;
}
\ No newline at end of file
}
#followmsg {
position: absolute;
top:0; left:0; right:0;
text-align: center;
display:none;
cursor:pointer;
}
#followmsg>span {
background-color:rgba(60,60,60,0.7);
border-radius: 0 0 0.5em 0.5em;
padding: 0.1em 0.5em;
}
......@@ -11,6 +11,14 @@ function Game(assets, snakeMoveStrategy, container)
this.logHandlers = [];
this.gameInfoReceived = false;
this.preGameInfoMessages = [];
let vis=this.vis;
$("#followmsg").click(function(event) {
vis.Unfollow();
$("#followmsg").hide();
event.preventDefault();
});
}
Game.prototype.AddLogHandler = function(callback, thisArg)
......
......@@ -247,11 +247,19 @@ GameVisualization.prototype.FollowName = function(name)
let snake = this.snakes[id];
if (snake.GetName() == this.follow_name)
{
this.viewport.follow(snake.GetHeadSprite(), { radius: 200 });
$("#followmsg>span>span").text(this.follow_name);
$("#followmsg").show();
this.viewport.follow(snake.GetHeadSprite(), { radius: 0 });
}
}
};
GameVisualization.prototype.Unfollow = function()
{
this.follow_name = null;
delete this.viewport.plugins['follow'];
};
GameVisualization.prototype.UpdateStagePosition = function()
{
if ((++this.updateVisibilityCounter < 25) || (!this.foodMap))
......
......@@ -2,13 +2,20 @@
{% load static %}
{% block content %}
<div id="stage" class="fullwindow" style="background-color:#00000080"></div>
<div id="stage" class="fullwindow" style="background-color:#00000080">
<div id="followmsg">
<span>
Following <span></span>.
Click here to stop.
</span>
</div>
</div>
<table id="bot_stats">
<thead>
<tr>
<td>Snake</td>
<td>natural</td>
<td>carrison</td>
<td>carrion</td>
<td>hunted</td>
</tr>
</thead>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment