Need help with making a planet with a moon orbit the sun.

edited October 2016 in Questions about Code

.

Tagged:

Answers

  • Try formatting your code

    Empty line before and after code section

    Mark the code with mouse

    Ctrl-o

  • Answer ✓

    Does it work?

    What is missing?

  • edited October 2016

    Whenever I run the TestPlanet I get ''Could not run the sketch (Target VM failed to initialize).''

  • You can also search the forum for past discussions of orbiting planet simulations -- there are many. Search for "orbit" "planet" "solar" etc., e.g. How to model the solar system, etc..

  • Is this one sketch or 2?

  • edited October 2016

    Chrisir, I'm not sure if you can open this link or not but try https://github.com/barcaxi/oop/blob/master/assignments/Assigment1.md#part-1---moon-and-planet-classes. Its 2 sketches, I can do the first sketch where the moon just orbits nothing and is on a blank background but I can't get it working with the planet added.

  • Maybe it crashes when you don't have setup and draw

  • Is this not correct then, this is what I have in my tester.

    Planet earth;
    
        void setup()
        {
          size(800, 800);  
    
          // add tester code here - create a planet & moon object, call some of its methods, etc.
          Moon moon = new Moon("moon", 7.5, 50, 2, 28);
          Planet earth = new Planet("earth", 25, 200, 1, moon);
    
        }
    
        void draw()
        {
          background(0, 0, 0);
          fill(255, 255, 0);
          ellipse(width/2, height/2, 100, 100);  
          translate(width/2, height/2);
          earth.display();
        }
    
  • Yeah sure

  • Just put it all together

  • When I go to run it now I get this. http://puu.sh/rUnBo.png

  • No idea how to fix it

  • Test it

    Read it thoroughly

  • No idea how to fix it

    @Shayy --

    • What do the error messages say?
    • What line numbers do they refer to?
    • When you look at that line, is the message a correct description of a problem?
    • How could you fix the problem?
    • If you don't understand, could you look the error message up? Or look up how the parts are supposed to work?

    Once you have tried to fix the problem, if you are still struggling, come back, explain what you tried, and explain what you are trying to accomplish -- and forum members will help!

Sign In or Register to comment.