Показать сообщение отдельно
Старый 11.02.2008, 02:18   #1
Putin
Оператор ЭВМ
 
Регистрация: 11.03.2007
Сообщений: 46
Написано 0 полезных сообщений
(для 0 пользователей)
Космический Бой

"Бой" в космосе:

УПРАВЛЕНИЕ: стрелки; смена вида-на доп клаве 4,5,6,8; стреляем A(engl); выход SPACE
Код:
Graphics3D 640,480,16,1 
SetBuffer BackBuffer() 
 
SeedRnd MilliSecs() 
;================================== 
Global pp.player 
Global f1=LoadFont("Courier New",14) 
Global dot1, bullet1, spark 
Global sk#=0, enemy_num 
 
;================================== 
Const ships=1, bullets=2, p_ships=3 
 
;================================== 
Type player; player 
Field corp, ent,life, speed#, fuel#, weapon, lW, rW, bW, look 
End Type 
 
Type bullet1 
Field ent, timer, state 
End Type 
 
Type spark 
Field ent, time 
End Type 
 
Type enemy1; first enemy 
Field ent, life, period 
End Type 
 
;================================== 
create_level() 
 
 
;==================MAIN LOOP 
Repeat 
 
controls () 
player_phisic () 
update_bullet1 () 
update_sparks() 
enemy_update() 
 
RenderWorld 
UpdateWorld 
draw_cabine() 
Flip 
 
Until KeyHit(57) 
End 
;================================= 
Function draw_cabine() 
Select pp\look 
Case 1 
Color 80,180,180 
Rect 0,301,640,480 
Rect 0,0,640,39 
Rect 0,0,39,301 
Rect 601,39,640,301 
Color 0,0,0 
Line 0,0,40,40 
Line 640,0,600,40 
Line 0,341,40,301 
Line 640,341,600,301 
Line 0,341,640,341 
Color 160,50,200 
Line 40,40,200,100 
Line 600,40,440,100 
Rect 200,100,440-200,300-100+1,0 
;parametrs 
Color 50,50,250 
Rect 400,400,pp\speed#,10 
Rect 398,398,164,14,0 
; weapon target 
Select pp\weapon 
Case 1 
Color 10,87,124 
Line 320,200,300,220 
Line 320,200,340,220 
End Select 
Case 2 
Color 80,180,180 
Rect 0,301,640,480 
Rect 0,0,640,39 
Rect 0,0,39,301 
Rect 601,39,640,301 
Color 0,0,0 
Line 0,0,40,40 
Line 640,0,600,40 
Line 0,341,40,301 
Line 640,341,600,301 
Line 0,341,640,341 
Color 160,50,200 
Line 40,40,200,100 
Line 600,40,440,100 
Line 440,100,200,300 
Rect 200,100,440-200,300-100+1,0 
Case 3 
Color 80,180,180 
Rect 0,301,640,480 
Rect 0,0,640,39 
Rect 0,0,39,301 
Rect 601,39,640,301 
Color 0,0,0 
Line 0,0,40,40 
Line 640,0,600,40 
Line 0,341,40,301 
Line 640,341,600,301 
Line 0,341,640,341 
Color 160,50,200 
Line 40,40,200,100 
Line 600,40,440,100 
Line 200,100,440,300 
Rect 200,100,440-200,300-100+1,0 
Case 4; back vision 
Color 80,180,180 
Rect 0,301,640,480 
Rect 0,0,640,39 
Rect 0,0,39,301 
Rect 601,39,640,301 
Color 0,0,0 
Line 0,0,40,40 
Line 640,0,600,40 
Line 0,341,40,301 
Line 640,341,600,301 
Line 0,341,640,341 
Color 160,50,200 
Line 40,40,200,100 
Line 600,40,440,100 
Line 200,100,440,300 
Line 440,100,200,300 
Rect 200,100,440-200,300-100+1,0 
End Select 
 
Text 100,100, "ENEMYS "+enemy_num 
 
 
End Function 
Function create_level() 
 
create_enemy() 
 
pp.player=New player 
pp\ent=CreateCamera(); main camera 
PositionEntity pp\ent,0,0,-5 
RotateEntity pp\ent,0,0,0 
pp\corp=CreateCube(pp\ent); ships corpus 
ScaleEntity pp\corp,2,2,2 
EntityRadius pp\corp,2 
EntityType pp\corp,p_ships 
pp\speed=0 
pp\lW=CreateCamera(pp\ent); left camera 
RotateEntity pp\lW,0,90,0 
pp\rW=CreateCamera(pp\ent); right camera 
RotateEntity pp\rW,0,-90,0 
pp\bW=CreateCamera(pp\ent); right camera 
RotateEntity pp\bW,0,-180,0 
pp\fuel#=100 
CameraProjMode pp\rW,0; turn of camera 
CameraProjMode pp\lW,0; turn of camera 
CameraProjMode pp\bW,0; turn of camera 
CameraProjMode pp\ent,1 
EntityRadius pp\lW,2 
EntityType pp\lW,p_ships 
EntityRadius pp\rW,2 
EntityType pp\rW,p_ships 
pp\look=1 
 
 
pp\weapon=1 
 
 
 
dot1=CreateSprite() 
ScaleSprite dot1,.2,.2 
EntityColor dot1,234,100,100 
EntityType dot1,bullets 
EntityRadius dot1,1 
HideEntity dot1 
 
Collisions bullets,ships,2,2 
Collisions bullets,p_ships,2,2 
Collisions ships, ships, 2,2 
 
End Function 
Function controls() 
 
If KeyDown (203) TurnEntity pp\ent,0, 0, 1 
If KeyDown (205) TurnEntity pp\ent,0, 0,-1 
 
If KeyDown (200) TurnEntity pp\ent, 1,0,0 
If KeyDown (208) TurnEntity pp\ent,-1,0,0 
 
If KeyDown (78) Then pp\speed#=pp\speed#+0.25 
If KeyDown (74) Then pp\speed#=pp\speed#-0.25 
 
If pp\speed#>4 pp\speed#=4 
If pp\speed#<0 pp\speed#=0 
 
If KeyHit(30) Then 
bp.bullet1=New bullet1 
bp\state=1 
bp\ent=CopyEntity (dot1,pp\ent) 
PositionEntity bp\ent,Rnd(-1,1),Rnd(-1,1),3 
RotateSprite bp\ent,Rnd(-300,300) 
EntityParent bp\ent,0 
EntityType bp\ent, bullets 
EntityRadius bp\ent,1 
EndIf 
 
; look control 
If KeyHit(77) Then 
pp\look=2 
CameraProjMode pp\ent,0; turn of camera 
CameraProjMode pp\lW,0; turn of camera 
CameraProjMode pp\bW,0; turn of camera 
CameraProjMode pp\rW,1 
EndIf 
 
If KeyHit(75) Then 
pp\look=3 
CameraProjMode pp\bW,0; turn of camera 
CameraProjMode pp\ent,0; turn of camera 
CameraProjMode pp\rW,0; turn of camera 
CameraProjMode pp\lW,1 
EndIf 
 
If KeyHit(76) Then 
pp\look=1 
CameraProjMode pp\bW,0; turn of camera 
CameraProjMode pp\rW,0; turn of camera 
CameraProjMode pp\lW,0; turn of camera 
CameraProjMode pp\ent,1 
EndIf 
 
If KeyHit(80) Then 
pp\look=4 
CameraProjMode pp\ent,0; turn of camera 
CameraProjMode pp\rW,0; turn of camera 
CameraProjMode pp\lW,0; turn of camera 
CameraProjMode pp\bW,1 
 
EndIf 
End Function 
Function player_phisic() 
MoveEntity pp\ent,0,0,pp\speed# 
 
 
 
For bb.bullet1 =Each bullet1 
If CountCollisions (pp\corp)>0 Then 
CameraClsColor pp\ent,250,10,10 
CameraClsColor pp\lW,250,10,10 
CameraClsColor pp\rW,250,10,10 
CameraClsColor pp\bW,250,10,10 
Else 
CameraClsColor pp\ent,0,0,0 
CameraClsColor pp\lW,0,0,0 
CameraClsColor pp\bW,0,0,0 
CameraClsColor pp\rW,0,0,0 
EndIf 
 
Next 
 
End Function 
Function update_bullet1() 
For bb.bullet1=Each bullet1 
 
Select bb\state; whos bullet 
Case 1 
MoveEntity bb\ent,0,.5,6 
Default 
MoveEntity bb\ent,0,0,6 
End Select 
 
ang=ang+1 
RotateSprite bb\ent,ang 
bb\timer = bb\timer+1 
If bb\timer>160 Or EntityCollided(bb\ent,p_ships) Then 
sp.spark=New spark 
sp\ent=CreateSphere(6,bb\ent) 
EntityParent sp\ent,0 
EntityColor sp\ent,Rnd(200,250),34,26 
FreeEntity bb\ent 
Delete bb 
EndIf 
Next 
 
 
End Function 
Function update_sparks() 
For ss.spark=Each spark 
sk#=sk#+0.5 
If sk#>1 sk#=0 
ss\time=ss\time+1 
ScaleEntity ss\ent,sk#,sk#,sk# 
If ss\time>40 Then 
FreeEntity ss\ent 
Delete ss 
EndIf 
Next 
End Function 
Function create_enemy() 
 
For n=0 To 105 
e1.enemy1=New enemy1 
e1\ent=CreateCube() 
ScaleEntity e1\ent,2,2,2 
EntityColor e1\ent,10,135,32 
PositionEntity e1\ent,Rnd(3000,-3000),Rnd(-200,200),1000 
EntityType e1\ent,ships 
EntityRadius e1\ent,1 
enemy_num=enemy_num+1 
Next 
 
End Function 
Function enemy_update() 
For e1.enemy1=Each enemy1 
If EntityDistance(e1\ent,pp\ent)>100 MoveEntity e1\ent,0,0,1.5 
If EntityDistance(e1\ent,pp\ent)<100 MoveEntity e1\ent,0,0,1 
 
TurnEntity e1\ent,DeltaPitch(e1\ent,pp\ent)/5, DeltaYaw(e1\ent,pp\ent)/5,0 
 
If EntityDistance(e1\ent,pp\ent)<300 Then; shoting script 
e1\period=e1\period+1 
If e1\period>10 e1\period=0 
If e1\period=0 Then 
bp.bullet1=New bullet1 
bp\ent=CopyEntity (dot1,e1\ent) 
PositionEntity bp\ent,Rnd(-1,1),Rnd(-1,1),3 
RotateSprite bp\ent,Rnd(-300,300) 
EntityParent bp\ent,0 
EntityType bp\ent, bullets 
EntityRadius bp\ent,1 
EndIf 
EndIf 
 
If EntityCollided(e1\ent,bullets) e1\life=e1\life-1 
 
If e1\life<0 Then;enemy deth 
For z=0 To 7 
sp.spark=New spark 
sp\ent=CreateCube(e1\ent) 
PositionEntity sp\ent,Rnd(-10,10),Rnd(-10,10),Rnd(-10,10) 
EntityColor sp\ent,Rnd(20,256),Rnd(200,250),Rnd(10,100) 
EntityParent sp\ent,0 
Next 
FreeEntity e1\ent 
Delete e1 
enemy_num=enemy_num-1 
EndIf 
Next 
 
End Function
Хотелось бы услышать рекомендации и предложения ).
Смайлы при копирование декодируются в цифры?

Последний раз редактировалось tormoz, 11.02.2008 в 03:38.
(Offline)
 
Ответить с цитированием