Enemy archer with 12 angles

Discussion and feedback on Construct 2

Post » Mon Mar 17, 2014 5:53 pm

I know this is prertty basic :P 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 :D

CAPX:
https://www.dropbox.com/s/80hsm7soafuw6 ... rcher.capx
You do not have the required permissions to view the files attached to this post.
B
23
S
6
G
3
Posts: 316
Reputation: 3,461

Post » Tue Mar 18, 2014 11:01 pm

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
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Wed Mar 19, 2014 11:47 pm

eli0s wrote: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 :) thanks a lot :D
B
23
S
6
G
3
Posts: 316
Reputation: 3,461

Post » Thu Mar 20, 2014 12:17 am

eli0s wrote: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 :P
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!!!
B
23
S
6
G
3
Posts: 316
Reputation: 3,461

Post » Thu Mar 20, 2014 2:26 pm

Well, I won't pretend that I understand the math neither :? I just fiddle with the numbers until I get what I want. Pretty much as the next monkey will do :oops:

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!
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Thu Mar 20, 2014 4:12 pm

eli0s wrote:Well, I won't pretend that I understand the math neither :? I just fiddle with the numbers until I get what I want. Pretty much as the next monkey will do :oops:

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!


:D thanks a lot!! you are gold :) i really appreciate it
B
23
S
6
G
3
Posts: 316
Reputation: 3,461

Post » Thu Mar 20, 2014 5:54 pm

You're welcome!
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests