Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Oct 2015 20:08 Edited at: 9th Oct 2015 20:19
Hi.

I want after hit Player Punch to enemy, enemy throwing from A point to B Point. But I don't know how can Throwing enemy.

Note: I want do this without Physics.

Thanks to anyone who can help me.


Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Oct 2015 22:17
i would use the distance (b.x-a.x) from a to b as angle 0-180 degree in sinus
y=starty+Sin(angle) * flyingheight
x from a to b
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Uncle Martin
17
Years of Service
User Offline
Joined: 9th Jul 2006
Location: Tampa, Florida, USA
Posted: 10th Oct 2015 06:05 Edited at: 10th Oct 2015 06:11
I know you said you didn't want to use physics, but you can implement your own simple 2D physics for projectile motion. When the punch is received, you can impart an instantaneous X & Y velocity into the character being thrown & let your physics code do the rest. Here's some sample code that shows all that. Hit the space bar to "throw". You can go in & adjust the constants for gravity & friction & set it to bounce or "flop". I provided a "ball" as a sprite, but use whatever small image you want. Enjoy.

Code every line like it might be your last...
Someday it will be.

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 10th Oct 2015 12:54
example from me
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Oct 2015 14:45
Thanks Markus and Uncle Martin for your Examples.

I check them and if there is any problem ask again.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Oct 2015 20:41 Edited at: 11th Oct 2015 21:39
I wrote new code for Throwing :



Please tell me this code is good or not. mean will be on devices no have problem?

Thanks.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Oct 2015 23:56 Edited at: 12th Oct 2015 00:03
its not frame independent, means on slower devices the game play is slower.
but because of today quad core handys with GHz CPUs i would not care, i think u will reach 60 FPS.

your example looks good but the player seems stops abrupt at the slide part.

if you want see the flight curve u can set EnableClearColor(0) before loop.
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 12th Oct 2015 05:56 Edited at: 12th Oct 2015 05:57
Thanks Markus.

Quote: "your example looks good but the player seems stops abrupt at the slide part."


yes, seem after come to custom position,stops abrupt. can you find where is the problem?

Quote: "if you want see the flight curve u can set EnableClearColor(0) before loop."


good idea, but what I use EnableClearColor(0), flight curve is Shakes. is this relate to my code? or this problem is normal after use EnableClearColor(0)?

Thanks
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Oct 2015 07:41
"can you find where is the problem"
about the stop at the end i think its because the whole way from left to right is a linear movement.

"flight curve is Shakes."
i don't know, maybe because its just a fast movement.

your code will be better to understand if u call this new position only once
"SetSpritePosition(Enemy..."
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 12th Oct 2015 09:45
OK, Thanks Markus for your help.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 12th Oct 2015 10:14
You could pre-calculate all the positions in the "throw path" and store in an array. Then you could use the timer to grab the required position from the array following a punch hit.

Before you ask: No, I'm not going to give you the code.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Oct 2015 11:43
i agree, a pre-calculate list is a good idea because its easy to create/fill.
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-04-24 10:44:11
Your offset time is: 2024-04-24 10:44:11