Masterneme's Shooters & Experiments

Hi,

I’ve been making a sprite-based first person shooter (“Doom clone”) with Unreal Engine 4 called ProBoon. Additionally, the idea was to release the code with some basic assets so people could learn how to do the same, I called this Project Boon.

Because my personal life has been a mess the progress has been really slow but I have almost all the pieces needed for a single player “Doom clone”.

Now Unreal Engine 5 is out and I’m going to port everything to it. But sharing some logic is difficult because of the visual scripting language and Unreal Engine has its own way of doing things, so I’ve found myself “fighting” the engine many times.

I decided to make a “low graphics” Project Boon with Defold. I’m not interested in just first person shooters and Defold is better than UE for the small projects and experiments I have in mind.

I have nothing to show yet, I’m finishing some video tutorials but I will start posting stuff very soon, this was just my “Hello Forum”.

I don’t want to overcomplicate things so I’ll start making a 2D top-down shooter with Kenney’s assets. Something like Hotline Miami with Doom mechanics. Once I become more experienced with the engine I’ll add the 3rd dimension.

So far, I’m liking the experience, Lua and Defold are great and the messaging system is pretty cool.

I’ll have to figure out how to translate some things from UE but I think it’ll work out fine.

12 Likes

OK, before I start I’m already thinking about the future. I want to keep most if not all the stats from weapons and characters in one place and stay away from OOP as much as possible.

From what I’ve learned so far, I could create a Lua file with a table containing all that and then import anything I need using “require”.

In fact, and correct me if I’m wrong, I could basically put every stat there, including power-ups, health packs, armor, ammo… everything, and use what I need when I need it.

For Unreal Engine 5 Epic released Lyra, a 3rd person shooter. And they have chosen a data driven modular design. I want to use the same approach in UE5 and Defold.

Any thoughts?

Yeah, that sounds like a great approach for Defold. It’s how I structure things.

2 Likes

For future reference, I found this thread talking about data driven weapon systems.

I started organizing data in a Lua module. It’s SO COOL that I can do everything within the Defold editor.

Now I have a doubt about sprites/flipbooks:

flipbook

Player is green and moving to the right.
Enemy is red and it has 4 idle animations for each angle.

When Player crosses the edge between angles from FRONT to RIGHT I want to know the exact position on the flipbook animation so I can switch the animation angle and continue from that point instead of starting over.

In other words, let’s say I have the animations idle_front and idle_right. Both last 1 second.
When Player crosses the edge, idle_front is at 400ms.
Then, to make the character animation seamless, I start idle_right from 400ms + deltaTime.

I’ve been reading the documentation and, if I’m not mistaken, I could do this using the cursor and offset properties on sprite.play_flipbook() but I’m not sure, is this correct or the values they provide are for other stuff?

If I can’t use those properties I already have a plan B to do the same with timers, so it’s not a big deal.

I’m not being cheeky, but have you tested it? It should be very quick to do. For what it’s worth I do think getting and setting the sprite cursor is the correct approach.

3 Likes

Not yet, I just wanted to consult about the cursor property because I wasn’t sure about what it does.

For future reference, I found this example.

Update: I downloaded the examples and, after a few tests, I confirm that with cursor, get and set I can get the results I want. :+1:

4 Likes

I’ve been going through a bunch of tutorials, examples, reading the documentation and other stuff to immerse myself into Defold.

I’m going to start posting my progress here.

I’m going to build a top-down twin-tick shooter similar to Smash TV. I just finished the War Battles tutorial and will use it as a foundation, here it’s a video demoing it:

Yes, I know it’s lame. But that’s the point, so one day in the future I can look back and see how much I’ve progressed.

2 Likes

Now the player can move and shoot in different directions:

It’s embarrasing but this took me a while to figure out. All because I wasn’t totally satisfied with the default way of handling directions. As I tipically do, I had to find the most complex logic and make things difficult for myself. :sweat_smile:

Well at least now it’s working and I’ve learnt a lot about Defold so I guess it’s worth it.

The problem was that if the player presses left and right or up and down at the same time, I want it to stop moving, since it makes sense to me that both directions would cancel each other out.

With the default control bindings it doesn’t do that. Not a problem for most people but I’m very picky, so what I did is assigning values to each one of the 4 directions.

Right becomes 1 instead of (1, 0, 0)
Up becomes 2 instead of (0, 1, 0)
Left becomes 4 instead of (-1, 0, 0)
Down becomes 8 insead of (0, -1, 0)

Then I add all the values and the total is a number I can use to find different values inside some tables.

I’m only extracting Vector3s, but now that it’s done I can expand it for animations.

I’m not sure if you have played many twin stick shooters, most of them have weird ways to handle movement and the character animation looks anatomically incorrect, as if it didn’t have a spine or something. :laughing:

With Unreal Engine you process this using Blend Spaces and I wanted a similar result.

2 Likes

There are probably more ways to solve this. That’s how I do it, I just use flags:

-- booleans to check if opposing keys are pressed
local pressing_up = false
local pressing_down = false
local pressing_left = false
local pressing_right = false

Then, I set the flag to true if the key is pressed , check and set the corresponding value in the vector to 0 to stop movement:

-- do not move if opposing keys are pressed
if pressing_down and pressing_up then
	self.move.z = 0
end
if pressing_left and pressing_right then
	self.move.x = 0
end

And at the end of the update function, I reset the flags:

-- reset booleans to check for opposing keys 
pressing_down = false
pressing_up = false
pressing_left = false
pressing_right = false
2 Likes

I usually do something like this:

if action_id == hash("left") then
    self.input_x =  self.input_x - 1
end
elseif action_id == hash("right") then
    self.input_x =  self.input_x + 1
end

And at the end of the update(), I reset it with self.input_x = 0

5 Likes

@Mathias_Westerdahl: Mathias, that is clever and so much shorter!

1 Like

That’s a very elegant solution! I think I’m going to use it to calculate shooting so I can know both, the direction the character is facing and where’s moving to. Thank you.

And thank you @anon95708182 too, I was going to do something similar at first but I thought it would be easier to manage animations by adding numbers. I also need to calculate opposites to reverse animations some times so the character looks walking backwards instead of “moonwalking”, so it’s good to know that someone else is doing that and it works.

4 Likes

I added sound effects, walking animations and automatic shooting at a determined rate.

There’re some glitches that need fixing but I’m going to focus on building other stuff first

2 Likes

Well done for working so hard on this and making so much progress in just three weeks.

This is a great feeling isn’t it? Programming seems very difficult when you are starting out, but it’s also true that there is a huge amount of potential just from mastering the basics. Keep us updated!

2 Likes

Thanks to all the examples and code snippets I’m learning a lot. I’m getting very close to a point where I can have almost if not all the functionality needed to clone games like Gauntlet or Alien Shooter.

For something more sophisticated I’d have to do some research about path finding. I’ll do that in the future.

Something I’m not so sure about how to do is decals for explosions and blood. I’ve been thinking about using a grid layer like the early Command & Conquer games, but I guess the “proper” way is to use sprites.

Crimsonland or Alien Shooter would have the floor completely covered in blood at the end of the level and I want something like that.

My initial idea is to have a “decal manager” game object that would receive a message every time an enemy dies. Then it would spawn a sprite and save it in a table.

Is this a good idea or is there already a proven/better way that I’m not aware of?

1 Like

Rather than having one manager, it might be simpler to include the code for blood spatter in each individual enemy (if you use that explosion animation, it’s just a case of changing the sprite to a blood puddle each time).

Wouldn’t that make the game go beyond the engine scripts limit? Because Crimsonland and Alien Shooter can easily have you kill thousands of enemies and I want that too :smiling_imp:

More angles added to enemies.

1 Like

I’m preparing an update but this post is not about that.

This is a “note to self” to remind me about a game called Brutal Mood that I had on my wishlist but forgot about it.

It’s a combination of Hotline Miami and Doom, exactly the concept I wanted to play with. It has a lot of positive feedback and interest, so it’s a potentially viable idea worth pursuing.

I’m not sure if I want to add lighting effects though. I prefer a cleaner look, like Crimsonland or Alien Shooter have. Maybe some kind of fog of war to hide unvisited rooms?