0

I'm trying to make a snake game first on javascript then I'll rewrite it on maybe Flash.
After reading some sources I've got some questions. First of all let's see the alghorithm of creating playfield:

<script type="text/javascript">
var height = 20; //height of the game area
var width = 30; //width of the game area
var b = 0;
document.write("<table bgcolor=white bordercolor=black ");
document.write("align=center border=1 cellpadding=0 cellspacing=0><tr><td>");
for (b = 0; b < height+2; b++)
document.write("<img src=images2/end.gif width=0 height=0>");

cause of the for cycle we put a small gif image in a table 21 times. Is it efficient cause it's easier to make document.write once with big ground image. Is there any other way of visualizing the play field without document.write?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by gusano79
0

Is there any other way of visualizing the play field without document.write?

Just as an example, here's a JavaScript snake game that doesn't use document.write ; it looks like it uses YUI.

You could probably use JavaScript to update the DOM directly; different playing field states (empty, snake, food) could just be CSS classes you change on the <TD> s for display.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.