Strumenti Utente

Strumenti Sito


it:ugbasic:user:example:bug675
Traduzioni di questa pagina:


ugBASIC Manuale Utente

SCOPO

SORGENTE

 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<heightmin THEN 
 			height=heightmin:slope=0-slope
 		ENDIF
 		IF height<0 THEN 
 			height=0
 			slope=0-slope
 			
 		ENDIF
 							
 		DRAW x,0 TO x,height,COLOR(vertFonce)
 			
 	NEXT
 	
 	CALL placeTanks
 
 		
 END PROC
 
 PROCEDURE tir[tankNumber AS INTEGER]
 	VAR tempX AS FLOAT,tempY AS FLOAT
 	VAR tempYArrondi AS INTEGER
 	VAR departX AS FLOAT
 	VAR departY AS FLOAT	
 	VAR puissance AS FLOAT
 	VAR dec_x AS FLOAT
 	VAR dec_y AS FLOAT
 	VAR i AS INTEGER
 	SET LINE $FFFF
 	'Prendre compte de l'angle pour faire partir de le tir plus ? droite ou plus ? gauche...
 	
 	IF tankNumber = 1 THEN
 		puissance=puissance1
 		angle=angle1
 	ELSE
 		puissance=puissance2
 		angle=angle2
 	ENDIF
 	
 	
 	tempX = COS(angle) * 10.0
 	tempY = SIN(angle) * 10.0
 	
 	
 	IF (tankNumber = 1) THEN 		
 		departX =  (xTank1*32.0)+22.0+(tempX)
 		tempYArrondi = yTank1 / 16
 		MUL tempYArrondi, 16
 		departY = tempYArrondi + (tempY) + 16
 		
 	ELSE 	
 		departX =  (xTank2*32.0)+8.0+(tempX)
 		tempYArrondi = yTank2 / 16
 		MUL tempYArrondi, 16
 		departY =  tempYArrondi + (tempY) +14
 				
 	ENDIF
 	
 	dec_x =  COS(angle-1):dec_x = dec_x * puissance
 	dec_y = SIN(angle-1): dec_y = dec_y * puissance
 	
 	WAIT 100 MS
 	
 		
 	WHILE departY < 400.0 AND departX < 640.0 AND departX >= 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
 

FILE

COME ESEGUIRLO

Atari 400/800

Per poter eseguire l'esempio, è necessario disporre dell'emulatore Altirra, e in particolare che l'eseguibile x64sc sia accessibile.

Digitare quindi il seguente comando:

 # 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)

Per poter eseguire l'esempio, è necessario disporre dell'emulatore Altirra, e in particolare che l'eseguibile x64sc sia accessibile.

Digitare quindi il seguente comando:

 # 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

Per poter eseguire l'esempio, è necessario disporre dell'emulatore VICE, e in particolare che l'eseguibile x64sc sia accessibile.

Digitare quindi il seguente comando:

 # 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

Usando YAPE

Per poter eseguire l'esempio, è necessario disporre dell'emulatore YAPE, e in particolare che l'eseguibile yape sia accessibile.

Digitare quindi il seguente comando:

 # Linux 
 ugbc.plus4 bug675.bas -o example.prg
 yape example.prg
 
 # Windows 
 ugbc.plus4.exe bug675.bas -o example.prg
 yape example.prg
Usando VICE

Per poter eseguire l'esempio, è necessario disporre dell'emulatore VICE, e in particolare che l'eseguibile xplus4 sia accessibile.

Digitare quindi il seguente comando:

 # 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

Per poter eseguire l'esempio, è necessario disporre dell'emulatore XROAR, e in particolare che l'eseguibile x64sc sia accessibile.

Digitare quindi il seguente comando:

 # Linux 
 ugbc.d32 bug675.bas -o example.bin
 xroar -rompath (percorso ROM) example.bin
 
 # Windows 
 ugbc.d32.exe bug675.bas -o example.bin
 xroar.exe -rompath (percorso ROM) example.bin

Dragon 64

Per poter eseguire l'esempio, è necessario disporre dell'emulatore XROAR, e in particolare che l'eseguibile x64sc sia accessibile.

Digitare quindi il seguente comando:

 # Linux 
 ugbc.d64 bug675.bas -o example.bin
 xroar -rompath (percorso ROM) example.bin
 
 # Windows 
 ugbc.d64.exe bug675.bas -o example.bin
 xroar.exe -rompath (percorso ROM) example.bin

PC128 Olivetti Prodest

Per poter eseguire l'esempio, è necessario disporre dell'emulatore DCMOTO, e in particolare che l'eseguibile x64sc sia accessibile.

Digitare quindi i seguenti comandi:

 # Linux 
 ugbc.pc128op bug675.bas -o example.bin
 dcmoto example.bin
 (scegliere example.bin)
 (scegliere BASIC 128)
 CLEAR,&H2FFF: LOADM"CASS:",R: EXEC
 
 # Windows 
 ugbc.pc128op.exe bug675.bas -o example.bin
 dcmoto example.bin
 (scegliere BASIC 128)
 CLEAR,&H2FFF: LOADM"CASS:",R: EXEC

Thomson MO5

Per poter eseguire l'esempio, è necessario disporre dell'emulatore DCMOTO, e in particolare che l'eseguibile x64sc sia accessibile.

Digitare quindi i seguenti comandi:

 # Linux 
 ugbc.mo5 bug675.bas -o example.bin
 dcmoto example.bin
 (scegliere example.bin)
 (scegliere BASIC 128)
 CLEAR,&H2FFF: LOADM"CASS:",R: EXEC
 
 # Windows 
 ugbc.mo5.exe bug675.bas -o example.bin
 dcmoto example.bin
 (scegliere BASIC 128)
 CLEAR,&H2FFF: LOADM"CASS:",R: EXEC

Commodore VIC-20

Per poter eseguire l'esempio, è necessario disporre dell'emulatore XEMU, e in particolare che l'eseguibile xmega65 sia accessibile.

Digitare quindi il seguente comando:

 # 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

Per poter eseguire l'esempio, è necessario disporre dell'emulatore Speccy, e in particolare che l'eseguibile speccy sia accessibile.

Digitare quindi il seguente comando:

 # Linux 
 ugbc.zx bug675.bas -o example.tap
 Speccy example.tap
 
 # Windows 
 ugbc.zx.exe bug675.bas -o example.tap
 Speccy example.tap

ColecoVision

Per compilare e mandare in esecuzione l'esempio, hai bisogno di avere l'emulatore openMsx oppure il BlueMSX, e in particolare che il suo eseguibile sia accessibile.

Dopo di che, digita questo comando sulla linea di comando:

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

Per compilare e mandare in esecuzione l'esempio, hai bisogno di avere l'emulatore BlueMSX, e in particolare che il suo eseguibile sia accessibile.

Dopo di che, digita questo comando sulla linea di comando:

 # 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

Per compilare e mandare in esecuzione l'esempio, hai bisogno di avere l'emulatore BlueMSX, e in particolare che il suo eseguibile sia accessibile.

Dopo di che, digita questo comando sulla linea di comando:

 # 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

PROBLEMI?

Se hai trovato un problema nel cercare di eseguire questo esempio, se pensi che ci sia un bug o, più semplicemente, vorresti che fosse migliorato, apri una segnalazione su GitHub per questo specifico esempio. Grazie!

POWERED BY