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 8003863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:45:49+00:00 2026-06-04T16:45:49+00:00

I have a function that sets a draw-state for a specific tile given another

  • 0

I have a function that sets a draw-state for a specific tile given another tile. The tile that’s draw state is going to change compares tiles that are surrounding it and then updates accordingly. I’ll try to illustrate that below

[b] [b] [a]
[b] [a] [a]
[a] [a] [a]  where a = sand && b = water

when a detects that b is bordering it, it must update its draw-state. So I have a function that works for an upper case, lower case, left case, and right case. I now need to modify that function so it can handle a left-right case, upper-right case, lower-right case, etc. etc. Here is my function

public override void CompareBorderingTiles(Tile T)
    {
        if (T is Water)
        {
            float leftBound = location.X - (Tile.TileWidth * Tile.TileScale);
            float rightBound = location.X + (Tile.TileWidth * Tile.TileScale);
            float upperBound = location.Y - (Tile.TileHieght * Tile.TileScale);
            float bottomBound = location.Y + (Tile.TileHieght * Tile.TileScale);
            if (T.GridLocation.X == leftBound)
            {
                drawstate = DrawState.Left;
            }
            if (T.GridLocation.X == rightBound)
                drawstate = DrawState.Right;
            if (T.GridLocation.Y == upperBound)
                drawstate = DrawState.Upper;
            if (T.GridLocation.Y == bottomBound)
                drawstate = DrawState.Lower; 
        }

        base.CompareBorderingTiles(T);
    }

It should be pretty explanatory as to why i’d want to break out of this function, or maybe not. Basically I have an enum which tells me what my draw-state is (drawstate is the enum).
Can anybody tell me if I can set that correct draw state and then get out of my function?

  • 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-06-04T16:45:51+00:00Added an answer on June 4, 2026 at 4:45 pm

    Just use a return statement where you want to end:

    return;
    

    So, in your code you could do:

    public override void CompareBorderingTiles(Tile T)
    {
        if (T is Water)
        {
            float leftBound = location.X - (Tile.TileWidth * Tile.TileScale);
            float rightBound = location.X + (Tile.TileWidth * Tile.TileScale);
            float upperBound = location.Y - (Tile.TileHieght * Tile.TileScale);
            float bottomBound = location.Y + (Tile.TileHieght * Tile.TileScale);
            if (T.GridLocation.X == leftBound)
            {
                drawstate = DrawState.Left;
                return;
            }
            if (T.GridLocation.X == rightBound)
            {
                drawstate = DrawState.Right;
                return;
            }
            if (T.GridLocation.Y == upperBound)
            {
                drawstate = DrawState.Upper;
                return;
            }
            if (T.GridLocation.Y == bottomBound)
            {
                drawstate = DrawState.Lower; 
                return;
            }
        }
    
        base.CompareBorderingTiles(T);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help with my C code. I have a function that sets a
So I have function that formats a date to coerce to given enum DateType{CURRENT,
I have a function that sets a vector to a string, copies a Sweave
I have the following code in my codebehind Page_Load function that sets the default
I have a function that sets display=none on a table row. At the end
I have a function that sets a timer, and calls itself back upon expiration
I have the following c++ function that sets an integer using a string. #include
I have written a function init-set-key-mappings that sets all the global keys in .emacs
I have a function that sets and unset's a $_SESSION variable depending on what
I have a function that sets text input's to whenever they are clicked/focused on.

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.