Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Creating Grid and Random coordinates

843785Nov 14 2008 — edited Nov 14 2008
Hi all, I'm currently trying to create a java Snake game similar to classic snake mobile phone game.
So far i have created the grid and the food object to be placed onto the grid. However, how do i get food to be displayed onto the grid with the letter 'F' in random positions until the snake has eaten them.
Here is what i have so far.
import java.util.Arrays.*;
import java.util.Random.*;
import java.lang.*;
import java.util.*;

public class SnakeGame
{
	int x;
	int y;
	public Object grid[31][31]; //31 x 31 grid
	{
	Random x = new Random(31);
	Random y = new Random(31);
	Object food = new Object();
	}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 12 2008
Added on Nov 14 2008
31 comments
1,489 views