[Solved] Need Help/Advice for creating top down wall building events/extension

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

Screenshots of events at bottom.

Hello. I am working on something that is less of a game, and a bit more of an app, but the behaviors & extensions I’m working on still have in game usage.
(It is unrelated to the first forum post I made.)

I am making a garden planning app, and I am trying to create an extension to draw top down “vector” rooms and garden beds. I am currently only regular tiled sprites in the main scene, but I have been experimenting with this because it would allow for the creation of irregularly shaped buildings and garden beds. I would love to get it working so I can share it with everyone else, I think it could be used to make some neat stuff.

How its supposed to work

There are currently 9 objects involved.

  • 5 sprite objects. 4 are named Node1, Node2, Node3, & Node 4. They all are centered around a central sprite named NodeMother.
  • 2 Shape Painters one called “Walls” and another called “Floor”
  • 2 tiled sprites - one called “BlueWalls” and another called “BrownFlooring”

You can drag the nodes and create a rectangle any shape you want. A shaper painter called “Walls” draws a rectangle between each node except NodeMother. It also masks “BlueWalls”. ShapePainter “Floor” draws a rectangle between all 4 nodes and masks “BrownFlooring”. Once you drag the nodes into the shape you want you can drag NodeMother and they’ll maintain the same relative position relative to it (for the most part, one will usually shift slightly off, but its usually not enough to compromise the core shape).

Problems

It works most of the time. However if you overlay nodes to make a more complicated shape, it can temporarily break(See screenshots below)…

I think a lot of the problem lies in my object picking events. I tried to do a simplified version but it just didnt work, so I had to manually for however many of these Node/NodeMother pairs exist at once. Even then it can only seem to handle two or three and it wont work for any more than that.

My object picking events just dont work that well and I have a feeling I complicated them more than I needed to. I had initially tried to do this with one node object use variable for the objects to allow for the creation of more than one node per “room” so that other shapes besides rectangles could be made, but this is what I could get working. I also have a feeling that the events that determine the relative position of the nodes could also be simplified.

(the “rectangles” drawing extension could also be improved, if two objects have the same X position the wall only shows up as a thin line, but I think I can do figure that out myself.)

If we could get this working, I’d love to work on a tutorial for it. I love the tutorials on youtube and in the documentation. I felt like I learned a lot when I followed the procedural generation tutorial.

I’ve attached the project file at the bottom. I’m not asking anyone to fix this for me, just a little help or to be pointed in the right direction.

Thank you in advance.

P.S. Let me know if you have any questions/ need clarification. My event sheet is spaghetti.

Related screenshots


Two “rooms”

Moved together to create a more complex shape. Node 1 from the right “room” is now covering Node 2 from the right. Node 3 is from the left room is covering Node 4 from right room.

When you the drag the node the shapes are supposed to be cleared until you drop it again. The Node is also supposed to snap to a grid. Neither of these are happening here.

This is one of the things that can happen when I try to simplify the events that pick nodes with same “_instance.node_group” variable.

Project files (optional)

Ok another question. How do I attach a zip? Should I just upload it to gd.games instead? I got it zipped but it will only let me do gifs, jpegs and pngs. Do I need more trust?

gd.games link: Native Plant Gardening (Tile based gardening) | Play on gd.games

Right click to create Nodes and NodeMother.

Event Screenshots






It’s best to post a screenshot of the relevant events. You can post links to a file sharing site like Google Drive but you’d get a quicker reply by posting a screenshot. Not everyone is willing to download a project or they’re reading the posts on their phone.

You can also post a link to a playable version.

Ok, thank you, I’ll get right on it.

edit: Also I just realized I can be a bit more specific about one of the problems. I wrote the vents for distinguishing between groups of Nodes first, and if I remember correctly it worked fine for the most part. I added the NodeMother afterwards. I think the problem seen in screenshot 3 might have something to do with the object picking. It only seems to occur when I start dragging a node and moving. Dragging the NodeMother itself doesn’t cause it, and I dont think it happened before I added the NodeMother, so I think it might have something to do with that.

I’m going to try and see if I can separate out the events the NodeMother events in another event group to see if its a problem with the NodeMother.

Edit2: Ok, that specific screenshot is something to do with the NodeMother. I removed the events related to it and now it doesn’t do that weird thing where it wont clear the shape painter or snap to a grid. It works perfectly fine without the NodeMother. Let me grab some screenshots of the difference real quick.




Edit: I created an updated version of the example that lets you toggle between these events and the ones on the original post.

Here it is: gd.games game build

1 Like

I’m not at my PC. I’ll have a look later.

There’s a lot of code. I honestly don’t have the patience to look through it. Nothing personal.

Here’s how I would handle the drawing of the separate shapes onto separate shape painters. There is no masking and dragging the green “mother” doesn’t drag the group. But I hope this gives you some idea. There’s leftover code bc I originally played with the idea of using external layouts to add the initial objects. I think that is probably the way to go but I didn’t have time for that. So, I kept it similar to your concept. With layouts, you could have preset shapes or different types of textures.

Source: (click green [Code and select download)

add group with right mouse, move numbers or “nodes” with the left mouse.

the group object contains the numbered nodes newSprite1 thru 4

1 Like

Its ok, I don’t take it personally! I spent many frustrating hours on it before I decided to bring it here. I know its ins and outs better and even I barely have the patience for it. Also, layouts is also a concept I thought of. I just decided I should fix that weird bug with the NodeMother before I went about implementing that. Thanks for the example so much!

Your code is much simpler than even the one I made without the NodeMother. The entire square doesn’t disappear when you drag a node too! Thats was another thing I was to get working but couldn’t.

Thanks again and have a great rest of your week! :slight_smile:

1 Like

You’re welcome. It can be difficult looking at events when you don’t understanding the goal or their function. A lot of events can cause a bit of information overload. It’s also tough imagining things in action.

Good luck. It looks like an interesting project.

1 Like

I did some messing around with the example you shared and I was able to get the Nodes to follow the correct mother and not bug out when they get close to another “room”. It works perfectly now!

( I abandoned using external layouts though, the counterID variable wouldn’t reliably load onto them for some reason. Since I have to use separate objects anyway I could possibly just give them their own variables to control their position.)

Gdevelop won’t let me share the example because its technically already online but heres the events:



I get what you mean about information overload and understanding many complex events. Have you seen the island generator in the documentation? Its pretty neat but I don’t even begin to understand its inner workings.
Thanks for your help and the compliment. :slight_smile:

1 Like