Many, many years ago I remember having a Binatone early videogame system at home. All it could play were Pong-type games where a paddle controller moved a "stick" up and down the screen, in an attempt to bounce a "block" back across the screen. You can make a Pong-style squash game using 2DIY.
(1) Choose a "journey" activity. The car is going to be the ball / block in the game. The ball is going to need to collide with the stick, so you need to choose a "monster" element to be the stick. To move the stick, you need to go into the elements animation options and click on the "ADV" option. Now you need to put in the following code;
if(Key.isDown(65)==true) { this._y +=8; }
if(Key.isDown(81)==true) { this._y +=-8; }
The values 65 and 81 correspond to the A and Q keys - see this article for other keys.
The stick element also needs to be told what to upon collision with the ball.
Click on the arrow to the right and choose the "Advanced" option and enter the following code;
_root.car._rotation+=170;
This will cause the ball to bounce off at an angle of 170 degrees (you can change it to whatever you wish)
(2) The ball will not move in this activity at the moment - it is waiting for the "Up" arrow key to be pressed to move it. However, by selecting a sun element, making it transparent and then in the animation options add the following code;
if(Key.isDown(38)==false) { _root.v=10; }
This code tells the activity to keep the velocity (V) of the ball at a constant value when the up arrow (value 38) is NOT being pressed.
(3) You now need to add lots (yes, lots!) of monster elements around the edge of the screen, make them transparent and add the following code to the advanced collision options;
_root.car._rotation+=90;
This code makes the ball bounce of at 90 degrees, but it can be altered to any value you wish.
In the activity there are transparent monsters on the left of the screen (beyond the white line) that are set to lose a life upon collision.
(4) Now choose your background colour. The example is black and white, as that was the original design for Pong.


Recent Comments