jasjisdo / gtge

Automatically exported from code.google.com/p/gtge
2 stars 2 forks source link

AWTInput/EnhancedAWTInput internal array may overload. #10

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a game that sleeps for three seconds in the update(long) method.
2. Execute more than 20 keypresses during this three seconds.

The problem is that the internal counter on the 20-sized array is only 
reset on refresh or update.  Update is called fairly regularly, but if the 
AWTInput class is to be used outside of the GTGE framework, not knowing 
this restriction of resetting via these two methods (or doing some weird 
threading like the above) may cause an index-out-of-bounds exception.

The easiest way to solve this problem is to abstract the array out to a 
list, allowing implementors to get and set it as a property, but setting 
it internally to a new ArrayList.  This would also allow for not using an 
index as well as the array, for clearing the list would be very easy using 
ArrayList.clear();. 

Original issue reported on code.google.com by MetroidF...@gmail.com on 21 Apr 2008 at 12:19

GoogleCodeExporter commented 8 years ago
Oh that indeed is problem but why not use a Queue/Stack? That would be way more
efficient and faster because it would not allocate array all the time ;P

Full ack on the rest

Original comment by jan.brac...@googlemail.com on 21 Apr 2008 at 5:18