• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Grid

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Did you just should on me? You should read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic