Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cheat for hidden game "Atari Breakout" in Google Image Search

How would a cheat/auto moving paddle in this hidden html game look like?

There is a

<div id="breakout-ball"><span>●</span></div>

and a

<div id="breakout-paddle"></div>

when moving the mouse the paddle is moved horizontally. How can I connect the movement of the ball with the paddle?

This question will become "community wiki" as soon as possible.

like image 247
powtac Avatar asked May 13 '13 23:05

powtac


2 Answers

function cheat() {
    var ball   = document.getElementById('breakout-ball');
    var paddle = document.getElementById('breakout-paddle');

    paddle.style.left = ball.style.left;

    setTimeout(cheat, 20);
}

cheat();

// Add this via the FireBug console. 
like image 200
powtac Avatar answered Nov 09 '22 12:11

powtac


I modified your solution slightly to account for the scenario of the ball going off screen and breaking the hack and also the ball getting jammed into the corner.

function cheat() {
  var ball   = document.getElementById('breakout-ball');
  var paddle = document.getElementById('breakout-paddle');

  var buffer = Math.floor((Math.random()*100)+1);
  var leftVal = parseInt(ball.style.left, 10);

  if (ball.style.left) {
    paddle.style.left = (leftVal - buffer) + 'px';
  }


  setTimeout(cheat, 100);
}

cheat();

To be honest though, if you are going down that road why not do this?

function cheat() {
  var paddle = document.getElementById('breakout-paddle');

  paddle.style.width = '100%';
}

cheat();

Anyway I'm going to continue to dig into the code and do some deeper manipulation

like image 44
Matt Avatar answered Nov 09 '22 10:11

Matt