This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Run the physics update loop for each game registered in _games | |
/// </summary> | |
private static void ProcessGamesTick() | |
{ | |
DateTime timestamp; | |
foreach(var game in _games.Values) | |
{ | |
// If in one of the previous rounds we had a goal condition | |
if (_goalTimestamps.TryGetValue(game.GameId, out timestamp)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Compute the next state for this game, based on player inputs and ball position | |
/// </summary> | |
/// <param name="game"></param> | |
private static void ProcessTick(Game game) | |
{ | |
// 1: Apply inputs received from players (and progressively remove them from the buffer) | |
// 2: Update ball position | |
// 3: Check for collisions and if collision, update ball status | |
// 4: If no collision, check for a goal condition and update status if goal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Application_Start() | |
{ | |
AreaRegistration.RegisterAllAreas(); | |
RegisterGlobalFilters(GlobalFilters.Filters); | |
RegisterRoutes(RouteTable.Routes); | |
InMemoryUserRepository.GetInstance().ConnectedUsers.ToList().Clear(); | |
InMemoryUserRepository.GetInstance().WaitingList.ToList().Clear(); | |
InMemoryRoomRepository.GetInstance().Rooms.ToList().Clear(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Invoked when a new client joins the system | |
/// </summary> | |
public void Joined() | |
{ | |
// 1: Add user to list of connected users | |
// 2: If waiting list is empty add user to waiting list | |
// 3: Else find an opponent (first in the waiting list) and remove him from the waiting list | |
// 4: Create room and assign both users | |
// 5: Create a group for this room |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
var username = @Html.Raw(Json.Encode(Model)); | |
PongR.createInstance(1200,600,username); | |
PongR.connect(); | |
}); | |
pongR.PublicPrototype.connect = function () { | |
$.connection.hub.start() | |
.done(function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
var chat = new chatR.chatViewModel(); | |
var users = new chatR.connectedUsersViewModel(); | |
var currentUser = new chatR.user(@Html.Raw(Json.Encode(Model))); // The username chose by the user is stored in the model | |
// Proxy creation | |
var chatHub = $.connection.chatHub; // chatHub is the name of the Hub as declared in server side code | |
chatHub.username = currentUser.username; // This is the round-trip state | |
// Client-side event handlers, as declared inside the Hub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ChatR.Hubs | |
{ | |
public class ChatHub : Hub, IDisconnect | |
{ | |
private InMemoryRepository _repository; | |
public ChatHub() | |
{ | |
_repository = InMemoryRepository.GetInstance(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Author: Valerio Gheri | |
* Date: 22/07/2012 | |
* Description: ChatR namespace js file and viewmodels declaration | |
*/ | |
// Namespace | |
var chatR = {}; | |
// Models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="myContainer" class="container-fluid"> | |
<div class="row-fluid"> | |
<!-- This is the contact box --> | |
<div id="users-list" class="span2"> | |
<h4>Users</h4> | |
<ul data-bind="foreach: contacts"> | |
<li class="user-box"><span class="user-box-name" data-bind="text: username"></span></li> | |
</ul> | |
</div> | |
<!-- This is the chat box --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@if (false) { | |
<script src="../../Scripts/jquery-1.7.2-vsdoc.js" type="text/javascript"></script> | |
<script src="../../JS/iLikeIt.js" type="text/javascript"></script> | |
} | |
<div class="container"> | |
<h1>iLikeIt!</h1> | |
<br /> | |
<h3>iLikeIt! is a simple, proof of concept, image voting system</h3> |