Moved the score to center of the screen

master
Abhinav Sarkar 2013-10-15 19:30:06 +05:30
parent 3b4171c716
commit daae81a751
2 changed files with 10 additions and 1 deletions

View File

@ -34,6 +34,12 @@ body {
#canvas { #canvas {
border: 2px green solid; border: 2px green solid;
} }
#score {
font-size: 70px;
text-anchor: middle;
dominant-baseline: central;
}
</style> </style>
</head> </head>
<body> <body>
@ -49,13 +55,13 @@ body {
</span> </span>
</div> </div>
<svg id="canvas"> <svg id="canvas">
<text id="score">0</text>
<circle id="ball" /> <circle id="ball" />
<rect id="lpaddle" /> <rect id="lpaddle" />
<rect id="rpaddle" /> <rect id="rpaddle" />
</svg> </svg>
<div> <div>
<div style="float: left"> <div style="float: left">
score <span id="score">0</span>
fps <span id="fps">0</span> fps <span id="fps">0</span>
</div> </div>
use W-S keys to move the left paddle and Up-Down arrow keys to move the right paddle use W-S keys to move the left paddle and Up-Down arrow keys to move the right paddle

View File

@ -86,6 +86,9 @@
(dom/set-attr! "r" *ball-radius*) (dom/set-attr! "r" *ball-radius*)
(dom/set-attr! "cx" (first *center*)) (dom/set-attr! "cx" (first *center*))
(dom/set-attr! "cy" (second *center*))) (dom/set-attr! "cy" (second *center*)))
(doto (dom/by-id "score")
(dom/set-attr! "x" (first *center*))
(dom/set-attr! "y" (second *center*)))
(doseq [id ["lpaddle" "rpaddle"]] (doseq [id ["lpaddle" "rpaddle"]]
(doto (dom/by-id id) (doto (dom/by-id id)
(dom/set-attr! "width" *paddle-width*) (dom/set-attr! "width" *paddle-width*)