Information

Author:
    noshenim
Rating:
    N/A
(2 more votes required)
Type:
    Example
Language:
    GM 6
Reviews:
    None
Submited:
    August 25, 2010
Dev - DB/form (refering to updated - check code)
Download:
    DOWNLOAD (508)
Dev - make AJAX
Screenshots (2)
Dev - Also, on form submission, use GD to resize the image as a new thumbnail file
Dev - In the submission form, you can now upload a banner image
Intercepting moving objects
New code:
Quote

/*
strike( cannon x,y,speed, target x,y,speed,angle ) = best cannon angle
*/
var cx,cy,cs,ca,px,py,ps,pa;
cx=argument0;
cy=argument1;
cs=argument2;
px=argument3;
py=argument4;
ps=argument5;
pa=argument6;

var dir,alpha,phi,beta;
dir=point_direction(cx,cy,px,py);
alpha=ps/cs;//for every 1 that the bullet moves, the target moves by alpha
phi=degtorad(pa-dir); //pa-dir = distance in radians that pa is above dir
beta=alpha*sin(phi); //
if (abs(beta)>=1)return(-1);
dir+=radtodeg(arcsin(beta));
return dir;


Target platforms:



Dev - Warning
Dev - After editing rating, make rating display change
Dev - When editing, update "edited" column
Dev - Restore deleted comments
Dev - Display deleted comments if mod (hidden, then with dropdown)
Dev - After deletion or during edit, make rating dropdown appear again
Dev - Stricter rating rules. Prevent user from rating again
Dev - Pages
Dev - Reporting
It's pretty good, but it's not perfect. Sometimes it wouldn't aim at the bullet at all when the line gun was below and right to the circle gun. It's certainly a good template for anyone who needs something like this though since you did include all the math behind it. 7/10
Posted by Ferret August 27, 2010 14:16 - 2.7 years ago
| [#1]

Not perfect. There are better solutions.
Posted by Juju August 27, 2010 14:57 - 2.7 years ago
| [#2]

:(

@ferret
If the target is moving too fast, then the bullet's won't be able to hit it. I wasn't able to find any problems.

Also, juju, are there better solutions when the bullet speed is much lower than the target speed? I guess that I could add the ability to do the simpler calculations when the bullet moves faster than the target, though.

I also don't know what the better way is.
Posted by noshenim August 27, 2010 18:44 - 2.7 years ago
| [#3]

Posted by OL August 29, 2010 20:33 - 2.7 years ago
| [#4]

Recent Activity
 
Active Users (0)