   Placing sprites in world coordinates
  Hello!  I'm having a hell of a time trying to figure out how to convert screen coordinates to world coordinates.  I finally have a decent working tile scrolling program.  I can grab any tile number "latch" the screen to it just fine, but when I try to place an object in the world, it just ends up scrolling with the screen.  I've tried many different combinations of pixels by tile or map dimensions and whatnot, but it hasn't worked out.  I'm just lost on this, and really wouldn't even bother asking if I didn't feel I had tried everything.  I've searched the forums, but most of what I am finding is concerning 3D stuff.  I'm not that advanced.  I really appreciate any help I can get.  I know it probably is something simple I am not doing correctly.Some things to mention:Using C++Using DirecXUsing regular square tilesThank you!   
  Try setting up some linear equations and assume axes stay aligned from world to screen space (no rotation).I.e.ScreenX = WorldX * ScaleX + OffsetXScreenY = WorldY * ScaleY + OffsetYThen you of course get WorldX = (ScreenX - OffsetX) / ScaleX, etc.Offset is the offset in pixels (so you can scroll screen). Also, if WorldX = 0 <=> ScreenX = 0 and the same for Y it helps a great deal. Furthermore, try sharing World coordinates for objects and tiles if movement isn't restricted to tiles. Otherwise, you need to add another transformation like WorldX = TileX * TileScaleX + TileOffsetX.Anyway, given these equations, it's trivial to find screen coordinates for objects in world and world coordinates for objects on screen.   ;  ugh.  I'm still not able to detach it from screen coordinates.  Just not figuring it out.  I had a tough time getting images to load and figuring out tiles in the first place, but they seem simple now compared to this, and I know when I get this worked out, it will seem so obvious as well.Thanks for the input, I'm going to keep working through different equations.  Can't do much until I am able to move beyond this point anyway.   ;  The way that I have solved this problem in my current project is thusly: my game objects don't know the difference between their "world" and "screen" coordinates. The tiles don't, either.Currently I have a "camera", which is nothing more than a rectangle, that can be moved through the world to see different parts of it. The most important thing I did was to enable my drawing functions to apply an "offset" to drawing coordinates. That way you can draw objects at their "world" coordinates, and if you apply the offset of your camera, then they will appear at their proper places.So, what you end up doing is something like this:* We're going to draw the scene  * Apply the offset of the camera to the graphics system    * Draw all of your tiles in the visible area at their "world" coordinates    * Draw all of your objects in the visible area at their "world" coordinates  * Un-apply the offset of the camera to the graphics system* We're done drawing one frame!I simply added two functions to my Graphics object, Vector2D getOffset() and void setOffset(Vector2D) to facilitate this. And then my drawing functions like drawImage(image, x, y) use the offset internally to draw things at the right place.If you implement it this way you only have to keep track of the camera's position and then apply it to the graphics system at the right time to draw everything in place.   ;  Long story short you kept your game objects in world coordinates and only displayed what the camera could see.The next step is to attach the camera to a player or object so the camera follows the target object.Just something to think about but may be cool. In 3d first person shooters sometimes the camera switches to an NPC or other player when you die and are waiting to respawn. I like to do this with 2d RPGs as well so that the camera can follow different NPCs in a cut scene as well.   ;  Yes, pretty much. That way the objects don't need to know about the camera, they just draw themselves where they are in the world and that's it. it really simplifies things from a coding perspective if you do it this way.   ;  I guess we are looking at improvising things rather than looking at who has done this first. Good that karnataka gov has taken such measures in the line of improvement. We appreciate it.Does anyone know where I can find deep technical information about smart cards?. I'm doing a report for the company I'm working for. smart card