- This wiki is out of date, use the continuation of this wiki instead
Fget angle
From FenixWiki
(Difference between revisions)
| Revision as of 00:08, 9 July 2007 (edit) Sandman (Talk | contribs) m (βReturns) β Previous diff |
Revision as of 11:00, 11 July 2007 (edit) (undo) Sandman (Talk | contribs) Next diff β |
||
| Line 23: | Line 23: | ||
| == Notes == | == Notes == | ||
| The [[angle]] value returned by this function is in thousandths of degrees, as most angles within [[Fenix]] are. | The [[angle]] value returned by this function is in thousandths of degrees, as most angles within [[Fenix]] are. | ||
| + | |||
| + | == Example == | ||
| + | <pre> | ||
| + | Program angling; | ||
| + | Const | ||
| + | screen_width = 320; | ||
| + | screen_height = 200; | ||
| + | screen_depth = 8; | ||
| + | Begin | ||
| + | |||
| + | // Set the screen mode | ||
| + | set_mode(screen_width,screen_height,screen_depth); | ||
| + | |||
| + | // Create mouse graph, assign to mouse.graph | ||
| + | mouse.graph = new_map(20,20,screen_depth); | ||
| + | map_clear(0,mouse.graph,rgb(255,0,0)); | ||
| + | |||
| + | // Create arrow, assign to graph | ||
| + | graph = new_map(30,30,screen_depth); | ||
| + | drawing_map(0,graph); | ||
| + | drawing_color(rgb(0,255,0)); | ||
| + | draw_line( 0,29,29,30/2); | ||
| + | draw_line( 0, 0,30,30/2); | ||
| + | |||
| + | // Set position | ||
| + | x = screen_width /2; | ||
| + | y = screen_height/2; | ||
| + | |||
| + | // Always point to the mouse | ||
| + | Repeat | ||
| + | // Get the angle between this process' coordinates and those of the mouse. | ||
| + | angle = fget_angle(x,y,mouse.x,mouse.y); | ||
| + | frame; | ||
| + | Until(key(_esc)) | ||
| + | |||
| + | End | ||
| + | </pre> | ||
| + | Used in example: [[set_mode]](), [[new_map]](), [[map_clear]](), [[drawing_map]](), [[drawing_color]](), [[draw_line]](), [[mouse]], [[graph]], [[x]], [[y]], [[angle]] | ||
| + | |||
| + | This example could also be done with [[get_angle]](), but that would be more work. | ||
Revision as of 11:00, 11 July 2007
Contents |
Definition
INT fget_angle ( <INT pointA-X> , <INT pointA-Y> , <INT pointB-X> , <INT pointB-Y> )
Returns the angle between two certain points. The returned angle will be ranging from 0 to 360000 (0-360ΒΊ).
Parameters
| INT pointA-X | - The X-coordinate of point A. |
| INT pointA-Y | - The Y-coordinate of point A. |
| INT pointB-X | - The X-coordinate of point B. |
| INT pointB-Y | - The Y-coordinate of point B. |
Returns
INT : The angle between point A and point B.
Notes
The angle value returned by this function is in thousandths of degrees, as most angles within Fenix are.
Example
Program angling;
Const
screen_width = 320;
screen_height = 200;
screen_depth = 8;
Begin
// Set the screen mode
set_mode(screen_width,screen_height,screen_depth);
// Create mouse graph, assign to mouse.graph
mouse.graph = new_map(20,20,screen_depth);
map_clear(0,mouse.graph,rgb(255,0,0));
// Create arrow, assign to graph
graph = new_map(30,30,screen_depth);
drawing_map(0,graph);
drawing_color(rgb(0,255,0));
draw_line( 0,29,29,30/2);
draw_line( 0, 0,30,30/2);
// Set position
x = screen_width /2;
y = screen_height/2;
// Always point to the mouse
Repeat
// Get the angle between this process' coordinates and those of the mouse.
angle = fget_angle(x,y,mouse.x,mouse.y);
frame;
Until(key(_esc))
End
Used in example: set_mode(), new_map(), map_clear(), drawing_map(), drawing_color(), draw_line(), mouse, graph, x, y, angle
This example could also be done with get_angle(), but that would be more work.
