Page 11 of 27

Re: Advanced Tiled Loader

Posted: Sun May 27, 2012 1:46 pm
by Nixola
Try this:

Code: Select all

for i, v in ipairs(map) do
for ii, vv in ipairs(v) do
v[ii] = ii + (i-1)*16
end
end

Code: Select all

> map.print = function(self)
>> for i, v in ipairs(self) do
>> print(v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12], v[13], v[14], v[15], v[16])
>> end
>> end
> map:print()
1	2	3	4	5	6	7	8	9	10	11	12	13	14	15	16
17	18	19	20	21	22	23	24	25	26	27	28	29	30	31	32
33	34	35	36	37	38	39	40	41	42	43	44	45	46	47	48
49	50	51	52	53	54	55	56	57	58	59	60	61	62	63	64
65	66	67	68	69	70	71	72	73	74	75	76	77	78	79	80
81	82	83	84	85	86	87	88	89	90	91	92	93	94	95	96
97	98	99	100	101	102	103	104	105	106	107	108	109	110	111	112
113	114	115	116	117	118	119	120	121	122	123	124	125	126	127	128
129	130	131	132	133	134	135	136	137	138	139	140	141	142	143	144
145	146	147	148	149	150	151	152	153	154	155	156	157	158	159	160
161	162	163	164	165	166	167	168	169	170	171	172	173	174	175	176
177	178	179	180	181	182	183	184	185	186	187	188	189	190	191	192
193	194	195	196	197	198	199	200	201	202	203	204	205	206	207	208
209	210	211	212	213	214	215	216	217	218	219	220	221	222	223	224
225	226	227	228	229	230	231	232	233	234	235	236	237	238	239	240
241	242	243	244	245	246	247	248	249	250	251	252	253	254	255	256

Re: Advanced Tiled Loader

Posted: Sun May 27, 2012 2:14 pm
by SimonLarsen
Nixola wrote:Try this:
...
I think you misunderstand. I'm talking about the id's returned by map.tileLayers.layer.tileData(x,y). They are assigned by ATL not me. :nyu:

Re: Advanced Tiled Loader

Posted: Sun May 27, 2012 5:24 pm
by Nixola
:oops:
Try to find the error in the code then, if ATL coder doesn't answer

Re: Advanced Tiled Loader

Posted: Sun May 27, 2012 6:24 pm
by arthur_pessoa
This is awesome! thx!!! This make me so happy i could shit a rainbow right now :awesome: :awesome: :awesome:

Re: Advanced Tiled Loader

Posted: Sun May 27, 2012 6:44 pm
by KingRecycle
I am having a problem with the player sprite not detecting obstacle walls until half of his body touches the tile. This started when I tried to get the player to move smoothly instead of tile by tile.

Re: Advanced Tiled Loader

Posted: Sun May 27, 2012 7:24 pm
by Kadoba
SimonLarsen wrote:I think you misunderstand. I'm talking about the id's returned by map.tileLayers.layer.tileData(x,y). They are assigned by ATL not me. :nyu:


This was definitely a bug but it should be fixed now.

Re: Advanced Tiled Loader

Posted: Sun May 27, 2012 9:05 pm
by KingRecycle
It seems ATL thinks the sprites body is his right foot instead of his whole body for some reason.

Re: Advanced Tiled Loader

Posted: Sun May 27, 2012 10:13 pm
by Kadoba
KingRecycle wrote:It seems ATL thinks the sprites body is his right foot instead of his whole body for some reason.
I'm having a hard time following your code. How exactly are you doing the collision detection?

Re: Advanced Tiled Loader

Posted: Sun May 27, 2012 10:48 pm
by KingRecycle
Kadoba wrote:
KingRecycle wrote:It seems ATL thinks the sprites body is his right foot instead of his whole body for some reason.
I'm having a hard time following your code. How exactly are you doing the collision detection?

Well it checks if the next tile has the obstacle property. Takes the tile the player is on and adds to it the direction the player is moving for the next tile.

So if the next tile is an obstacle tile it doesn't let the player move that direction.

Re: Advanced Tiled Loader

Posted: Mon May 28, 2012 9:41 am
by SimonLarsen
Kadoba wrote:This was definitely a bug but it should be fixed now.
Yeah, just saw the commit. It works now. Thanks a bunch man, the library is great. ^^