Guest User

Untitled

a guest
Jul 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1.  
  2. function Dynamic(x, y, move_x, move_y, max_x, max_y,elem,bkg) {
  3. this.startMovement = Start;
  4. this.Movement = Move;
  5. this.x = x;
  6. this.y = y;
  7. this.move_x = move_x;
  8. this.move_y = move_y;
  9. this.max_x = max_x;
  10. this.max_y = max_y;
  11. this.elem = elem;
  12. this.elem.style = elem.style;
  13. this.elem.style.left = elem.style.left;
  14. this.elem.style.top = elem.style.top;
  15. this.bkg = bkg;
  16. this.test = Test;
  17. this.print = Print;
  18. }
  19. function Start() {
  20.  
  21. setInterval(this.Movement, 1);
  22. }
  23. function Test() {
  24. return this.x + ',' + this.y;
  25. }
  26. function Print() {
  27. document.write(this.test());
  28. }
  29. function Move() {
  30.  
  31. if (this.x < 0 || this.x > this.max_x) {
  32. alert("In_If_x");
  33. this.move_x *= -1;
  34. }
  35. if (this.y < 0 || this.y > this.max_y) {
  36. alert("In_If_y");
  37. this.move_y *= -1;
  38. }
  39. // this.print();
  40. // alert();
  41. // alert(this.test());
  42. // alert("ewfwegfew");
  43.  
  44. this.x += this.move_x;
  45. this.y += this.move_y;
  46.  
  47. // this.elem = document.getElementById('img');
  48. // this.elem.style;
  49. // this.elem.style.left;
  50. // this.elem.style.top;
  51.  
  52. // this.elem.style.left = this.x;
  53. // this.elem.style.top = this.y;
  54. // this.print();
  55. // alert("after_print")
  56. var z = this.y;
  57. var m = z.toString();
  58. // document.getElementById('img').style.top = this.y + "px";
  59. // document.getElementById('img').style.left = this.x + "px";
  60. this.elem.style.left = this.x;
  61. this.elem.style.top = this.y;
  62. alert(this);
  63. }
  64. function Push() {
  65. var elem = document.getElementById('img');
  66. var bkg = document.getElementById('div');
  67. var dyn = new Dynamic(3, 5, 1, 1, 300, 300, elem, bkg);
  68. dyn.startMovement();
  69. // dyn.print();
  70. }
Add Comment
Please, Sign In to add comment