Jump to content
  • Advertisement
Sign in to follow this  
mike74

football squares

This topic is 4724 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm making the game "football squares" for the web. When displaying the results of a game, there is a 10x10 grid, and the winning square has a certain color. Additionally, the squares surrounding the winner also win something and have a certain color. Also, there are bonus squares that have another color. Anyway, occasionally the bonus squares may be the same as surrounding squares or the winner. So, in these cases, the square needs to have two colors. Also, there are some cases when it might have three colors. Anyhow, my question is... does anyone know an easy way to do this with HTML? I am using a table, and each square is a cell in the table. This would be very easy to do if it wasn't for the fact that each square needs to have the winner's name written on it. The name should really be centered vertically and horizontally, so this sort of obviates the obvious solution of throwing a simple table with two or three cells into the square and putting the name in one of those cells. Mike C. http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
Advertisement
Havent done HTML in awhile but you could possibly leave the background the same color and make the name the color you would want it to be. from what i remember changing the color of text is fairly simple.. just my suggestion though.

Share this post


Link to post
Share on other sites
If you're using PHP (which I assume you are, because its a web game, right?), then you can use a loop to check each square. If a particular square overlaps, then you can 'echo' out the comined color (which you should figure out manually).

If you're not drawing the tables dynamically, then you'll need a short PHP snippet at each cell.

I think I have two good examples here:


<?php
/*first, you should make a code for each possibility. Non-winning-and-bonus squares should have a code of 0, bonus squares 1, and winning squares 2. That way, you can check what a cell holds simply by adding the code numbers together.*/

for(int c = 0; c < 10; c++)
{
echo '<td>';
for(int r = 0; r < 10; r++)
{
if(cell[r][c] == 0) echo '<tr color="#000000">' + text + '</tr>'; //black color for nothing square
if(cell[r][c] == 1) echo '<tr color="#FF0000">' + text + '</tr>';; //red bonus square
if(cell[r][c] == 2) echo '<tr color="#0000FF">' + text + '</tr>'; //blue winner square
if(cell[r][c] == 3) echo '<tr color="#FF00FF">' + text + '</tr>'; //purple winner bonus square
}
echo '</td>';
}
?>



If you're not displaying the table dynamically (using PHP), then you'll have to have the if statements in each cell. Also, I'm not very experienced in PHP, so this might not be the best way of doing this.

Hope this helps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!