*> Thanks for the response! Takes about 3 weeks to get a post and response on here! Wow....*
It was 10 days... about a week and a half. And all of us are reading through these posts and answering on our own personal time. *> So, it looks like the answer to my question is that nothing is preventing the second apple being drawn over the first. Unless I am missing something here....* Yes... and I misunderstood your original question. I was telling you where/how to add the code to put that check in. Good luck with Android! It's a great platform... ---------------------------------------------------------------------- There are only 10 types of people in the world... Those who know binary and those who don't. ---------------------------------------------------------------------- On Wed, Mar 10, 2010 at 1:39 PM, Mike <[email protected]> wrote: > > Thanks for the response! Takes about 3 weeks to get a post and > response on here! Wow.... > > I am really just getting up to speed on formatting issue....crawling > right now. > I'm a noob, so this may seem obvious to veterans but...after digging a > little deeper into the demo, I found this; > > /** > * Draws some apples. > * > */ > private void updateApples() { > for (Coordinate c : mAppleList) { > setTile(YELLOW_STAR, c.x, c.y); > } > > And > > map.putIntArray("mAppleList", coordArrayListToArray(mAppleList)); > > And cross referencing with the developers documentation; > > "Normally, Lists allow duplicate elements, as compared to Sets, where > elements have to be unique. " > > So, it looks like the answer to my question is that nothing is > preventing the second apple being drawn over the first. Unless I am > missing something here.... > > > > > > On Mar 8, 7:52 pm, Justin Anderson <[email protected]> wrote: > > Sure, just write some simple code that makes sure newCoord is not already > in > > mAppleList... put it right after the check for colliding with the snake > > location. > > > > ---------------------------------------------------------------------- > > There are only 10 types of people in the world... > > Those who know binary and those who don't. > > ---------------------------------------------------------------------- > > > > On Fri, Feb 26, 2010 at 1:40 PM, Mike <[email protected]> wrote: > > > > > My first post here...hello! > > > > > Can anyone tell me what is to prevent the Snake demo from putting 2 > > > apples in the same location? > > > When the game starts, it populates 2 apples. > > > > > Here is the relevant method; > > > > > private void addRandomApple() { > > > Coordinate newCoord = null; > > > boolean found = false; > > > while (!found) { > > > // Choose a new location for our apple > > > int newX = 1 + RNG.nextInt(mXTileCount - 2); > > > int newY = 1 + RNG.nextInt(mYTileCount - 2); > > > newCoord = new Coordinate(newX, newY); > > > > > // Make sure it's not already under the snake > > > boolean collision = false; > > > int snakelength = mSnakeTrail.size(); > > > for (int index = 0; index < snakelength; index++) { > > > if (mSnakeTrail.get(index).equals(newCoord)) { > > > collision = true; > > > } > > > } > > > // if we're here and there's been no collision, then we > > > have > > > // a good location for an apple. Otherwise, we'll circle > > > back > > > // and try again > > > found = !collision; > > > } > > > if (newCoord == null) { > > > Log.e(TAG, "Somehow ended up with a null newCoord!"); > > > } > > > mAppleList.add(newCoord); > > > } > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Beginners" group. > > > > > NEW! Try asking and tagging your question on Stack Overflow at > > >http://stackoverflow.com/questions/tagged/android > > > > > To unsubscribe from this group, send email to > > > [email protected]<android-beginners%[email protected]> > <android-beginners%[email protected]<android-beginners%[email protected]> > > > > > For more options, visit this group at > > >http://groups.google.com/group/android-beginners?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > [email protected]<android-beginners%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

