Starship to try

Discuss any general programming issues here
Post Reply
ArtBlink
Posts: 437
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Starship to try

Post by ArtBlink » Sat Dec 04, 2010 3:28 pm

Hello,

Try this, i think ou like that ;-)

Code: Select all

@SCREEN {Mode = "ask", Width = 640, Height = 400}

FC=200
CX=160
CY=100
CZ=200
Function Controle()
	If IsKeyDown("Left")=True Then Gauche() ; Vers la gauche
	If IsKeyDown("Right")=True Then Droite() ; Vers la droite
	If IsKeyDown("Up")=True Then Haut() ; Vers le Haut
	If IsKeyDown("Down")=True Then Bas() ; Vers le bas
	If IsKeyDown("a")=True Then Zoomin() ; Zoom in
	If IsKeyDown("z")=True Then Zoomout() ; Zoom Out
	If IsKeyDown("e")=True Then SetFormStyle(#ANTIALIAS); Antialiasing sur le starship
	If IsKeyDown("r")=True Then SetFormStyle(#NORMAL); Enlève l'Antialiasing sur le starship

EndFunction

Function Gauche()
	AY=AY+1
	If AY>359 Then AY=0
EndFunction

Function Droite()
	AY=AY-1
	If AY<0 Then AY=359
EndFunction

Function Haut()
	AX=AX+1
	If AX>359 Then AX=0
EndFunction
	
Function Bas()
	AX=AX-1
	If AX<0 Then AX=359
EndFunction

Function Zoomin()
	CZ=CZ+10
	If CZ>500 Then CZ=500
EndFunction

Function Zoomout()
	CZ=CZ-10
	If CZ<80 Then CZ=80
EndFunction

Function PRG()
	
	Controle() ; Exécution de la fonction Controle
	; Réservation mémoire et création des tableaux
	Dim CO[360] ; 360 cases réservé car une rotation c'est 360° pour le Cosinus
	Dim SI[360] ; 360 cases réservé car une rotation c'est 360° pour le Sinus
	Dim X[8] ; Un cube, c'est 8 points en X
	Dim Y[8] ; Un cube, c'est 8 points en Y
	Dim Z[8] ; Un cube, c'est 8 points en Z
	Dim XE[8] ; Point final du cube a dessiner en X
	Dim YE[8] ; Point final du cube a dessiner en Y
	Dim ZZ[8] ; Point final du cube a dessiner en Z
	Dim P1[12] ; Un cube, c'est 12 lignes (point de départ de la ligne)
	Dim P2[12] ; Un cube, c'est 12 lignes (point final de la ligne)
	
Flip ; Flip d'écran pour le double buffer
Cls ; Effacement de l'écran sinon on verrait des starship partout lol
TextOut(#CENTER,0,"LA GUERRE DES ETOILES")
TextOut(#CENTER,10,"A Hollywood")
TextOut(0,20,"Touche fléché pour la rotation de l'objet")
TextOut(0,30,"touche a = Zoom Arrière")
TextOut(0,40,"touche z = Zoom Avant")
TextOut(0,50,"touche e = SURPRISE!!!")
TextOut(0,60,"touche r = Enlève la surprise")
TextOut(0,70,"ctrl + c = QUITTER")
For I=0 To 359
	CO[I]=Cos(I*0.1)*256 ; Mise en mémoire de 360 calcule du Cosinus des angles sur 360°
	SI[I]=Sin(I*0.1)*256 ; Mise en mémoire de 360 calcule du Sinus des angles sur 360°
Next 

;Coordonnée de l'objet à dessiner, objet donnée gratieusement par l'ami Thellier, grand programmeur 3D ;-)
;J'ai créé un tableau unique avec les coordonnèes U et V pour les textures, mais je maîtrise pas, et les 
;coordonnées X, Y et Z, le tableau est donc sous le format coord[U,V,X,Y,Z] et surtout pas coord[U][V][X][Y][Z] 
;coord[] est un tableau à 1 colonne ou 1 ligne (selon comment vous l'imaginer sous excel par exemple)
	
	
	For I=0 To 95
		; il y a 96 lignes de coordonnées, donc 0 à 95, sa fait 96 graduations
		; tous les tableaux Hollywood commence à l'adresse 0
	coord={
	0.647059,0.545455,-0.013836,-0.009224,-0.039999,
	0.588235,0.309091,0.076100,0.046121,-0.536000,
	0.686275,0.309091,0.076100,-0.046121,-0.536000,
	0.852941,0.545455,-0.013836,-0.202934,-0.039999,
	0.647059,0.600000,-0.034591,-0.009224,-0.039999,
	0.852941,0.600000,-0.034591,-0.202934,-0.039999,
	0.686275,0.363636,0.055346,-0.046121,-0.536000,
	0.588235,0.363636,0.055346,0.046121,-0.536000,
	0.852941,0.545455,-0.013836,-0.202934,0.039999,
	0.686275,0.309091,0.076100,-0.046121,0.536001,
	0.588235,0.309091,0.076100,0.046121,0.536001,
	0.647059,0.545455,-0.013836,-0.009224,0.039999,
	0.588235,0.363636,0.055346,0.046121,0.536001,
	0.686275,0.363636,0.055346,-0.046121,0.536001,
	0.852941,0.600000,-0.034591,-0.202934,0.039999,
	0.647059,0.600000,-0.034591,-0.009224,0.039999,
	1.000000,0.400000,0.041509,-0.341298,0.007999,
	0.901961,0.400000,0.041509,-0.249055,0.007999,
	0.901961,0.109091,0.152200,-0.249055,0.007999,
	0.970588,0.054545,0.172955,-0.313625,0.007999,
	0.901961,0.400000,0.041509,-0.249055,0.000000,
	1.000000,0.400000,0.041509,-0.341298,0.000000,
	0.970588,0.054545,0.172955,-0.313625,0.000000,
	0.901961,0.109091,0.152200,-0.249055,0.000000,
	0.852941,0.054545,0.172955,-0.202934,0.000000,
	0.852941,0.054545,0.172955,-0.202934,0.007999,
	0.666667,0.054545,0.172955,-0.027673,0.000000,
	0.666667,0.054545,0.172955,-0.027673,0.007999,
	0.666667,0.000000,0.193710,-0.027673,0.000000,
	0.666667,0.000000,0.193710,-0.027673,0.007999,
	0.941176,0.000000,0.193710,-0.285952,0.000000,
	0.941176,0.000000,0.193710,-0.285952,0.007999,
	0.156863,0.636364,-0.048427,0.451989,0.039999,
	0.156863,0.545455,-0.013836,0.451989,0.016000,
	0.274510,0.472727,0.013836,0.341298,0.023999,
	0.274510,0.636364,-0.048427,0.341298,0.072000,
	0.558824,0.472727,0.013836,0.073794,0.023999,
	0.558824,0.636364,-0.048427,0.073794,0.072000,
	0.156863,0.545455,-0.013836,0.451989,-0.008000,
	0.274510,0.472727,0.013836,0.341298,-0.016000,
	0.558824,0.472727,0.013836,0.073794,-0.016000,
	0.156863,0.636364,-0.048427,0.451989,-0.039999,
	0.274510,0.636364,-0.048427,0.341298,-0.056000,
	0.558824,0.636364,-0.048427,0.073794,-0.056000,
	0.009804,0.636364,-0.048427,0.590353,0.000000,
	0.156863,0.690909,-0.069182,0.451989,0.023999,
	0.274510,0.727273,-0.083018,0.341298,0.039999,
	0.343137,0.727273,-0.083018,0.276728,0.023999,
	0.343137,0.727273,-0.083018,0.276728,-0.016000,
	0.274510,0.727273,-0.083018,0.341298,-0.024000,
	0.156863,0.690909,-0.069182,0.451989,-0.016000,
	0.000000,0.636364,-0.048427,0.599577,0.000000,
	0.558824,0.727273,-0.083018,0.073794,-0.016000,
	0.558824,0.727273,-0.083018,0.073794,0.023999,
	0.549020,0.818182,-0.117609,0.083018,0.112000,
	0.549020,0.945455,-0.166037,0.083018,0.056000,
	0.549020,1.000000,-0.186791,0.083018,0.007999,
	0.549020,1.000000,-0.186791,0.083018,-0.008000,
	0.549020,0.945455,-0.166037,0.083018,-0.056000,
	0.549020,0.818182,-0.117609,0.083018,-0.112000,
	0.549020,0.472727,0.013836,0.083018,-0.056000,
	0.549020,0.363636,0.055346,0.083018,-0.008000,
	0.549020,0.363636,0.055346,0.083018,0.007999,
	0.549020,0.472727,0.013836,0.083018,0.056000,
	1.000000,0.472727,0.013836,-0.341298,0.056000,
	1.000000,0.709091,-0.076100,-0.341298,0.088000,
	0.921569,0.818182,-0.117609,-0.267504,0.112000,
	1.000000,0.363636,0.055346,-0.341298,0.007999,
	1.000000,0.363636,0.055346,-0.341298,-0.008000,
	1.000000,0.472727,0.013836,-0.341298,-0.056000,
	0.921569,0.818182,-0.117609,-0.267504,-0.112000,
	1.000000,0.709091,-0.076100,-0.341298,-0.088000,
	0.813725,1.000000,-0.186791,-0.166037,0.007999,
	0.813725,1.000000,-0.186791,-0.166037,-0.008000,
	0.843137,0.945455,-0.166037,-0.193710,-0.056000,
	0.843137,0.945455,-0.166037,-0.193710,0.056000,
	0.441176,0.363636,0.055346,0.184485,0.488000,
	0.441176,0.181818,0.124528,0.184485,0.488000,
	0.441176,0.181818,0.124528,0.184485,0.552001,
	0.441176,0.363636,0.055346,0.184485,0.696001,
	0.441176,0.509091,0.000000,0.184485,0.552001,
	0.745098,0.127273,0.145282,-0.101467,0.552001,
	0.745098,0.127273,0.145282,-0.101467,0.488000,
	0.745098,0.363636,0.055346,-0.101467,0.488000,
	0.745098,0.600000,-0.034591,-0.101467,0.552001,
	0.745098,0.363636,0.055346,-0.101467,0.696001,
	0.441176,0.509091,0.000000,0.184485,-0.552000,
	0.441176,0.363636,0.055346,0.184485,-0.696000,
	0.441176,0.181818,0.124528,0.184485,-0.552000,
	0.441176,0.181818,0.124528,0.184485,-0.488000,
	0.441176,0.363636,0.055346,0.184485,-0.488000,
	0.764706,0.363636,0.055346,-0.119915,-0.696000,
	0.764706,0.600000,-0.034591,-0.119915,-0.552000,
	0.764706,0.363636,0.055346,-0.119915,-0.488000,
	0.764706,0.127273,0.145282,-0.119915,-0.488000,
	0.764706,0.127273,0.145282,-0.119915,-0.552000
	}
; J'ai du rajouter une ligne de trois 0 qui ne sont pas des coordonnées du vaisseau, on verra plus tard pourquoi ;-)
; P1 c'est 3 chiffres formant 1 triangle
P1={
	0,0,0,
	0,1,2,
	0,2,3,
	4,5,6,
	4,6,7,
	7,1,0,
	7,0,4,
	2,1,7,
	2,7,6,
	3,2,6,
	3,6,5,
	0,3,5,
	0,5,4,
	8,9,10,
	8,10,11,
	12,13,14,
	12,14,15,
	15,11,10,
	15,10,12,
	13,12,10,
	13,10,9,
	14,13,9,
	14,9,8,
	15,14,8,
	15,8,11,
	16,17,18,
	16,18,19,
	20,21,22,
	20,22,23,
	23,18,17,
	23,17,20,
	24,25,18,
	24,18,23,
	26,27,25,
	26,25,24,
	28,29,27,
	28,27,26,
	30,31,29,
	30,29,28,
	22,19,31,
	22,31,30,
	21,16,19,
	21,19,22,
	20,17,16,
	20,16,21,
	18,25,31,
	18,31,19,
	22,30,24,
	22,24,23,
	24,30,28,
	24,28,26,
	31,25,27,
	31,27,29,
	32,33,34,
	32,34,35,
	35,34,36,
	35,36,37,
	33,38,39,
	33,39,34,
	34,39,40,
	34,40,36,
	38,41,42,
	38,42,39,
	39,42,43,
	39,43,40,
	44,44,45,
	44,45,46,
	44,46,47,
	44,47,48,
	44,48,49,
	44,49,50,
	44,50,44,
	44,44,51,
	44,51,51,
	51,51,38,
	51,38,33,
	51,44,41,
	51,41,38,
	41,44,50,
	50,49,42,
	50,42,41,
	49,48,52,
	49,52,43,
	49,43,42,
	48,47,53,
	48,53,52,
	46,35,37,
	46,37,53,
	46,53,47,
	46,45,32,
	46,32,35,
	32,45,44,
	44,51,33,
	44,33,32,
	36,40,43,
	36,43,52,
	36,52,53,
	36,53,37,
	36,37,37,
	54,55,56,
	54,56,57,
	54,57,58,
	54,58,59,
	54,59,60,
	54,60,61,
	54,61,62,
	54,62,63,
	64,65,66,
	64,66,54,
	64,54,63,
	63,62,67,
	63,67,64,
	62,61,68,
	62,68,67,
	61,60,69,
	61,69,68,
	59,70,71,
	59,71,69,
	59,69,60,
	56,72,73,
	56,73,57,
	57,73,74,
	57,74,58,
	58,74,70,
	58,70,59,
	54,66,75,
	54,75,55,
	55,75,72,
	55,72,56,
	69,71,65,
	69,65,64,
	69,64,67,
	69,67,68,
	75,66,65,
	75,65,71,
	75,71,70,
	75,70,74,
	75,74,73,
	75,73,72,
	76,77,78,
	76,78,79,
	76,79,80,
	81,82,83,
	81,83,84,
	81,84,85,
	78,85,79,
	77,81,78,
	76,82,77,
	80,83,76,
	79,84,80,
	85,84,79,
	84,83,80,
	83,82,76,
	82,81,77,
	81,85,78,
	86,87,88,
	86,88,89,
	86,89,90,
	91,92,93,
	91,93,94,
	91,94,95,
	87,91,88,
	88,95,89,
	89,94,90,
	90,93,86,
	86,92,87,
	87,92,91,
	86,93,92,
	90,94,93,
	89,95,94,
	88,91,95,
}

		;Calcule 3D grâce au magazine Dream N°27 de Mars 1996 que j'ai modifié pour le Starship
		Y1=(coord[I*5+3]*100*CO[AX]+coord[I*5+4]*100*SI[AX])/256 
		; I*5+3, faite le calcule sur une feuille blanche, le résultat sera l'adresse de la donnée dans le tableau coord[], vous allez vite comprendre (c'est la valeur en X)
		Z1=(-coord[I*5+3]*100*SI[AX]+coord[I*5+4]*100*CO[AX])/256
		X1=(coord[I*5+2]*100*CO[AY]+Z1*SI[AY])/256
		ZZ[I]=(-coord[I*5+2]*100*SI[AY]+Z1*CO[AY])/256
		X=(X1*CO[AZ]+Y1*SI[AZ])/256
		Y=(-X1*SI[AZ]+Y1*CO[AZ])/256
		D=FC/(Sqrt(X^2+Y^2+(CZ+ZZ[I])^2))
		XE[I]=320+X*D
		YE[I]=200+Y*D
	Next
	; Calcule final
	For I=0 To 169
		GP1=P1[I*3+3]
		GP2=P1[I*3+4]
		GP3=P1[I*3+5]
		X=XE[GP1]
		Y=YE[GP1]
		X1=XE[GP2]
		Y1=YE[GP2]
		X2=XE[GP3]
		Y2=YE[GP3]
		;un triangle c'est 3 côtés donc 3 traçage de lignes
		Line (X,Y,X1,Y1,#WHITE) ; Traçage des lignes du premier côtés de chaque triangle
		Line (X1,Y1,X2,Y2,#WHITE) ; Traçage des lignes du deuxième côtés de chaque triangle
		Line (X2,Y2,X,Y,#WHITE) ; Traçage des lignes du troisième côtés de chaque triangle

	Next
EndFunction

BeginDoubleBuffer

SetInterval(1,PRG,1000/50)

Repeat
WaitEvent
Forever
So, good fun and boost this release for you're demo for example or 3D game make with hollywood ;-)

Respect

ArtBlink
Posts: 437
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Re: Starship to try

Post by ArtBlink » Sun Dec 05, 2010 11:06 am

Hello,

Try this engine, it is more optimized.

@Andreas: i'm happy to say you, 3D on hollywood is possible ;-)

Good play with this code, and use it in your demo, game, or other forum.

Respect

Code: Select all

@SCREEN {Mode = "ask", Width = 640, Height = 400}

FC=200
CX=0
CY=0
CZ=200
; Réservation mémoire et création des tableaux
	Dim CO[360] ; 360 cases réservé car une rotation c'est 360° pour le Cosinus
	Dim SI[360] ; 360 cases réservé car une rotation c'est 360° pour le Sinus
	Dim TA[360]
	Dim X[96] ; Le vaisseau, c'est 32 triangle soit 96 pts 
	Dim Y[96] ; Le vaisseau, c'est 32 triangle soit 96 pts 
	Dim Z[96] ; Le vaisseau, c'est 32 triangle soit 96 pts 
	Dim XE[170] ; Point final du triangle a dessiner en X
	Dim YE[170] ; Point final du triangle a dessiner en Y
	Dim ZZ[170] ; Point final du triangle a dessiner en Z
	Dim P1[170] ; Un vaisseau, c'est 170 lignes (point de départ de la ligne)
	Dim C[169]
	Dim V[6]
;Coordonnée de l'objet à dessiner, objet donnée gratieusement par l'ami Thellier, grand programmeur 3D ;-)
;J'ai créé un tableau unique avec les coordonnèes U et V pour les textures, mais je maîtrise pas, et les 
;coordonnées X, Y et Z, le tableau est donc sous le format coord[U,V,X,Y,Z] et surtout pas coord[U][V][X][Y][Z] 
;coord[] est un tableau à 1 colonne ou 1 ligne (selon comment vous l'imaginer sous excel par exemple)
	coord={
	0.647059,0.545455,-0.013836,-0.009224,-0.039999,
	0.588235,0.309091,0.076100,0.046121,-0.536000,
	0.686275,0.309091,0.076100,-0.046121,-0.536000,
	0.852941,0.545455,-0.013836,-0.202934,-0.039999,
	0.647059,0.600000,-0.034591,-0.009224,-0.039999,
	0.852941,0.600000,-0.034591,-0.202934,-0.039999,
	0.686275,0.363636,0.055346,-0.046121,-0.536000,
	0.588235,0.363636,0.055346,0.046121,-0.536000,
	0.852941,0.545455,-0.013836,-0.202934,0.039999,
	0.686275,0.309091,0.076100,-0.046121,0.536001,
	0.588235,0.309091,0.076100,0.046121,0.536001,
	0.647059,0.545455,-0.013836,-0.009224,0.039999,
	0.588235,0.363636,0.055346,0.046121,0.536001,
	0.686275,0.363636,0.055346,-0.046121,0.536001,
	0.852941,0.600000,-0.034591,-0.202934,0.039999,
	0.647059,0.600000,-0.034591,-0.009224,0.039999,
	1.000000,0.400000,0.041509,-0.341298,0.007999,
	0.901961,0.400000,0.041509,-0.249055,0.007999,
	0.901961,0.109091,0.152200,-0.249055,0.007999,
	0.970588,0.054545,0.172955,-0.313625,0.007999,
	0.901961,0.400000,0.041509,-0.249055,0.000000,
	1.000000,0.400000,0.041509,-0.341298,0.000000,
	0.970588,0.054545,0.172955,-0.313625,0.000000,
	0.901961,0.109091,0.152200,-0.249055,0.000000,
	0.852941,0.054545,0.172955,-0.202934,0.000000,
	0.852941,0.054545,0.172955,-0.202934,0.007999,
	0.666667,0.054545,0.172955,-0.027673,0.000000,
	0.666667,0.054545,0.172955,-0.027673,0.007999,
	0.666667,0.000000,0.193710,-0.027673,0.000000,
	0.666667,0.000000,0.193710,-0.027673,0.007999,
	0.941176,0.000000,0.193710,-0.285952,0.000000,
	0.941176,0.000000,0.193710,-0.285952,0.007999,
	0.156863,0.636364,-0.048427,0.451989,0.039999,
	0.156863,0.545455,-0.013836,0.451989,0.016000,
	0.274510,0.472727,0.013836,0.341298,0.023999,
	0.274510,0.636364,-0.048427,0.341298,0.072000,
	0.558824,0.472727,0.013836,0.073794,0.023999,
	0.558824,0.636364,-0.048427,0.073794,0.072000,
	0.156863,0.545455,-0.013836,0.451989,-0.008000,
	0.274510,0.472727,0.013836,0.341298,-0.016000,
	0.558824,0.472727,0.013836,0.073794,-0.016000,
	0.156863,0.636364,-0.048427,0.451989,-0.039999,
	0.274510,0.636364,-0.048427,0.341298,-0.056000,
	0.558824,0.636364,-0.048427,0.073794,-0.056000,
	0.009804,0.636364,-0.048427,0.590353,0.000000,
	0.156863,0.690909,-0.069182,0.451989,0.023999,
	0.274510,0.727273,-0.083018,0.341298,0.039999,
	0.343137,0.727273,-0.083018,0.276728,0.023999,
	0.343137,0.727273,-0.083018,0.276728,-0.016000,
	0.274510,0.727273,-0.083018,0.341298,-0.024000,
	0.156863,0.690909,-0.069182,0.451989,-0.016000,
	0.000000,0.636364,-0.048427,0.599577,0.000000,
	0.558824,0.727273,-0.083018,0.073794,-0.016000,
	0.558824,0.727273,-0.083018,0.073794,0.023999,
	0.549020,0.818182,-0.117609,0.083018,0.112000,
	0.549020,0.945455,-0.166037,0.083018,0.056000,
	0.549020,1.000000,-0.186791,0.083018,0.007999,
	0.549020,1.000000,-0.186791,0.083018,-0.008000,
	0.549020,0.945455,-0.166037,0.083018,-0.056000,
	0.549020,0.818182,-0.117609,0.083018,-0.112000,
	0.549020,0.472727,0.013836,0.083018,-0.056000,
	0.549020,0.363636,0.055346,0.083018,-0.008000,
	0.549020,0.363636,0.055346,0.083018,0.007999,
	0.549020,0.472727,0.013836,0.083018,0.056000,
	1.000000,0.472727,0.013836,-0.341298,0.056000,
	1.000000,0.709091,-0.076100,-0.341298,0.088000,
	0.921569,0.818182,-0.117609,-0.267504,0.112000,
	1.000000,0.363636,0.055346,-0.341298,0.007999,
	1.000000,0.363636,0.055346,-0.341298,-0.008000,
	1.000000,0.472727,0.013836,-0.341298,-0.056000,
	0.921569,0.818182,-0.117609,-0.267504,-0.112000,
	1.000000,0.709091,-0.076100,-0.341298,-0.088000,
	0.813725,1.000000,-0.186791,-0.166037,0.007999,
	0.813725,1.000000,-0.186791,-0.166037,-0.008000,
	0.843137,0.945455,-0.166037,-0.193710,-0.056000,
	0.843137,0.945455,-0.166037,-0.193710,0.056000,
	0.441176,0.363636,0.055346,0.184485,0.488000,
	0.441176,0.181818,0.124528,0.184485,0.488000,
	0.441176,0.181818,0.124528,0.184485,0.552001,
	0.441176,0.363636,0.055346,0.184485,0.696001,
	0.441176,0.509091,0.000000,0.184485,0.552001,
	0.745098,0.127273,0.145282,-0.101467,0.552001,
	0.745098,0.127273,0.145282,-0.101467,0.488000,
	0.745098,0.363636,0.055346,-0.101467,0.488000,
	0.745098,0.600000,-0.034591,-0.101467,0.552001,
	0.745098,0.363636,0.055346,-0.101467,0.696001,
	0.441176,0.509091,0.000000,0.184485,-0.552000,
	0.441176,0.363636,0.055346,0.184485,-0.696000,
	0.441176,0.181818,0.124528,0.184485,-0.552000,
	0.441176,0.181818,0.124528,0.184485,-0.488000,
	0.441176,0.363636,0.055346,0.184485,-0.488000,
	0.764706,0.363636,0.055346,-0.119915,-0.696000,
	0.764706,0.600000,-0.034591,-0.119915,-0.552000,
	0.764706,0.363636,0.055346,-0.119915,-0.488000,
	0.764706,0.127273,0.145282,-0.119915,-0.488000,
	0.764706,0.127273,0.145282,-0.119915,-0.552000
	}
; J'ai du rajouter une ligne de trois 0 qui ne sont pas des coordonnées du vaisseau, on verra plus tard pourquoi ;-)
; P1 c'est 3 chiffres formant 1 triangle
P1={
	0,0,0,
	0,1,2,
	0,2,3,
	4,5,6,
	4,6,7,
	7,1,0,
	7,0,4,
	2,1,7,
	2,7,6,
	3,2,6,
	3,6,5,
	0,3,5,
	0,5,4,
	8,9,10,
	8,10,11,
	12,13,14,
	12,14,15,
	15,11,10,
	15,10,12,
	13,12,10,
	13,10,9,
	14,13,9,
	14,9,8,
	15,14,8,
	15,8,11,
	16,17,18,
	16,18,19,
	20,21,22,
	20,22,23,
	23,18,17,
	23,17,20,
	24,25,18,
	24,18,23,
	26,27,25,
	26,25,24,
	28,29,27,
	28,27,26,
	30,31,29,
	30,29,28,
	22,19,31,
	22,31,30,
	21,16,19,
	21,19,22,
	20,17,16,
	20,16,21,
	18,25,31,
	18,31,19,
	22,30,24,
	22,24,23,
	24,30,28,
	24,28,26,
	31,25,27,
	31,27,29,
	32,33,34,
	32,34,35,
	35,34,36,
	35,36,37,
	33,38,39,
	33,39,34,
	34,39,40,
	34,40,36,
	38,41,42,
	38,42,39,
	39,42,43,
	39,43,40,
	44,44,45,
	44,45,46,
	44,46,47,
	44,47,48,
	44,48,49,
	44,49,50,
	44,50,44,
	44,44,51,
	44,51,51,
	51,51,38,
	51,38,33,
	51,44,41,
	51,41,38,
	41,44,50,
	50,49,42,
	50,42,41,
	49,48,52,
	49,52,43,
	49,43,42,
	48,47,53,
	48,53,52,
	46,35,37,
	46,37,53,
	46,53,47,
	46,45,32,
	46,32,35,
	32,45,44,
	44,51,33,
	44,33,32,
	36,40,43,
	36,43,52,
	36,52,53,
	36,53,37,
	36,37,37,
	54,55,56,
	54,56,57,
	54,57,58,
	54,58,59,
	54,59,60,
	54,60,61,
	54,61,62,
	54,62,63,
	64,65,66,
	64,66,54,
	64,54,63,
	63,62,67,
	63,67,64,
	62,61,68,
	62,68,67,
	61,60,69,
	61,69,68,
	59,70,71,
	59,71,69,
	59,69,60,
	56,72,73,
	56,73,57,
	57,73,74,
	57,74,58,
	58,74,70,
	58,70,59,
	54,66,75,
	54,75,55,
	55,75,72,
	55,72,56,
	69,71,65,
	69,65,64,
	69,64,67,
	69,67,68,
	75,66,65,
	75,65,71,
	75,71,70,
	75,70,74,
	75,74,73,
	75,73,72,
	76,77,78,
	76,78,79,
	76,79,80,
	81,82,83,
	81,83,84,
	81,84,85,
	78,85,79,
	77,81,78,
	76,82,77,
	80,83,76,
	79,84,80,
	85,84,79,
	84,83,80,
	83,82,76,
	82,81,77,
	81,85,78,
	86,87,88,
	86,88,89,
	86,89,90,
	91,92,93,
	91,93,94,
	91,94,95,
	87,91,88,
	88,95,89,
	89,94,90,
	90,93,86,
	86,92,87,
	87,92,91,
	86,93,92,
	90,94,93,
	89,95,94,
	88,91,95,
}
For I=0 To 359
	CO[I]=Cos(I*0.1)*359 ; Mise en mémoire de 360 calcule du Cosinus des angles sur 360°
	SI[I]=Sin(I*0.1)*359 ; Mise en mémoire de 360 calcule du Sinus des angles sur 360°
	TA[I]=Tan(I*0.1)*359
Next 

Function Controle()
	If IsKeyDown("Left")=True Then Gauche() ; Vers la gauche
	If IsKeyDown("Right")=True Then Droite() ; Vers la droite
	If IsKeyDown("Up")=True Then Haut() ; Vers le Haut
	If IsKeyDown("Down")=True Then Bas() ; Vers le bas
	If IsKeyDown("a")=True Then Zoomin() ; Zoom in
	If IsKeyDown("z")=True Then Zoomout() ; Zoom Out
	If IsKeyDown("e")=True Then SetFormStyle(#ANTIALIAS); Antialiasing sur le starship
	If IsKeyDown("r")=True Then SetFormStyle(#NORMAL); Enlève l'Antialiasing sur le starship
	If IsKeyDown("t")=True Then SetFillStyle(#FILLCOLOR) ; Zoom Out
	If IsKeyDown("y")=True Then SetFillStyle(#FILLNONE);   
	
EndFunction

Function Gauche()
	AY=AY+1
	If AY>359 Then AY=0
EndFunction

Function Droite()
	AY=AY-1
	If AY<0 Then AY=359
EndFunction

Function Haut()
	AX=AX+1
	If AX>359 Then AX=0
EndFunction
	
Function Bas()
	AX=AX-1
	If AX<0 Then AX=359
EndFunction

Function Zoomin()
	CZ=CZ+10
	If CZ>500 Then CZ=500
EndFunction

Function Zoomout()
	CZ=CZ-10
	If CZ<80 Then CZ=80
EndFunction

Function PRG()
	Controle() ; Exécution de la fonction Controle
	Flip ; Flip d'écran pour le double buffer
	Cls ; Effacement de l'écran sinon on verrait des starship partout lol
	TextOut(#CENTER,0,"LA GUERRE DES ETOILES")
	TextOut(#CENTER,10,"A Hollywood")
	TextOut(0,20,"Touche fléché pour la rotation de l'objet")
	TextOut(0,30,"touche a = Zoom Arrière")
	TextOut(0,40,"touche z = Zoom Avant")
	TextOut(0,50,"touche e = Antialiasing")
	TextOut(0,60,"touche r = Retirer l'Antialiasing")
	TextOut(0,70,"touche t = 3D Surface pleine")
	TextOut(0,80,"touche y = 3D filaire")
	TextOut(0,90,"ctrl + c = QUITTER")
	
	For I=0 To 95
		; il y a 96 lignes de coordonnées, donc 0 à 95, sa fait 96 graduations
		; tous les tableaux Hollywood commence à l'adresse 0
		;Calcule 3D grâce au magazine Dream N°27 de Mars 1996 que j'ai modifié pour le Starship
		Y1=(coord[I*5+3]*100*CO[AX]+coord[I*5+4]*100*SI[AX])/256 
		; I*5+3, faite le calcule sur une feuille blanche, le résultat sera l'adresse de la donnée dans le tableau coord[], vous allez vite comprendre (c'est la valeur en X)
		Z1=(-coord[I*5+3]*100*si[AX]+coord[I*5+4]*100*co[AX])/256
		X1=(coord[I*5+2]*100*CO[AY]+Z1*SI[AY])/256
		ZZ[I]=(-coord[I*5+2]*100*SI[AY]+Z1*CO[AY])/256
		X=(X1*CO[AZ]+Y1*SI[AZ])/256
		Y=(-X1*SI[AZ]+Y1*CO[AZ])/256
		D=FC/(Sqrt(X^2+Y^2+(CZ+ZZ[I])^2))
		XE[I]=320+X*D
		YE[I]=200+Y*D
	Next
	
	; Calcule final
	For I=0 To 169
		GP1=P1[I*3+3]
		GP2=P1[I*3+4]
		GP3=P1[I*3+5]
		X=XE[GP1]
		Y=YE[GP1]
		
		V[0]=XE[GP2]
		V[1]=YE[GP2]
		V[2]=XE[GP3]
		V[3]=YE[GP3]
		V[4]=XE[GP1]
		V[5]=YE[GP1]
		
		;un triangle c'est 3 côtés donc 3 traçage de lignes
		Polygon(CX,CY,v,3,ARGB(180, $ffffff))
	Next
	
EndFunction

BeginDoubleBuffer

SetInterval(1,PRG,1000/50)

Repeat
WaitEvent
Forever

Post Reply