Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Random Grid Movement  RSS feed

 
Star Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I was wondering how i would go about outputing a 2 dimensional grid made up of asterixes and have a full stop move about it randomly. As a beginner im getting a little lost but i'm sure i'll get there with your help.

Much Appreciated.
[ November 25, 2006: Message edited by: Star Smith ]
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post what (the code) have you tried so far -- we can't tell where are you lost. (not to mention not having enough information to fully understand the problem)

Henry
 
Star Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is all i've got so far. It prints out the grid and generates a random number upto 4, representing each direction it can move in. Now i'm not sure how i can get the full stop to move randomly. Thanks for the interest in helping.

-----------------------------------------------------------------
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you ever play any of the character mode Adventure games on PCs? You have to be a certain age to know what those are. They always say things like "You are standing in a room with four doors ..." So pretend you are standing in a room and pick a random number for which way you'd like to move. You have to figure out the X,Y coordinates for the next room and make sure you're not trying to move off the edge of the grid, then you can move.

Are you planning to draw this as characters via System.out? If so you'll have to redraw the whole grid each time which may be a bit hard to follow. But once you feel really good about how it works, we can try putting a Swing front end on it.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Stan]: Did you ever play any of the character mode Adventure games on PCs? You have to be a certain age to know what those are. They always say things like "You are standing in a room with four doors ..."

I find I have a sudden craving for wumpus-burgers...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!