Difference between revisions of "GSDP:GAM100/CProcessing/Vec2"

From Inside
Jump to: navigation, search
>Zachary.logsdon
(New page: {{GSDP:GAM100API.css}} =vec2_t= ==Description== A vec2_t (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 th...)
 
>Zachary.logsdon
 
Line 1: Line 1:
 
{{GSDP:GAM100API.css}}
 
{{GSDP:GAM100API.css}}
=vec2_t=
+
=Vec2=
 
==Description==
 
==Description==
A vec2_t (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.
+
A Vec2 (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==
 
==Example==
Line 9: Line 9:
 
{
 
{
 
     // create a position vec2
 
     // create a position vec2
     vec2_t position;
+
     Vec2 position;
  
 
     // set the position
 
     // set the position

Latest revision as of 09:13, 8 May 2019

Vec2

Description

A Vec2 (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
    Vec2 position;

    // set the position
    position.x = 100;
    position.y = 200;

    // scale the position by 1.5
    position = vec2_scale(position, 1.5f);

    // draw a rectangle at the position
    rect(position.x, position.y, 50, 50);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>