This commit is contained in:
Giorgio Croci 2017-05-26 16:55:27 +02:00
commit fa72b365c0
3 changed files with 74 additions and 41 deletions

View file

@ -14,18 +14,18 @@ type Element struct { //struttura che contiene sia cibo sia amebe
}
func (e Element) String() string {
return fmt.Sprintf("<E'Cibo=%t Salute=%d Eta=%d>", e.IsFood, e.Health, e.Age)
return fmt.Sprintf("E'Cibo=%t Salute=%d Eta=%d", e.IsFood, e.Health, e.Age)
}
func Costruttore(razza int, evoluzione int, costomov int, costosex int, premura int, salute int) *Element {
nuovo := new(Element)
nuovo.IsFood=false
nuovo.Health=salute
nuovo.Age=0
nuovo.Razza=razza
nuovo.Evoluzione=evoluzione
nuovo.CostoMov=costomov
nuovo.CostoSex=costosex
nuovo.Premura=premura
nuovo.IsFood = false
nuovo.Health = salute
nuovo.Age = 0
nuovo.Razza = razza
nuovo.Evoluzione = evoluzione
nuovo.CostoMov = costomov
nuovo.CostoSex = costosex
nuovo.Premura = premura
return nuovo
}

View file

@ -16,5 +16,9 @@ func handlerRoot(w http.ResponseWriter, r *http.Request) {
if err != nil {
panic(err.Error())
}
templ.Execute(w, new(interface{}))
varmap := map[string]interface{}{
"matrice": Matrix,
"tempoAggiorna": Clock,
}
templ.Execute(w, varmap)
}

View file

@ -1,56 +1,85 @@
<html>
<head>
<title>GoBug</title>
<!--meta http-equiv="refresh" content="{{ .tempoAggiorna }}"-->
<meta charset="UTF-8">
<style type="text/css">
h1,h2,h3,h4,p {
color: white;
text-align: center;
font-size:2.4em;
}
body{
h1,h2,h3,h4 {
color: white;
text-align: center;
font-size:2.4em;
}
p {
color: white;
font-size:2em;
}
body {
background: #009999;
}
table{
table {
border: 1px solid white;
empty-cells: show;
background: white;
padding: 0px;
width:100%;
height: 100%;
}
div {
width:20%;
height: 89%;
background-color: #006666;
}
td,tr{
td,tr {
background: white;
padding: 0px
padding: 0px;
}
td.cibo{
.cibo {
background: #FFFF33;
padding: 0px
padding: 0px;
}
td.razza1{
.razza1 {
background: #00ff00;
padding: 0px
}td.razza2{
background: #FF0000;
padding: 0px
padding: 0px;
}
.razza2 {
background: #FF0000;
padding: 0px;
}
</style>
</head>
<body>
<h1> Go bug</h1>
<h1>Go bug</h1>
<div style="float:left; display:block; width:70%; height:89%; ">
<table>
<tr>
<td class="cibo"></th>
<td class="razza1"></td>
<td class="razza2"></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
{{range $riga := .matrice}}
<tr>
{{range $cella := $riga}}
<td {{ if not $cella }}
class="vuoto"
{{ else }}
{{ if $cella.IsFood }}
class="cibo"
{{ else }}
class="razza1"
{{ end }}
{{ end }}>{{ $cella }}</td>
{{ end }}
</tr>
{{ end }}
</table>
</div>
<div style="float:left; display:block; width:1%; height:89%; "></div>
<div style="float:left; display:block; width:29%; height:89%; ">
<h1>legenda</h1>
<div style="float:left; display:block; width:30%; height:20%; background-color:#FFFF33;"></div>
<div style="float:right; display:block; width:65%; height:20%; "><p>Food</p></div>
<div style="float:right; display:block; width:100%; height:2%; "></div>
<div style="float:left; display:block; width:30%; height:20%; background-color:#00ff00;"></div>
<div style="float:right; display:block; width:65%; height:20%; "><p>Razza1</p></div>
<div style="float:right; display:block; width:100%; height:2%;"></div>
<div style="float:left; display:block; width:30%; height:20%; background-color:#F00;"></div>
<div style="float:right; display:block; width:65%; height:20%; "><p>Razza2</p></div>
</div>
</div>
</body>
</html>