Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Dynamic(x, y, move_x, move_y, max_x, max_y,elem,bkg) {
- this.startMovement = Start;
- this.Movement = Move;
- this.x = x;
- this.y = y;
- this.move_x = move_x;
- this.move_y = move_y;
- this.max_x = max_x;
- this.max_y = max_y;
- this.elem = elem;
- this.elem.style = elem.style;
- this.elem.style.left = elem.style.left;
- this.elem.style.top = elem.style.top;
- this.bkg = bkg;
- this.test = Test;
- this.print = Print;
- }
- function Start() {
- setInterval(this.Movement, 1);
- }
- function Test() {
- return this.x + ',' + this.y;
- }
- function Print() {
- document.write(this.test());
- }
- function Move() {
- if (this.x < 0 || this.x > this.max_x) {
- alert("In_If_x");
- this.move_x *= -1;
- }
- if (this.y < 0 || this.y > this.max_y) {
- alert("In_If_y");
- this.move_y *= -1;
- }
- // this.print();
- // alert();
- // alert(this.test());
- // alert("ewfwegfew");
- this.x += this.move_x;
- this.y += this.move_y;
- // this.elem = document.getElementById('img');
- // this.elem.style;
- // this.elem.style.left;
- // this.elem.style.top;
- // this.elem.style.left = this.x;
- // this.elem.style.top = this.y;
- // this.print();
- // alert("after_print")
- var z = this.y;
- var m = z.toString();
- // document.getElementById('img').style.top = this.y + "px";
- // document.getElementById('img').style.left = this.x + "px";
- this.elem.style.left = this.x;
- this.elem.style.top = this.y;
- alert(this);
- }
- function Push() {
- var elem = document.getElementById('img');
- var bkg = document.getElementById('div');
- var dyn = new Dynamic(3, 5, 1, 1, 300, 300, elem, bkg);
- dyn.startMovement();
- // dyn.print();
- }
Add Comment
Please, Sign In to add comment