Enemy archer with 12 angles

0 favourites
  • 7 posts
From the Asset Store
Wasteland Blues
$16.10 USD
30% off
A post apocalyptic music pack with 12 main themes and 12 in-game loops
  • I know this is prertty basic <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz"> but i wanted to put this in case someone needs it...

    this is a little .Capx showing how you can make an enemy point in your direction with the angle(x1,y1,x2,y2) expression... its pretty simple... i think i did a good job at picking correctly here...

    using this you can have an archer(rifleman, sniper, etc) with 7 animation to point to the player... and then

    1. put an invisible turret pinned to the archer to fire at the player projectiles.

    2. set the angle of motion of the bullets at the exact agle the archer is looking depending of the angle he is looking (depending of wich animation is on)

    i dont know if this requires high cpu proccesing...let me know guys... what do you think?? any expert can tell me if this is a high cpu way of doing this?? or not... thanks <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    CAPX:

    https://www.dropbox.com/s/80hsm7soafuw6 ... rcher.capx

  • There is a much simpler (with fewer events) way to do this, although I don't know if it's less CPU intensive.

    Unfortunately, I don't remember where I found this example, so I can't give credit to the original creator. I think what he or she manages with 2 events is simply brilliant!!!

    Here is the example, almost as I had found it, I believe I'd striped it some point and click movement functionality and kept only the angle related math.

    http://www.eli0s.com/Tests/AngleSimple.capx

    And here is my adaptation on a tower that uses the sprite's frame number (instead of animations) as a variable in order to change the visual result.

    http://www.eli0s.com/Tests/AngleTower.capx

  • There is a much simpler (with fewer events) way to do this, although I don't know if it's less CPU intensive.

    Unfortunately, I don't remember where I found this example, so I can't give credit to the original creator. I think what he or she manages with 2 events is simply brilliant!!!

    Here is the example, almost as I had found it, I believe I'd striped it some point and click movement functionality and kept only the angle related math.

    http://www.eli0s.com/Tests/AngleSimple.capx

    And here is my adaptation on a tower that uses the sprite's frame number (instead of animations) as a variable in order to change the visual result.

    http://www.eli0s.com/Tests/AngleTower.capx

    O: WOW i will check it out

  • There is a much simpler (with fewer events) way to do this, although I don't know if it's less CPU intensive.

    Unfortunately, I don't remember where I found this example, so I can't give credit to the original creator. I think what he or she manages with 2 events is simply brilliant!!!

    Here is the example, almost as I had found it, I believe I'd striped it some point and click movement functionality and kept only the angle related math.

    http://www.eli0s.com/Tests/AngleSimple.capx

    And here is my adaptation on a tower that uses the sprite's frame number (instead of animations) as a variable in order to change the visual result.

    http://www.eli0s.com/Tests/AngleTower.capx

    it looks very easy

    can you tell me this string "int(32*(1+tower.a/180)+0.5)%33"

    i tried to toy around with it... but math is not my strong side

    i understand that you convert the angle variable "a" and change it to a integer to "dir" that matches your number of animations so you can call the animation just using "dir"

    very impressive... im very good at understanding logic

    but math just kills me

    SO can you please tell me how would you chage that 32 that returns int(32*(1+tower.a/180)+0.5)%33 expression

    to the 12 angles that i need?? instead of 32

    and instead of 180º to 360º as you saw in my example... if you help me i will appreciate it and definitely will give you the credit in my game

    thanks!!!

  • Well, I won't pretend that I understand the math neither

    In your case, since you want a full circle divided into 12 frames the expression that works is the following: int(12*(1+Archer.a/360)+0.5)%12

    Here is an example, I added some movement and arrow firing functionality just for fun. What interests you are the the 2 first events.

    http://www.eli0s.com/Tests/LunatrapArcherExample.capx

    I hope that helps!

  • Well, I won't pretend that I understand the math neither

    In your case, since you want a full circle divided into 12 frames the expression that works is the following: int(12*(1+Archer.a/360)+0.5)%12

    Here is an example, I added some movement and arrow firing functionality just for fun. What interests you are the the 2 first events.

    http://www.eli0s.com/Tests/LunatrapArcherExample.capx

    I hope that helps!

    i really appreciate it

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You're welcome!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)