
Chanwit Kaewkasi
By: a guest on
Sep 17th, 2008 | syntax:
Groovy | size: 2.67 KB | hits: 839 | expires: Never
<?xml version="1.0" encoding="UTF-8"?>
<?init
class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<?variable
-resolver
class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?page zscriptLanguage="GroovyGrails"?>
<zk>
<zscript>
r += "${it} "
}
}
}
}
buffer[i] = it
correct++
}
}
wrong++
if(wrong
== 12
) gameOver
= true
if(correct
== word.
length()) win
= true
}
}
}
words = ['polyglot','alliance','web']
nextstep = {
if(hangman.
win || hangman.
gameOver) return
hangman.guess self.label
answer.value = hangman.revealedWord
count.
style = 'color: green'
count.
value = 'YOU WIN !!!'
count.
style = 'color: red'
count.
value = 'GAME OVER'
imgStep.src = "images/hangman/step${hangman.wrong+1}.gif"
count.
value = hangman.
wrong
}
}
</zscript>
<vbox>
<hbox>
<label id="count" value="${hangman.wrong}"/>
</hbox>
<image id="imgStep" src="images/hangman/step1.gif"/>
<hbox>
The Word:
<label id="answer" value="${hangman.revealedWord}"/>
</hbox>
Chracters:
<hbox>
<button label
="${each}" width
="28px" forEach="${a_to_m}" onClick
="nextstep()"/
>
</hbox>
<hbox>
<button label
="${each}" width
="28px" forEach="${n_to_z}" onClick
="nextstep()"/
>
</hbox>
<box height="20px"/>
<label value="New Game?"
style="cursor: pointer; text-decoration: underline; color: maroon;"
onClick="Executions.sendRedirect 'index.zul'"/>
</vbox>
</zk>