BlueGit

timfa frameworkv3

move clicking, fix vector assignments in transform

timfa Tim · pushed by timfa

Authored 2022-10-21 · 4 years ago

Hash
2d2afd524f3b86acaaf2d0ad9624f3c232680478
Parent
723e2a0c
2 files changed +67 −14
framework/engine/objectComponents/collider.js +12 −11
@@ -17,19 +17,20 @@ class Collider
17 17 {
18 18 if (this.enabled)
19 19 {
20 let pressed = GameInput.mousePressed();
21 let held = GameInput.mouseHeld();
22 if (pressed.left || pressed.middle || pressed.right)
23 {
24 this.checkClick(true, pressed);
25 }
20 this.checkCollisions();
21 }
26 22
27 if (held.left || held.middle || held.right)
28 {
29 this.checkClick(false, held);
30 }
23 let pressed = GameInput.mousePressed();
24 let held = GameInput.mouseHeld();
31 25
32 this.checkCollisions();
26 if (pressed.left || pressed.middle || pressed.right)
27 {
28 this.checkClick(true, pressed);
29 }
30
31 if (held.left || held.middle || held.right)
32 {
33 this.checkClick(false, held);
33 34 }
34 35 }
35 36
@@ -17,19 +17,20 @@ class Collider
17 {
17 {
18 if (this.enabled)
18 if (this.enabled)
19 {
19 {
20 let pressed = GameInput.mousePressed();
20 this.checkCollisions();
21 let held = GameInput.mouseHeld();
21 }
22 if (pressed.left || pressed.middle || pressed.right)
23 {
24 this.checkClick(true, pressed);
25 }
26
22
27 if (held.left || held.middle || held.right)
23 let pressed = GameInput.mousePressed();
28 {
24 let held = GameInput.mouseHeld();
29 this.checkClick(false, held);
30 }
31
25
32 this.checkCollisions();
26 if (pressed.left || pressed.middle || pressed.right)
27 {
28 this.checkClick(true, pressed);
29 }
30
31 if (held.left || held.middle || held.right)
32 {
33 this.checkClick(false, held);
33 }
34 }
34 }
35 }
35
36
framework/engine/objectComponents/transform.js +55 −3
@@ -1,11 +1,63 @@
1 1 class Transform
2 2 {
3 position = null;
4 scale = null;
3 get position ()
4 {
5 if (!this.g_position)
6 this.g_position = new vector(0, 0);
7
8 return this.g_position;
9 }
10
11 set position (v)
12 {
13 if (!this.g_position)
14 this.g_position = new vector(v.x, v.y);
15
16 this.g_position.x = v.x;
17 this.g_position.y = v.y;
18 }
19
20 get scale ()
21 {
22 if (!this.g_scale)
23 this.g_scale = new vector(0, 0);
24
25 return this.g_scale;
26 }
27
28 set scale (v)
29 {
30 if (!this.g_scale)
31 this.g_scale = new vector(v.x, v.y);
32
33 this.g_scale.x = v.x;
34 this.g_scale.y = v.y;
35 }
36
37 get velocity ()
38 {
39 if (!this.g_velocity)
40 this.g_velocity = new vector(0, 0);
41
42 return this.g_velocity;
43 }
44
45 set velocity (v)
46 {
47 if (!this.g_velocity)
48 this.g_velocity = new vector(v.x, v.y);
49
50 this.g_velocity.x = v.x;
51 this.g_velocity.y = v.y;
52 }
53
54 g_position = null;
55
56 g_scale = null;
5 57 rotation = 0;
6 58 gameObject = null;
7 59
8 velocity = null;
60 g_velocity = null;
9 61 angularVelocity = 0;
10 62
11 63 get size ()
@@ -1,11 +1,63 @@
1class Transform
1class Transform
2{
2{
3 position = null;
3 get position ()
4 scale = null;
4 {
5 if (!this.g_position)
6 this.g_position = new vector(0, 0);
7
8 return this.g_position;
9 }
10
11 set position (v)
12 {
13 if (!this.g_position)
14 this.g_position = new vector(v.x, v.y);
15
16 this.g_position.x = v.x;
17 this.g_position.y = v.y;
18 }
19
20 get scale ()
21 {
22 if (!this.g_scale)
23 this.g_scale = new vector(0, 0);
24
25 return this.g_scale;
26 }
27
28 set scale (v)
29 {
30 if (!this.g_scale)
31 this.g_scale = new vector(v.x, v.y);
32
33 this.g_scale.x = v.x;
34 this.g_scale.y = v.y;
35 }
36
37 get velocity ()
38 {
39 if (!this.g_velocity)
40 this.g_velocity = new vector(0, 0);
41
42 return this.g_velocity;
43 }
44
45 set velocity (v)
46 {
47 if (!this.g_velocity)
48 this.g_velocity = new vector(v.x, v.y);
49
50 this.g_velocity.x = v.x;
51 this.g_velocity.y = v.y;
52 }
53
54 g_position = null;
55
56 g_scale = null;
5 rotation = 0;
57 rotation = 0;
6 gameObject = null;
58 gameObject = null;
7
59
8 velocity = null;
60 g_velocity = null;
9 angularVelocity = 0;
61 angularVelocity = 0;
10
62
11 get size ()
63 get size ()