Jump to content
  • Advertisement

Edu82

Member
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Edu82

  • Rank
    Newbie

Personal Information

  • Interests
    Programming
  1. Hi! I need a way to convert screen coordinates obtained from mouse clicks to world coordinates in my 2D game. To create a zoom effect controlled by the user, before drawing a model, I will scale all of it's points by a world scale value. The screen origin (0,0) is at the top left corner while the world has it's center (0,0) at the center of the screen (screen width/2, screen height/2). I need a function to convert the coords obtained by mouse clicks (screen coords) to the corresponding scaled-world coordinates, so that I can determine what world element is clicked by the user in this scaled world. None of my approaches worked as required and unfortunately none of the found solutions where aplicable to my case. This is a very simple example JS Bin: https://jsbin.com/rifutaboce/3/edit?html,output Use the mouse wheel to zoom in/out Click on the screen to set a point Thanks!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!