This wiki is out of date, use the continuation of this wiki instead

Collision

From FenixWiki

(Difference between revisions)
Jump to: navigation, search

Revision as of 13:47, 19 April 2007


Contents

Definition

INT Collision ( <INT processID|processType> )

Checks if a process collided with the process calling Collision().


Parameters

INT processID or processType - The ID or Type of the process to be checked.

Returns

INT : The ID of the collided process.

0 - No collision
>0 - The processID of the process colliding with the current process

Example

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 )
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

Used in example: new_map, map_clear, write_string, advance, graph

Personal tools