- This wiki is out of date, use the continuation of this wiki instead
Collision
From FenixWiki
(Difference between revisions)
Revision as of 14:10, 19 April 2007 (edit) Sandman (Talk | contribs) m ← Previous diff |
Current revision (11:35, 21 July 2008) (edit) (undo) Sandman (Talk | contribs) m (→Example) |
||
(4 intermediate revisions not shown.) | |||
Line 3: | Line 3: | ||
==Definition== | ==Definition== | ||
- | '''INT''' Collision ( <'''INT''' processID| | + | '''INT''' Collision ( <'''INT''' processID|processTypeID> ) |
Checks if a [[process]] collided with the process calling Collision(). | Checks if a [[process]] collided with the process calling Collision(). | ||
+ | |||
+ | When a [[processTypeID]] is specified, there could be multiple fitting collisions. In this case, collision() returns a [[processID]] on each subsequent call, until it returns 0. This can be reset by use of the [[frame]]; statement, and in such case, frame(0); can be handy. | ||
== Parameters == | == Parameters == | ||
{| | {| | ||
- | | '''INT''' processID | + | | '''INT''' processID<nowiki>|</nowiki>processTypeID || - The ProcessID of the process or the ProcessTypeID of the type of processes to be checked. |
|} | |} | ||
Line 22: | Line 24: | ||
== Example == | == Example == | ||
<pre> | <pre> | ||
- | Program example; | ||
- | Private | ||
- | int map; | ||
- | Begin | ||
- | |||
- | // Create the graph for the ship | ||
- | map = new_map(20,20,8); | ||
- | map_clear(0,map,rgb(0,255,255)); | ||
- | |||
- | // Create the graph for the Main process | ||
- | graph = new_map(50,50,8); | ||
- | map_clear(0,graph,rgb(255,255,0)); | ||
- | |||
- | // Position the main process and create the ship | ||
- | x = y = z = 100; | ||
- | SpaceShip(0,map,100,100,0,20,5000); | ||
- | |||
- | Loop | ||
- | frame; | ||
- | End | ||
- | End | ||
- | |||
Process SpaceShip( int file , int graph , int x , int y , int angle , int maxspeed , int maxturnspeed ) | Process SpaceShip( int file , int graph , int x , int y , int angle , int maxspeed , int maxturnspeed ) | ||
Private | Private | ||
Line 58: | Line 38: | ||
// Handle collision | // Handle collision | ||
if( (collisionID = collision(type main))) | if( (collisionID = collision(type main))) | ||
- | + | text = "collision with: " + collisionID; | |
else | else | ||
text = "no collision"; | text = "no collision"; | ||
Line 64: | Line 44: | ||
frame; | frame; | ||
End | End | ||
+ | End | ||
+ | |||
+ | Process Main() | ||
+ | Private | ||
+ | int map; | ||
+ | Begin | ||
+ | |||
+ | // Create the graph for the ship | ||
+ | map = new_map(20,20,8); | ||
+ | map_clear(0,map,rgb(0,255,255)); | ||
+ | |||
+ | // Create the graph for the Main process | ||
+ | graph = new_map(50,50,8); | ||
+ | map_clear(0,graph,rgb(255,255,0)); | ||
+ | |||
+ | // Position the main process and create the ship | ||
+ | x = y = z = 100; | ||
+ | SpaceShip(0,map,100,100,0,20,5000); | ||
+ | |||
+ | Repeat | ||
+ | frame; | ||
+ | Until(key(_ESC)) | ||
+ | |||
+ | let_me_alone(); | ||
+ | |||
End | End | ||
</pre> | </pre> | ||
- | Used in example: [[new_map]](), [[map_clear]](), [[ | + | Used in example: [[write_string]](), [[key]](), [[collision]](), [[new_map]](), [[map_clear]](), [[advance]](), [[let_me_alone]](), [[graph]], [[type]] |
+ | |||
+ | {{Funcbox | ||
+ | | category = Processinteraction | ||
+ | }} |
Current revision
Contents |
[edit] Definition
INT Collision ( <INT processID|processTypeID> )
Checks if a process collided with the process calling Collision().
When a processTypeID is specified, there could be multiple fitting collisions. In this case, collision() returns a processID on each subsequent call, until it returns 0. This can be reset by use of the frame; statement, and in such case, frame(0); can be handy.
[edit] Parameters
INT processID|processTypeID | - The ProcessID of the process or the ProcessTypeID of the type of processes to be checked. |
[edit] Returns
INT : The ID of the collided process.
0 | - No collision |
>0 | - The processID of the process colliding with the current process |
[edit] Example
Process SpaceShip( int file , int graph , int x , int y , int angle , int maxspeed , int maxturnspeed ) Private int speed; int collisionID; string text; Begin write_string(0,0,0,0,&text); Loop // Handle movement speed+=key(_up)*(speed<maxspeed)-key(_down)*(speed>-maxspeed); angle+=(key(_left)-key(_right))*maxturnspeed; advance(speed); // Handle collision if( (collisionID = collision(type main))) text = "collision with: " + collisionID; else text = "no collision"; end frame; End End Process Main() Private int map; Begin // Create the graph for the ship map = new_map(20,20,8); map_clear(0,map,rgb(0,255,255)); // Create the graph for the Main process graph = new_map(50,50,8); map_clear(0,graph,rgb(255,255,0)); // Position the main process and create the ship x = y = z = 100; SpaceShip(0,map,100,100,0,20,5000); Repeat frame; Until(key(_ESC)) let_me_alone(); End
Used in example: write_string(), key(), collision(), new_map(), map_clear(), advance(), let_me_alone(), graph, type
Processinteraction Functions | |
• Advance() • Collision() • Exists() • Get_angle() • Get_dist() • Get_id() • Let_me_alone() • Signal() • Xadvance() • |