This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Ok I am really new at this just so ya know. I am put a gird in an applet with a dot (otherwise known as my "ant") that travels east, west, south and north. I am in the beginning stages of building this code, but I have the grid done and I am working on the dot. I am a little confused about the dot, here is my code:
I am confused on the //draw a dot that represents an ant part. I want the dot to start at 160, 160. So that it is practically in the middle of the grid when it starts traveling. You can't use what I have the x = 160 or y = 160, so how do I change that to start the dot in the middle of the grid. If anyone can point me in the right direction that would be awesome. Also if anyone can help me out or something on how to simulate the traveling ant that would be good as well. I don't want anyone to think I am on here to just get the code. Cause I am not really, I was just hoping someone could help me out and point me in the right direction on these two things. I would appreciate any help anyone can give...I really want to learn java and applets and so on and I am just struggeling. If anyone has any good books or ideas of how to learn things more easily that would be great too!! You guys are awesome and thanks in advance!!
Animations are complex programs and it is difficult to try to explain or describe beyond a simple statement and an example. The statement: draw the animation in the paintComponent method of a component (JPanel) and manipulate the components variables from within your event code. Animations are pretty easy when you get the idea but it seems to take some practice to find the way. Here's an example (a possibility) using a Swing Timer. You are (really) only limited by your imagination in this kind of program so there's lots of room to experiment.