gamedev
Work a lot on the level editor. I've added edge tiles, but this caused a problem with the level format because the number of tiles is now in the double digits and I was using two digits in the tile maps. The first determined if the tile was drivable or not and the second was the index of each tile. I had to make the tile maps triple digits now because of that.
gamedev
So, I think I fixed the lag problem, key word being "think". So, in SFML, you have two objects for sounds: sf::SoundBuffer and sf::Sound. The sound buffer just loads the sound file. And sf::Sound is an instance of said sound with a pointer to the buffer. Up until now, I have every game object holding all of the sounds they play in their own sf::Sound objects. I thought it wouldn't be a strain on the memory because the actual sound data is stored in the buffers, but now I have a singleton class to handle all the sound playing.
I've noticed that there is somewhat less lag when there is a clutter of cars, but I haven't truly verified that yet. I haven't done it on a huge cluster of cars. Anyway, this should be a good thing, because the game is piss easy right now with amount of enemies on-screen.
gamedev
Maybe it did fix the lag, but only slightly. I've also rearranged some if-statements, which also seemed to help.
Regardless, if you drive slowly enough, eventually all the cars in the level will appear on-screen at once because the only start moving once they are fully onscreen and will only disappear once they are on the bottom of the screen. So you will eventually get lag. But nobody is going to play the game that way so who cares?
Unlike my previous game, enemies do have some sort of AI, as opposed to just having patterns. Naturally, there are a few state machines and lot of if-statements even for this basic AI, but that's also because of poor planning. Some could be turned into switch statements.
Also, having a mine car does increase difficulty, a little bit. So, I probably won't need that much more cars on screen.
Anyway, the game is coming along nicely and quickly regardless. Like the last game, don't expect anything ground-breaking, just something that would be fun for a couple of minutes.
gamedev
Oh, I've also replaced one large if-else statement with a switch statement. I think that might help with performance. Contrary to popular belief, a switch statement and an if-else statement do not compile the same way. if-else uses branching instructions (constantly checking for and calculating conditions) while a switch statement uses a lookup table.
gamedev
gamedev
I'm realizing that this game is piss easy because Spy Hunter-style enemies can only attack from the side. While I do have a mine car. It isn't enough. Unlike the original Spy Hunter, enemies cannot appear from behind because this game has predefined enemy placement. And if you know where the enemies can attack, you can always attack from behind, and never have to deal with the threat of enemies attacking you.
I plan on adding one more enemy that appears from behind and will shoot you on sight. Hopefully, it will add a little bit more challenge. However, I need to be careful about adding too many enemies on screen because of the lag problem that I can only mitigate so much.
The other option is just to scrap predefined enemy placement altogether, and have cars appear from either the top or bottom after a certain interval with a limit on how many cars can appear on-screen at once. This would obviously be a hard choice because I put so much work in designing the levels and even creating my own level editor, but unexpected turns are just simply a reality in game development.
gamedev
Now, I'm experimenting with having randomly spawning enemies as opposed to predefined enemy placement in levels. It should help with the problems I had previously and also allow me to include enemies that appear from behind (which I haven't implemented yet).
I should also tweak the behavior of some enemies. Have them catch up to the player, if they attack from the side.
gamedev
@xianc78
Good job, it fits the theme perfectly
gamedev
@LukeAlmighty Thanks. Now, going off from your deleted post (not offended btw), I just realized that not everyone has a middle name, which may be a problem.
gamedev
@xianc78 @LukeAlmighty not everyone uses their initials. some people use shortened versions of their first name or tag, or just letters they like.
@xianc78
Sorry.
I wrote the first post on impulse, and then immediately realized, just how tasteless it was.
gamedev
@xianc78 ski free vibes
gamedev
Okay it doesn't seem like it's fixing the lag. At least it did fix the problem of audio crashing (apparently you can't have more than 140 sf::Sound objects in memory). I will try to fix the problem tomorrow because my adderall is wearing off.
#gamedev #SFML