Hi chris,
iam developing games in jsp, in this game iam showing crossword & player has to find out the correct names & submit through input box. but my moto is that player has to find these names from the crosswords in some time limit.
so i want to show timer of 5 min. & player has to find maximum names within 5 min outerwise player will loose the game.
I already code that generate Bollywood Crosswords on browser & now i just need to show 5 min time limit.
complete code without timer:
<body>
<%
String gameId=request.getParameter("gameId");
if(gameId==null)
gameId="start";
String moves=request.getParameter("moves");
if(moves==null)
moves="0";
int gmoves=Integer.parseInt(moves);
String row1[]={"K","A","R","E","E","N","A","H"};
String row2[]={"O","A","C","D","E","F","G","H"};
String row3[]={"Y","B","J","D","E","F","G","H"};
String row4[]={"L","B","C","O","E","F","G","H"};
String row5[]={"A","B","C","D","L","F","G","H"};
String corrAns[]={"Abhi","shah","amir","salmaan","kajol","amrita","tabu","madhuri"};
String userAns=request.getParameter("userAns");
if(userAns==null || (userAns!=null && userAns.equals("")))
userAns="-";
int answer=0;
if(!userAns.equals("-"))
{
int index;
for(index=0;index<corrAns.length;index++)
{
if(corrAns[index].equals(userAns))
{ %>
<b>Good! Correct Answer</b><br/>
<% }
}
if(!corrAns[index].equals(userAns))
{ %>
<b>Sorry! Wrong Answer.</b><br/>
<% }
}
%>
<br/>
<b>Bollywood Crossword</b><br/>
<%
if(gameId.equals("start"))
{
String s="";
for(int i=0;i<row1.length;i++)
{
s=row1[i]+" ";
%><%=s%><%
}
%><br/><%
for(int j=0;j<row2.length;j++)
{
s=row2[j]+" ";
%><%=s%><%
}
%><br/><%
for(int j=0;j<row3.length;j++)
{
s=row3[j]+" ";
%><%=s%><%
}
%><br/><%
for(int j=0;j<row4.length;j++)
{
s=row4[j]+" ";
%><%=s%><%
}
%><br/><%
for(int j=0;j<row5.length;j++)
{
s=row5[j]+" ";
%><%=s%><%
}
%>
<br/>
Find out all bollywood stars in a minimum time ...<br/>
Click here to begin: <br/>
<form action="<%=rootpath%>">
<input type="hidden" name="_rapsvc" value="<%=_rapsvc%>" />
<input type="hidden" name="_svc" value="<%=_rapsvc%>" />
<input type="hidden" name="_raptype" value="SERVICE" />
<input type="hidden" name="gameId" value="starting" />
<input type="hidden" name="req_id" value="3" />
<br/>
<input type="submit" name="sbmt" value="Start Game" />
</form>
<%
}
else if(gameId.equals("win"))
{
%>
<br/>
!!Congrats!!<br/>
You have done it
<%
}
else
{
gameId="started";
String s="";
for(int i=0;i<row1.length;i++)
{
s=row1[i]+" ";
%><%=s%><%
}
%><br/><%
for(int j=0;j<row2.length;j++)
{
s=row2[j]+" ";
%><%=s%><%
}
%><br/><%
for(int j=0;j<row3.length;j++)
{
s=row3[j]+" ";
%><%=s%><%
}
%><br/><%
for(int j=0;j<row4.length;j++)
{
s=row4[j]+" ";
%><%=s%><%
}
%><br/><%
for(int j=0;j<row5.length;j++)
{
s=row5[j]+" ";
%><%=s%><%
}
%>
<br/>
Score: <%=gmoves%><br/>
<form action="<%=rootpath%>">
Enter the
word <input type="input" value="" name="userAns" /><br/>
<input type="hidden" value="<%=gmoves%>" name="moves" />
<input type="hidden" value="<%=gameId%>" name="gameId" />
<input type="hidden" name="_rapsvc" value="<%=_rapsvc%>" />
<input type="hidden" name="_svc" value="<%=_rapsvc%>" />
<input type="hidden" name="_raptype" value="SERVICE" />
<input type="hidden" name="req_id" value="3" />
<br/>
<input type="submit" name="sbmt" value="Submit" />
</form>
<%
}
%>
<br/>
<a href="<%=rootpath%>&req_id=3">Restart</a></br>
<a href="<%=rootpath%>&req_id=2">Menu</a></p>
</body>
<%
}
%>
</html>
still crossword are not arrange. ijust check userAns with corrAns.
i think you got my point what actually i want to show..
Thanks