This commit is contained in:
Giorgio Croci 2017-05-26 15:38:59 +02:00
commit 655d3eab0c
4 changed files with 64 additions and 32 deletions

View File

@ -6,6 +6,7 @@
h1 { h1 {
color: white; color: white;
text-align: center; text-align: center;
font-size:2.4em;
} }
body{ body{
background: #009999; background: #009999;
@ -13,35 +14,43 @@
table{ table{
border: 1px solid white; border: 1px solid white;
empty-cells: show; empty-cells: show;
background: white;
padding: 0px; padding: 0px;
width:100%; width:100%;
height: 80%; height: 89%;
} }
td,tr{ td,tr{
background: white; background: white;
width: 100px
height: 10px
padding: 0px padding: 0px
} }
td.cibo{
background: #FFFF33;
padding: 0px
}
td.razza1{
background: #00ff00;
padding: 0px
}td.razza2{
background: #FF0000;
padding: 0px
}
</style> </style>
</head> </head>
<body> <body>
<h1> Go bug</h1> <h1> Go bug</h1>
<table> <table>
<tr> <tr>
<th></th> <td class="cibo"></th>
<th></th> <td class="razza1"></td>
<th></th> <td class="razza2"></td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td></td> <td></td>
<td></td> <td></td>
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>

20
html.go Normal file
View File

@ -0,0 +1,20 @@
package main
import (
"html/template"
"net/http"
)
// ServiHTML fa partire il server html
func ServiHTML() {
http.HandleFunc("/", handlerRoot)
http.ListenAndServe(":3000", nil)
}
func handlerRoot(w http.ResponseWriter, r *http.Request) {
templ, err := template.ParseFiles("template/hello.html")
if err != nil {
panic(err.Error())
}
templ.Execute(w, new(interface{}))
}

View File

@ -51,6 +51,9 @@ func main() { //FUNZIONE MAIN
} }
} }
} }
go ServiHTML() // fai partire il server html
fmt.Println("Situazione iniziale: ") fmt.Println("Situazione iniziale: ")
stampaMatrice() stampaMatrice()
@ -89,7 +92,6 @@ func muovi(h int, w int) { //FUNZIONE MUOVI: aggiorna la posizione di tutti gli
} }
if tmpNewElem := Matrix[nuovaPosizioneH][nuovaPosizioneW]; tmpNewElem != nil { if tmpNewElem := Matrix[nuovaPosizioneH][nuovaPosizioneW]; tmpNewElem != nil {
if tmpNewElem.Razza != elemento.Razza { //se non è dalla stessa razza if tmpNewElem.Razza != elemento.Razza { //se non è dalla stessa razza
if tmpNewElem.IsFood || (tmpNewElem.Health+tmpNewElem.Evoluzione) < (elemento.Health+elemento.Evoluzione) { // se e' cibo o un insetto piu debole if tmpNewElem.IsFood || (tmpNewElem.Health+tmpNewElem.Evoluzione) < (elemento.Health+elemento.Evoluzione) { // se e' cibo o un insetto piu debole
elemento.Health += tmpNewElem.Health //prelevamento energia essere fagocitato elemento.Health += tmpNewElem.Health //prelevamento energia essere fagocitato

1
template/hello.html Normal file
View File

@ -0,0 +1 @@
hello