GMBR
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.
Entrar

Esqueci-me da senha

Últimos assuntos
» Alguém aqui já ganha dinheiro com seus games?
por theguitarmester Ontem à(s) 11:43

» Colisões não funcionando
por theguitarmester Ontem à(s) 10:16

» Como ajustar velocidade de cada frame da animação no game maker
por pequetux Sex 26 Abr 2024, 16:45

» Preciso de ajuda
por AftonDuGrau Dom 21 Abr 2024, 20:18

» Como faz o evento drawn GUI, não se repetir?
por aminaro Sex 19 Abr 2024, 20:30

» PROBLEMAS COM FÍSICAS DE ÁGUA
por aminaro Ter 16 Abr 2024, 10:07

» Retorno da GMBR!!!
por Ralphed Sex 12 Abr 2024, 22:45

» JOGADOR PARANDO NO AR QUANDO ATACA
por aminaro Qua 10 Abr 2024, 13:51

» Problemas com texto interativo
por Kaaru72 Dom 07 Abr 2024, 11:31

» Erro escondido e indecifrável
por dev_gabize.azv Qui 04 Abr 2024, 10:11

» Mudar cor de apenas uma palavra
por Ralphed Sáb 30 Mar 2024, 00:39

» Procuro Programador de game maker
por Wou Sex 15 Mar 2024, 10:27

» Mod APK
por gamerainha Qua 13 Mar 2024, 06:30

» Aceito pedidos de sprites (Com exemplos meus)
por Sevilha Qua 28 Fev 2024, 12:17

» Inventário simples
por Isquilo_Roedor Qui 22 Fev 2024, 15:18

» Problemas na programaçnao de inimigo [jogo DOOM LIKE]
por Black Mirror Dom 11 Fev 2024, 13:34

» ANDROID MULTI TOUCH
por DiegoBr Dom 04 Fev 2024, 12:13

» Servidor de Discord do fórum?
por Lighter Sáb 27 Jan 2024, 17:18

» Save e Load Json
por Klinton Rodrigues Qui 25 Jan 2024, 11:12

» Colisão com mais de um objeto
por aminaro Seg 22 Jan 2024, 15:02

» Oi sou novo aqui
por Thiago Silveira Alexandre Sáb 20 Jan 2024, 20:55

» Como acessar conteudo comprado no marketplace
por macmilam Sex 19 Jan 2024, 07:42

» Devlogs em vídeos do Block Room
por Joton Seg 15 Jan 2024, 16:56

» ACERVO GMBR MAGAZINE
por Joton Qui 11 Jan 2024, 19:21

» como aumentar o obj sem aumentar a colisão??
por GabrielXavier Qua 10 Jan 2024, 07:21


Como reorganizar peças no "Match 3"?

Ir para baixo

Como reorganizar peças no "Match 3"? Empty Como reorganizar peças no "Match 3"?

Mensagem por Dragonrod Seg 16 Jul 2018, 20:23

Saudações,

Recentemente comecei a seguir esse tutorial para criar um jogo estilo Candy Crush (Match 3), porém os vídeos acabam antes do autor explicar como fazer o jogo reconhecer que não há mais combinações possíveis e reorganizar as peças do jogo.

Seguem os códigos dos meus objetos:

* Objeto que cria a maioria das variáveis
Código:
Information about object: obj_control
Sprite:
Solid: false
Visible: true
Depth: -50
Persistent: false
Parent:
Children:
Mask:

No Physics Object
Create Event:

execute code:

global.point = 50

globalvar F1,F2,F1x,F1y,F2x,F2y,Xs,Ys,Cs,clw,clh,AlTim,Gs,lfm,Lvl,Pg,pop;
Lvl = 1
lfm = 20 // Left Movements
Gs = 0 // Global Score
Pg = Gs //Pontuação Geral
Cs = 68//Cell Size
clw = 7//Column Witdh
clh = 7//Column Height
F1 = 0
F2 = 0
F1x = 0
F1y = 0
F2x = 0
F2y = 0
pop = 0

Xs = 376
Ys = 147

AlTim = 3

scr_CreateBlocks()

Step Event:

execute code:

//HIGHSCORE
if (Hscore < Pg)
{
    Hscore = Pg
}

Draw Event:

execute code:

draw_background_part(bg02,0,0,1132,116,0,0)

/*
draw_text(15,15,F1)
draw_text(15,30,F1x)
draw_text(15,45,F1y)
draw_text(15,60,F2)
draw_text(15,75,F2x)
draw_text(15,100,F2y)

Key Release Event for <Space> Key:

Restart the current room

*Objeto dos blocos/peças
Código:
Information about object: obj_Block
Sprite: spr_blocks
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:

No Physics Object
Create Event:

execute code:

image_index = irandom(5)
image_speed = 0

var N1,N2,N3,N4;

off = false
stable = false
onHold = false
noMatch = false
match = 0
Ye = Ys+(clh*Cs)-Cs//The last cell in the verticall colomn

Active = true

NoV = 0
NoH = 0

Destroy Event:

execute code:

op = instance_create(x,y,obj_puff)
op.co = image_index

Alarm Event for alarm 0:

execute code:

if Active = true
{
off = false
maxW = (Xs+((clh-3)*Cs))+1//maximum Width
maxH = (Ys+((clh-3)*Cs))+1//maximum Height
minH = Ys - 1//minimum Height

//Check Horizontally
if (x <= maxW) and (y >= minH)
if (!position_empty(x+Cs,y)) and (!position_empty(x+(Cs*2),y))
{
    //var N1,N2;
    N1 = instance_position(x+Cs,y,obj_Block)
    N2 = instance_position(x+(Cs*2),y,obj_Block)
    
    if ((N1.stable = true) and (N2.stable = true))
    {
        if (N1.image_index = image_index) and (N2.image_index = image_index)
        {
            match = 1
        }
    }
}
//Check Vertically
if (y <= maxH) and (y >= minH)
if (!position_empty(x,y+Cs)) and (!position_empty(x,y+(Cs*2)))
{
    //var N3,N4;
    N3 = instance_position(x,y+Cs,obj_Block)
    N4 = instance_position(x,y+(Cs*2),obj_Block)
    
    if ((N3.stable = true) and (N4.stable = true))
    {
        if (N3.image_index = image_index) and (N4.image_index = image_index)
        {
            match = 2
        }
    }
}

switch (match)
{
    case 1:
    with(N1)
    alarm[1] = AlTim
    with(N2)
    alarm[1] = AlTim
    alarm[1] = AlTim
    match = 0
    break;
    
    case 2:
    with(N3)
    alarm[1] = AlTim
    with(N4)
    alarm[1] = AlTim
    alarm[1] = AlTim
    match = 0
    break;
}
}

Alarm Event for alarm 1:

execute code:

instance_destroy()

Step Event:

execute code:

if Active = true
{
if (off)
exit;

//Physics
if (!onHold)
{
    if place_free(x,y+12) and (y<Ye)
    {
        y += 4
        stable = false
    }
    else
    {
        stable = true
        off = true
        alarm[0] = 5
    }
}
else
{
    if (!noMatch)
    {
        //F1
        if (F1 = id)
        {
            //X
            if ((x < F2x) and (y = F2y))
            {
                x+=4
            }
            else
            if ((x > F2x) and (y = F2y))
            {
                x-=4
            }
            //Y
            if ((x = F2x) and (y < F2y))
            {
                y+=4
            }
            else
            if ((x = F2x) and (y > F2y))
            {
                y-=4
            }
            //On Position
            if ((x == F2x) and (y == F2y))
            {
                with(obj_Block)
                    scr02();
                    exit;
            }
        }
//==========================================
            //F2
        if (F2 = id)
        {
            //X
            if ((x < F1x) and (y = F1y))
            {
                x+=4
            }
            else
            if ((x > F1x) and (y = F1y))
            {
                x-=4
            }
            //Y
            if ((x = F1x) and (y < F1y))
            {
                y+=4
            }
            else
            if ((x = F1x) and (y > F1y))
            {
                y-=4
            }
            //On Position
            if ((x == F1x) and (y == F1y))
            {
                with(obj_Block)
                    scr02();
                    exit;
            }
        }
    }
    else
    {
        //F2
        if (F2 = id)
        {
            //X
            if ((x < F2x) and (y = F2y))
            {
                x+=4
            }
            else
            if ((x > F2x) and (y = F2y))
            {
                x-=4
            }
            //Y
            if ((x = F2x) and (y < F2y))
            {
                y+=4
            }
            else
            if ((x = F2x) and (y > F2y))
            {
                y-=4
            }
            //On Position
            if ((x == F2x) and (y == F2y))
            {
                onHold = false
                noMatch = false
                F2 = 0
                    exit;
            }
        }
//==========================================
            //F1
        if (F1 = id)
        {
            //X
            if ((x < F1x) and (y = F1y))
            {
                x+=4
            }
            else
            if ((x > F1x) and (y = F1y))
            {
                x-=4
            }
            //Y
            if ((x = F1x) and (y < F1y))
            {
                y+=4
            }
            else
            if ((x = F1x) and (y > F1y))
            {
                y-=4
            }
            //On Position
            if ((x == F1x) and (y == F1y))
            {
                onHold = false
                noMatch = false
                F1 = 0
                    exit;
            }
        }
    }
}
}

execute code:

//check game over
if (lfm < 1)
{
    //Active = false
    alarm[0] = -1
    onHold = false
    if place_free(x,y+12) and (y<Ye)
    {
        y += 4
        stable = false
    }
    if !instance_exists(obj_PopGOver)
        instance_create(room_width/2,room_height/2+15,obj_PopGOver)
}
//Check for Level Up
if ((Gs >= global.tg) and (stable = true))
{
    Active = false
    pop = 0
    instance_create(room_width/2,room_height/2+15,obj_PopUp)
    Lvl ++
    Gs = 0
    global.tg = global.tg + (floor(global.tg/10)*3)
    lfm += 10
}

//Check if there is no Match
/*
{
    if (NoV = 1 and NoH = 1)
    {
        with(obj_Block)
        image_index = irandom(5)
    }
}

Mouse Event for Left Pressed:

execute code:

if Active = true
{
if (lfm > 0)
{
    if ((instance_number(obj_Block) == ((clh*clw)+clw)))
    {
        if (F2 == 0) and (stable) and (y>=(Ys-1))
        if (F1 == 0)
        {
            scr01()
        }
        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(obj_Block)
                    onHold = true
            }
            else
            {
                scr01()
            }
        }
    }
}
}

Draw Event:

execute code:

draw_self()
if (F1 = id) and (F2 = 0)
draw_sprite(spr_selected,0,x,y)

/*
draw_text(x,y-10,NoH)
draw_text(x,y+10,NoV)


Se alguém souber o que fazer, serei imensamente grato, pois eu já tentei de tudo x__x
Desde já, agradeço
Dragonrod
Dragonrod

Games Ranking : Sem avaliações

Data de inscrição : 28/06/2017
Reputação : 0
Número de Mensagens : 5
Prêmios : Como reorganizar peças no "Match 3"? Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

https://dragonrod342.deviantart.com/

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos