mory مدیر انجمن
تاريخ عضويت: 3 شنبه 3 خرداد 1384 تعداد ارسالها: 1187
4 شنبه 2 آذر 1384 - 03:41 |
|
|
اينا زياد مهم نيست . فقط چيزي كه نبايد زياد استفاده كني . حلقه هاست .
اينو ببين خودت متوجه ميشي . اين يه اينفورميشن از برنامه سربازهاي دشمن تو بازيه نجات بندره . من با همه جزپيات بازي و داشتن حدود 10 سرباز چيزي بالاي 40 فريم از بازي ميگيرم . يعني خيلي خوب و نرم . حالا برنامه رو يه نگاهي بنداز .
كد: |
Information about object: enemyparent1
Sprite: spriteright
Solid: false
Visible: true
Depth: -9
Persistent: false
Parent: <no parent>
Mask: mask
Create Event:
execute code:
image_index=0;image_speed=0;image_xscale=1;image_yscale=1;
sprite_index=spriteright ;
xx=x;rdirection=0;dotime=0; stay=true;
yy=y;z=.01;sp=1;
image_index=-1;
z=0;moving=false;
editx=1
edity=1
//
gunman=false;shottime=5;gunsound=true;
show_position=false;
instance_create(x,y,ob_position);
//
timer=0;step=1;imspeed=1;snplay=false;gunman_time=0;fire_time=0;
Alarm Event for alarm 0:
execute code:
a=1;gunman=true;
Alarm Event for alarm 1:
execute code:
a=0;gunman=true;
Step Event:
perform a step towards position (xx,yy) with speed sp avoiding solid only
execute code:
dotime+=1;sp=1.2;image_speed=imspeed;
if shottime <1000 shottime+=1 else shottime=5;
//
if (dotime>5 )
{
rdirection=round(direction);dotime=0
/*right*/ if (rdirection<=020 or rdirection>=340){sprite_index=spriteright;}
/*right-up*/ if (rdirection>=020 and rdirection<=70){sprite_index=sprite_u_r;}
/*up*/ if (rdirection>=070 and rdirection<110){sprite_index=spriteup;}
/*up-left*/ if (rdirection>=110 and rdirection<160){sprite_index=sprite_u_l;}
/*left*/ if (rdirection>=160 and rdirection<200){sprite_index=spriteleft;}
/*left-down*/if (rdirection>=200 and rdirection<250){sprite_index=sprite_d_l;}
/*down*/ if (rdirection>=250 and rdirection<290){sprite_index=spritedown;}
/*down-r*/ if (rdirection>=290 and rdirection<340){sprite_index=sprite_d_r;}
}
//check for reach//
if (abs(xx-x)<2 and abs(yy-y)<2 and gunman=false) {stay=true xx=x;yy=y;image_speed=.3 sprite_index=sprite_stay} else stay=false ;
if gunman=true {stay=false;sp=0;xxx=mouse_x;yyy=mouse_y;sprite_index=sp_gunman1;image_speed=0;}
execute code:
if gunman_time>10000 gunman_time=50 else gunman_time+=1;
if timer>2000 timer=0 else timer+=1;
if fire_time>10000 fire_time=50 else fire_time+=1;
if stay=true direction=270;
if gunman=false
{
if timer < 400+random(300) and step=1 {xx=random(room_width) ;yy=random(room_height) ;step=2}
if timer < 900+random(300) and timer>400 and step=2 {xx=random(room_width); yy=random(room_height); step=3}
if timer < 1400+random(300) and timer>800 and step=3 {xx=random(room_width); yy=random(room_height); step=1 ; timer=0}
if collision_point(xx,yy,rigid,1,0) {if xx<room_width-30 xx+=3 else xx-=3; if xx<room_height-100 xx+=3 else xx-=3}
}
if (distance_to_object(oo)<10 or a=1 and gunman_time>fps/10)
{
if collision_line(x,y,oo.x,oo.y,rigid,1,0)<0 {
gunman=true;xx=oo.x;yy=oo.y; xxx=oo.x-2+random(4);yyy=oo.y-3+random(6)
if snplay=false {sound_play(sn_rifle_reload) snplay=true}
}
else{gunman=false }
}
else
{gunman=false;snplay=false if gunman_time>90 gunman_time=0}
//fire to enemy
if gunman=true { fire_time+=1 if fire_time>150+random(50) {instance_create(oo.x,oo.y,ob_bullet_rifle);fire_time=0} } else fire_time=0 ;
End Step Event:
set variable depth to -y
Collision Event with object ob_bullet_rifle:
execute code:
with(self) instance_destroy();
Draw Event:
execute code:
//drawing view
/*
if stay=false {
z_rad=degtorad(-direction+15);
z_rad2=degtorad(-direction-15);
z_rad3=degtorad(-direction);
x2=x+300*cos(z_rad);y2=y+150*sin(z_rad);
x3=x+300*cos(z_rad2);y3=y+150*sin(z_rad2);
x4=x+300*cos(z_rad2);y4=y+150*sin(z_rad2);
draw_triangle(x,y,x2,y2,x3,y3,-1)
*/
for (i=0 ;i<40 ;i+=2 )
{
z_rad=degtorad(-direction-20+i);
x2=x+300*cos(z_rad);y2=y+150*sin(z_rad);
draw_line(x,y,x2,y2);if i>0 draw_line(x2,y2,x3,y3)
x3=x2;y3=y2;
if collision_line(x,y,x2,y2,oo,1,1) {alarm[0]=fps/5 doalarm=1 a=1} else {if doalarm=1{ alarm[1]=fps/5 ; doalarm=0}};
}
/////
/*saye*/draw_sprite_ext(sprite_index,image_index,x,y,.8,.1,0,c_black,.4);
if gunman=true
{draw_sprite_ext(sp_hadaf3,-1,xxx,yyy-10,1,1,45,c_blue,1);draw_sprite_ext(sprite_index,direction/10,x,y,0.6,0.6,0,c_green,1)}
//
if (stay=true) draw_sprite_ext(sprite_stay,-1,x,y,0.6,0.6,0,c_green,1);
if (stay=false && gunman=false) draw_sprite_ext(sprite_index,-1,x,y,0.6,0.6,0,c_green,1)
//
Key Release Event for G-key Key:
execute code:
//if gunman=false { gunman=true;sound_stop(sn_footstep);sound_play(sn_rifle_reload) } else {gunman=false;xx=x;yy=y sound_play(sn_rifle_reload2)}
|
ذهنتو درگير اينچيزا نكن . همون اول يه نمايش دهنده فريم ريت بزار گوشه برنامه ات كه موقع اجراي اگه دستور ناجوري رو استفاده كردي و باعث كندي شد متوجه بشي . |
_________________ و مهم نيست كي پنيرتو دزديده قورباغتو قورت بده .
|
|