Vector2 for GameMaker
A downloadable constructor
Intro
Vector2, a common data type for game engines, is missing from GameMaker no more!
Github repo coming soon~
Vector2
- Fully-documented
- Example code
- Both return and overwrite behavior
- 15 methods:
- slope
- magnitude
- normalized
- add
- subtract
- component multiply (scale per-axis)
- scale (linear)
- round
- floor
- ceiling
- dot product
- angle
- lerp
- reflect
- rotate
More than just a coordinate, Vector2 allows you to determine many things such as the slope of a surface, or the speed of an object from a pair of coordinates (using subtract and then magnitude), or which direction one character is looking relative to another (dot product), for example, using very similar code to what you might find in other modern game engines.
For example, you could use Vector2 like this to create a sprite that orbits your object:
//create event v2 = new Vector2(16,16)//offset va=v2//vector a //draw event draw_sprite(sprOrbiter,va.x,va.y) //step event v2 = v2.rotate(degtorad(3)) va = v2.add(v2,new Vector2(x,y))
In this example, we use a sprite, but we could use anything, like a particle effect or another object. Simply access the x and y components and various methods of a Vector2 using dot notation.
Download
Click download now to get access to the following files:
Development log
- Vector2 1.11 day ago
- Vector2 1.03 days ago