aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/examples/sokol/particles/modules/particle/vec2
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/old/examples/sokol/particles/modules/particle/vec2
downloadcli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.gz
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.bz2
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/old/examples/sokol/particles/modules/particle/vec2')
-rw-r--r--v_windows/v/old/examples/sokol/particles/modules/particle/vec2/v.mod0
-rw-r--r--v_windows/v/old/examples/sokol/particles/modules/particle/vec2/vec2.v89
2 files changed, 89 insertions, 0 deletions
diff --git a/v_windows/v/old/examples/sokol/particles/modules/particle/vec2/v.mod b/v_windows/v/old/examples/sokol/particles/modules/particle/vec2/v.mod
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/v_windows/v/old/examples/sokol/particles/modules/particle/vec2/v.mod
diff --git a/v_windows/v/old/examples/sokol/particles/modules/particle/vec2/vec2.v b/v_windows/v/old/examples/sokol/particles/modules/particle/vec2/vec2.v
new file mode 100644
index 0000000..ec41485
--- /dev/null
+++ b/v_windows/v/old/examples/sokol/particles/modules/particle/vec2/vec2.v
@@ -0,0 +1,89 @@
+// Copyright(C) 2019 Lars Pontoppidan. All rights reserved.
+// Use of this source code is governed by an MIT license file distributed with this software package
+module vec2
+
+pub struct Vec2 {
+pub mut:
+ x f64
+ y f64
+}
+
+pub fn (mut v Vec2) zero() {
+ v.x = 0.0
+ v.y = 0.0
+}
+
+pub fn (mut v Vec2) from(src Vec2) {
+ v.x = src.x
+ v.y = src.y
+}
+
+// * Addition
+// + operator overload. Adds two vectors
+pub fn (v1 Vec2) + (v2 Vec2) Vec2 {
+ return Vec2{v1.x + v2.x, v1.y + v2.y}
+}
+
+pub fn (v Vec2) add(vector Vec2) Vec2 {
+ return Vec2{v.x + vector.x, v.y + vector.y}
+}
+
+pub fn (v Vec2) add_f64(scalar f64) Vec2 {
+ return Vec2{v.x + scalar, v.y + scalar}
+}
+
+pub fn (mut v Vec2) plus(vector Vec2) {
+ v.x += vector.x
+ v.y += vector.y
+}
+
+pub fn (mut v Vec2) plus_f64(scalar f64) {
+ v.x += scalar
+ v.y += scalar
+}
+
+// * Subtraction
+pub fn (v1 Vec2) - (v2 Vec2) Vec2 {
+ return Vec2{v1.x - v2.x, v1.y - v2.y}
+}
+
+pub fn (v Vec2) sub(vector Vec2) Vec2 {
+ return Vec2{v.x - vector.x, v.y - vector.y}
+}
+
+pub fn (v Vec2) sub_f64(scalar f64) Vec2 {
+ return Vec2{v.x - scalar, v.y - scalar}
+}
+
+pub fn (mut v Vec2) subtract(vector Vec2) {
+ v.x -= vector.x
+ v.y -= vector.y
+}
+
+pub fn (mut v Vec2) subtract_f64(scalar f64) {
+ v.x -= scalar
+ v.y -= scalar
+}
+
+// * Multiplication
+pub fn (v1 Vec2) * (v2 Vec2) Vec2 {
+ return Vec2{v1.x * v2.x, v1.y * v2.y}
+}
+
+pub fn (v Vec2) mul(vector Vec2) Vec2 {
+ return Vec2{v.x * vector.x, v.y * vector.y}
+}
+
+pub fn (v Vec2) mul_f64(scalar f64) Vec2 {
+ return Vec2{v.x * scalar, v.y * scalar}
+}
+
+pub fn (mut v Vec2) multiply(vector Vec2) {
+ v.x *= vector.x
+ v.y *= vector.y
+}
+
+pub fn (mut v Vec2) multiply_f64(scalar f64) {
+ v.x *= scalar
+ v.y *= scalar
+}