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

View File

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

View File

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

5
dump.h
View File

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

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

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

View File

@ -143,4 +143,5 @@ get-turret 12 + set-turret! ( Rotate turret )
</dl> </dl>
Good luck blowing everybody up! Good luck blowing everybody up!
include(nav.html.inc)
</html> </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 <dd>Returns a random number in the range [0, n). That is, between
0 and n-1, inclusive.</dd> 0 and n-1, inclusive.</dd>
</dl> </dl>
include(nav.html.inc)
</body> </body>
</html> </html>

View File

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

View File

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

View File

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