Need help with a buy system in td game!

So i need a way to click on a tower and buy it with a certain amount of money and then place it using grid system…
now sadly I cant use @hihilogic info/example

3 Likes

3 Likes

link?

3 Likes

to my game?

2 Likes
2 Likes

would you want to do a click to select and click to place or click and drag

3 Likes

NA NI
click to select and then click to place seems like it would be easier but i dont want it to be placed on the (road) just the (play area) and again grid system

2 Likes

that part of if it’s on the road or not should be easy
For this you need to split it up into two things, the selection and the placement.
Selection:

  • there needs to be an indication of what is selected
  • when a new object is selected, all other objects should be deselected

Placement:

  • needs to detect if it is a place-able tile(for example, whether there is a road or not)
  • can only place if there is enough money
  • needs to spawn the tower inside the square correctly
  • needs to subtract the money after the tower is placed
1 Like

for the selection part i could have a number for each tower and then use a filter to decide which tower i want to place

1 Like

yes that sound like it would work

1 Like

now for the placement part i dont know how that’s going to work in the block coding anyways in theory it is decently simple

1 Like

could you make an example for it

1 Like

This is my own game that I made
buying towers logic is all in the spawner and button_buyTower objects

There is some extra stuff in there with the selection part cause I used one object type

3 Likes

I saw that a lot of people are using grid based placement, the TD game I started working on you can place them anywhere, even on top of other towers, but they move out of the way. I need to make a failsafe cause they can bug out and fly around when you place them within the road, lol.

Also I haven’t had much of an issue with a purchasing system. What I have installed is that you click on a tower and it spends the money when you place it, then you can upgrade each tower individually by sending messages to a money counter that keeps track of income and outcome, like gaining money from Windmills and enemy kills and spends money on upgrades and tower purchases.

3 Likes

that sounds pretty cool : )
what happens if the screen is full and you place a tower down?

1 Like

I haven’t tried it, but you probably won’t gain enough money to get there yet.

2 Likes

That REALLY sounds like a challenge :upside_down_face:

3 Likes

The game breaks after wave 6 so idk if you can, lol. I’ve yet to fix that.

2 Likes

Does anyone have an idea on how to make this work.

1 Like

basically whatever tower you click on sends a message and attaches it to the selector and then click on the grid pay area you want to place i ton

1 Like