11-28-2003, 10:27 PM
mine problem:
i've got 3 layers, the engine put the characters above all layers,
but it checks if the npcY(n) is on or one above a layer 3 tile.
Then the layer 3 tile is put above the character. The problem is how to calculate the position to put the layer 3 tiles above the character. Currently it correctly put it above the main character but thats because i made some routines which are dependent on cameraX and cameraY which is calculated from the npc(pc) axis values, but the tiles are moving to the left and right above the other npcs when i walk with my character.
Anywayz could someone help me with calculating the right position to put the layer 3 tiles above the chars.
i've got 3 layers, the engine put the characters above all layers,
but it checks if the npcY(n) is on or one above a layer 3 tile.
Then the layer 3 tile is put above the character. The problem is how to calculate the position to put the layer 3 tiles above the character. Currently it correctly put it above the main character but thats because i made some routines which are dependent on cameraX and cameraY which is calculated from the npc(pc) axis values, but the tiles are moving to the left and right above the other npcs when i walk with my character.
Anywayz could someone help me with calculating the right position to put the layer 3 tiles above the chars.
Code:
SUB drawcharobj
FOR i = 0 TO npcs
SnpcY(i) = npcY(i)
Inpc(i) = i
NEXT i
FOR i = npcs + 1 TO npcs + nmys
SnpcY(i) = nmyY(i - npcs)
Inpc(i) = i
NEXT i
FOR d = 0 TO npcs + nmys
FOR i = 0 TO npcs + nmys
IF SnpcY(i) > SnpcY(i + 1) THEN SWAP t, SnpcY(i + 1): SWAP tt, Inpc(i + 1): SWAP SnpcY(i + 1), SnpcY(i): SWAP Inpc(i + 1), Inpc(i): SWAP SnpcY(i), t: SWAP Inpc(i), tt
NEXT i
NEXT d
FOR i = 0 TO npcs + nmys
n = Inpc(i)
IF n <= npcs THEN
IF npcIngame(n) = 1 THEN
xpos = npcX(n) - cameraX
ypos = npcY(n) - cameraY
IF npcSpr(n) <= 3 THEN DQBput 1, xpos - 10, ypos, VARSEG(shadow1%(0)), VARPTR(shadow1%(0))
IF npcSpr(n) = 4 THEN DQBput 1, xpos - 10, ypos, VARSEG(shadow2%(0)), VARPTR(shadow2%(0))
IF npcSpr(n) = 0 THEN DQBput 1, xpos - 10, ypos - 30, VARSEG(hero%((nframe(n) + nadd(n)) * 352)), VARPTR(hero%((nframe(n) + nadd(n)) * 352))
IF npcSpr(n) = 1 THEN DQBput 1, xpos - 10, ypos - 30, VARSEG(npc1%((nframe(n) + nadd(n)) * 352)), VARPTR(npc1%((nframe(n) + nadd(n)) * 352))
IF npcSpr(n) = 2 THEN DQBput 1, xpos - 10, ypos - 30, VARSEG(npc2%((nframe(n) + nadd(n)) * 352)), VARPTR(npc2%((nframe(n) + nadd(n)) * 352))
IF npcSpr(n) = 3 THEN DQBput 1, xpos - 10, ypos - 30, VARSEG(npc3%((nframe(n) + nadd(n)) * 352)), VARPTR(npc3%((nframe(n) + nadd(n)) * 352))
IF npcSpr(n) = 4 THEN DQBput 1, xpos - 10, ypos - 30, VARSEG(orb%((nframe(oc) + nadd(oc)) * 202)), VARPTR(orb%((nframe(oc) + nadd(oc)) * 202))
IF npcSpr(n) = 5 THEN DQBput 1, xpos - 25, ypos - 25, VARSEG(vec1%(vadd * 677)), VARPTR(vec1%(vadd * 677))
IF numb = 1 THEN DQBprint 1, STR$(n), xpos - 20, ypos - 30, 32
xtile = INT(npcX(n) / 20)
ytile = INT(npcY(n) / 20)
IF xtile < 1 THEN xtile = 1
IF xtile > mapx THEN xtile = mapx - 1
IF ytile < 1 THEN ytile = 1
IF ytile > mapy THEN ytile = mapy - 1
xpos = cameraX MOD 20 'i guess this has to be make dependent from the char cordinates instead of the camera
ypos = cameraY MOD 20
x = npcX(n) - cameraX
y = npcY(n) - cameraY
x = INT(x / 20)
y = INT(y / 20)
'here begins the putting of the tiles from layer 3 with the calculated positions
IF mapc(xtile, ytile) > 0 THEN
DQBput 1, x * 20 - xpos, y * 20 - ypos, VARSEG(tile%(mapc(xtile, ytile) * 202)), VARPTR(tile%(mapc(xtile, ytile) * 202))
IF mapc(xtile - 1, ytile) > 0 THEN DQBput 1, x * 20 - xpos - 20, y * 20 - ypos, VARSEG(tile%(mapc(xtile - 1, ytile) * 202)), VARPTR(tile%(mapc(xtile - 1, ytile) * 202))
IF mapc(xtile + 1, ytile) > 0 THEN DQBput 1, x * 20 - xpos + 20, y * 20 - ypos, VARSEG(tile%(mapc(xtile + 1, ytile) * 202)), VARPTR(tile%(mapc(xtile + 1, ytile) * 202))
END IF
IF mapc(xtile, ytile + 1) > 0 THEN
DQBput 1, x * 20 - xpos, y * 20 - ypos + 20, VARSEG(tile%(mapc(xtile, ytile + 1) * 202)), VARPTR(tile%(mapc(xtile, ytile + 1) * 202))
IF mapc(xtile - 1, ytile + 1) > 0 THEN DQBput 1, x * 20 - xpos - 20, y * 20 - ypos + 20, VARSEG(tile%(mapc(xtile - 1, ytile + 1) * 202)), VARPTR(tile%(mapc(xtile - 1, ytile + 1) * 202))
IF mapc(xtile + 1, ytile + 1) > 0 THEN DQBput 1, x * 20 - xpos + 20, y * 20 - ypos + 20, VARSEG(tile%(mapc(xtile + 1, ytile + 1) * 202)), VARPTR(tile%(mapc(xtile + 1, ytile + 1) * 202))
END IF
END IF
END IF
IF n > npcs THEN
IF nmyingame(n - npcs) = 1 THEN
xpos = nmyX(n - npcs) - cameraX
ypos = nmyY(n - npcs) - cameraY
DQBput 1, xpos - 10, ypos, VARSEG(shadow1%(0)), VARPTR(shadow1%(0))
IF nmySpr(n - npcs) = 1 THEN DQBput 1, xpos - 16, ypos - 24, VARSEG(enemy1%((nmyframe(n - npcs) + nmyadd(n - npcs)) * 514)), VARPTR(enemy1%((nmyframe(n - npcs) + nmyadd(n - npcs)) * 514))
END IF
END IF
NEXT i
END SUB