# Masterneme's Shooters & Experiments

**URL:** <https://forum.defold.com/t/masternemes-shooters-experiments/70841>\
**Category:** Dev diaries\
**Created:** [May 4, 2022, 9:41am UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841 "2022-05-04T09:41:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [May 4, 2022, 9:41am UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/1 "2022-05-04T09:41:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [May 6, 2022, 3:26pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/2 "2022-05-06T15:26:15Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Alex\_8BitSkull](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alex_8bitskull/32/5424_2.png) [@Alex\_8BitSkull](https://forum.defold.com/u/Alex_8BitSkull)\
**Post date:** [May 6, 2022, 3:41pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/3 "2022-05-06T15:41:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [May 6, 2022, 3:56pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/4 "2022-05-06T15:56:29Z")

</div>

For future reference, I found [this thread](https://forum.defold.com/t/creating-a-weapon-system/7498) talking about data driven weapon systems.

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [May 8, 2022, 11:16am UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/5 "2022-05-08T11:16:16Z")

</div>

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](https://forum-defold.b-cdn.net/uploads/default/original/3X/f/c/fcf45e15fab806f36cadfd8e0c9b178b6e8c0588.png)

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.

---

<div class="post-metadata">

**Author:** ![Alex\_8BitSkull](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alex_8bitskull/32/5424_2.png) [@Alex\_8BitSkull](https://forum.defold.com/u/Alex_8BitSkull)\
**Post date:** [May 8, 2022, 11:22am UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/6 "2022-05-08T11:22:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [May 8, 2022, 11:42am UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/7 "2022-05-08T11:42:29Z")

</div>

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](https://defold.com/examples/animation/cursor/).

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. 👍

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [May 13, 2022, 4:57pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/8 "2022-05-13T16:57:05Z")

</div>

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:

[![](https://img.youtube.com/vi/NRY6g8YPjQI/maxresdefault.jpg "Tinkering With Defold Engine #1") ](https://www.youtube.com/watch?v=NRY6g8YPjQI)

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.

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [May 23, 2022, 3:42pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/9 "2022-05-23T15:42:39Z")

</div>

Now the player can move and shoot in different directions:

[![](https://img.youtube.com/vi/hfbNcjwyR2I/maxresdefault.jpg "Tinkering With Defold Engine #2") ](https://www.youtube.com/watch?v=hfbNcjwyR2I)

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. 😅

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. 😆

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

---

<div class="post-metadata">

**Author:** ![anon95708182](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@anon95708182](https://forum.defold.com/u/anon95708182)\
**Post date:** [May 24, 2022, 7:47am UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/10 "2022-05-24T07:47:54Z")

</div>

> [@masterneme](#):
>
> 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.

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

```lua
-- 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

```

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [May 24, 2022, 7:55am UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/11 "2022-05-24T07:55:07Z")

</div>

I usually do something like this:

```lua
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`

---

<div class="post-metadata">

**Author:** ![anon95708182](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@anon95708182](https://forum.defold.com/u/anon95708182)\
**Post date:** [May 24, 2022, 7:58am UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/12 "2022-05-24T07:58:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [May 24, 2022, 9:31am UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/13 "2022-05-24T09:31:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [May 25, 2022, 12:27pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/14 "2022-05-25T12:27:15Z")

</div>

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

[![](https://img.youtube.com/vi/GlrRgevpu-o/maxresdefault.jpg "Tinkering With Defold Engine #3") ](https://www.youtube.com/watch?v=GlrRgevpu-o)

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

---

<div class="post-metadata">

**Author:** ![88.josh](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/88.josh/32/20137_2.png) [@88.josh](https://forum.defold.com/u/88.josh)\
**Post date:** [May 26, 2022, 7:46pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/15 "2022-05-26T19:46:58Z")

</div>

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

> [@masterneme](#):
>
> It’s SO COOL that I can do everything within the Defold editor.

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!

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [June 3, 2022, 5:43pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/16 "2022-06-03T17:43:07Z")

</div>

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.

[![](https://img.youtube.com/vi/_wmY_w7rI5s/maxresdefault.jpg "Tinkering With Defold Engine #4") ](https://www.youtube.com/watch?v=_wmY_w7rI5s)

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?

---

<div class="post-metadata">

**Author:** ![88.josh](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/88.josh/32/20137_2.png) [@88.josh](https://forum.defold.com/u/88.josh)\
**Post date:** [June 3, 2022, 6:33pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/17 "2022-06-03T18:33:27Z")

</div>

> [@masterneme](#):
>
> 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.

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).

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [June 3, 2022, 7:47pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/18 "2022-06-03T19:47:10Z")

</div>

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 😈

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [June 4, 2022, 10:34am UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/19 "2022-06-04T10:34:14Z")

</div>

More angles added to enemies.

[![](https://img.youtube.com/vi/A_pKymgLBn0/maxresdefault.jpg "Tinkering With Defold Engine #5") ](https://www.youtube.com/watch?v=A_pKymgLBn0)

---

<div class="post-metadata">

**Author:** ![masterneme](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/masterneme/32/31665_2.png) [@masterneme](https://forum.defold.com/u/masterneme)\
**Post date:** [June 15, 2022, 8:40pm UTC](https://forum.defold.com/t/masternemes-shooters-experiments/70841/20 "2022-06-15T20:40:40Z")

</div>

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?

[Next page](https://forum.defold.com/t/masternemes-shooters-experiments/70841.md?page=2)
