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

2014/5/13

java.lang.OutOfMemoryError: Java heap space

1
2
3
GRIFFIN GRIFFIN

2014/5/15

#
Ok its uploaded
danpost danpost

2014/5/15

#
Ok. I got it. If you want you can go to the scenario and under the big 'Open in Greenfoot' button on the right in small print, you will find 'edit scenario / delete scenario / get data' and delete it back off the site.
GRIFFIN GRIFFIN

2014/5/15

#
ok
GRIFFIN GRIFFIN

2014/5/15

#
Tell me when you see a problem. I know there are many bugs but tell me about ones relating to this one;)
danpost danpost

2014/5/15

#
Ok. The value of 'small' that the Healthbar object contains is being set to 'Infinity' due to the fact that MaxHealth in the tank class (as well as in the Healthbar class) have not been set to any value, yet. So, you were dividing by zero and coming up with 'Infinity' for its value; which in turn exceeded the VM limit for what you were using the value for. I changed both 'MaxHealth' values to '200' and the error went away.
GRIFFIN GRIFFIN

2014/5/15

#
Well maxhealth is changed throughout the game (when you upgrade the armor), will I still be able to change it when that happens? And maxhealth should be getting set in the tank's constructor function or the once boolean if statement, getting the data from DATA
GRIFFIN GRIFFIN

2014/5/15

#
Ok so I changed maxhealth to one, but now the turret gun doesn't point at the tank anymore and the gun is staying on top of the health bar instead of the tank. Is that what yours was doing?
danpost danpost

2014/5/15

#
GRIFFIN wrote...
And maxhealth should be getting set in the tank's constructor function or the once boolean if statement, getting the data from DATA
That may be; however, the Tank object never gets a chance to act and set those values before the Healthbar tries to use it. This is because of the way you are using 'once' in the classes. All one-time actions that can be performed without the needing the objects in the world should be done within the constructor of the class; and all one-time actions that require the actor be in the world should be done in the 'addedToWorld' method of the class (it is an Actor class method that by default is empty, and is called automatically when you 'addObject' the object into a world). Also, I see you still have poor subclassing issues.
danpost danpost

2014/5/15

#
GRIFFIN wrote...
Ok so I changed maxhealth to one, but now the turret gun doesn't point at the tank anymore and the gun is staying on top of the health bar instead of the tank. Is that what yours was doing?
Yes. Mine was doing that also. That is due to your poor subclassing issues. By having Healthbar extend Tank, it is considered a Tank object (just like it is considered an Actor object, which Tank extends). So, the gun is using the first element in the list of, now, multiple Tank objects to set its location to; and, at the moment, that first element is the Healthbar Tank object (I phrased it like that so you could better understand the issue).
GRIFFIN GRIFFIN

2014/5/15

#
I think I understand the issue. Thank you so much for helping, what do you suggest I do about the subclass issue? Not have any at all? And I don't understand why the turret gun doesn't work anymore or the gun not staying on the tank.
GRIFFIN GRIFFIN

2014/5/15

#
Ok I get it now, so I should make the health bar not a subclass of the tank?
GRIFFIN GRIFFIN

2014/5/15

#
Ok I made nothing a subclass of the tank and it worked!!! Thank you very much i probably wouldn't have been able to do it without you.
GRIFFIN GRIFFIN

2014/5/15

#
One last question (if you don't mind) now that I have made these changes, the game is slow and doesn't run smoothly, any ideas on what could be causing that?
danpost danpost

2014/5/15

#
GRIFFIN wrote...
Ok I get it now, so I should make the health bar not a subclass of the tank?
Correct. It should not subclass the tank.
danpost danpost

2014/5/15

#
GRIFFIN wrote...
One last question (if you don't mind) now that I have made these changes, the game is slow and doesn't run smoothly, any ideas on what could be causing that?
Yes. It seems that every actor is setting its image every act cycle when with most of them you only need to set it once in the constructor (instead of the act).
There are more replies on the next page.
1
2
3