Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMovementcat

Posted 25 June 2013 - 09:18 AM

Dear Guys,

 

i have a understanding Question it work now for me but i dont know why maybe you can help or why even the Problem occur's.

 

I have a TileMap with 32, 32 Tiles and a normal Camera Class that follows my Player and for the Editor it follow the Mouse, but there i had a Probleme the Mouse Position was incorrect so i did Invert the Matrix for my Mouse Position.

 

It worked fine, exept in the Display Region under 0,0 so -32,0 etc etc or -32,-32, or every negativ value. Hope you understand me since my English arent the best.

 

It was not much difference but the Cursor was just a bit off. So i will show you some Code maybe you know why this happens.

 

 

Camera.cs

 public void Update(IFocus focus)
        {
 
            if(_follow == true)
            center = focus.getFocus();
            _width = focus.getWidth() / 2;
            _height = focus.getHeight() / 2;

            transform = Matrix.CreateTranslation(new Vector3(-center.X, -center.Y, 0)) *
                Matrix.CreateRotationZ(_rotation) *
                Matrix.CreateScale(_zoom) *
                Matrix.CreateTranslation(new Vector3(view.Width / 2, view.Height / 2, 0));
        }
    }
}


my Input Manager 

mousePos.X = mouseState.X;
            mousePos.Y = mouseState.Y;
            mousePos = Vector2.Transform(mousePos, Matrix.Invert(cam.transform));

            if (mousePos.Y < 0)
            {
                mousePos.Y = mousePos.Y - 32;
            }

            if (mousePos.X < 0)
            {
                mousePos.X = mousePos.X - 32;
            }

            return mousePos;
        }

So here is a intresting Point, if i have this 2 If cases, everything ist fine but if i delete them my Cursor is off in negativ Display Values. But still fine in normal Display Regions.

 

And maybe its Interesting aswell here i "snap" the current Tile so that my Cursor is always Perfectly over a Tile its in my Editor.cs

 _cursorLocX = (int)(mousePos.X / _tileWidth) * _tileWidth;
 _cursorLocY = (int)(mousePos.Y / _tileHeight) * _tileHeight;

Thanks for reading, if you need any more Informations please let me know.

 

greetings Move


#7Movementcat

Posted 25 June 2013 - 09:17 AM

Dear Guys,

 

i have a understanding Question it work now for me but i dont know why maybe you can help or why even the Problem occur's.

 

I have a TileMap with 32, 32 Tiles and a normal Camera Class that follows my Player and for the Editor it follow the Mouse, but there i had a Probleme the Mouse Position was incorrect so i did Invert the Matrix for my Mouse Position.

 

It worked fine, exept in the Display Region under 0,0 so -32,0 etc etc or -32,-32, or every negativ value. Hope you understand me since my English arent the best.

 

It was not much difference but the Cursor was just a bit off. So i will show you some Code maybe you know why this happens.

 

 

Camera.cs

 public void Update(IFocus focus)
        {
 
            if(_follow == true)
            center = focus.getFocus();
            _width = focus.getWidth() / 2;
            _height = focus.getHeight() / 2;

            transform = Matrix.CreateTranslation(new Vector3(-center.X, -center.Y, 0)) *
                Matrix.CreateRotationZ(_rotation) *
                Matrix.CreateScale(_zoom) *
                Matrix.CreateTranslation(new Vector3(view.Width / 2, view.Height / 2, 0));
        }
    }
}


my Input Manager 

mousePos.X = mouseState.X;
            mousePos.Y = mouseState.Y;
            mousePos = Vector2.Transform(mousePos, Matrix.Invert(cam.transform));

            if (mousePos.Y < 0)
            {
                mousePos.Y = mousePos.Y - 32;
            }

            if (mousePos.X < 0)
            {
                mousePos.X = mousePos.X - 32;
            }

            return mousePos;
        }

So here is a intresting Point, ich i have this 2 If cases, everything ist fine but if i delete them my Cursor is off in negativ Display Values.

 

And maybe its Interesting aswell here i "snap" the current Tile so that my Cursor is always Perfectly over a Tile its in my Editor.cs

 _cursorLocX = (int)(mousePos.X / _tileWidth) * _tileWidth;
 _cursorLocY = (int)(mousePos.Y / _tileHeight) * _tileHeight;

Thanks for reading, if you need any more Informations please let me know.

 

greetings Move


#6Movementcat

Posted 25 June 2013 - 09:16 AM

Dear Guys,

 

i have a understanding Question it work now for me but i dont know why maybe you can help or why even the Problem occur's.

 

I have a TileMap with 32, 32 Tiles and a normal Camera Class that follows my Player and for the Editor it follow the Mouse, but there i had a Probleme the Mouse Position was incorrect so i did Invert the Matrix for my Mouse Position.

 

It worked fine, exept in the Display Region under 0,0 so -32,0 etc etc or -32,-32, or every negativ value. Hope you understand me since my English arent the best.

 

It was not much difference but the Cursor was just a bit off. So i will show you some Code maybe you know why this happens.

 

 

Camera.cs

 public void Update(IFocus focus)
        {
 
            if(_follow == true)
            center = focus.getFocus();
            _width = focus.getWidth() / 2;
            _height = focus.getHeight() / 2;

            transform = Matrix.CreateTranslation(new Vector3(-center.X, -center.Y, 0)) *
                Matrix.CreateRotationZ(_rotation) *
                Matrix.CreateScale(_zoom) *
                Matrix.CreateTranslation(new Vector3(view.Width / 2, view.Height / 2, 0));
        }
    }
}


my Input Manager 

mousePos.X = mouseState.X;
            mousePos.Y = mouseState.Y;
            mousePos = Vector2.Transform(mousePos, Matrix.Invert(cam.transform));

            if (mousePos.Y < 0)
            {
                mousePos.Y = mousePos.Y - 32;
            }

            if (mousePos.X < 0)
            {
                mousePos.X = mousePos.X - 32;
            }

            return mousePos;
        }

So here is a intresting Point, ich i have this 2 If cases, everything ist fine but if i delete them my Cursor is off in negativ Display Values.

 

And maybe its Interesting aswell here i "snap" the current Tile so that my Cursor is always Perfectly over a Tile

 _cursorLocX = (int)(mousePos.X / _tileWidth) * _tileWidth;
 _cursorLocY = (int)(mousePos.Y / _tileHeight) * _tileHeight;

Thanks for reading, if you need any more Informations please let me know.

 

greetings Move


#5Movementcat

Posted 25 June 2013 - 09:16 AM

Dear Guys,

 

i have a understanding Question it work now for me but i dont know why maybe you can help or why even the Problem occur's.

 

I have a TileMap with 32, 32 Tiles and a normal Camera Class that follows my Player and for the Editor it follow the Mouse, but there i had a Probleme the Mouse Position was incorrect so i did Invert the Matrix for my Mouse Position.

 

It worked fine, exept in the Display Region under 0,0 so -32,0 etc etc or -32,-32, or every negativ value. Hope you understand me since my English arent the best.

 

It was not much difference but the Cursor was just a bit off. So i will show you some Code maybe you know why this happens.

 

 

Camera.cs

 public void Update(IFocus focus)
        {
 
            if(_follow == true)
            center = focus.getFocus();
            _width = focus.getWidth() / 2;
            _height = focus.getHeight() / 2;

            transform = Matrix.CreateTranslation(new Vector3(-center.X, -center.Y, 0)) *
                Matrix.CreateRotationZ(_rotation) *
                Matrix.CreateScale(_zoom) *
                Matrix.CreateTranslation(new Vector3(view.Width / 2, view.Height / 2, 0));
        }
    }
}


my Input Manager 

mousePos.X = mouseState.X;
            mousePos.Y = mouseState.Y;
            mousePos = Vector2.Transform(mousePos, Matrix.Invert(cam.transform));

            if (mousePos.Y < 0)
            {
                mousePos.Y = mousePos.Y - 32;
            }

            if (mousePos.X < 0)
            {
                mousePos.X = mousePos.X - 32;
            }

            return mousePos;
        }

So here is a intresting Point, ich i have this 2 If cases, everything ist fine but if i delete them my Cursor is off in negativ Display Values.

 

And maybe its Interesting aswell here i "snap" the current Tile so that my Cursor is always Perfectly over a Tile

 _cursorLocX = (int)(mousePos.X / _tileWidth) * _tileWidth;
 _cursorLocY = (int)(mousePos.Y / _tileHeight) * _tileHeight;

Thanks for reading, if you need any more Informations please let me know.

 

greetings Move


#4Movementcat

Posted 25 June 2013 - 09:15 AM

Dear Guys,

 

i have a understanding Question it work now for me but i dont know why maybe you can help or why even the Problem occur's.

 

I have a TileMap with 32, 32 Tiles and a normal Camera Class that follows my Player and for the Editor it follow the Mouse, but there i had a Probleme the Mouse Position was incorrect so i did Invert the Matrix for my Mouse Position.

 

It worked fine, exept in the Display Region under 0,0 so -32,0 etc etc or -32,-32, or every negativ value. Hope you understand me since my English arent the best.

 

It was not much Differenz but the Cursor was just a bit off. So i will show you some Code maybe you know why this happens.

 

 

Camera.cs

 public void Update(IFocus focus)
        {
 
            if(_follow == true)
            center = focus.getFocus();
            _width = focus.getWidth() / 2;
            _height = focus.getHeight() / 2;

            transform = Matrix.CreateTranslation(new Vector3(-center.X, -center.Y, 0)) *
                Matrix.CreateRotationZ(_rotation) *
                Matrix.CreateScale(_zoom) *
                Matrix.CreateTranslation(new Vector3(view.Width / 2, view.Height / 2, 0));
        }
    }
}


my Input Manager 

mousePos.X = mouseState.X;
            mousePos.Y = mouseState.Y;
            mousePos = Vector2.Transform(mousePos, Matrix.Invert(cam.transform));

            if (mousePos.Y < 0)
            {
                mousePos.Y = mousePos.Y - 32;
            }

            if (mousePos.X < 0)
            {
                mousePos.X = mousePos.X - 32;
            }

            return mousePos;
        }

So here is a intresting Point, ich i have this 2 If cases, everything ist fine but if i delete them my Cursor is off in negativ Display Values.

 

And maybe its Interesting aswell here i "snap" the current Tile so that my Cursor is always Perfectly over a Tile

 _cursorLocX = (int)(mousePos.X / _tileWidth) * _tileWidth;
 _cursorLocY = (int)(mousePos.Y / _tileHeight) * _tileHeight;

Thanks for reading, if you need any more Informations please let me know.

 

greetings Move


#3Movementcat

Posted 25 June 2013 - 09:15 AM

Dear Guys,

 

i have a understanding Question it work now for me but i dont know why maybe you can help or why even the Problem occur's.

 

I have a TileMap with 32, 32 Tiles and a normal Camera Class that follows my Player and for the Editor it follow the Mouse, but there i had a Probleme the Mouse Position was incorrect to i did Invert the Matrix for my Mouse Position.

 

It worked fine, exept in the Display Region under 0,0 so -32,0 etc etc or -32,-32, or every negativ value. Hope you understand me since my English arent the best.

 

It was not much Differenz but the Cursor was just a bit off. So i will show you some Code maybe you know why this happens.

 

 

Camera.cs

 public void Update(IFocus focus)
        {
 
            if(_follow == true)
            center = focus.getFocus();
            _width = focus.getWidth() / 2;
            _height = focus.getHeight() / 2;

            transform = Matrix.CreateTranslation(new Vector3(-center.X, -center.Y, 0)) *
                Matrix.CreateRotationZ(_rotation) *
                Matrix.CreateScale(_zoom) *
                Matrix.CreateTranslation(new Vector3(view.Width / 2, view.Height / 2, 0));
        }
    }
}


my Input Manager 

mousePos.X = mouseState.X;
            mousePos.Y = mouseState.Y;
            mousePos = Vector2.Transform(mousePos, Matrix.Invert(cam.transform));

            if (mousePos.Y < 0)
            {
                mousePos.Y = mousePos.Y - 32;
            }

            if (mousePos.X < 0)
            {
                mousePos.X = mousePos.X - 32;
            }

            return mousePos;
        }

So here is a intresting Point, ich i have this 2 If cases, everything ist fine but if i delete them my Cursor is off in negativ Display Values.

 

And maybe its Interesting aswell here i "snap" the current Tile so that my Cursor is always Perfectly over a Tile

 _cursorLocX = (int)(mousePos.X / _tileWidth) * _tileWidth;
 _cursorLocY = (int)(mousePos.Y / _tileHeight) * _tileHeight;

Thanks for reading, if you need any more Informations please let me know.

 

greetings Move


PARTNERS