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

2016/7/30

Greenfoot Freezes Altogether

1
2
elektrikpulse61 elektrikpulse61

2016/7/31

#
Alright. I will attempt to implement what you have into my code. I'll post an update (probably in about 12-14 hours or so) on whether or not I need any further assistance. Thank you for your patience and willingness to help me thus far!
danpost danpost

2016/7/31

#
I remembered you mentioning that you are using 'System.currentTimesMillis' to track the time. You will not be able to do that with a Trajectory object as the object will only be in the world a very short amount of time compared to how long a Projectile object would. It might be best to count the number of times the actor moves for both the Trajectory and Projectile objects. That way they will be consistent with each other. Also, using move counting (or act counting -- which should be the same thing, as far as the value is concerned) makes things more consistent (if using system time and some underlying project decides to hog your CPU momentarily, it could mess up things a bit -- as lag time would be depriving run-time of your scenario).
elektrikpulse61 elektrikpulse61

2016/7/31

#
Alright, what you're saying makes sense, and I've considered it, but how exactly would I be able to ensure that the Trajectory object would actually hit whatever target it is aiming at before it says "step limit reached; time to leave the world" (so-to-speak)? I mean, the step counter would have to be very very large, and although better in terms of consistency, would it still be more efficient than using System.currentTimeMillis()? EDIT: The step counter would have to be large because if a projectile were to have, say, 3 ricochets, and it were to be fired almost at a 0 degree angle (so basically almost directly to the right), it would have to travel my 500-something-pixel-wide world. In that case, the value would be 2,000-something. Is that more efficient? It very well could be, but I'm not very good at approximating how many computer resources each method (not programming method, but method of solving a problem) requires and uses up.
danpost danpost

2016/8/1

#
The 'isAimedAt' method will return any actor that is in the path, if any (if none, it returns a 'null' value). Line 5 in the other code is where it is received in to the enemy tank class, where it is used to shoot a projectile if 'tank c' is what is returned. As far as the step counter, it might be best (at first) not to implement it and just use ricochet count and blocking actors. I mean, we know that eventually an actor will either be in the path or so many edges will be encountered; so, there will not be an infinite loop (this is presuming that a 'move' method is used for just moving the trajectory or projectile actors and other actions are done elsewhere). What I am saying is that you get some semblance of a running scenario and then build from that.
elektrikpulse61 elektrikpulse61

2016/8/1

#
Alright. Will do that. Thank you so much for your help on this, danpost. It goes to show how in-depth this stuff can be. A (what I thought was) simple error turned into a huge discussion about efficiency and other methods to better my scenario overall. That's why I love programming so much. Once again, thank you for your knowledge (and patience) !
danpost danpost

2016/8/1

#
elektrikpulse61 wrote...
since the movement is all done within one act cycle, the parent tank will not have moved any since it "fired" its last Trajectory object. Therefore, if the parent is returned a character as the "bumped into" object (the parent is also a parameter, allowing the Trajectory object to send information to the original tank), it will just fire wherever it is currently.
I missed this earlier -- maybe I was not quite sure what your trying to say. It appears you are trying to say that the parent will instantly be found to be an object within the trajectory path and, of course, you want the trajectory to go beyond the parent before returning any value. For that, we can change line 14 in the 'isAimedAt' method to:
1
if (bumped != null && bumped != parent) break;
You need to login to post a reply.
1
2