{{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 COUNT 16
DEFINE STRING SPACE 256
DEFINE TASK COUNT 1
BITMAP ENABLE (160,200,16)
' RESOLUTION 640,400
CLS
BLIT putimage AS (SOURCE 1)
BLIT puttransmask AS (((DESTINATION) MASKED (INVERSE(THRESHOLD SOURCE 2))) OR (SOURCE 1))
BLIT putTransMask2 AS (SOURCE 1 OR DESTINATION)
' ORIGIN 0,400 UP
OPTION EXPLICIT
DEGREE
GLOBAL boom,ciel,plancheSprite,tankDroit,tankGauche
GLOBAL puissance1,puissance2
GLOBAL xTank1,yTank1,xTank2,yTank2
GLOBAL angle,angle1,angle2
GLOBAL putimage,puttransmask
GLOBAL paramImg1,paramImg2
CONST jaune = 3
CONST rouge = 4
CONST vertFonce = 1
CONST vertClair = 5
CONST vertKaki = 6
CONST fond = 2
CONST bleuFonce = 14
CONST noir = 15
VAR boom AS IMAGE, ciel AS IMAGE, plancheSprite AS IMAGE
VAR angle AS FLOAT
VAR angle1 AS FLOAT
VAR angle2 AS FLOAT
VAR paramImg1 AS IMAGE,paramImg2 AS IMAGE
'VAR puissance1 AS FLOAT
'VAR puissance2 as FLOAT
VAR xTank1 AS INTEGER, yTank1 AS INTEGER, xTank2 AS INTEGER,yTank2 AS INTEGER
'VAR fond as IMAGE
boom := NEW IMAGE(14,17)
ciel := NEW IMAGE(15,17)
angle = 0.0
angle1 = 45.0
angle2 = 135.0
VAR puissance1 AS FLOAT
puissance1 = 100.0
VAR puissance2 AS FLOAT
puissance2 = 100.0
PROCEDURE debugValues[label AS STRING, value1 AS FLOAT, value2 AS FLOAT]
PEN COLOR(rouge)
LOCATE 0,1:PRINT " ";
LOCATE 0,1:PRINT label;value1;" ";value2
WAIT 100 MS
'WAIT KEY
END PROC
PROCEDURE gereExplosion[x,y]
IF (x > 0) AND (x < 640) AND (y > 0) AND (y < 400) THEN
IF (POINT(x,y) <> COLOR(fond)) THEN
RETURN TRUE
ENDIF
ENDIF
RETURN FALSE
END PROC
PROCEDURE drawGenericCanon[tankNumber , efface]
VAR tempX AS INTEGER,tempY AS INTEGER
VAR baseCanonX,baseCanonY,finCanonX,finCanonY AS SIGNED 32BIT
VAR topNegatif AS INTEGER
VAR couleur AS COLOR
VAR tempYArrondi AS INTEGER
SET LINE $FFFF
IF (tankNumber = 1) THEN
angle = angle1
couleur = COLOR(rouge)
ELSE
angle = angle2
couleur=COLOR(vertClair)
ENDIF
IF (efface = TRUE) THEN
couleur = COLOR(fond)
ENDIF
tempX = COS(angle) * 10.0
tempY = SIN(angle) * 10.0
IF tankNumber = 1 THEN
baseCanonX = xTank1 * 32.0
baseCanonX = baseCanonX + 22
tempYArrondi = yTank1 / 16
MUL tempYArrondi, 16
baseCanonY = tempYArrondi
ADD baseCanonY, 16
ELSE
baseCanonX = xTank2 * 32.0
ADD baseCanonX, 8
tempYArrondi = yTank2 / 16
MUL tempYArrondi, 16
baseCanonY = tempYArrondi
ADD baseCanonY, 14
ENDIF
finCanonX = baseCanonX + tempX
finCanonY = baseCanonY + tempY
DRAW baseCanonX,baseCanonY TO finCanonX,finCanonY,couleur
'LOCATE 1,1:PRINT baseCanonX;" ";baseCanonY;" ";tempY;" ";angle2
END PROC
PROCEDURE effaceCanon [tankNumber]
CALL drawGenericCanon[tankNumber,TRUE]
END PROC
PROCEDURE dessineCanon [tankNumber]
CALL drawGenericCanon[tankNumber,FALSE]
END PROC
'A corriger
PROCEDURE placeTanks
VAR couleur,x,y,couleurFondLocal,yChar
'Place Tank 1
xTank1=1+RND(5):xTank2=xTank1+11:yTank1=400:yTank2=400
couleur = POINT(xTank1*32,yTank1)
couleurFondLocal = POINT(4,390)
WHILE (couleur = couleurFondLocal)
yTank1 = yTank1 - 2
couleur = POINT(xTank1*32,yTank1)
WEND
PEN COLOR(rouge)
yChar = yTank1 / 16
yChar = 24 - yChar
'LOCATE 1,2 : PRINT yTank1 ;":"; couleur; ":";couleurFondLocal
LOCATE xTank1-1,yChar-1 : PRINT " "
LOCATE xTank1-1,yChar : PRINT " ";CHR(64);" "
CALL dessineCanon[1]
'Place Tank 2
couleur = POINT(xTank2*8,yTank2)
WHILE (couleur = couleurFondLocal )
yTank2 = yTank2 - 2
couleur = POINT(xTank2*32,yTank2)
WEND
PEN COLOR(vertClair)
yChar = yTank2/16
yChar = 24 - yChar
'LOCATE 1,3 : PRINT ytank2 ;":"; couleur
LOCATE xTank2-1,yChar-2 : PRINT " "
LOCATE xTank2-1,yChar : PRINT " ";CHR(65);" "
CALL dessineCanon[2]
'PEN COLOR(2)
'LOCATE 1,4 : FOR i=0 TO 15:PEN COLOR(i):PRINT i;" ";:NEXT
END PROC
PROCEDURE affichePaysage2
VAR stepmax AS FLOAT, stepchange AS FLOAT
VAR heightmax AS FLOAT, height AS FLOAT
VAR heightmin AS FLOAT
VAR x AS FLOAT, slope AS FLOAT
VAR temp AS INTEGER
VAR stepHeight AS FLOAT
VAR tempHeight AS FLOAT
VAR tempSlope AS FLOAT
RANDOMIZE TIMER
height = 200 + RND(60)
FONT LOAD "drop.png" TO 64
PAPER COLOR(fond)
CLS COLOR(fond)
stepmax = 3.0
stepchange=2.0
heightmax = 260.0
heightmin = 48.0
temp = heightmax
height =RND(temp)
temp = stepmax
temp = RND(temp)*3.0
slope = temp - stepmax
tempSlope = (RND(2000) / 1000.0)
FOR x=0 TO 640 STEP 4
height = height + slope
tempSlope = RND(2000)
tempSlope = tempSlope / 1000.0
slope= slope + tempSlope - 1
IF slope > stepmax THEN
slope=stepmax
ENDIF
IF slope < (stepmax*-1) THEN
slope=stepmax*-1
ENDIF
IF height>heightmax THEN
height=heightmax:slope=0-slope
ENDIF
IF height= 0.0 AND departY >= 0.0
FOR i = 1 TO 10
PEN COLOR(noir)
POINT AT (departX, departY)
WAIT 60 MS
PEN COLOR(fond)
POINT AT (departX, departY)
departX = departX + (dec_x / 10.0)
departY = departY + (dec_y / 10.0)
NEXT
dec_x=dec_x / 1.25
dec_y=dec_y / 1.25
dec_y=dec_y - 10.0
IF (gereExplosion[departX,departY]) THEN
CALL debugValues["Boom ",departX,departY]
'CALL dessineExplosion[departX,departY]
GOTO fin
ENDIF
WEND
fin:
END PROC
COLOR BORDER RGB(0,0,255)
plancheSprite := LOAD IMAGE("tiger128x128x4.png")
PUT IMAGE plancheSprite AT 0,100 WITH TRANSPARENCY
angle1 = 45
angle2 = 135
GET IMAGE boom FROM 1,98
PUT IMAGE boom AT 50,200
WAIT KEY
CLS
VAR ink AS INTEGER
FOR ink = 1 TO 15
PEN COLOR(ink)
PRINT "stylo ", ink
NEXT
WAIT KEY RELEASE
CLS
CALL affichePaysage2
VAR localTankNumber = 1
DO
IF (localTankNumber = 1) THEN
angle = angle1
ELSE
angle = angle2
ENDIF
IF JLEFT(0) AND (angle < 179) THEN
effaceCanon [localTankNumber]
IF localTankNumber = 1 THEN
angle1 = angle1 + 1
ELSE
angle2 = angle2 + 1
ENDIF
dessineCanon[localTankNumber]
ENDIF
IF JRIGHT(0) AND (angle > 0) THEN
effaceCanon [localTankNumber]
IF localTankNumber = 1 THEN
angle1 = angle1 + 1
ELSE
angle2 = angle2 + 1
ENDIF
dessineCanon[localTankNumber]
ENDIF
IF JUP(0) THEN
IF localTankNumber = 1 THEN
IF (puissance1 < 200 ) THEN
puissance1 = puissance1 + 1
ENDIF
ELSE
IF (puissance2 < 200 ) THEN
puissance2 = puissance2 + 1
ENDIF
ENDIF
'CALL affichPuissance
ENDIF
IF JDOWN(0) THEN
IF localTankNumber = 1 THEN
IF (puissance1 >0 ) THEN
puissance1 = puissance1 - 1
ENDIF
ELSE
IF (puissance2 >0 ) THEN
puissance2 = puissance2 - 1
ENDIF
ENDIF
' 'CALL affichPuissance
ENDIF
IF JFIRE(0) THEN
tir [localTankNumber]
IF localTankNumber = 1 THEN
localTankNumber = 2
ELSE
localTankNumber = 1
ENDIF
ENDIF
WAIT 20 MS
LOOP
==== SOURCE FILE ====
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/bug675.bas|bug675.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 bug675.bas -o example.xex
altirra example.xex
# Windows
ugbc.atari.exe bug675.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 bug675.bas -o example.xex
altirra example.xex
# Windows
ugbc.atarixl.exe bug675.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 bug675.bas -o example.prg
x64sc example.prg
# Windows
ugbc.c64.exe bug675.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 bug675.bas -o example.prg
yape example.prg
# Windows
ugbc.plus4.exe bug675.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 bug675.bas -o example.prg
xplus4 example.prg
# Windows
ugbc.plus4.exe bug675.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 bug675.bas -o example.bin
xroar -rompath (your rom path) example.bin
# Windows
ugbc.d32.exe bug675.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 bug675.bas -o example.bin
xroar -rompath (your rom path) example.bin
# Windows
ugbc.d64.exe bug675.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 bug675.bas -o example.k7
dcmoto
(choose BASIC 128)
CLEAR,&H2FFF: LOADM"CASS:",R: EXEC
# Windows
ugbc.pc128op.exe bug675.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 bug675.bas -o example.k7
dcmoto
(choose BASIC 128)
CLEAR,&H2FFF: LOADM"CASS:",R: EXEC
# Windows
ugbc.pc128op.exe bug675.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 bug675.bas -o example.prg
xvic --memory 24k example.prg
# Windows
ugbc.vic20.exe bug675.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 bug675.bas -o example.tap
Speccy example.tap
# Windows
ugbc.zx.exe bug675.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 bug675.bas -o example.rom
openmsx -cart example.rom
# Windows
ugbc.msx1.exe bug675.bas -o example.rom
openmsx -cart example.rom
== blueMSX ==
# Linux
ugbc.msx1 bug675.bas -o example.rom
bluemsx example.rom
# Windows
ugbc.msx1.exe bug675.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 bug675.bas -o example.rom
openmsx -machine \"COL - ColecoVision\" -cart example.rom
# Windows
ugbc.coleco.exe bug675.bas -o example.rom
bluemsx -machine \"COL - ColecoVision\" example.rom
== blueMSX ==
# Linux
ugbc.coleco bug675.bas -o example.rom
bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom
# Windows
ugbc.coleco.exe bug675.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 bug675.bas -o example.rom
bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom
# Windows
ugbc.sc3000.exe bug675.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 bug675.bas -o example.rom
bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom
# Windows
ugbc.sg1000.exe bug675.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 |}}]]