Hello everyone!
I'm working on a game for school and have noticed that I am starting to get some lag, and fear I'm using way too much memory.
My game has a player that constantly moves forward. Along the path they encounter obstacles in the form of various animations. For example, there are dogs pacing back and forth, cars moving, people walking, etc.
As of now I have the various obstacle's individual animation methods in a do together block
Example:
world.playAnimations
do together
car1.animate
car2.animate
walker.animate
dog.animate
etc
Each of these individual methods then looks like this:
While world.playing==true
test if player is within 15 meters car1
then car1 move forward at speed
In an attempt to make every play unique, all of the animations are currently using a select-random-number-between to determine the distance away from the player to begin moving and the object's speed itself.
I'm thinking that this is likely not the proper or most efficient way to tackle this and I'm afraid of making my code any messier than it probable already is. Any suggestions on a better way to handle this? Will removing the random number selections make a difference?
Also on a different but similar note, is there a decent strategy for collision detection using arrays instead of lists? For instance I have a lot of stationary items that need collision detection as well. I have broken them down into organized lists and am using the for all items together code.
Hopefully this makes some sense