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!

OPTION EXPLICIT DEFINE IMAGE FREE HEIGHT DEFINE MSPRITE ASYNC BITMAP ENABLE COLOR BORDER BLACK CONST maxAlienships = 5 DIM index AS BYTE DIM spaceImage AS IMAGE DIM spaceshipImage AS IMAGE DIM spaceshipSprite AS MSPRITE DIM spaceshipLeftMove AS PATH DIM spaceshipRightMove AS PATH DIM spaceshipMove AS PATH DIM spaceshipX AS POSITION, spaceshipY AS POSITION DIM alienshipImage AS IMAGE DIM alienshipSprite(maxAlienships) AS MSPRITE DIM alienshipLeftMove(maxAlienships) AS PATH DIM alienshipRightMove(maxAlienships) AS PATH DIM alienshipMove(maxAlienships) AS PATH DIM alienshipLX(maxAlienships) AS POSITION, alienshipRX(maxAlienships) AS POSITION DIM alienshipX AS POSITION, alienshipY AS POSITION spaceImage := LOAD IMAGE("space.png") spaceshipImage := LOAD IMAGE("spaceship.png") spaceshipSprite = MSPRITE(spaceshipImage) spaceshipLeftMove = CREATE PATH( 200, 200 TO 50, 200 ) spaceshipRightMove = CREATE PATH( 50, 200 TO 200, 200 ) spaceshipMove = spaceshipRightMove alienshipImage := LOAD IMAGE("alienship.png") index = 0 DO alienshipSprite(index) = MSPRITE(alienshipImage) alienshipLX(index) = index*32 alienshipRX(index) = 200+index*10 alienshipLeftMove(index) = CREATE PATH( alienshipRX(index), 60+index*16 TO alienshipLX(index), 60+index*32 ) alienshipRightMove(index) = CREATE PATH( alienshipLX(index), 60+index*32 TO alienshipRX(index), 60+index*16 ) alienshipMove(index) = alienshipRightMove(index) INC index EXIT IF index = maxAlienships LOOP CLS PUT IMAGE spaceImage AT 0, 0 DO TRAVEL spaceshipMove TO spaceshipX, spaceshipY SPRITE spaceshipSprite AT spaceshipX, spaceshipY IF spaceshipX = 200 THEN spaceshipMove = spaceshipLeftMove ELSE IF spaceshipX = 50 THEN spaceshipMove = spaceshipRightMove ENDIF index = 0 DO TRAVEL alienshipMove(index) TO alienshipX, alienshipY SPRITE alienshipSprite(index) AT alienshipX, alienshipY IF alienshipX = alienshipRX(index) THEN alienshipMove(index) = alienshipLeftMove(index) ELSE IF alienshipX = alienshipLX(index) THEN alienshipMove(index) = alienshipRightMove(index) ENDIF INC index EXIT IF index = maxAlienships LOOP MSPRITE UPDATE LOOP

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.