Bomberman C++ template

Hello there guys, I made this template in about 10h of work and I would like to know your opinion, things to change and improve, a better design etc.
It’s a multiplayer (4players) game based on the classic bomberman ,i want to add an AI controller for the bomberman character, some basic AI for the enemies movement and networking stuff.

Based on my game made for unity:

Its always good to see people sharing their work.

I only opened one class, the character class, and right away I see you have something which isn’t that efficient: checking every-tick for exploded-bombs. You should ‘tell’ the owner the bomb has exploded - if the owner isn’t null. A question though: don’t you destroy the bomb actors when they explode? If so, shouldn’t you get NPE’s in the Tick() function in character? Well, unless you checked the validity of the bomb pointer, didn’t notice if you did when I opened it.

Yes, this is the kind of conversation i was expecting hehe :slight_smile: i’m so glad you bring this topic on.
Well, there is not a big amount of bombs that a player can have, so, O( n ) when n is as much 30 (super big limit) is not consuming so much, personally, I don’t like the approach of making the bomb to send messages to the owner, because the owner owns the bomb and you can manage all of them from one site, then we can remove the tick from the bomb, and make everything in the same character tick, no?..i first did the tick in the bomb , but maybe this is just a design conversation now? Well, what i do is just wait for the bomb to complete the animations operations and start its ready to remove state in the case the owner wants something to do with it, like entering an object pool or something like that…,anyway yes, we should measure the efficience of calling the function to check instead of waiting for a message from the bomb, and then get information to do whatever other stuff it should do, like apply damage?..

People at Epic always say the we should avoid use tick as far as we can, in my experience tick is only for character movement, and stuff you will need every tick like animations, for the bombs I would make a class with time, a mesh and probably a list of effects driven by components, in the begin play set a timer and one event to bind for that timer, after the explosion check who was damage for that, in this case you can use an interface attached to every class that can be damage, like a character or blocks.

I thinks we should based all on facts, Your game mode will hold points and references to your controllers as it should, then your character is able to move, spawn bombs and receive damage (can be better if you add pick objects and use extra skills), the bombs only wait and bum!, the bombs send a message to every effected, and the character send a message to the game mode if he was affected, and probably the game mode can send a message back with the score or rules updated for a UI or something

Hello Zharma, what about using TakeDamage instead of overloading the classes with an interface? , I have made the changes you suggest. Now the question is what is the best way to add collisiopn detection, with a sensor (non-physic collider) and configure a channel, or do the sphere test each n milliseconds during the blast for each part in the 4 directions using the amount related directly with the power of the bomb?


removed the tick from the bomb, created player controller to get the input and control the character (pawn) and a blastdamage class to apply on takedamage, so the control chain is :

  • GameMode creates the bomberman player controller and the character
  • player interaction: input is read from player controller that calls the character functions to move, fire, etc
  • Character creates a bomb and add it to a list ,set also the owner in the bomb
  • The bomb contains only timers:
    • for the fuze to explode ,once
    • size animation together repeated each 0.015sec
    • the explosion creates the blast particles, it then check for collision(colliders or sphere test to detect a hit)
  • the bomb tries to use the character to send him the message of what it hits with the blast if there is no owner, the bomb can call the takeDamage that’s implemented in all actors

In the next step, the character should use the gamemode to know what state is the game in, check what to do with the hit, …and use TakeDamage function for the list of actors being affected by the bomb, this formula works good, for blocks, characters, other bombs, etc, what do you think?


Yeah! take damage is good, it is just because I like to use my own stuff implementing my interfaces, in the first place for more control, and second because make me feel good, I was looking your code, on your bomb try to use a mini state machine, you have many bools, having many bools usually force you to check flow controls everywhere and for rule is not good if you have 3 or more if concatenated, this situation usually means something bad in the logic, for this you can use a enum defining every state, then you can make a transition rule and then you can change from 1 state to another safely, also will help you to debug easily because if a single state is not behaving as it should, you can identify the problem faster,

Another thing, you are animating your bomb size in a loop from your timer, there are more performance ways to archive this, my first option is make a material, you can control your size multiplying your world vertex normal by the sin or cosine of time, something like this: abs(VWN * (Sin(Delta * GrowSpeed))) and all this inside your world offset in your material, the second options is even more artistic, in your favorite 3d package make an animation and import skeletal meshes, probably this is heavy but better for aesthetics