BlueGit

blue-star speeltuin

cookie test

timfa Tim · pushed by timfa

Authored 2022-10-15 · 4 years ago

Hash
caf93735bbb2c291640c503d340bc58f2a96171f
Parent
b7f76fde
2 files changed +63 −0
build/framework.js +59 −0
@@ -565,7 +565,11 @@ class Scene
565 565 {
566 566 if(this.parentScene)
567 567 {
568 this.real_position.x = this.parentScene.real_position.x + (this.position.x * this.parentScene.real_size.x);
569 this.real_position.y = this.parentScene.real_position.y + (this.position.y * this.parentScene.real_size.y);
568 570
571 this.real_size.x = this.parentScene.real_size.x * this.size.x;
572 this.real_size.y = this.parentScene.real_size.y * this.size.y;
569 573 }
570 574 else
571 575 {
@@ -782,6 +786,61 @@ var GameAudio =
782 786 * /e/Development/Repositories/frameworkv3/framework/util/audio.js
783 787 */
784 788
789 /*
790 * Start File:
791 * /e/Development/Repositories/frameworkv3/framework/util/cookie.js
792 */
793 var CookieManager =
794 {
795 setCookie: function(cname, cvalue, exdays = 365)
796 {
797 const d = new Date();
798
799 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
800 let expires = "expires="+d.toUTCString();
801
802 let newCookie = cname + "=" + cvalue + ";" + expires + ";path=kiop/";
803 document.cookie = newCookie;
804 },
805
806 getCookie: function(cname)
807 {
808 let name = cname + "=";
809 let ca = document.cookie.split(';');
810
811 for(let i = 0; i < ca.length; i++)
812 {
813 let c = ca[i];
814
815 while (c.charAt(0) == ' ')
816 {
817 c = c.substring(1);
818 }
819
820 if (c.indexOf(name) == 0)
821 {
822 return c.substring(name.length, c.length);
823 }
824 }
825
826 return "";
827 },
828
829 deleteCookie: function(cname)
830 {
831 const d = new Date();
832
833 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
834 let expires = "expires=Thu, 01 Jan 1970 00:00:00 UTC"
835
836 document.cookie = cname + "=delete;" + expires + ";path=/";
837 }
838 }
839 /*
840 * End File:
841 * /e/Development/Repositories/frameworkv3/framework/util/cookie.js
842 */
843
785 844 /*
786 845 * Start File:
787 846 * /e/Development/Repositories/frameworkv3/framework/util/ease.js
@@ -565,7 +565,11 @@ class Scene
565 {
565 {
566 if(this.parentScene)
566 if(this.parentScene)
567 {
567 {
568 this.real_position.x = this.parentScene.real_position.x + (this.position.x * this.parentScene.real_size.x);
569 this.real_position.y = this.parentScene.real_position.y + (this.position.y * this.parentScene.real_size.y);
568
570
571 this.real_size.x = this.parentScene.real_size.x * this.size.x;
572 this.real_size.y = this.parentScene.real_size.y * this.size.y;
569 }
573 }
570 else
574 else
571 {
575 {
@@ -782,6 +786,61 @@ var GameAudio =
782 * /e/Development/Repositories/frameworkv3/framework/util/audio.js
786 * /e/Development/Repositories/frameworkv3/framework/util/audio.js
783 */
787 */
784
788
789/*
790 * Start File:
791 * /e/Development/Repositories/frameworkv3/framework/util/cookie.js
792 */
793var CookieManager =
794{
795 setCookie: function(cname, cvalue, exdays = 365)
796 {
797 const d = new Date();
798
799 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
800 let expires = "expires="+d.toUTCString();
801
802 let newCookie = cname + "=" + cvalue + ";" + expires + ";path=kiop/";
803 document.cookie = newCookie;
804 },
805
806 getCookie: function(cname)
807 {
808 let name = cname + "=";
809 let ca = document.cookie.split(';');
810
811 for(let i = 0; i < ca.length; i++)
812 {
813 let c = ca[i];
814
815 while (c.charAt(0) == ' ')
816 {
817 c = c.substring(1);
818 }
819
820 if (c.indexOf(name) == 0)
821 {
822 return c.substring(name.length, c.length);
823 }
824 }
825
826 return "";
827 },
828
829 deleteCookie: function(cname)
830 {
831 const d = new Date();
832
833 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
834 let expires = "expires=Thu, 01 Jan 1970 00:00:00 UTC"
835
836 document.cookie = cname + "=delete;" + expires + ";path=/";
837 }
838}
839/*
840 * End File:
841 * /e/Development/Repositories/frameworkv3/framework/util/cookie.js
842 */
843
785/*
844/*
786 * Start File:
845 * Start File:
787 * /e/Development/Repositories/frameworkv3/framework/util/ease.js
846 * /e/Development/Repositories/frameworkv3/framework/util/ease.js
src/objects/arrow.js +4 −0
@@ -22,21 +22,25 @@ class Arrow extends GameObject
22 22 if(GameInput.isHeld(GameInput.keys.ArrowRight))
23 23 {
24 24 this.transform.position.x += this.speed * deltaTime;
25 CookieManager.setCookie("arrow", "right")
25 26 }
26 27
27 28 if(GameInput.isHeld(GameInput.keys.ArrowLeft))
28 29 {
29 30 this.transform.position.x -= this.speed * deltaTime;
31 CookieManager.setCookie("arrow", "left")
30 32 }
31 33
32 34 if(GameInput.isHeld(GameInput.keys.ArrowUp))
33 35 {
34 36 this.transform.position.y -= this.speed * deltaTime;
37 CookieManager.setCookie("arrow", "up")
35 38 }
36 39
37 40 if(GameInput.isHeld(GameInput.keys.ArrowDown))
38 41 {
39 42 this.transform.position.y += this.speed * deltaTime;
43 CookieManager.setCookie("arrow", "down")
40 44 }
41 45
42 46 if(oldPos.distanceTo(this.transform.position) > 1)
@@ -22,21 +22,25 @@ class Arrow extends GameObject
22 if(GameInput.isHeld(GameInput.keys.ArrowRight))
22 if(GameInput.isHeld(GameInput.keys.ArrowRight))
23 {
23 {
24 this.transform.position.x += this.speed * deltaTime;
24 this.transform.position.x += this.speed * deltaTime;
25 CookieManager.setCookie("arrow", "right")
25 }
26 }
26
27
27 if(GameInput.isHeld(GameInput.keys.ArrowLeft))
28 if(GameInput.isHeld(GameInput.keys.ArrowLeft))
28 {
29 {
29 this.transform.position.x -= this.speed * deltaTime;
30 this.transform.position.x -= this.speed * deltaTime;
31 CookieManager.setCookie("arrow", "left")
30 }
32 }
31
33
32 if(GameInput.isHeld(GameInput.keys.ArrowUp))
34 if(GameInput.isHeld(GameInput.keys.ArrowUp))
33 {
35 {
34 this.transform.position.y -= this.speed * deltaTime;
36 this.transform.position.y -= this.speed * deltaTime;
37 CookieManager.setCookie("arrow", "up")
35 }
38 }
36
39
37 if(GameInput.isHeld(GameInput.keys.ArrowDown))
40 if(GameInput.isHeld(GameInput.keys.ArrowDown))
38 {
41 {
39 this.transform.position.y += this.speed * deltaTime;
42 this.transform.position.y += this.speed * deltaTime;
43 CookieManager.setCookie("arrow", "down")
40 }
44 }
41
45
42 if(oldPos.distanceTo(this.transform.position) > 1)
46 if(oldPos.distanceTo(this.transform.position) > 1)