Medieval themed 2D strategy game

Thank you. This helped narrow down the problem. It’s not fixed, but now I have input in the panel.

I first split up the “open panels” and “reset” panels into different if statements. I had the panel reset message as an elseif and after splitting it into two separate messages, I realized that it was calling them at the same time.

However, I think this is where the main problem was. This logic was working before, but I changed how selection works yesterday and it didn’t cause an error until today.

I commented out the error. I think I can add that logic elsewhere in addition to not toggling input on/off on the panels. Since I’m removing the panels from view after selection, they won’t be clickable anyway.

if #selected > 0 then
			msg.post(selected[1].id, "deselect")
			-- msg.post("/guis#panel", "reset_panels")
		end

I should learn how to use version tracking.

1 Like

Back on track. I now have a way to queue up multiple waypoints for a unit.

1 Like

For the story, I have the following concept:

Milliseconds before the destruction of the entire universe, you were saved by a being from a higher dimension.

You are the last sign of intelligence.

Nothing and no one else survived.

You have been sent back into time to monitor humanity throughout the ages; guiding them, protecting them, and observing abnormalities.

What caused the destruction?

Could it have been prevented?

Good luck.

This begins the player’s journey through different ages in time; expanding their kingdom, exploring new regions, and solving the mystery. This concept also opens a lot of room for creativity; the abnormalities will gradually be introduced to the player over time, opening up new mechanics, spells, gameplay elements, etc.

1 Like

I set up the logic for gathering food and I’m happy with how it works. I’m using go.animate as a way to pace the messages for the transaction. I also have it self.move check to make sure the process stops once the unit moves.

There’s a trigger check when a gatherer is in the vicinity of a resource has food. If there’s a food<->gatherer match, the gatherer stores the id. It then sends the message to the farm to collect food as long as the gatherer is idle at the waypoint pos.

Once the gatherer is full, it deposits the food at home and awaits further instructions.

1 Like

Currently working on setting up the hex concept for the game. Hexes will be used to alert enemies, expand territory, etc. Because hexes are not a shape that’s supported as a collision object, I’m creating tiles… in Keynote.

I think this solution will work. After the shapes are finished, I’ll use Shoebox to create the tilesheet.

Edit: I was overcomplicating this. I’m instead going to let Defold and Shoebox create the tiles for me.

Last update until I figure this out. It is harder than I imagined. I think it’s a simple concept, but it’s new and therefore not coming to me so easily.

Ended up going with this for now. I’ll create different tilemaps or gameobjects per hex. Each hex is 4 tiles.

image

Working on how units will position themselves at a waypoint. I came up with a solution using a collection factory. By attaching the factory to a waypoint, I can calculate how I want the units positioned. I’ll use this same mechanic to position units during combat.

I also made it so the unit you click on is picked from the stack. And, when that unit returns to the waypoint, it’s added to the end of the line instead of its original position.

2 Likes

Wonder who would win - wolves or berries?

2 Likes

Good question. The berries could be poisonous.

2 Likes

Gradually making progress. I created a docking system for the waypoints. You can see how the units rearrange themselves when they spawn and arrive/leave a destination.

Today I was working on the combat. The game that inspired my game is ranged only. This means I have to come up with my own mechanic for melee combat.

I created a rough version to see how it feels. You can see how the units position themselves when they intersect. I’m using the same docking system that I created for destination waypoints – I just rearranged the positions.

Animations could be better, but those could be improved upon later. I want to first come up with a mechanic that’s intuitive, fun, and feels natural. I’ll get it eventually.

I’m open to ideas for this type of combat. I’ve been looking at other games for inspiration, but no other game quite does it the way I want. Because movement in my game is waypoint to waypoint, there needs to be a way for melee units to fight that doesn’t seem strange.

5 Likes

Now that I have movement, gathering, and a semi-functional combat system, I’m working on how I’ll populate the world. I’m currently using a module to spawn gos in random cords based on the pos I send.

Here’s an example of spawning a lot of wolves.

function M.spawn_enemy(n, type, pos)
	if type == wolf then
		for i = 1,n do
			math.randomseed(socket.gettime() * 100000 * i)
			local rx = pos.x + math.random(-500, 500)
			local ry = pos.y + math.random(-500, 500)
			local i = factory.create("/factories#wolf", vmath.vector3(rx, ry, 1), nil)
		end
	end
end
1 Like

Looks great!

By the way, you should only seed the random number generator once when your application starts. Not multiple times like you do now.

2 Likes

I’ve set up bars for the units and got them to update accordingly. Here’s a video that shows the bars that indicate when items are gathered and damage is taken.

I’m still testing combat. The video also shows some basic interaction. I think it’s coming together. Need more time to test out different situations and fine tune how it feels.

1 Like

When I wasn’t sure what to major in, I chose architecture. It was interesting and fun, but I eventually dropped the classes because there were too rules and too much math. I simply wanted to design.

I’m now feeling that same way with my game. There are things I want to do, but find myself limited due to either my understanding of mathematics or the rules of the engine.

I admit I’ve made progress. But there’s a mechanic I want to implement that is either going to take me a long time to figure out or cause me to drop this game entirely.

The mechanic in my opinion is simple. I want to have logic based on when a unit enters/exit a hex. For example, if a unit enters a hex, the enemies within that hex will become hostile toward that player and move to the players’s destination. The enemies continue to move to the player’s waypoint until combat begins or the player exits.

This mechanic is already done in another game, so I know it’s possible. I was thinking of using triggers, but this seems to require too many groups. Because each hex needs its own logic, there would have to be a different group for every hex. Additionally, each hex would also have to have a seperate script, which I’m told is not good for performance.

I was given this resource to look at, but the concept is too complicated for me to understand, let alone implement. I get the jist of it, but I’m not sure how to make it work in Defold.

http://www.playchilla.com/how-to-check-if-a-point-is-inside-a-hexagon

Here’s an example of what I’ve created so far. Overall, I’m happy with my work if I were to scrap this project. I’ve learned a lot and I can confidently carry my skills over to the next project.

I’m also considering changing the mechanics for my game to something within my mathematical limitations. I was never good at math. And until this point in my life, I’ve never had a use for anything beyond basic math.

I’d like to know more about “each hex needs its own logic” and “a different group for every hex”.

Do you really need that? Couldn’t you use the id of hex (or a script property if you have a script per hex) to look up what kind of hex it is and use this information to run different code paths through your script/module?

Each hex will perform similar functions, but not simultaneously.

Things like:

  • Spawning buildings, food
  • Tracking how much of the map the player has explored
  • etc.

I initially had a unique script per hex, but ran into some issues with the trigger events. My plan was to store the unit id when it enters the hex — and remove it when it exits. That way I would be able to look up all of the units within a hex.

The problem was that when the trigger event occured in one hex, every hex received the event. Perhaps because the on message event is global? The scripts were all different, but they all needed to have to same functions.

I will likely go back to this and try to get it working. I had some discussions in Discord that suggested I not use a script per hex and look into drawing the hexes in code and checking the bounds. But getting this approach to work is beyond my understanding.

Couldn’t you use the id of hex (or a script property if you have a script per hex) to look up what kind of hex it is and use this information to run different code paths through your script/module?

I could do this to store the id of the hex, but I’m not sure how to interact with the units and the hex itself. If a unit were to enter a hex and I use a trigger event / message.enter, it would be received by every hex. How would I make it so the hex the unit enters is the only one that receives the event?

I’m thinking I have to relay multiple messages; one for the trigger event, one to send the correct id to the unit or hex (depending on where I start the event), and one more to confirm the connection.

Thank you for the explanation.

No. This doesn’t sound right at all. I’m going to put together an example.

1 Like

Likely don’t need, although I’m interested in what you write.

I just found the source of the problem. I am using a 1x1 model to draw the hex that’s scaled to 2,000 at the go level. Because of this, the collision shape was also scaled by 2,000. I only realized this when turning on Physics Debugging.

Ah, that explains it :slight_smile:

2 Likes

I’m feeling more comfortable now implementing the features I want. But, something isn’t right. The game feels off. It’s not fun.

I’m playing around with different movement mechanics in order to make the game more action-focused. While I like the game that inspired me to create my game, I’m finding myself getting further away from its mechanics. Ranged-only combat in space behaves a lot differently than soldiers on land.

I’ve been testing different mobile games to get ideas. That’s mostly been uneventful. There’s a lot of really bad mobile games out there and most of them are spam traps with video ads.

I’m now thinking of more of a classic RTS or modern-day MOBA approach to movement. That is, the player can move the units anywhere on the map instead of waypoint to waypoint.

This game may evolve into something else entirely down the road. Pivoting is not a bad thing. Fortnite comes to mind. :slight_smile:

One thing is for certain, I’ll be reusing the code and mechanics I create now in future games. Perhaps I’ll take a short break the next time an interesting game jam comes along.

2 Likes

Fast as fast can be, you’ll never catch me!

Testing some logic. The enemies become hostile to player units that enter the region. They’ll first move to the player’s destination and then continue to follow the player, hoping to intersect with it before it leaves.

If the player exits, the enemies return to their original location.

1 Like