Turret AI sensing for games like Boom Beach


#1

@AHappyCoder
@GoatLord
This might interest you

If you've played Boom Beach or Clash of Clans and wanted to make a cannon that senses when an enemy is near and aims and shoots at them, this is a way to do it on Hopscotch

Place a circle on the screen that will act as a sensor
Place something like a cannon in the circles centre
Place a cannon ball at the circles centre

Code for cannon:

When (enemy) bumps circle (point towards+code) to the enemy

Code for cannonball:

When (enemy) bumps circle (point towards+code) to the enemy
Move forward "X"
Set position to the circle "X" and "Y" position, set invisibility to 0%

When cannonball bumps enemy, set invisibility to 100%

Only when an enemy is touching the circle will the cannon ball be fired at it.


#2

Heres a like.
:heart:
I'm going to try this out.
If I publish something with it you will get credit.


#5

https://c.gethopscotch.com/p/y1rh5z7ft

I quickly made this after you said you were going to make this on Hopscotch.


#6

I made this one.
You aren't on the side of the turret, you are the anteater trying not to get hit by it.
You have to collect Red Heart jewels (idk lol)
It's called Cops and Robbers
Drag the anteater to control it.


#7

That's a great idea.

For a challenge do you think you could use cos/sine
to have a yellow circle orbit a character-tower
Make the screen black like night.
Only when the yellow circle bumps the player have the player shot at.
This would be like sneaking into a building at night with someone checking the premises with a spot light.
You could make a game like this with your idea of a jewel thief
And have your cos/sine code for making the yellow circle move closer/further from the tower


#8

I could start on something like that for the second version.
It will take some time though.


#9

Does your published game lag when u play?
My ipad is the ipad 3 and it"s pretty worn out and weakening in performance.
Even the project i published had a little lag and wasn't running smoothly for me


#10

No, I have an iPad Air 2 so it runs pretty smooth.


#11

I made The Jewel Thief
Same control method.
When the spotlight hits you, it permanently stays on you and two turrets start firing.
One fires the opposite direction to you, the other fires at you.
So it is pretty hard once you get detected.
In the future I might make a really hard version with a four way shooter.


#12

That runs smoother on my ipad than your last effort.
I like the light staying on the players character when it touches it
One thing i noticed is after the lights focusing on the players sprite, if i take my finger off the sprite and press it again, the sprite won't move when pressing.sliding my finger around the screen.
Maybe send the light to the back of the sprite will fix this


#13

@Stradyvarious that is a very cool design! I might use this in something :D

@GoatLord Yeah! That is hard, my score is 110 and I didn't get detected lol. Like Strady said, if you take you finger off the player once you are detected you can't move. Maybe a hitbox would help!


#14

I fixed it and released a new version.


#15

Here is the link: https://c.gethopscotch.com/p/y1rm4rqyy

Oh and @AHappyCoder
I will make the spotlight harder to dodge as your score gets higher in the next version


#16

Yeah i just searched and played it.
The game runs very well.
If you add more to the game, post a link here or make a new topic showing your game.
I'd be very interested to see your results


#17

Ok sure.
I will definitely be updating it over time.


#18

Also, an idea would be have the player instantly die if they touch the centre triangle.
This would make the game more challenging, so the player can't take a shortcut through the centre


#19

The next version is here!
The player dies if they touch the turret, and the spotlight gets faster as the score gets bigger.
@AHappyCoder i have a feeling you will find it much harder to get to 100 undetected now!
The Jewel Thief v2


#21

awesome.
It's more challenging now with you extra additions.


#22

Version 4 is out now!
With a Modulus clock to increase the speed of the spotlight by 0.25 every 5 points you get!
https://c.gethopscotch.com/p/y3ptm3rx9


#23

It works great.
Good job
I still can't really think of how i would use modular when i think of my previous projects.