Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - waroffice

#1
Thanks dreamerman and fuzzy70,

I will read that tutorial when I get time, I'm at work now, but I do understand my mistake.

Thanks for looking

#2
I will clarify the L4 variable.  Its just toggled with a key press so I can turn on or off each layer.

I added that in after reaslising it was drawing the player on top.


ah thats it.

its drawing the player ever iteration.

I need to only draw the player once like you say

Would looping through the map twice be bad?

EG:

Code (glbasic) Select

FOR u = 0 TO w
FOR v = 0 TO h
IF (u+x_off<=map_data.width) AND (v+y_off<=map_data.height)
IF L1 THEN DRAWANIM 0,map[u+x_off][v+y_off].L1_tile,x+(u*tile_height),y+(v*tile_height)
IF L2 THEN DRAWANIM 0,map[u+x_off][v+y_off].L2_tile,x+(u*tile_height),y+(v*tile_height)
IF L3 THEN DRAWANIM 0,map[u+x_off][v+y_off].L3_tile,x+(u*tile_height),y+(v*tile_height)
ENDIF
NEXT
NEXT

DRAWANIM 1,7,(Player.X*tile_height)-(x_off*tile_height),(Player.Y*tile_height)-(y_off*tile_height) // Player

IF L4
    FOR u = 0 TO w
FOR v = 0 TO h
IF (u+x_off<=map_data.width) AND (v+y_off<=map_data.height)
                    DRAWANIM 0,map[u+x_off][v+y_off].L4_tile,x+(u*tile_height),y+(v*tile_height)
                ENDIF
        NEXT
    NEXT
ENDIF
#3
Good morning,

I'm not sure if this is a bug or I am doing something wrong.

I have a tile map engine that has 4 layers and a player.

It renders them in this order.

Layer1
Layer2
Layer3
Player
Layer4

Only it is always showing the player on top of everything.

At first I thought it was the ID of the sprites so I loaded the same file again with a different ID and set that for layer 4 and it still renders the player last.

Some code and screenshots:

Code (glbasic) Select


LOADANIM "TILES.png",0,32,32  // 0 is the handle
LOADANIM "player.png",1,32,32 // 1 is the handle

FOR u = 0 TO w
FOR v = 0 TO h
IF (u+x_off<=map_data.width) AND (v+y_off<=map_data.height)
IF L1 THEN DRAWANIM 0,map[u+x_off][v+y_off].L1_tile,x+(u*tile_height),y+(v*tile_height)
IF L2 THEN DRAWANIM 0,map[u+x_off][v+y_off].L2_tile,x+(u*tile_height),y+(v*tile_height)
IF L3 THEN DRAWANIM 0,map[u+x_off][v+y_off].L3_tile,x+(u*tile_height),y+(v*tile_height)
DRAWANIM 1,7,(Player.X*tile_height)-(x_off*tile_height),(Player.Y*tile_height)-(y_off*tile_height) // Player
IF L4 THEN DRAWANIM 0,map[u+x_off][v+y_off].L4_tile,x+(u*tile_height),y+(v*tile_height)
ENDIF
NEXT
NEXT



I turned off rendering the first 3 layers for this shot



I then made the changes as below and got this (with the layers all intact)

Code (glbasic) Select


LOADANIM "TILES.png",0,32,32  // 0 is the handle
LOADANIM "player.png",1,32,32 // 1 is the handle
LOADANIM "TILES.png",2,32,32  // 2 is the handle

FOR u = 0 TO w
FOR v = 0 TO h
IF (u+x_off<=map_data.width) AND (v+y_off<=map_data.height)
IF L1 THEN DRAWANIM 0,map[u+x_off][v+y_off].L1_tile,x+(u*tile_height),y+(v*tile_height)
IF L2 THEN DRAWANIM 0,map[u+x_off][v+y_off].L2_tile,x+(u*tile_height),y+(v*tile_height)
IF L3 THEN DRAWANIM 0,map[u+x_off][v+y_off].L3_tile,x+(u*tile_height),y+(v*tile_height)
DRAWANIM 1,7,(Player.X*tile_height)-(x_off*tile_height),(Player.Y*tile_height)-(y_off*tile_height) // Player
IF L4 THEN DRAWANIM 2,map[u+x_off][v+y_off].L4_tile,x+(u*tile_height),y+(v*tile_height)  // Additional tile set
ENDIF
NEXT
NEXT