Skip to content

Commit

Permalink
Added initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
janne committed Apr 23, 2012
1 parent a02d301 commit 76c9351
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/client.coffee
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,10 @@
Template.board.column = -> [0..SIDE-1]

Meteor.startup ->
square_i = 0
squares = Square.find().fetch()
for col in [HOME_SQUARES+1..HOME_SQUARES+2]
for row in [0..HOME_SQUARES]
square = squares[square_i++]
# $('table#board tr#row_' + row + ' td#col_' + col).html(Meteor.ui.render -> Template.square({square: square}))
$('table#board tr#row_' + row + ' td#col_' + col).html(Template.square({square: square}))
15 changes: 15 additions & 0 deletions client/ludo.css
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,15 @@
table#board td {
border: solid 1px #aaa;
width: 20px;
height: 20px;
}

.red { background: #f00; }
.green { background: #0f0; }
.blue { background: #00f; }
.yellow { background: #ff0; }

div.square {
width: 100%;
height: 100%;
}
26 changes: 26 additions & 0 deletions client/ludo.html
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,26 @@
<head>
<title>Meteor Ludo</title>
</head>

<body>
{{> board}}
</body>

<template name="board">
<table id="board">
{{#each column}}
<tr id="row_{{this}}">
{{#each column}}
<td id="col_{{this}}">
</td>
{{/each}}
</tr>
{{/each}}
</table>
</template>

<template name="square">
<div class="square">
x
</div>
</template>
16 changes: 16 additions & 0 deletions model.coffee
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,16 @@
@HOME_SQUARES = 4
@PLAYER_DIFF = 2 + 2 * HOME_SQUARES
@SIDE = 3 + 2 * HOME_SQUARES
# @OUTER_LENGTH = 8 + 8 * HOME_SQUARES
# @TOTAL_LENGTH = OUTER_LENGTH + HOME_SQUARES

@COLORS = ['#f00', '#0f0', '#00f', '#ff0']

# { color }
@Square = new Meteor.Collection('square')

# { color, start_square }
@Player = new Meteor.Collection('player')

# { player, square }
@Piece = new Meteor.Collection('piece')
8 changes: 8 additions & 0 deletions server/server.coffee
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,8 @@
Meteor.startup ->
for player_id in [0..3]
color = COLORS[player_id]
player = Player.insert {color: color}
for num in [0..3]
Piece.insertplayer: player, square: null }
for num in [0..PLAYER_DIFF-1]
Square.insert {color: color}

0 comments on commit 76c9351

Please sign in to comment.