Add navigation links

This commit is contained in:
Neale Pickett 2010-07-22 18:08:55 -06:00
parent 7be64ca1fc
commit fc98369eba
11 changed files with 58 additions and 34 deletions

View File

@ -1,7 +1,7 @@
CFLAGS = -Wall
all: html run-tanks designer.cgi
html: forf.html
html: forf.html procs.html intro.html
run-tanks: run-tanks.o ctanks.o forf.o
run-tanks: LDFLAGS = -lm
@ -10,8 +10,10 @@ run-tanks.o: forf.h ctanks.h
forf.o: forf.c forf.h
ctanks.o: ctanks.h
forf.html: forf.html.sh forf/forf.txt
./forf.html.sh > $@
%.html: %.html.m4
m4 $< > $@
forf.html: forf/forf.txt
forf.%: forf/forf.%
cp forf/$@ $@

View File

@ -1,10 +1,11 @@
#ifndef __CTANKS_H__
#define __CTANKS_H__
/* Some useful constants */
/* τ = 2π */
#define TAU 6.28318530717958647692
#define PI 3.14159265358979323846
/* Some in-game constants */
#define TANK_MAX_SENSORS 10
#define TANK_RADIUS 7.5
#define TANK_SENSOR_RANGE 100

View File

@ -30,7 +30,7 @@ h1:first-child:before {
/*** left side bar ***/
#navigation {
nav {
position: absolute;
background: #222;
opacity: 0.9;
@ -39,18 +39,18 @@ h1:first-child:before {
padding: 0;
}
#navigation h3 {
nav h2 {
font-size: 100%;
border-bottom: 2px solid #444;
}
#navigation ul {
nav ul {
list-style: none;
padding: 0;
margin: 0;
}
#navigation li a {
nav li a {
display: block;
height: 25px;
width: 90px;
@ -63,13 +63,13 @@ h1:first-child:before {
font-size: 0.9em;
}
#navigation li a:hover {
nav li a:hover {
color: #f4f4f4;
background: #333;
border-right: 4px solid #2a2;
}
#navigation li .active {
nav li .active {
color: #999;
background: #333;
border-right: 4px solid #444;

5
dump.h
View File

@ -2,6 +2,10 @@
#include <stdio.h>
#ifndef TAU
#define TAU 6.28318530717958647692
#endif
/* Debugging */
#define DUMPf(fmt, args...) fprintf(stderr, "%s:%s:%d " fmt "\n", __FILE__, __FUNCTION__, __LINE__, ##args)
#define DUMP() DUMPf("")
@ -12,6 +16,7 @@
#define DUMP_f(v) DUMPf("%s = %f", #v, v)
#define DUMP_p(v) DUMPf("%s = %p", #v, v)
#define DUMP_xy(v) DUMPf("%s = (%f, %f)", #v, v[0], v[1]);
#define DUMP_angle(v) DUMPf("%s = %.3fτ", #v, (v/TAU));
/* Tektronix 4014 drawing */
#define TEK_ENABLE "\033[?38h"

11
forf.html.sh → forf.html.m4 Executable file → Normal file
View File

@ -1,6 +1,4 @@
#! /bin/sh
cat <<EOF
<!DOCTYPE html>
<html>
<head>
<title>Forf Manual</title>
@ -8,9 +6,8 @@ cat <<EOF
<link rel="stylesheet" href="dirtbags.css" type="text/css">
</head>
<body>
EOF
markdown forf/forf.txt
cat <<EOF
syscmd(markdown forf/forf.txt)
include(nav.html.inc)
</body>
</html>
EOF

View File

@ -143,4 +143,5 @@ get-turret 12 + set-turret! ( Rotate turret )
</dl>
Good luck blowing everybody up!
include(nav.html.inc)
</html>

10
nav.html.inc Normal file
View File

@ -0,0 +1,10 @@
<nav>
<h2>Resources</h2>
<ul>
<li><a href="summary.html">Summary</a></li>
<li><a href="intro.html">Introduction</a></li>
<li><a href="forf.html">Forf manual</a></li>
<li><a href="procs.html">Tanks procedures</a></li>
<li><a href="designer.html">Tanks designer</a></li>
</ul>
</nav>

View File

@ -66,6 +66,8 @@
<dd>Returns a random number in the range [0, n). That is, between
0 and n-1, inclusive.</dd>
</dl>
include(nav.html.inc)
</body>
</html>

View File

@ -65,10 +65,10 @@ END {
if (killer[id]) {
reason[id] = reason[id] " (" name[killer[id]] ")";
}
print score[id] >> (path[id] "/points");
}
# Give the winner a point
print "1" >> (path[winner] "/points");
# Dole out points
# Output the table
print "<table id=\"results\">";

View File

@ -41,11 +41,13 @@ window.onload = go;
</script>
</head>
<body>
<h1>Tanks Round $next</h1>
<div id="game_box"><canvas id="battlefield"></canvas></div>
<p><span id="fps">0</span> fps</p>
EOF
./rank.awk $rfn >>$fn
rm -f $rfn
cat nav.html.inc >>$fn
cat <<EOF >>$fn
</body>
</html>

View File

@ -8,6 +8,8 @@ function esc(s) {
}
BEGIN {
ngames = 20;
print "<!DOCTYPE html>";
print "<html>";
print " <head>";
@ -17,15 +19,9 @@ BEGIN {
print " <body>";
print " <h1>Dirtbags Tanks</h1>";
print " <h2>Resources</h2>";
print " <ul>";
print " <li><a href=\"intro.html\">Introduction</a></li>";
print " <li><a href=\"forf.html\">Forf manual</a></li>";
print " <li><a href=\"procs.html\">Tanks procedures</a></li>";
print " <li><a href=\"designer.html\">Tanks designer</a></li>";
print " </ul>";
print " <p>New here? Read the <a href=\"intro.html\">introduction</a>.</p>";
print " <h2>Rankings</h2>";
print " <p>Over the last 20 games only.</p>";
print " <ol>";
for (i = 1; i < ARGC; i += 1) {
id = ARGV[i];
@ -43,13 +39,16 @@ BEGIN {
color[id] = "#c0c0c0";
}
p = 0;
while (1 == getline < (id "/points")) {
p += $0;
for (j = 0; 1 == getline < (id "/points"); j += 1) {
pts[id, j % ngames] = int($0);
}
scores[p] = p;
points[id] = p;
nscores
total = 0;
for (j = 0; j < ngames; j += 1) {
total += pts[id, j];
}
scores[total] = total;
points[id] = total;
}
while (1) {
# Find highest score
@ -66,7 +65,7 @@ BEGIN {
for (id in points) {
if (points[id] == maxscore) {
printf("<li><span class=\"swatch\" style=\"background-color: %s;\">#</span> %s (%d wins)</li>\n", color[id], names[id], points[id]);
printf("<li><span class=\"swatch\" style=\"background-color: %s;\">#</span> %s (%d points)</li>\n", color[id], names[id], points[id]);
}
}
}
@ -79,6 +78,11 @@ BEGIN {
printf("<li><a href=\"round-%04d.html\">%04d</a></li>\n", i, i);
}
print " </ul>";
while (getline < "nav.html.inc") {
print;
}
print " </body>";
print "</html>";
}