another isometric query

ok, aside from the “don’t reinvent the wheel” bit, I am writing my own scroller.
I have spent a number of hours going over planetation by zparticle(fantastic and a great learning tool)
but wanted to do my own on a lesser scale.

Anyway, my problem is npc’s walking around.

I have my avatar centered on the canvas. I translate the background image ( a group of isometric tiles)
then draw each tile, then draw my avatar centered. the tranlate back to draw layovers(menus, stats, etc)

I am hopelessly lost on when, how where to draw the npcs. If an npc is at x=100, y=100(walking at y+1) and I scroll
the background, his location is affect by that scroll.

He still walks along the y axis at +1 per update, but is now two buildings over because of the scroll.

here is my process…

create tiles ans set at postitions starting at 0,0, aligning them properly for isometric look and feel.

then I get the map width and height and set the avatar at half of each(centered on map)

I then calc a translation tx and ty to tranlate the map so avatar is centered on canvas/screen.

When I scroll north(for example) I scroll all background images(tiles only right now) the appropriate
1up and 2over(from zoggles isometric schema). Each tiles location is updated(then drawn at the appropriate time)

I missed something somewhere in my code design and my npc’s scroll all over the place.

Any suggestions?

M

Sounds like you know this already but:

You need three coordinate systems
1> one for the location of an object inside of the map
2> one for the location of the map in the viewport.
3> one for the location of the viewport on the screen

So let’s say:

1> The maps upper left hand corner is drawn at 100,100 on the screen/viewport (vpx,vpy)
2> The visible area of the map (viewport) is 500x500 pixels on the screen (vpw,vph)
3> The coordinates inside of the map start at 0,0 in the upper left hand corner of the map (mx,my)
4> The map is 1000x1000 pixels (mw,mh)
5> The map is currently scrolled 10 pixels to the left and 10 pixels up (spx,spy) (the map coordinate 10,10 is at viewport coordinate 0,0 which is at screen coordinate 100,100)

If a character stands at mx=100, my=100 then it should be drawn at vpx+100-spx, vpy+100-spy.

I think that’s right, :slight_smile: I haven’t done anything with maps in a while.

[edit] that works for square map maybe not isometric but it should be close.

thanks, that was great. I seemed to have solved it. Now to some pixalation.

M