|
Posted By
|
Message
|
 infinitum3d
Registered 3/3/2012 10:18:24 PM
Points 66
|
13th March, 2012 at 3/13/2012 12:46:53 AM -
I have an archer shootingan object at my mousecursor. The problem is, it sometimes misses. My hotspot is set to the center of each of my objects. Any idea what could be wrong?
Thanks!
n/a
|
 Chris Burrows
Registered 9/14/2002
Points 2396
|
13th March, 2012 at 3/13/2012 1:10:41 AM -
Post your mfa and I'll take a look.
n/a
|
 infinitum3d
Registered 3/3/2012 10:18:24 PM
Points 66
|
14th March, 2012 at 3/14/2012 8:24:16 PM -
So I figured it out. There are only 32 directions the arrow can travel using the Bouncing Ball movement type. (15 if you don't count straight up/straight down or backwards.) Is there any way to increase the number of directions using a different movement type? I can probably calculate actual degrees to get 360 directions (using y=mx+b), but if there is an easier way, I'd love to hear it =
Thanks!
Edited by infinitum3d
n/a
|
 Windybeard Games
Registered 4/14/2005
Points 101
 
|
15th March, 2012 at 3/15/2012 1:42:58 AM -
• Always
→ Set Angle("Player") to ATan2(Y( "Player" )-YMouse, XMouse-X( "Player" ))
→ Set XPos("Bullet") to XPos("Bullet") + (Cos(Angle("Bullet")) * Velocity("Bullet")
→ Set YPos("Bullet") to YPos("Bullet") - (Sin(Angle("Bullet")) * Velocity("Bullet")
→ Set X("Bullet") to XPos("Bullet")
→ Set Y("Bullet") to YPos("Bullet")
• Repeat while left mouse button is pressed
→ Create Bullet at 0,0 from Player
→ Set Angle("Bullet") to Angle("Player")
→ Set XPos("Bullet") to X("Player")
→ Set YPos("Bullet") to Y("Player")
http://cid-b1e7ee094271bbda.skydrive.live.com/self.aspx/Public/shooter2.mfa
got that from a search of articles. (sketchy's post 2009)
SWEEZY GUNNER! Coming soon.
http://www.create-games.com/project.asp?id=2205
https://www.facebook.com/SweezyGunner
|
 infinitum3d
Registered 3/3/2012 10:18:24 PM
Points 66
|
15th March, 2012 at 3/15/2012 12:42:01 PM -
ATan2 gives a syntax error in TGF2.
n/a
|
 Stephen [NeonairGames] Crazy?
Registered 7/24/2002
Points 4522

|
15th March, 2012 at 3/15/2012 1:27:06 PM -
Have you seen my archery physics example? Maybe that would help.
http://create-games.com/download.asp?id=7477
http://www.neonairgames.net
|
 Duncan Thelonious Dunc
Registered 5/18/2002
Points 577
|
15th March, 2012 at 3/15/2012 9:51:40 PM -
ATan2 was added in build 248 or 249 or something, it works in TGF2:NE. Check version?
n/a
|
 infinitum3d
Registered 3/3/2012 10:18:24 PM
Points 66
|
15th March, 2012 at 3/15/2012 11:39:08 PM -
Yep. Wrong version. Should I run the #253 build or #251?
n/a
|
 Duncan Thelonious Dunc
Registered 5/18/2002
Points 577
|
16th March, 2012 at 3/16/2012 12:57:11 PM -
I have no idea if there's any benefit to using 251 over 253
n/a
|
 Jenswa Possibly Insane
Registered 8/26/2002
Points 2217
|
22nd March, 2012 at 3/22/2012 7:06:42 PM -
Instead of relying on trigonometric functions, just use dy and dx instead
The distance along the horizontal and vertical axis between the archer and the object can be calculated from their respective x and y coordinates, dx = x_object - x_archer and dy= y_object - y_archer.
Those number you get must then be 'normalized' to 1. Example: if the ratio dx/dy is" 50/10, normalize to 1/0.2 meaning 1 pixel to the right and 0.2 pixels up. You can multiply this ratio with the speed of your arrow and you've all the directions you need.
Check out DTV Boxes http://ow.ly/k13fh (work in progress)
Download hh_beer.zip from http://ge.tt/4d07kPc/v/0 and hhxl.zip from http://ge.tt/3kbXlPc/v/0
|
 infinitum3d
Registered 3/3/2012 10:18:24 PM
Points 66
|
23rd March, 2012 at 3/23/2012 12:44:17 PM -
Thanks Jenswa. My original intent was to use the slope intercept equation y = mx + b or more precisely, m = (y2-y1)/(x2-x1).
n/a
|
 Jenswa Possibly Insane
Registered 8/26/2002
Points 2217
|
23rd March, 2012 at 3/23/2012 9:25:46 PM -
Your welcome infinitum3d,
last night after posting I continued reading Calculus and read the word slope and I knew that was exactly the word I was looking for. I am a mathematichs teacher in Holland and sometimes I can't find the right English words for these cases, but the explanation mostly rings a bell.
You only need the slope because that will give you right direction, just remember to do the signs the right way.
Scaling the slope (triangle isn't it) should give you full control over the speed.
Happy coding with your archer.
Check out DTV Boxes http://ow.ly/k13fh (work in progress)
Download hh_beer.zip from http://ge.tt/4d07kPc/v/0 and hhxl.zip from http://ge.tt/3kbXlPc/v/0
|
|
|
|