How do objects in the game work properly with the time that the game runs?
Posted: Fri Nov 22, 2019 10:36 pm
Hey guys! I am making a platform game with bump. I encountered a situation with my method of jumping. Each time the player presses 'w' the character will jump (I put self.vy = -370), and in the Player: update (dt) function I have the command that if self.vy <200 is self.vy = self .vy + 20. Because I use bump for collision, when the player touches the ground, he will stop himself, I don't need to make self.vy = 0.
Everything was pretty stable, until I added a lot of objects to my game, a few hundred objects (I made the money drop every time the player punched an enemy). My game started to become more laggy and each character's jump was many times higher than normal (2 or 3 times higher). How to fix this error? I want when my game becomes laggy, the characters still jump as high as before.
And from this issue I started thinking about my game performance. There were only about 300-400 objects in the game right now, but it was starting to lag. Well, to put it further, every time I run the code my character is first affected by gravity and falls, but for 1 second all the objects stay still, I think it is lag, or is it initializing the game's initial objects and then running a few seconds later, I don't want the delay (I wonder if my computer configuration is weak or not?
32 bit, RAM: 2GB, Processor: 2.6Hz). In the future, I plan to create a full map and then move the camera along with the character, but given the current situation, it is probably impossible. I would like to ask more about your game, how many objects exist at the same time? And with a game, how many objects co-exist as well? I used to think about splitting the map, each part about 3 to 4 screens, when the character went over that area, delete that area then save it to the data file of the area that went through and Draw a new zone. But that is a bit difficult, I think it initialized like minecraft, but my map is limited. Because of the complexity, I haven't done it yet, it would be nice if you could share more with me about this.
Above are my questions, please answer me, I am very thankful to you.
Everything was pretty stable, until I added a lot of objects to my game, a few hundred objects (I made the money drop every time the player punched an enemy). My game started to become more laggy and each character's jump was many times higher than normal (2 or 3 times higher). How to fix this error? I want when my game becomes laggy, the characters still jump as high as before.
And from this issue I started thinking about my game performance. There were only about 300-400 objects in the game right now, but it was starting to lag. Well, to put it further, every time I run the code my character is first affected by gravity and falls, but for 1 second all the objects stay still, I think it is lag, or is it initializing the game's initial objects and then running a few seconds later, I don't want the delay (I wonder if my computer configuration is weak or not?
32 bit, RAM: 2GB, Processor: 2.6Hz). In the future, I plan to create a full map and then move the camera along with the character, but given the current situation, it is probably impossible. I would like to ask more about your game, how many objects exist at the same time? And with a game, how many objects co-exist as well? I used to think about splitting the map, each part about 3 to 4 screens, when the character went over that area, delete that area then save it to the data file of the area that went through and Draw a new zone. But that is a bit difficult, I think it initialized like minecraft, but my map is limited. Because of the complexity, I haven't done it yet, it would be nice if you could share more with me about this.
Above are my questions, please answer me, I am very thankful to you.