Entrar
Últimos assuntos
» Procuro Programador de game makerpor Wou Sex 15 Mar 2024, 10:27
» Retorno da GMBR!!!
por vinians Qui 14 Mar 2024, 19:07
» Mod APK
por gamerainha Qua 13 Mar 2024, 06:30
» Mudar cor de apenas uma palavra
por lunalol Sex 01 Mar 2024, 13:42
» 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
» Alguém aqui já ganha dinheiro com seus games?
por Joton Seg 15 Jan 2024, 16:49
» 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
» Asteroid Core - Early Acesse Update [0.2.0.0]
por JOZ. Seg 08 Jan 2024, 14:39
» Versionamento de código com GitHub
por GabrielXavier Seg 08 Jan 2024, 07:32
» Rio Rise - novo launcher do Gta San Andreas SAMP Brasil
por kolesovsup Sex 29 Dez 2023, 07:16
» a funçao approach ainda existe?
por PEDRINDEV Ter 26 Dez 2023, 20:05
» Inimigo ataca até por trás! >:(
por saim Sex 22 Dez 2023, 08:55
» [RESOLVIDO]Spawn após morte
por Deception_1999 Dom 17 Dez 2023, 16:39
» Remunerado $$$ - Procuro programador para ajudar a "montar" um jogo
por theguitarmester Sáb 02 Dez 2023, 16:28
» Game maker nao abre
por Cerf Dom 26 Nov 2023, 12:01
Como reorganizar peças no "Match 3"?
Página 1 de 1
Como reorganizar peças no "Match 3"?
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
*Objeto dos blocos/peças
Se alguém souber o que fazer, serei imensamente grato, pois eu já tentei de tudo x__x
Desde já, agradeço
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
Tópicos semelhantes
» Peças de Dama
» PEDIDO troca de peças????
» duvida escolha de peças
» Boss e suas peças
» [pedido] engine de alinhar peças
» PEDIDO troca de peças????
» duvida escolha de peças
» Boss e suas peças
» [pedido] engine de alinhar peças
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos
|
|