by gorilla_bas on Sun Apr 13, 2008 2:40 pm
My game
- Code: Select all
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
Global P_InvadersCount=0
Global P_InvadersCount1=0
Global P_InvadersCount2=0
Global timer=0
Global Punti=10
Global Tunnel_mesh
Global Background
Global Tunnel_tex
Global Tunnel_Texture_Coord#=0
Global t_r1,t_r2,ta_r1,ta_r2
Global t_g1,t_g2,ta_g1,ta_g2
Global t_b1,t_b2,ta_b1,ta_b2
Global x_rect=100
Global x_rect1=100
Global y_rect=10
Global numColpi=30
Global numColpi1=30
Global stato$="menu"
Const tipo_nemico=1
Const tipo_personaggio=2
Const tipo_proiettile=3
Const tipo_proiettile1=4
Const tipo_ambulanza=5
Const tipo_tunnel=6
Const tipo_nemico1=7
method=1
response=2
method_info$="sphere-to-polygon"
response_info$="slide1"
;attivo la collisione
Collisions tipo_personaggio,tipo_nemico,method,response
Collisions tipo_proiettile,tipo_nemico,1,2
Collisions tipo_personaggio,tipo_nemico1,method,response
Collisions tipo_proiettile,tipo_nemico1,1,2
Collisions tipo_personaggio,tipo_ambulanza,method,response
Collisions tipo_proiettile,tipo_ambulanza,1,2
Collisions tipo_proiettile1,tipo_personaggio,1,2
Collisions tipo_personaggio,tipo_tunnel,method,response
Collisions tipo_nemico,tipo_tunnel,1,2
Collisions tipo_nemico1,tipo_tunnel,1,2
Type P_InvadersInfo
Field x,y,z
Field mesh
End Type
Type P_InvadersInfo1
Field x,y,z
Field mesh
End Type
Type P_InvadersInfo2
Field x,y,z
Field mesh
End Type
Type AmbulanzaInfo
Field x,y,z
Field mesh
End Type
Type IBullet
Field mesh
End Type
Type IBullet1
Field mesh
End Type
Type OBullet
Field mesh
End Type
box_x=20
box_y=10
Tunnel_mesh=CreateCylinder(12)
FlipMesh Tunnel_mesh
ScaleMesh Tunnel_mesh,500,12000,500
RotateEntity Tunnel_mesh,90,0,0
EntityType tunnel_mesh,tipo_tunnel
PositionEntity tunnel_mesh,0,0,11400
EntityColor tunnel_mesh,255,100,0
t_r1=255:ta_r1=t_r1
t_g1=100:ta_g1=t_g1
t_b1=0:ta_b1=t_b1
BackGround=CreateCylinder(12)
FlipMesh BackGround
ScaleMesh BackGround,510,12000,510
RotateEntity BackGround,90,0,0
PositionEntity BackGround,0,0,11400
EntityColor BackGround,0,255,255
t_r2=0:ta_r2=t_r2
t_g2=255:ta_g2=t_g2
t_b2=255:ta_b2=t_b2
If t_r1>ta_r1 Then t_r1=t_r1-1
If t_g1>ta_g1 Then t_g1=t_g1-1
If t_b1>ta_b1 Then t_b1=t_b1-1
If t_r2>ta_r2 Then t_r2=t_r2-1
If t_g2>ta_g2 Then t_g2=t_g2-1
If t_b2>ta_b2 Then t_b2=t_b2-1
If t_r1<ta_r1 Then t_r1=t_r1+1
If t_g1<ta_g1 Then t_g1=t_g1+1
If t_b1<ta_b1 Then t_b1=t_b1+1
If t_r2<ta_r2 Then t_r2=t_r2+1
If t_g2<ta_g2 Then t_g2=t_g2+1
If t_b2<ta_b2 Then t_b2=t_b2+1
EntityColor Tunnel_mesh,t_r1,t_g1,t_b1
EntityColor Background,t_r2,t_g2,t_b2
ta_r1=Rand(10,255):ta_g1=Rand(10,255):ta_b1=Rand(10,255)
ta_r2=Rand(10,255):ta_g2=Rand(10,255):ta_b2=Rand(10,255)
Global luce = CreateLight()
RotateEntity luce,45,0,0
Global camera=CreateCamera()
CameraRange camera,1,45000
Global sfera=CreateSphere()
PositionEntity sfera,0,0,10
EntityType sfera,tipo_personaggio
ScaleEntity sfera,1,1,1
EntityColor sfera,0,0,125
ResetEntity sfera
While(P_InvadersCount < 16)
nemico.P_InvadersInfo=New P_InvadersInfo
nemico\mesh=CreateCylinder()
nemico\x=Rnd(-80,100)
nemico\y=Rnd(-80,100)
nemico\z=Rnd(80,160)
ScaleEntity nemico\mesh,1,3,1
RotateEntity nemico\mesh,Rnd(360),Rnd(360),Rnd(360)
MoveEntity nemico\mesh,Rnd(360),Rnd(360),Rnd(360)
EntityColor nemico\mesh,125,0,0
EntityType nemico\mesh,tipo_nemico
PositionEntity nemico\mesh, nemico\x,nemico\y,nemico\z
P_InvadersCount=P_InvadersCount+1
Wend
While(P_InvadersCount1 < 18)
nemico1.P_InvadersInfo1=New P_InvadersInfo1
nemico1\mesh=CreateCube()
nemico1\x=Rnd(-90,100)
nemico1\y=Rnd(-90,100)
nemico1\z=Rnd(230,330)
ScaleEntity nemico1\mesh,1,3,1
RotateEntity nemico1\mesh,Rnd(360),Rnd(360),Rnd(360)
MoveEntity nemico1\mesh,Rnd(360),Rnd(360),Rnd(360)
EntityColor nemico1\mesh,125,0,0
EntityType nemico1\mesh,tipo_nemico1
PositionEntity nemico1\mesh, nemico1\x,nemico1\y,nemico1\z
P_InvadersCount1=P_InvadersCount1+1
Wend
While(P_InvadersCount2 < 1008)
nemico2.P_InvadersInfo2=New P_InvadersInfo2
nemico2\mesh=CreateCube()
nemico2\x=Rnd(-210,210)
nemico2\y=Rnd(-210,210)
nemico2\z=Rnd(2000,6500)
ScaleEntity nemico2\mesh,1,3,1
EntityColor nemico2\mesh,125,0,0
EntityType nemico2\mesh,tipo_nemico1
PositionEntity nemico2\mesh, nemico2\x,nemico2\y,nemico2\z
P_InvadersCount2=P_InvadersCount2+1
Wend
;create helps
While(AmbulanzaCount < 7)
ambulanza.AmbulanzaInfo=New AmbulanzaInfo
ambulanza\mesh=CreateSphere()
ambulanza\x=Rnd(-100,100)
ambulanza\y=Rnd(-40,80)
ambulanza\z=Rnd(60,500)
ScaleEntity ambulanza\mesh,1,1,1
EntityColor ambulanza\mesh,0,122,123
EntityType ambulanza\mesh,tipo_ambulanza
PositionEntity ambulanza\mesh, ambulanza\x,ambulanza\y,ambulanza\z
AmbulanzaCount=AmbulanzaCount+1
Wend
r#=255:v#=255:b#=255
EntityParent camera,sfera
While Not KeyDown (1)
UpdateMenu()
UpdateIstruzioni()
UpdateGioco()
UpdatePunteggio()
Wend
Function UpdateMenu()
If (stato$="menu")
PositionEntity camera,0,0,0
If KeyDown(28)=True Then
stato$="gioco"
End If
If KeyDown (57)=True Then
stato$="istruzioni"
End If
If KeyDown(2)=True Then
stato$="punteggio"
End If
UpdateWorld()
RenderWorld()
Color 255,100,200
Text 10,0,"PRIMITIVE INVADERS"
Text 10,30,"BENVENUTI:INVIO PER GIOCARE,SPAZIO PER ISTRUZIONI,1 PER PUNTEGGI"
Flip
End If
End Function
Function UpdateIstruzioni()
If (stato$="istruzioni")
PositionEntity camera,0,0,0
If KeyDown(28)=True Then
stato$="gioco"
End If
UpdateWorld()
RenderWorld()
Color 255,100,200
Text 5,0,"Uccidi le primitive nemiche comandando la sfera, occhio alle sfere amiche:"
Text 5,20,"le ambulanze, se le intercetti ti ridanno vita.
Text 5,40,"Conquista punti uccidendo i nemici in rosso."
Text 5,60,"COMANDI: freccette muovono, Invio spara, w/s avanti indietro,a turbo"
Text 5,100,"Copiright (falsissimo): Numa :P"
Flip
End If
End Function
Function UpdatePunteggio()
If (stato$="punteggio")
PositionEntity camera,0,0,0
If KeyDown(28)=True Then
stato$="gioco"
End If
UpdateWorld()
RenderWorld()
Color 255,100,200
Text 5,20,"Miglior punteggio:"+Punti
Flip
End If
End Function
Function UpdateGioco()
If (stato$="gioco")
PositionEntity camera,0,0,-10
timer=timer+1
x1#=0:y1#=0:z1#=0
If KeyDown(203)=True Then x1# = -0.7
If KeyDown(205)=True Then x1# = 0.7
If KeyDown(208)=True Then y1# = -0.3
If KeyDown(200)=True Then y1# = 0.7
If KeyDown(17)=True Then z1# = 0.7
If KeyDown(31)=True Then z1# = -0.7
If KeyDown(18)=True Then pitch#=pitch#+1
If KeyDown(19)=True Then pitch#=pitch#-1
If KeyDown(32)=True Then yaw#=yaw#+1
If KeyDown(33)=True Then yaw#=yaw#-1
If KeyDown(46)=True Then roll#=roll#+1
If KeyDown(47)=True Then roll#=roll#-1
If KeyDown(59)=True Then r#=r#-1
If KeyDown(59)=True Then v#=v#-1
If KeyDown(59)=True Then b#=b#-1
AmbientLight r#,v#,b#
MoveEntity sfera,x1#,y1#,z1#
RotateEntity sfera,pitch#,yaw#,roll#
If KeyHit(28)
bullet.OBullet=New OBullet
bullet\mesh=CreateSphere()
EntityColor bullet\mesh,0,0,125
ScaleEntity bullet\mesh,0.5,0.5,0.5
PositionEntity bullet\mesh,EntityX(sfera),EntityY(sfera),EntityZ(sfera)
RotateEntity bullet\mesh,EntityPitch(sfera),EntityYaw(sfera),EntityRoll(sfera)
EntityType bullet\mesh,tipo_proiettile
End If
For bullet.OBullet=Each OBullet
MoveEntity bullet\mesh,0,0,0.4
Next
For nemico.P_InvadersInfo=Each P_InvadersInfo
If nemico<>Null
MoveEntity nemico\mesh,0,0,-0.1
If numColpi>0
If (timer Mod 50=0)
DebugLog "SPARO timer="+timer
bullet1.IBullet=New IBullet
bullet1\mesh=CreateSphere()
EntityColor bullet1\mesh,125,0,0
ScaleEntity bullet1\mesh,0.5,0.5,0.5
PositionEntity bullet1\mesh,EntityX(nemico\mesh),EntityY(nemico\mesh),EntityZ(nemico\mesh)
RotateEntity bullet1\mesh,EntityPitch(nemico\mesh),EntityYaw(nemico\mesh),EntityRoll(nemico\mesh)
PointEntity bullet1\mesh,sfera
EntityType bullet1\mesh,tipo_proiettile1
End If
For bullet1.IBullet=Each IBullet
MoveEntity bullet1\mesh,0,0,0.7
If EntityCollided(sfera,3)
x_Rect=x_rect-0.6
FreeEntity bullet1\mesh
Delete bullet1
End If
Next
numColpi=numColpi-1
End If
If EntityCollided (nemico\mesh,3)
Punti=Punti+5
FreeEntity (nemico\mesh)
Delete nemico
End If
End If
Next
For nemico1.P_InvadersInfo1=Each P_InvadersInfo1
If nemico1<>Null
MoveEntity nemico1\mesh,0,0,-0
If numColpi1>0 And Rand(15) = 15 Then
If (timer Mod 12=0)
DebugLog "SPARO timer="+timer
bullet2.IBullet1=New IBullet1
bullet2\mesh=CreateCube()
EntityColor bullet2\mesh,125,0,0
ScaleEntity bullet2\mesh,0.5,0.5,0.5
PositionEntity bullet2\mesh,EntityX(nemico1\mesh),EntityY(nemico1\mesh),EntityZ(nemico1\mesh)
RotateEntity bullet2\mesh,EntityPitch(nemico1\mesh),EntityYaw(nemico1\mesh),EntityRoll(nemico1\mesh)
PointEntity bullet2\mesh,sfera
EntityType bullet2\mesh,tipo_proiettile1
End If
For bullet2.IBullet1=Each IBullet1
MoveEntity bullet2\mesh,0,0,1
If EntityCollided(sfera,4)
x_Rect=x_rect-0.6
FreeEntity bullet2\mesh
Delete bullet2
End If
Next
numColpi1=numColpi1-1
End If
If EntityCollided (nemico1\mesh,3)
Punti=Punti+8
FreeEntity (nemico1\mesh)
Delete nemico1
End If
End If
Next
For ambulanza.AmbulanzaInfo=Each AmbulanzaInfo
If ambulanza<>Null
MoveEntity ambulanza\mesh,0,0,-0.3
If EntityCollided (ambulanza\mesh,3)
x_rect=x_rect+5
FreeEntity (ambulanza\mesh)
Delete ambulanza
End If
End If
Next
For nemico2.P_InvadersInfo2=Each P_InvadersInfo2
If nemico2<>Null
MoveEntity nemico2\mesh,0,0,-2
If EntityCollided (nemico2\mesh,2)
x_rect=x_rect-0.8
End If
If EntityCollided (nemico2\mesh,3)
Punti=Punti+5
FreeEntity (nemico2\mesh)
Delete nemico2
End If
End If
Next
numColpi=numColpi+3
numColpi1=numColpi1+6
If KeyDown(30)=True And x_rect1>0
If KeyDown(203)=True Then x1# = x1#-5
If KeyDown(205)=True Then x1# = x1#+5
If KeyDown(208)=True Then y1# = y1#-5
If KeyDown(200)=True Then y1# = y1#+5
If KeyDown(17)=True Then z1# = z1#+5
If KeyDown(31)=True Then z1# =z1#-5
MoveEntity sfera,x1#,y1#,z1#
EntityColor sfera,125,125,0
x_rect1=x_rect1-1
End If
If (Punti>20 And Punti<26) Or (Punti>50 And Punti <56) Or (Punti>80 And Punti<86) Then
x_rect1=100
End If
UpdateWorld()
RenderWorld()
Text 200,10,"Punti="+Punti
Color 125,125,0
Text 0,40,"TURBO"
Rect 45,40,x_rect1,y_rect
If x_rect<=100 And x_rect>50 Then
Color 0,255,0
Rect 40,10,x_rect,y_rect
Else
Color 255,0,0
Rect 40,10,x_rect,y_rect
End If
Text 0,10,"HP"
If x_rect=0 Then
Text 200,200,"GAME OVER; NUMA HAS OWNED YOU"
End
stato$="menu"
End If
Flip
End If
End Function