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
» Problema ao entrar por uma porta e voltar por ela
por aminaro Seg 06 maio 2024, 10:08

» Alguém aqui já ganha dinheiro com seus games?
por theguitarmester Ter 30 Abr 2024, 11:43

» Colisões não funcionando
por theguitarmester Ter 30 Abr 2024, 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


[Engine] DS Grids Game Maker 4.3

2 participantes

Ir para baixo

[Engine] DS Grids Game Maker 4.3 Empty [Engine] DS Grids Game Maker 4.3

Mensagem por GameMakerTutoriais Ter 27 Mar 2012, 15:08

E aí pessoal. É o seguinte... Esse é um esqueminha de scripts pra simular as funções ds_grid dentro do Game Maker 4. Esses scripts são usados exatamente do mesmo jeito que as funções. Como não são funções do GM, eles obviamente são mais lentos.

Download: http://bit.ly/GTaENZ
[Engine] DS Grids Game Maker 4.3 Dsgrid10

Qualquer dica ou sugestão pra acelerar esse engine vai ser super bem-vinda. Tratei cada grid como um objeto persistente ao invés de usar variáveis globais. A velocidade pra acessar a grid é a mesma pra acessar uma variável local. Eu testei ele várias vezes função por função e acho que ficou bom, levando em consideração todas as "limitações" do Gm4.

Mas pode melhorar. Qualquer dica pra melhorar postem aí quem interessar a ajudar. Valeu!


avatar
GameMakerTutoriais

Data de inscrição : 29/01/2011
Reputação : 26
Número de Mensagens : 800
Prêmios : [Engine] DS Grids Game Maker 4.3 Empty

Medalhas x 0 Tutoriais x 4 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

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

Ir para o topo Ir para baixo

[Engine] DS Grids Game Maker 4.3 Empty Re: [Engine] DS Grids Game Maker 4.3

Mensagem por PedroX Qua 28 Mar 2012, 14:11

Poderia fazer uma versão gmk?
Mesmo que não será necessário usá-los nas novas versões, seria bom vê-los.
Valeu.

Até mais!

_________________


Leia o Manual do Iniciante e a Lista de Tutoriais, para aprender bastante sobre o GM.
Recomendo o Manual completo das colisões, bem útil.
O exemplo Criar um chat (banir, kickar, etc) é interessante.

Para seu jogo ficar rápido e legal, aprenda a Aumentar o desempenho do seu jogo.

Aprenda a calcular a velocidade de suas animações


Entre para o Clube do Inglês:
PedroX
PedroX

Games Ranking : Nota B

Notas recebidas : C+B
Data de inscrição : 26/07/2008
Reputação : 311
Número de Mensagens : 6087
Prêmios : [Engine] DS Grids Game Maker 4.3 Empty

Medalhas x 0 Tutoriais x 17 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://web.whatsapp.com/send?phone=5519995935953&text=Pedro

Ir para o topo Ir para baixo

[Engine] DS Grids Game Maker 4.3 Empty Re: [Engine] DS Grids Game Maker 4.3

Mensagem por GameMakerTutoriais Qua 28 Mar 2012, 18:08

Upei uma versão gm6, daí funciona em qualquer uma, 6, 7, 8...

http://bit.ly/HhseP2

Se achar melhor, faz o seguinte. Cria dois objetos, marque "persistent" e tire o "visible". O nome dos dois é:

_NULL
_DSGRID

Vou colocar o aquivo gml aqui em baixo, depois é só importar... Nos scripts que tão aqui, os nomes são os mesmos das funções, mas no projeto do donwload eu coloquei um underline no início de cada um, pra não dar conflito com as funções do gm6 em diante.

Código:

#define ds_grid_add
// ds_grid_add(id, x, y, val);
if instance_exists(argument0) then argument0._dsgrid[argument1, argument2] += argument3; else return(0);
#define ds_grid_add_region
// ds_grid_add_region(id, x1, y1, x2, y2, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define(_dsid, argument1, argument2, argument3, argument4);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         _dsid._dsgrid[_dsw, _dsh] += argument5;
      end;
   end;
end;
#define ds_grid_clear
// ds_grid_clear(id, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   for (_dsw := 0; _dsw < _dsid._ds_width; _dsw += 1)
   begin
      for (_dsh := 0; _dsh < _dsid._ds_height; _dsh += 1)
      begin
         _dsid._dsgrid[_dsw, _dsh] := argument1;
      end;
   end;
end;
return(1);
#define ds_grid_create
// ds_grid_create(w, h);
if (argument0 < 1) or (argument1 < 1) then return(false);
with (_NULL)
begin
   _dsid := instance_create(-1, -1, _DSGRID);
   _dsid._ds_width  := argument0;
   _dsid._ds_height := argument1;
   for (_dsw := 0; _dsw < argument0; _dsw += 1)
   begin
      for (_dsh := 0; _dsh < argument1; _dsh += 1)
      begin
         _dsid._dsgrid[_dsw, _dsh] := 0;
      end;
   end;
end;
return(_NULL._dsid);
#define ds_grid_define
_maxx := min(max3(0, argument1, argument3), argument0._ds_width  - 1);
_maxy := min(max3(0, argument2, argument4), argument0._ds_height - 1);
_minx := max(0, min(argument1, argument3));
_miny := max(0, min(argument2, argument4));
_val  := 0;
_inc  := 0;
#define ds_grid_define_radius
_minx := max(0, argument1 - argument3);
_miny := max(0, argument2 - argument3);
_maxx := min(argument1 + argument3, argument0._ds_width  - 1);
_maxy := min(argument2 + argument3, argument0._ds_height - 1);
_val  := 0;
_inc  := 0;
#define ds_grid_destroy
// ds_grid_destroy(id)
if instance_exists(argument0) then with (argument0) instance_destroy();
#define ds_grid_get_disk_mean
// ds_grid_get_disk_mean(id, xm, ym, r);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define_radius(_dsid, argument1, argument2, argument3);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if point_distance(_dsw, _dsh, argument1, argument2) <= argument3 then 
         begin
            _val += _dsid._dsgrid[_dsw, _dsh];
            _inc += 1;
         end;
      end;
   end;
   if _inc <> 0 then return(_val/_inc)
   return(0);
end;
#define ds_grid_get
// ds_grid_get(id, x, y);
if instance_exists(argument0) then return (argument0._dsgrid[argument1, argument2]) else return(0);
#define ds_grid_get_disk_max
// ds_grid_get_disk_max(id, xm, ym, r);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define_radius(_dsid, argument1, argument2, argument3);
   _val -= _SIZEOF;
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if point_distance(_dsw, _dsh, argument1, argument2) <= argument3 then _val := max(_val, _dsid._dsgrid[_dsw, _dsh]);
      end;
   end;
   return (_val);
end;
#define ds_grid_get_disk_min
// ds_grid_get_disk_min(id, xm, ym, r);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define_radius(_dsid, argument1, argument2, argument3);
   _val := _SIZEOF;
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if point_distance(_dsw, _dsh, argument1, argument2) <= argument3 then _val := min(_val, _dsid._dsgrid[_dsw, _dsh]);
      end;
   end;
   return (_val);
end;
#define ds_grid_get_disk_sum
// ds_grid_get_disk_sum(id, xm, ym, r);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define_radius(_dsid, argument1, argument2, argument3);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if point_distance(_dsw, _dsh, argument1, argument2) <= argument3 then _val += _dsid._dsgrid[_dsw, _dsh];
      end;
   end;
   return (_val);
end;
#define ds_grid_get_max
// ds_grid_get_max(id, x1, y1, x2, y2);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define(_dsid, argument1, argument2, argument3, argument4);
   _val -= _SIZEOF;
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         _val := max(_val, _dsid._dsgrid[_dsw, _dsh]);
      end;
   end;
   return(_val);
end;
#define ds_grid_get_mean
// ds_grid_get_mean(id, x1, y1, x2, y2);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define(_dsid, argument1, argument2, argument3, argument4);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         _val += _dsid._dsgrid[_dsw, _dsh];
         _inc += 1;
      end;
   end;
   if _inc <> 0 then return(_val/_inc);
   return(0);
end;
#define ds_grid_get_min
// ds_grid_get_min(id, x1, y1, x2, y2);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define(_dsid, argument1, argument2, argument3, argument4);
   _val := _SIZEOF;
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         _val := min(_val, _dsid._dsgrid[_dsw, _dsh]);
      end;
   end;
   return(_val);
end;
#define ds_grid_get_sum
// ds_grid_get_sum(id, x1, y1, x2, y2);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define(_dsid, argument1, argument2, argument3, argument4);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         _val += _dsid._dsgrid[_dsw, _dsh];
      end;
   end;
   return(_val);
end;
#define ds_grid_height
// ds_grid_height(id)
if instance_exists(argument0) then return(argument0._ds_height) else return(0);
#define ds_grid_multiply
// ds_grid_multiply(id, x, y, val);
if instance_exists(argument0) then argument0._dsgrid[argument1, argument2] *= argument3; else return(0);
#define ds_grid_multiply_region
// ds_grid_multiply_region(id, x1, y1, x2, y2, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define(_dsid, argument1, argument2, argument3, argument4);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         _dsid._dsgrid[_dsw, _dsh] *= argument5;
      end;
   end;
end;
#define ds_grid_resize
// ds_grid_resize(id, w, h);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   for (_dsw := _dsid._ds_width; _dsw < argument1; _dsw += 1)
   begin
      for (_dsh := 0; _dsh < argument2; _dsh += 1)
      begin
         _dsid._dsgrid[_dsw, _dsh] := 0;
      end;
   end;
   for (_dsw := 0; _dsw < argument1; _dsw += 1)
   begin
      for (_dsh := _dsid._ds_height; _dsh < argument2; _dsh += 1)
      begin
         _dsid._dsgrid[_dsw, _dsh] := 0;
      end;
   end;
   _dsid._ds_width  := argument1;
   _dsid._ds_height := argument2;
end;
return(1);
#define ds_grid_set
// ds_grid_set(id, x, y, val);
if instance_exists(argument0) then argument0._dsgrid[argument1, argument2] := argument3; else return(0);
#define ds_grid_set_disk
// ds_grid_set_disk(id, xm, ym, r, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define_radius(_dsid, argument1, argument2, argument3);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if point_distance(_dsw, _dsh, argument1, argument2) <= argument3 then _dsid._dsgrid[_dsw, _dsh] := argument4;
      end;
   end;
end;
#define ds_grid_set_region
// ds_grid_set_region(id, x1, y1, x2, y2, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define(_dsid, argument1, argument2, argument3, argument4);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         _dsid._dsgrid[_dsw, _dsh] := argument5;
      end;
   end;
end;
#define ds_grid_start
// Must be called first. ONLY ONCE.
if instance_exists(_NULL) then exit;
instance_create(-1, -1, _NULL);
_NULL._SIZEOF := power(256, 7);
#define ds_grid_value_disk_exists
// ds_grid_value_disk_exists(id, xm, ym, r, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define_radius(_dsid, argument1, argument2, argument3);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if point_distance(_dsw, _dsh, argument1, argument2) <= argument3 then
         begin
            if _dsid._dsgrid[_dsw, _dsh] = argument4 then return (true);
         end;
      end;
   end;
   return (false);
end;
#define ds_grid_value_disk_x
// ds_grid_value_disk_x(id, xm, ym, r, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define_radius(_dsid, argument1, argument2, argument3);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if point_distance(_dsw, _dsh, argument1, argument2) <= argument3 then
         begin
            if _dsid._dsgrid[_dsw, _dsh] = argument4 then return (_dsw);
         end;
      end;
   end;
end;
#define ds_grid_value_disk_y
// ds_grid_value_disk_x(id, xm, ym, r, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define_radius(_dsid, argument1, argument2, argument3);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if point_distance(_dsw, _dsh, argument1, argument2) <= argument3 then
         begin
            if _dsid._dsgrid[_dsw, _dsh] = argument4 then return (_dsh);
         end;
      end;
   end;
end;
#define ds_grid_value_exists
// ds_grid_value_exists(id, x1, y1, x2, y2, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define(_dsid, argument1, argument2, argument3, argument4);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if _dsid._dsgrid[_dsw, _dsh] = argument5 then return (true);
      end;
   end;
   return (false);
end;
#define ds_grid_value_x
// ds_grid_value_x(id, x1, y1, x2, y2, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define(_dsid, argument1, argument2, argument3, argument4);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if _dsid._dsgrid[_dsw, _dsh] = argument5 then return (_dsw);
      end;
   end;
end;
#define ds_grid_value_y
// ds_grid_value_y(id, x1, y1, x2, y2, val);
if instance_exists(argument0) then _NULL._dsid := argument0.id else return(0);
with (_NULL)
begin
   ds_grid_define(_dsid, argument1, argument2, argument3, argument4);
   for (_dsw := _minx; _dsw <= _maxx; _dsw += 1)
   begin
      for (_dsh := _miny; _dsh <= _maxy; _dsh += 1)
      begin
         if _dsid._dsgrid[_dsw, _dsh] = argument5 then return (_dsh);
      end;
   end;
end;
#define ds_grid_width
// ds_grid_width(id)
if instance_exists(argument0) then return(argument0._ds_width) else return(0);

O único jeito que eu conheço de definir variáveis temporárias no Gm4 é através de objetos. Vc cria um objeto, usa as vars nele e depois destrói. Por isso que eu criei esse objeto _NULL. Mas ele só é criado uma vez e fica persistente.

Isso é pra influenciar o mínimo possível no objeto que vai usar a grid, que também é um objeto à parte. Então ficou tudo separado assim, mas se quiser mudar, manda ver. A ideia é achar um jeito de acelerar... Valeu!
avatar
GameMakerTutoriais

Data de inscrição : 29/01/2011
Reputação : 26
Número de Mensagens : 800
Prêmios : [Engine] DS Grids Game Maker 4.3 Empty

Medalhas x 0 Tutoriais x 4 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

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

Ir para o topo Ir para baixo

[Engine] DS Grids Game Maker 4.3 Empty Re: [Engine] DS Grids Game Maker 4.3

Mensagem por Conteúdo patrocinado


Conteúdo patrocinado


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