This site requires JavaScript, please enable it in your browser!
Greenfoot back
joandvgv
joandvgv wrote ...

2015/2/18

Pausing movement when there's one equal actor.

4
5
6
7
8
danpost danpost

2015/2/21

#
Yes. I would help to keep the two actor types with different behaviors separate. The Auto class can still maintain some rudimentary methods and fields that both share.
joandvgv6 joandvgv6

2015/2/21

#
Ok, well. My other account was temporarily banned (Don't know why) -_- I want you to take a look at my scenario: here How do I avoid that? It is not going down at that moment but all the turns make it go towards the scenario's bottom. Once it's reached it, the turns will make it go towards the top. When it's going towards the top, I just should use the coundition about left and 180 rotation. What about when it's going towards the bottom? How do I track when it's going towards the bottom and when i'ts going towards the top?
danpost danpost

2015/2/21

#
You still have a bunch of code in you classes that does not need to be there. Plus, much can be done to simplify what you have (most of the 'switch' statements can be replaced with single lines of code. You also have some methods with slightly different names that do the same thing ( 'setNumRuta' and 'setRuta', for example). The 'startUp' method being called from the 'act' method every cycle seems taxing. I wonder how much of that you really needed. I could not say how to improve on that because I do not know what values may change over time; although those values should be retrieved when needed, not automatically at the beginning of each act cycle. And for the values that do not change -- only if needed, they can be retrieved through the 'addedToWorld' method (this can be explained, if desired). The 'valor' array can be assigned its values when declared (instead of calling a method later to set the values of the array). In fact, a 2D array could be used for both the Auto (inspector) object and Recolector objects. I am sure there is more to say, but this a good start.
danpost danpost

2015/2/21

#
joandvgv6 wrote...
How do I track when it's going towards the bottom and when i'ts going towards the top?
Its rotation will be 90 when going down and 270 when going up (180 when going left and zero when going right).
danpost danpost

2015/2/21

#
joandvgv6 wrote...
I want you to take a look at my scenario: here
Why not upload the scenario here (checking the 'Publish source code' checkbox) !??! That way I can work with the classes directly.
joandvgv6 joandvgv6

2015/2/21

#
Yes. You're so right. However, I need to deliver this to my teacher in two days and got some more college stuff to do not related to this project. So, I just want to submit this completely functional and with no errors, despite of thing that could be simplified. Of course I still need to clean the code and make it more undestandable and if there's still time simplify things like replacing all those switches. That's why in my block note I have pasted all those suggestions you made in order to implement them later. All those initializations can be done somewhere else but in the act method. Right now the project is pretty functional (99%) the only issue so far is what I mentioned about the pictures and the turning stuff. And I still don't know how to solve that.
joandvgv6 joandvgv6

2015/2/21

#
danpost wrote...
joandvgv6 wrote...
I want you to take a look at my scenario: here
Why not upload the scenario here (checking the 'Publish source code' checkbox) !??! That way I can work with the classes directly.
Well, I meant just to take a look at the picture. But I will do it so you can help me a bit more.
danpost danpost

2015/2/21

#
If you tried to post an image in a discussion post, that is why you were temporarily blocked. You are only blocked from creating more posts until the greenfoot team okays the post; but, you are not banned. Once okayed, the post will appear and you will be able to continue posting under your original username.
joandvgv6 joandvgv6

2015/2/21

#
danpost wrote...
joandvgv6 wrote...
How do I track when it's going towards the bottom and when i'ts going towards the top?
Its rotation will be 90 when going down and 270 when going up (180 when going left and zero when going right).
I see. so It will be the same but changing 180 by 90?
danpost danpost

2015/2/21

#
danpost wrote...
If you tried to post an image in a discussion post, that is why you were temporarily blocked. You are only blocked from creating more posts until the greenfoot team okays the post; but, you are not banned. Once okayed, the post will appear and you will be able to continue posting under your original username.
Afterwards, you will not be blocked again, if you decide to post more images (unless, of course, any of those images are found to be unsuitable to be posted on this site).
joandvgv6 joandvgv6

2015/2/21

#
I just uploaded the scenario. take a look
danpost danpost

2015/2/21

#
I got it. It might take me a little while to see what is going on.
joandvgv6 joandvgv6

2015/2/21

#
Ok, meanwhile could yo help me with this little thing: After I remove a truck, I need to add the same truck, (well, a truck with the same route number) in other position. Tried this but didn't work.
 private void descarga()
    {
        if (relleno!=null){
       relleno.descargar(capacidad);
       eliminar();
       crear();

    }
   }
       
    private void eliminar()
   {
      if (isTouching(Relleno.class)) {
          getWorld().removeObject(this);
      }
   }
   private void crear()
   {
          Recolector recolectorcontinuado = new Recolector();
           getWorld().addObject(recolectorcontinuado, 963, 265);
     
         recolectorcontinuado.setnumRuta(7);
        }
   
danpost danpost

2015/2/21

#
First, if you want it to be added when the truck is removed, then you need to put the call to 'crear' in the 'eliminar' method inside the 'if' block (before removing the truck -- so you can 'getWorld'). Next, if you want it to have the same route number, use 'numRuta', not '7'.
joandvgv6 joandvgv6

2015/2/21

#
danpost wrote...
Next, if you want it to have the same route number, use 'numRuta', not '7'.
Sure. I din't mean that. I was trying to make it the same color because it will follow a different path. Thanks for that, will try it.
There are more replies on the next page.
4
5
6
7
8