help with learning project
I'm not an experienced programmer and I'm just trying to learn some more. I started a very demanding project which most likely won't ever finish but it doesn't have to either. Learning is the key.
I'm building a game, a roguelike to be exact. I'm sure you all know what those are like. Adom, nethack and so forth.
What would be the best way to create the playing area with swing? That area where all the characters are placed and the player character and monsters move around? Is there some quick way to create an area that would be a table with coordinates that I could manipulate? Insert and remove characters, change colours and alike.
I don't need exact code but some directions. If it's complicated and you want to link some example code I won't mind though.
Thanks in advance :)
You could just draw on the Graphics object. In AWT you'd use a Canvas object; I guess in Swing you'd just subclass JComponent and override paintComponent. The stuff you draw wouldn't be Swing components though; they'd probably just be sprites.
Alternatively...
if you want a text-ish interface, you could I suppose use a JTextArea.
But maybe the easiest thing would be to use a JTable, and then configure it so the cells are perfectly square and without borders between them. I believe that is possible. Then you could manipulate the characters by moving them across cells. Basically you'd probably end up implementing the game in a TableModel.
Just throwing ideas out here. You might want to ask on the Swing forum...
> I'm not an experienced programmer and I'm just trying
> to learn some more.
Urelated but important questions:
1) Are you in or have you taken a java class?
2) Have you gone completely through one or more java textbooks chapter by chapter?
The reason I ask is that some of the most frustrating experiences here for me and for original posters are from folks trying to learn java via the "trial and error" method. If this is not you, and you have gone through a course on Java or have completed a text book (or better two) then I say forge on ahead. If this is you, and you want to learn as you code, I strongly advise you to reconsider. You could be heading towards a world of frustration and a dislike of programming.
Good luck.
/Pete
> > I'm not an experienced programmer and I'm just
> trying
> > to learn some more.
>
> Urelated but important questions:
> 1) Are you in or have you taken a java class?
> 2) Have you gone completely through one or more java
> textbooks chapter by chapter?
I've read a few books and completed a few assignments. I know the basics such as using objects, different classes outside the main class, using functions and building algorithms. Swing isn't very familiar to be but it's one of the reasons why I chose to do this with it.
>Just throwing ideas out here. You might want to ask on the Swing forum...
I think those were good ideas. I suspected there were a lot of choices and that gave me some ideas. I'll check the Swing forum too. Perhaps I should have posted there in the first place.