PDA

View Full Version : DxDraw Surface and DXSpriteEngine



hammer
09-04-2004, 12:34 PM
i am trying to create a code in which when a unit (in turn based strategy) is attacked and when from his life is drained the drained amount to be displayed above it for a couple a seconds.

so my idea was after the damage calculations to display a text using the DxDraw Canvas above the unit but i couldnt do it because i cant get the coordinates of the unit on the screen the only coordinates i have are his place in the map which arent any good right about now cous the canvas displays the text only in the visible part of the screen and coordinates like 1000 5000 arent in the visible part of the screen. (i know the explanation isnt very good but i cant do it better hope you understand what i mean).

so thats my problem right about now

Traveler
09-04-2004, 01:27 PM
If your units are actually tiles (or something alike) then you need to take the tile coordinates and multiply them with the tileheight and -width. Then substract this value from the scrolling offset and you're set.

For example,
Your tiles are 32x32
The target tile = at 142,227
your scrolloffset = 4112, 6930

32*142= 4544
32*227= 7264

4544 - 4112 = 432
7264 - 6930 = 334


If this is not correct then show us of code, it might explain better what you have and how to deal with it.

hammer
09-04-2004, 08:58 PM
omg i cant believe that the solution is soo simple i think i need a rest .....
anyway thanks Traveler your idea worked perfectly

Traveler
10-04-2004, 11:00 AM
No problem at all. :D