View Single Post
Question with memory
Junior Member
Status: Offline
Posts: 2
Join Date: Jun 2017
Location: MA
Default Question with memory - 06-14-2017, 07:41 PM

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

do together
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

Last edited by thatCarpenterGuy; 06-14-2017 at 07:43 PM.
Reply With Quote