Please Login First
×
Create a new article
Write your page title here:
We currently have 322 articles on Inside. Type your article name above or click on one of the titles below and start writing!



    Inside

    GSDP:GAM100/CProcessing/CP Vector

    CP_Vector

    Description

    A CP_Vector (2D vector type) is a structure that can hold two float values. This is used for linear algebra, but can be used for any purpose that requires two values. There are a series of operations that can be done using a 2D vector that are also provided.

    Example

    void update() 
    {
      // create a position vec2
      CP_Vector position;
    
      // set the position
      position.x = 100;
      position.y = 200;
    
      // scale the position by 1.5
      position = CP_Vector_Scale(position, 1.5f);
    
      // draw a rectangle at the position
      CP_Graphics_DrawRect(position.x, position.y, 50, 50);
    }
    

    Related