2016년 10월 15일 토요일

[GMS]Match3 Gamemaker studio 따라하기 (candy crush) Part9~11

[GMS]Match3 Gamemaker studio 따라하기 (candy crush) Part9~11


Part9
스코어 막대와 별을 구현합니다.


sprite->sp_bbg 318*57*1장, origin X:9 Y:24 score bar를 표기하기위한 이미지
(====) 이런 모양의 이미지 입니다.

sprite->sp_bbar 300*30*5, origin X:0 Y:0 score bar를 표기하기위한 이미지
(//////) 이런 모양의 이미지 입니다.


sprite->sp_stars 48*52*2 별모양 아래 참고하시기 바랍니다. 24*52 이미지 2장 origin X:12 Y:37



object->obar::sp_bbg
obar::create
bar=300;// the size of the bar
a=0;
tg=25000;// target achivement
s[1]=10;//1st star percentage
s[2]=40;//2st star percentage
s[3]=70;//3st star percentage
for(i=1;i<4;i++)
{
    s[i]=s[i]*(bar/100);
    b[i]=0;
}


Control::create
globalvar F1,F2,F1x,F1y,F2x,F2y,Xs,Ys,Cs,clw,clh,gs;
gs=0;
Cs=68;
clw=7
clh=7
F1=0;
F2=0;
F1x=0;
F1y=0;
F2x=0;
F2y=0;
Xs = 116;
Ys = 166;
scr0();

obar::draw
a=(gs/tg)*bar;
draw_self();
draw_sprite_part(sp_bbar,0,0,0,a,30,x,y-15);
for(i=1;i<4;i++)
{
    if(a>s[i])
        {b[i]=1}
    draw_sprite(sp_stars,b[i],x+s[i],y);
}

room0::obar 적당한 위치 depth=-3


ogems::mouse_left_press
if((instance_number(ogems)==((clh*clw)+clw)))
{
if(F2=0) and (stable) and (y>(Ys-1))
if(F1=0)
{
    scr1();
}else
{
    if(F1!=id)and((x=F1x+Cs and y=F1y)or(x=F1x-Cs and y=F1y)or(x=F1x and y=F1y+Cs)or(x=F1x and y=F1y-Cs))
    {
    F2=id;
    F2x=x;
    F2y=y;
    with(all)
    onhold=true;
    }else{scr1();}
}
}

opuff::create
gs+=60;
a=0;
f=1;
alarm[0]=1;
co=0;
switch(co)
{
    case 0:
    c1=make_colour_rgb(99,254,123);
    c2=make_colour_rgb(0,138,42);
    break;
    case 1:
    c1=make_colour_rgb(107,107,221);
    c2=make_colour_rgb(33,41,82);
    break;
    case 2:
    c1=make_colour_rgb(254,230,1);
    c2=make_colour_rgb(187,163,1);
    break;
    case 3:
    c1=make_colour_rgb(254,205,107);
    c2=make_colour_rgb(180,24,1);
    break;
    case 4:
    c1=make_colour_rgb(164,164,164);
    c2=make_colour_rgb(33,3,33);
    break;
    case 5:
    c1=make_colour_rgb(221,234,254);
    c2=make_colour_rgb(66,82,147);
    break;
}



Part10
남은 카운트가 다되면 못 움직이게 하는 count move left 구현





sprite::sp_leftmv 70*70*1 origin 35, 35
oleftmv::draw
draw_self();
draw_text(x,y,lfm);


Control::create
globalvar F1,F2,F1x,F1y,F2x,F2y,Xs,Ys,Cs,clw,clh,gs,lfm;
lfm=10;
gs=0;
Cs=68;
clw=7
clh=7
F1=0;
F2=0;
F1x=0;
F1y=0;
F2x=0;
F2y=0;
Xs = 116;
Ys = 166;
scr0();

room배치


Control:depth=-1
oleftmv:depth=-10

scr2
match=0;
mxw=(Xs+((clh-3)*Cs))+1;
mxh=(Ys+((clh-3)*Cs))+1;
mnh=Ys-1;

if (x<mxw) and (y>mnh)
if (!position_empty(x+Cs,y)) and (!position_empty(x+(Cs*2),y))
{
    var N1,N2;
    N1=instance_position(x+Cs,y,ogems);
    N2=instance_position(x+(Cs*2),y,ogems);
    if (N1.stable==true and N2.stable==true)
    {
        if(N1.image_index==image_index) and (N2.image_index==image_index)
        {
           match=1;
        }
    }
}
if (y<mxh) and (y>mnh)
if (!position_empty(x,y+Cs)) and (!position_empty(x,y+(Cs*2)))
{
    var N3,N4;
    N3=instance_position(x,y+Cs,ogems);
    N4=instance_position(x,y+(Cs*2),ogems);
    if (N3.stable==true and N4.stable==true)
    {
        if(N3.image_index==image_index) and (N4.image_index==image_index)
        {
           match=2;
        }
    }
}
if(match>0)
if(F1!=0)
{lfm-=1;}

switch(match)
{
    case 1:
    with(N1)
    alarm[1]=1;
    with(N2)
    alarm[1]=1;
    alarm[1]=1;
    with(F1)
    {
        x=F2x;
        y=F2y;
    }
    with(F2)
    {
        x=F1x;
        y=F1y;
    }
    F1=0;
    F2=0;
    with(all)
    {
        off=false;
        onhold=false;
        nomatch=false;
    }
    match=0;
    break;
    case 2:
    with(N3)
    alarm[1]=1;
    with(N4)
    alarm[1]=1;
    alarm[1]=1;
    with(F1)
    {
        x=F2x;
        y=F2y;
    }
    with(F2)
    {
        x=F1x;
        y=F1y;
    }
    F1=0;
    F2=0;
    with(all)
    {
        off=false;
        onhold=false;
        nomatch=false;
    }
    match=0;
    break;
    default:
    if(F1=id)
    {F2.nomatch=true;}
    if(F2=id)
    {F1.nomatch=true;}
}


ogems::mouse left pressed

if (lfm>0)
if((instance_number(ogems)==((clh*clw)+clw)))
{
if(F2=0) and (stable) and (y>(Ys-1))
if(F1=0)
{
    scr1();
}else
{
    if(F1!=id)and((x=F1x+Cs and y=F1y)or(x=F1x-Cs and y=F1y)or(x=F1x and y=F1y+Cs)or(x=F1x and y=F1y-Cs))
    {
    F2=id;
    F2x=x;
    F2y=y;
    with(all)
    onhold=true;
    }else{scr1();}
}
}



Part11
level 처리 다음 레벨로 넘어가는 방법



bag0 7*7 지금까지 작업

bag1 5*6 room1에 새로 작업

room0 복사 room1 생성
room1:bag1 으로 변경

scr0 -> 변경 scrlvl0
scrlvl0()
lfm=10;
clw=7
clh=7
Xs = 116;
Ys = 166;
for(i=0;i<clw;i++){
    for(j=0;j<clh;j++){
        instance_create(Xs+i*Cs,Ys+j*Cs,ogems);
    }
}
for(i=0;i<clw;i++){
    instance_create(Xs+i*Cs,Ys-Cs,oGG);
}

Control::create
globalvar F1,F2,F1x,F1y,F2x,F2y,Xs,Ys,Cs,clw,clh,gs,lfm,stars;
stars=0;
gs=0;
Cs=68;
F1=0;
F2=0;
F1x=0;
F1y=0;
F2x=0;
F2y=0;
gameover=false;
switch (room)
{
    case room0:
    scrlvl0();
    break;
    case room1:
    scrlvl1();
    break;
}

Control::draw
draw_background_part(bag0,0,0,640,132,0,0);
if(lfm<1)
{
    if(stars>0)
    {
        room_goto_next();
    }else{
        if !gameover
        {
            instance_create(room_width/2,room_height/2,ogameover);
            gameover=true;
        }      
    }
}

obar::create
bar=300;// the size of the bar
a=0;
tg=25000;// target achivement
s[1]=10;//1st star percentage
s[2]=40;//2st star percentage
s[3]=70;//3st star percentage
for(i=1;i<4;i++)
{
    s[i]=s[i]*(bar/100);
    b[i]=0;
    star[i]=0;
}

obar::draw
a=(gs/tg)*bar;
draw_self();
draw_sprite_part(sp_bbar,0,0,0,a,30,x,y-15);
for(i=1;i<4;i++)
{
    if(a>s[i])
        {
            b[i]=1;
            star[i]=1;
        }
    draw_sprite(sp_stars,b[i],x+s[i],y);
}
stars=star[0]+star[1]+star[2];

sprites->sp_gameover text 이미지 만들기 250*100

objects->ogameover::sp_gameover
ogameover::MouseLeftPressed
room_restart();

scrlvl0->scrlvl1 복사 후 수정
scrlvl1()
lfm=10;
clw=5
clh=6
Xs = 184;
Ys = 166;
for(i=0;i<clw;i++){
    for(j=0;j<clh;j++){
        instance_create(Xs+i*Cs,Ys+j*Cs,ogems);
    }
}
for(i=0;i<clw;i++){
    instance_create(Xs+i*Cs,Ys-Cs,oGG);
}


동영상과는 좀 다르지만 그래도 봐줄만 합니다.

댓글 없음:

댓글 쓰기