Тема: Flight
Показать сообщение отдельно
Старый 15.02.2012, 18:11   #74
undertaker
Нуждающийся
 
Регистрация: 05.02.2012
Сообщений: 57
Написано 2 полезных сообщений
(для 4 пользователей)
Ответ: Flight

Graphics 0,0,32,1

SetBuffer BackBuffer()
FPS=CreateTimer(60)

Type player
Field x,px,deltax
Field y,py,deltay
End Type

Type bot
Field bbx#, bby#, bbangle#
Field bbhp%
End Type


Type car
Field x,px,deltax
Field y,py,deltay
End Type

Type TBullet
Field bx#, by#, angle#
End Type

Function TBullet_Update()
For b.TBullet = Each TBullet

b\bx = b\bx- Cos( b\angle ) * 15
b\by = b\by -Sin( b\angle ) * 15

Local this.bot
For bot = Each bot
Local dist# = Sqr((b\bx - bot\bbx) ^ 2 + (b\by - bot\bby) ^ 2)
If dist < 28 Then
bott\bbhp = bott\bbhp - 1
b\bx = -1000
Exit
EndIf
Next
If b\bx<0 Or b\bx>GraphicsWidth() Or b\by<0 Or b\by>GraphicsHeight() Or ImagesCollide (house1,300,340,0,bullet,b\bx,b\by,0) Or ImagesCollide(house2,750,340,0,bullet,b\bx,b\by,0) Or ImagesCollide(house2,-200,340,0,bullet,b\bx,b\by,0) Or ImagesCollide(house1,750,340,0,bullet,b\bx,b\by,0) Or ImagesCollide(house2,1250,340,0,bullet,b\bx,b\by,0 ) Or x<0 Or y<0 Or x>GraphicsWidth() Or y>GraphicsHeight() Then
Delete b
End If
Next
End Function

Function bot_Update()
Local this.bot
For this = Each bot
this\bbangle = ATan2(y - this\bby, x - this\bbx)
this\bbx = this\bbx + Cos(this\angle)*2
this\bby = this\bby + Sin(this\angle)*2

If Sqr((this\bbx - x) ^ 2 + (this\bby - y) ^ 2)<40 Then
zdorov = zdorov - 1
EndIf



If this\hp < 1 Then

Delete(this)
EndIf
Next
End Function

Function TBullet_Draw()
For b.TBullet = Each TBullet
DrawImage bullet,b\bx,b\by
Next
End Function

Function TEnemy_Draw()
Local this.TEnemy
For this = Each TEnemy
DrawImage bot,this\bbx,this\bby
Next
End Function

Global longc#
Global bullet=LoadImage("shot.bmp")
Global logo=LoadImage("logo1.bmp")
Global pistol1=LoadImage("pistol1.bmp")
Global ak471=LoadImage("ak-471.bmp")
Global pistolspeed=200000000000000
Global pistol=LoadImage("pistol.bmp")
Global ak47=LoadImage ("ak-47.bmp")
Global bx=140
Global by=100
Global chn=Rnd(4)
Global w=LoadImage("w.bmp")
Global Tbullet=LoadImage("shot.bpm")
Global dmgC#
Global y=100
Global x=100
Global speed#=3
Global zdorov#=100
Global speedc#=5
Global hp100=LoadImage("hp100.bmp")
Global hp80=LoadImage("hp80.bmp")
Global hp60=LoadImage("hp60.bmp")
Global hp40=LoadImage("hp40.bmp")
Global hp20=LoadImage("hp20.bmp")
Global cursor=LoadImage("cursor.bmp")
Global polosa=LoadImage("polosa.bmp")
Global Endd=LoadImage("end.bmp")
Global player=LoadImage("1.bmp")
Global player_angle
TFormFilter enable=0
RotateImage player,90
MidHandle player
MidHandle cursor
Global ground=LoadImage ("ground1.bmp")

Global house1=LoadImage ("house1.bmp")
Global house2=LoadImage ("house2.bmp")


Global car=LoadImage("car.bmp")
MidHandle car
Global cy=Rand(1366)
Dim playerg(361)
For t=0 To 361
playerg(t)=CopyImage(player)
MaskImage playerg(t),0,0,0
RotateImage playerg(t),t
Next

MaskImage hp100,255,255,255
MaskImage hp80,255,255,255
MaskImage hp60,255,255,255
MaskImage hp40,255,255,255
MaskImage hp20,255,255,255

MaskImage player,0,0,10

TileImage ground,0,0,0

Function updateplayer()
player_angle=ATan2(MouseY()-y,MouseX()-x)+180

DrawImage ground,0,0
DrawImage w,700,100

DrawImage house1,300,340
DrawImage house2,750,340
DrawImage house2,-200,340
DrawImage house1,750,340
DrawImage house2,1250,340
MaskImage pistol,255,255,255
MaskImage ak47,255,255,255
MaskImage pistol1,255,255,255
MaskImage ak471,255,255,255

DrawImage car,555,cy

MaskImage cursor,255,255,255
If KeyDown(2) Then pistolspeed=500 DrawImage pistol1,110,0
If KeyDown(3) Then pistolspeed=100 DrawImage ak471,110,0

px=x+speed*deltax
py=y+speed*deltay

DrawImage playerg(Int(player_angle)),x,y
Text 0,10,player_angle

If x<0 Then x=GraphicsWidth()
If x>GraphicsWidth() Then x=0
If y<0 Then y=GraphicsHeight()
If y>GraphicsHeight() Then y=0

cursorX=MouseX()
cursorY=MouseY()
DrawImage cursor,MouseX(),MouseY()

If KeyDown(200) Or KeyDown(17) Then
deltay=-1

EndIf

If KeyDown(20 Or KeyDown(31)
deltay=1

EndIf

If KeyDown(203) Or KeyDown(30)

deltax=-1
EndIf

If KeyDown(205) Or KeyDown(32)
deltax=1

EndIf

px=x+speed#*deltax
py=y+speed#*deltay

DrawImage pistol,110,0
If KeyDown (2) Then DrawImage pistol1,110,0
DrawImage ak47,220,0
If KeyDown (3) Then DrawImage ak471,220,0



If Not ImagesCollide (house1,300,340,0,player,px,py,0) Or ImagesCollide(house2,750,340,0,player,px,py,0) Or ImagesCollide(house2,-200,340,0,player,px,py,0) Or ImagesCollide(house1,750,340,0,player,px,py,0) Or ImagesCollide(house2,1250,340,0,player,px,py,0) Then
x=px
y=py
EndIf



If ImagesCollide(player,x,y,0,car,555,cy,0) Then zdorov#=zdorov#-0.5
If zdorov#>80 And zdorov#=<100 Then DrawImage hp100,5,5
If zdorov#>60 And zdorov#=<80 Then DrawImage hp80,5,5
If zdorov#>40 And zdorov#=<60 Then DrawImage hp60,5,5
If zdorov#>20 And zdorov#=<40 Then DrawImage hp40,5,5
If zdorov#>0 And zdorov#=<20 Then DrawImage hp20,5,5
If zdorov#<0 Then DrawImage endd,0,0



End Function
While Not KeyDown(1)
updateplayer()
TBullet_Update()
TBullet_Draw()
Flip
Cls
WaitTimer(FPS)

cx=555
If 1=1 Then cy=cy+speedc#
If cy<0 Then cy=GraphicsHeight()
If cy>GraphicsHeight() Then cy=0
longc#=Sqr((x-cx)^2+(y-cy)^2)
If longc#<40 Then speedc#=0
If longc#>40 Then speedc#=5


If KeyDown(2) Then pistolspeed=500 DrawImage pistol,110,0
If KeyDown(3) Then pistolspeed=100 DrawImage ak47,110,0

If MouseDown(1) Then
If MilliSecs()>timer_shoot+pistolspeed Then
timer_shoot=MilliSecs()
Local b.Tbullet=New Tbullet

b\bx=x
b\by=y
b\angle =player_angle+Rnd(-1.5,1.5)


EndIf
EndIf
Wend



попытался сделать ботов. и ничего не получилось. вот код игры. помогите пажалуйста. (если можно, то на примере этого кода) примного благодарен
(Offline)
 
Ответить с цитированием