Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:27:37+00:00 2026-05-31T01:27:37+00:00

Normally to set a boundary at a certain area, I would implement something like:

  • 0

Normally to set a boundary at a certain area, I would implement something like:

if(player.X > 400){

   player.X = 400;

}

This acts as though there is a vertical line at X=400, blocking movement beyond that. I’m wondering how I would implement at boundary for an area that is at a slant or diagonal rather than vertical/horizontal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:27:38+00:00Added an answer on May 31, 2026 at 1:27 am

    Hope I answer your question instead of making assumptions about what you are trying to achieve and suggesting a physics engine.

    Anyways I would suggest using a line equation and the MathHelper.Clamp function

    y = mX + b; // Line equation
    x = (y - b) / m
    

    So now you can get the x boundary for the y value of your Player

    MathHelper.Clamp(Player.X, min, (Player.Y - b) / m) 
    

    Or the x boundary from the y value of you Player

    MathHelper.Clamp(Player.Y, min, (m * Player.X) + b)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Normally you can do something like this for properties: public String s {get; set;
With AutoEventWireUp set to false, I would normally set a Page_Finalize like this: Include(Self.LoadComplete,
Is there a way to set the microphone volume in C# (normally done in
If I have a table of a hundred users normally I would just set
Normally you can do this: <select size=3> <option>blah</option> <option>blah</option> <option>blah</option> </select> And it would
Normally when using VMWare Server 1.0.7 you are asked if you would like to
I would normally set an instance variable in my controller, but I am unit
I normally use this step to set up records with factory_girl: Given /^the following
The WinForms ProgressBar control allows its foreground color to be set. While this normally
The baudrate is normally set to one of the specified values, like 9600, 56k

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.