Type your ugBASIC program here (remember: keywords like PRINT must be UPPERCASE!).
Click on Build menu to select the target: you will download the compiled binary file!

' ============================================================================ ' INITIALIZATION ' ============================================================================ ' We start measure time from the graphical initialization. t=TI ' Enable the monocrome bitmap graphic, ' with a minimum resolution of 160x100 pixels. BITMAP ENABLE(320,200,2) ' Pen color is black INK BLACK ' Paper color is white CLS WHITE ' Let's calculate the three constants CONST x1=(SCREEN WIDTH \ #2): CONST y1=0 CONST x2=0: CONST y2=(SCREEN HEIGHT - 1 ) CONST x3=(SCREEN WIDTH - 1): CONST y3=(SCREEN HEIGHT - 1 ) ' Number of points to draw CONST limit = 10000 ' ============================================================================ ' MAIN CYCLE ' ============================================================================ ' Initialize the coordinates. x=#x1 AS POSITION y=#y1 AS POSITION ' Initialize the counter. n=#0 AS INTEGER ' Repeat the cycle up to (limit) points. REPEAT ' Select a random triangle r=(RANDOM BYTE \ 32) AND 3 ' If the triange has been chosen... IF r=0 THEN ' Update the coordinates accordingly. ADD x, x1 : DIV x, #2 ADD y, y1 : DIV y, #2 ELSE IF r=1 THEN ADD x, x2 : DIV x, #2 ADD y, y2 : DIV y, #2 ELSE ADD x, x3 : DIV x, #2 ADD y, y3 : DIV y, #2 ENDIF ' Plot the point on the screen. PLOT x, y ' Increment the number of point traced. INC n UNTIL n=limit ' Calculate the time passed te=TI-t HOME ' Print the stats PRINT "time = ";(te/TICKS PER SECOND);" sec" PRINT "points = ";n%

Welcome to the ugBASIC sandbox!

This tool was designed to quickly test whether the code you are writing compiles correctly and determines the desired results. Since the source is compiled thanks to dedicated servers, separate from the browser you are using, some commands are not available: for example, you cannot load external files or resources by using the LOAD command. If you need to develop a program with a complete tool, we recommend installing the executables or the UGBASIC-IDE.

Unless required by applicable law or agreed to in writing, this website is given on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.