
The master page looks like this: overflow is a CSS2 attribute & this trick should work fine in popular browsers.More info. Is the a trick i can do to avoid that? All the content of the page is shown without scrolling so there should not be any need for the scroll bar. if (ball.Unwanted horizontal scroll-bar when using master pageĪfter changing some aspx-pages to use a master page, a horizontal scroll bar appear when I view the page in a browser. Now all what is left to do is to implement same functionality to detect collisions with all the borders in the draw() function.

There we simulate bouncing off the wall by reversing the speed in x direction. If the ball right x coordinate is larger than the window width, it means that the ball is going over the edge of the window, and the code between the curly brackets will be executed. What this code does is that it compares the ball right x coordinate with the window right edge coordinate, which is same as width of the window. These parameters can be altered, after the ball object has been created from the ball class. The speed is set to default zero and color to white (225 as grey scale). With our ball we will take the location and the diameter as variables to the constructor, so they can be defined when the ball object is created. The class will also include a special function called constructor, which allows us to create objects from the class. In a sense the relationship between class and object can be seen so, that the class is the drawings and plans of a house, and the object is the completed house in which one can live. A class is the description of the object and contains the variables and functions included in the object. To create an object, we need to have a template for creating it.

For our game we only need the location (as x and y coordinates), speed (as x and y components), diameter, and color. For example, a ball can have a diameter, weight, color, location in space, velocity, bounciness, and its methods could be for example rolling and bouncing. In more practical way of thinking, object in programming can be thought to be like any other object in real world. In programming, object is a collection of variables and methods. In processing we can create the ball as an object. To start programming the Pong-game we will define the ball.

More detailed (and longer) introduction can be found from the Processing website Explained here is the basic concept of an object and a class in Processing language.
