08-25-2006, 01:00 AM
Ok, this problem has been haunting me for 2 months now.
I am making a layering system, but I can't seem to understand how I'm supposed to get the characters to draw between layers
I'll provide the code for anyone who thinks they can help.
I've marked out the problem area's, and places where I think could use optimization.
verticalVal% = cam.y
tileX% = cam.x \ 16 'this division is by 16 and 12, always, so it stands to reason that it can be made faster somehow.
tileY% = verticalVal% \ 12
mapElem% = tileY% * 100 + tileX%
spriteX% = cam.x MOD 16 'the MOD command is a bit slow, I'm wondering what I can do here.
spriteY% = cam.y MOD 12
spriteElem% = spriteY% * 16 + spriteX%
FOR screenY% = 0 TO 192
offset& = buffoff% + screenY% * 238& + 4
FOR screenX% = 0 TO 238
SELECT CASE picl2%(mapl2%(mapElem%), spriteElem%)
CASE 0
POKE offset&, pic%(map%(mapElem%), spriteElem%)
CASE IS <> 0
'NPC's and monsters must somehow draw here. I find
the most trouble with this, because they must draw there pixels
with the map scanning pixel.
POKE offset&, picl2%(mapl2%(mapElem%), spriteElem%)
END SELECT
offset& = offset& + 1
spriteElem% = spriteElem% + 1
IF spriteElem% MOD 16 = 0 THEN 'again, the MOD command
spriteElem% = spriteElem% - 16
mapElem% = mapElem% + 1
END IF
NEXT
verticalVal% = verticalVal% + 1
tileY% = verticalVal% \ 12 again a division by an even number
mapElem% = tileY% * 100 + tileX%
spriteY% = spriteY% + 1
IF spriteY% = 12 THEN spriteY% = 0
spriteElem% = spriteY% * 16 + spriteX%
NEXT
I am making a layering system, but I can't seem to understand how I'm supposed to get the characters to draw between layers
I'll provide the code for anyone who thinks they can help.
I've marked out the problem area's, and places where I think could use optimization.
verticalVal% = cam.y
tileX% = cam.x \ 16 'this division is by 16 and 12, always, so it stands to reason that it can be made faster somehow.
tileY% = verticalVal% \ 12
mapElem% = tileY% * 100 + tileX%
spriteX% = cam.x MOD 16 'the MOD command is a bit slow, I'm wondering what I can do here.
spriteY% = cam.y MOD 12
spriteElem% = spriteY% * 16 + spriteX%
FOR screenY% = 0 TO 192
offset& = buffoff% + screenY% * 238& + 4
FOR screenX% = 0 TO 238
SELECT CASE picl2%(mapl2%(mapElem%), spriteElem%)
CASE 0
POKE offset&, pic%(map%(mapElem%), spriteElem%)
CASE IS <> 0
'NPC's and monsters must somehow draw here. I find
the most trouble with this, because they must draw there pixels
with the map scanning pixel.
POKE offset&, picl2%(mapl2%(mapElem%), spriteElem%)
END SELECT
offset& = offset& + 1
spriteElem% = spriteElem% + 1
IF spriteElem% MOD 16 = 0 THEN 'again, the MOD command
spriteElem% = spriteElem% - 16
mapElem% = mapElem% + 1
END IF
NEXT
verticalVal% = verticalVal% + 1
tileY% = verticalVal% \ 12 again a division by an even number
mapElem% = tileY% * 100 + tileX%
spriteY% = spriteY% + 1
IF spriteY% = 12 THEN spriteY% = 0
spriteElem% = spriteY% * 16 + spriteX%
NEXT