{{htmlmetatags>metatag-robots=() metatag-title=( | ugBASIC User Manual) metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum) metatag-description=(An isomorphic language for retrocomputers) metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png) metatag-og:title=( | ugBASIC User Manual) metatag-og:description=(An isomorphic language for retrocomputers) }} ====== ugBASIC User Manual ====== ===== ===== ==== PURPOSE ==== ==== SOURCE CODE ==== DEFINE STRING SPACE 128 DEFINE STRING COUNT 16 BITMAP ENABLE(16) CONST balls = 4 CONST step = 2 CONST levels = SCREEN HEIGHT / 16 CONST screenLimitH = ( SCREEN HEIGHT - 16 ) CONST screenLimitW = ( SCREEN WIDTH - 16 ) CONST ballStep = (SCREEN WIDTH / balls) DIM x(balls), y(balls), dx(balls), dy(balls), d@(balls), m@(balls) GLOBAL x, y, f, dx, dy, d, m GLOBAL ball, bar, bgball GLOBAL basket PROCEDURE prepareGraphics bgball := NEW IMAGES(balls,16,10) CLS BLACK INK GREY BAR 0,0 TO 15,3 INK BLUE DRAW"L16R2U3L2R16L2D3L4U3L3D3" bar := NEW IMAGE(16,4) GET IMAGE bar FROM 0, 0 CLS INK GREY BAR 0,0 TO 7,7 INK BLUE DRAW"BU8D8L7U8" basket := NEW IMAGE(8,8) GET IMAGE basket FROM 0, 0 CLS INK RED CIRCLE 4,4,4 PAINT(4,4) INK WHITE DRAW"BU2L1D1L1D1" ball := NEW IMAGE(16,10) GET IMAGE ball FROM 0, 0 CLS i = 0 ty = 16 REPEAT tx = (i * ballStep) + step x(i) = tx y(i) = ty ' dx(i) = 0 ' dy(i) = 0 GET IMAGE bgball FRAME i FROM tx, ty INC i UNTIL i = balls FILL d WITH 1 FILL m WITH 0 END PROCEDURE GLOBAL bx, by PROCEDURE drawBarrier bx = 0 i = 0: j = RND(255) REPEAT IF (j AND 1) = 0 THEN PUT IMAGE bar AT bx, by ENDIF j = j \ 2 ADD bx, 16 INC i UNTIL bx > screenLimitW END PROCEDURE PROCEDURE drawBarriersAndBaskets by = 16 REPEAT drawBarrier[] ADD by, 16 UNTIL by > screenLimitH - 16 bx = 0 REPEAT PUT IMAGE basket AT bx, by ADD bx, 16 UNTIL bx > screenLimitW END PROCEDURE PARALLEL PROCEDURE moveBall REPEAT WAIT WHILE [d] IF POINT([x]+3,[y]+9) = BLACK THEN [dy] = step [dx] = 0 ELSE [dy] = 0 IF [dx] = 0 THEN IF RND(100) > 50 THEN [dx] = step ELSE [dx] = -step ENDIF ENDIF IF [x] >= screenLimitW THEN [dx] = -[dx] ELSEIF [x] < step THEN [dx] = -[dx] ELSEIF POINT([x]+9,[y]+4) <> BLACK THEN [dx] = -[dx] ELSE IF POINT([x]-3,[y]+4) <> BLACK THEN [dx] = -[dx] ENDIF ENDIF [m] = 1 [d] = 1 UNTIL [y] > SCREEN HEIGHT END PROCEDURE PROCEDURE waitRaster maxy = 0 i = balls-1 REPEAT NOP WAIT WHILE m(i) NOP IF maxy < y(i) THEN maxy = y(i) + 15 ENDIF DEC i UNTIL i < 0 IF maxy > 0 THEN WHILE RASTER LINE < maxy WEND ENDIF END PROC PARALLEL PROCEDURE drawBalls DO waitRaster[] FORBID i = balls-1: REPEAT d(i) = 1 PUT IMAGE bgball FRAME i AT x(i),y(i) DEC i UNTIL i < 0 i = 0: REPEAT ADD x(i), dx(i) ADD y(i), dy(i) GET IMAGE bgball FRAME i FROM x(i),y(i) IF dx(i) <> 0 AND dy(0) <> 0 THEN PUT IMAGE ball AT x(i), y(i) WITH TRANSPARENCY ENDIF INC i UNTIL i = balls FILL d WITH 0 ALLOW LOOP END PROCEDURE 'PARALLEL PROCEDURE movePlayer ' ' DO ' WHILE pdelay: DEC pdelay: WEND ' IF JUP(0) AND ply > 0 AND POINT(plx + 4, ply - 16) = BLACK THEN ' ADD ply, -16 ' pdelay = 10 ' ENDIF ' IF JDOWN(0) AND ply < screenLimitH AND POINT(plx + 4, ply + 16) = BLACK THEN ' ADD ply, 16 ' pdelay = 10 ' ENDIF ' IF JLEFT(0) AND plx > 16 AND POINT(plx - step, ply) = BLACK THEN ' ADD plx, -step ' pdelay = 10 ' ENDIF ' IF JRIGHT(0) AND plx < screenLimitH AND POINT(plx + 8 + step, ply) = BLACK THEN ' ADD plx, step ' pdelay = 10 ' ENDIF ' LOOP ' 'END PROC prepareGraphics[] drawBarriersAndBaskets[] SPAWN drawBalls 'SPAWN movePlayer ==== SOURCE FILE ==== * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/contrib_game_old.bas|contrib_game_old.bas]]'' ==== HOW TO COMPILE AND RUN ==== The instructions here refer to compiling the example from the command line. For Microsoft Windows users we suggest using **[[https://spotlessmind1975.itch.io/ugbasic-ide|UGBASIC-IDE]]**, which allows you to compile the example with just one click.=== ATARI 400/800 family === In order to compile and run the example, you need to have the Altirra emulator, and in particular that the ''altirra'' executable is accessible. Then, type this command on the command line: # Linux ugbc.atari contrib_game_old.bas -o example.xex altirra example.xex # Windows ugbc.atari.exe contrib_game_old.bas -o example.xex altirra example.xex === ATARI 600XL/800XL/1200XL/XG(SE) family === In order to compile and run the example, you need to have the Altirra emulator, and in particular that the ''altirra'' executable is accessible. Then, type this command on the command line: # Linux ugbc.atarixl contrib_game_old.bas -o example.xex altirra example.xex # Windows ugbc.atarixl.exe contrib_game_old.bas -o example.xex altirra example.xex === Commodore 64 === In order to compile and run the example, you need to have the VICE emulator, and in particular that the ''x64sc'' executable is accessible. Then, type this command on the command line: # Linux ugbc.c64 contrib_game_old.bas -o example.prg x64sc example.prg # Windows ugbc.c64.exe contrib_game_old.bas -o example.prg x64sc example.prg === Commodore PLUS/4 === == Using YAPE == In order to run the example, you need to have the YAPE emulator. In particular that the ''yape'' executable is accessible. Then, type this command on the command line: # Linux ugbc.plus4 contrib_game_old.bas -o example.prg yape example.prg # Windows ugbc.plus4.exe contrib_game_old.bas -o example.prg yape example.prg == Using VICE == In order to run the example, you need to have the VICE emulator. In particular that the ''xplus4'' executable is accessible. Then, type this command on the command line: # Linux ugbc.plus4 contrib_game_old.bas -o example.prg xplus4 example.prg # Windows ugbc.plus4.exe contrib_game_old.bas -o example.prg xplus4 example.prg === Dragon 32 === In order to compile and run the example, you need to have the XROAR emulator, and in particular that the ''xroar'' executable is accessible. Then, type this command on the command line: # Linux ugbc.d32 contrib_game_old.bas -o example.bin xroar -rompath (your rom path) example.bin # Windows ugbc.d32.exe contrib_game_old.bas -o example.bin xroar.exe -rompath (your rom path) example.bin === Dragon 64 === In order to compile and run the example, you need to have the XROAR emulator, and in particular that the ''xroar'' executable is accessible. Then, type this command on the command line: # Linux ugbc.d64 contrib_game_old.bas -o example.bin xroar -rompath (your rom path) example.bin # Windows ugbc.d64.exe contrib_game_old.bas -o example.bin xroar.exe -rompath (your rom path) example.bin === PC128 Olivetti Prodest === In order to compile and run the example, you need to have the DCMOTO emulator, and in particular that the ''dcmoto'' executable is accessible. Then, type this command on the command line and on the emulator: # Linux ugbc.pc128op contrib_game_old.bas -o example.k7 dcmoto (choose BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.pc128op.exe contrib_game_old.bas -o example.k7 dcmoto (choose example.k7) (choose BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC === Thomson MO5 === In order to compile and run the example, you need to have the DCMOTO emulator, and in particular that the ''dcmoto'' executable is accessible. Then, type this command on the command line and on the emulator: # Linux ugbc.pc128op contrib_game_old.bas -o example.k7 dcmoto (choose BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.pc128op.exe contrib_game_old.bas -o example.k7 dcmoto (choose example.k7) (choose BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC === Commodore VIC-20 === In order to compile and run the example, you need to have the VICE emulator, and in particular that the ''xvic'' executable is accessible. Then, type this command on the command line: # Linux ugbc.vic20 contrib_game_old.bas -o example.prg xvic --memory 24k example.prg # Windows ugbc.vic20.exe contrib_game_old.bas -o example.prg xvic --memory 24k example.prg === ZX Spectrum === In order to compile and run the example, you need to have the Speccy emulator, and in particular that the ''speccy'' executable is accessible. Then, type this command on the command line: # Linux ugbc.zx contrib_game_old.bas -o example.tap Speccy example.tap # Windows ugbc.zx.exe contrib_game_old.bas -o example.tap Speccy example.tap === MSX === In order to compile and run the example, you need to have the openMsx or the BlueMSX emulator, and in particular that its executable is accessible. Then, type this command on the command line: == openMSX == # Linux ugbc.msx1 contrib_game_old.bas -o example.rom openmsx -cart example.rom # Windows ugbc.msx1.exe contrib_game_old.bas -o example.rom openmsx -cart example.rom == blueMSX == # Linux ugbc.msx1 contrib_game_old.bas -o example.rom bluemsx example.rom # Windows ugbc.msx1.exe contrib_game_old.bas -o example.rom bluemsx example.rom === ColecoVision === In order to compile and run the example, you need to have the openMsx or the BlueMSX emulator, and in particular that its executable is accessible. Then, type this command on the command line: == openMSX == # Linux ugbc.coleco contrib_game_old.bas -o example.rom openmsx -machine \"COL - ColecoVision\" -cart example.rom # Windows ugbc.coleco.exe contrib_game_old.bas -o example.rom bluemsx -machine \"COL - ColecoVision\" example.rom == blueMSX == # Linux ugbc.coleco contrib_game_old.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom # Windows ugbc.coleco.exe contrib_game_old.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom === SEGA SC-3000 === In order to compile and run the example, you need to have the BlueMSX emulator, and in particular that its executable is accessible. Then, type this command on the command line: # Linux ugbc.sc3000 contrib_game_old.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom # Windows ugbc.sc3000.exe contrib_game_old.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom === SEGA SG-1000 === In order to compile and run the example, you need to have the BlueMSX emulator, and in particular that its executable is accessible. Then, type this command on the command line: # Linux ugbc.sg1000 contrib_game_old.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom # Windows ugbc.sg1000.exe contrib_game_old.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom ==== ANY PROBLEM? ==== If you have found a problem trying to run this example, if you think there is a bug or, more simply, you would like it to be improved, [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=IMPROVE |open an issue]] for this example on GitHub. Thank you!===== POWERED BY ===== [[:ugbasic:user:examples|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]