oyyou's Profile User Rating: -----

Reputation: 28 Craftsman
Group:
Active Members
Active Posts:
196 (0.11 per day)
Joined:
26-April 10
Profile Views:
5,956
Last Active:
User is offline Mar 26 2015 09:16 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Icon   oyyou has not set their status

Posts I've Made

  1. In Topic: Clear 'white' space on random tile map

    Posted 18 Mar 2015

    View PostSkydiver, on 17 March 2015 - 08:34 PM, said:

    Probably a minor bug, but all your doors seem to always be at (0,1) relative to the room.

    Also, you probably want to do something like:
    enum Tile
    {
        Floor,
        Wall,
    };
    
    Tile [,] map = new Tile[100,100];
    
    


    You're right, they all like that! I must have turned my random off for whatever reason (I haven't got the code on hand), I'll give that a look later.

    I do have an enum setup but I see what you're saying and I didn't even consider doing it like that. Thanks!
  2. In Topic: Clear 'white' space on random tile map

    Posted 17 Mar 2015

    Done.

    Okay. So I was here is what I ended up doing

    1. Add a border around the map.
    2. Place a random variety of rooms around the dungeon.
    3. Remove one block from the walls of the rooms (a door).
    4. Looped through all the rooms, and used A* pathfinding to connect a path between any 2 rooms that don't have their own path.
    5. Filled in all my empty 'nodes' with my floor texture.

    Attached File  Untitled.png (380.97K)
    Number of downloads: 1

    Bug:
    It's possible to get an instance were there is a segregated area of the dungeon. But that's okay.
  3. In Topic: Clear 'white' space on random tile map

    Posted 14 Mar 2015

    View PostLaughingBelly, on 14 March 2015 - 05:42 PM, said:

    An image of what you expect the output to look like might help.

    Assuming you want to keep the outside boundary straight, you could walk through each brown line from one end to find all lines that do not have a wall in them. If you find such line, fill it with walls. If you want to keep a hallway around each entire room, you would have to look ahead one more line before deciding to fill that line.


    I've just tried something like that and ended up with the below image

    Which I don't think looks too bad.

    If I don't find a better solution within tomorrow, I'll leave it for now and implement other aspects of the game.
    But we'll have to see.

    // Attempt at cleanup
          for (int y = 1; y < MAP_HEIGHT - 1; y++)
          {
            for (int x = 1; x < MAP_WIDTH - 1; x++)
            {
              bool draw = true;
    
              foreach (Room room in rooms)
              {
                if (room.Intersects(x, y))
                {
                  draw = false;
                  continue;
                }
              }
    
              if (draw)
              {
                int w = 0;
                int h = 0;
                int r = random.Next(0, 2);
    
                if (r == 0)
                {
                  for (int i = x; i < MAP_WIDTH - 1; i++)
                  {
                    if (HasEmptyNeighbours(i, y))
                    {
                      w++;
                    }
                    else
                    {
                      break;
                    }
                  }
    
                  for (int i = x; i < x + w; i++)
                  {
                    map[y, i] = 1;
                  }
                }
                else
                {
                  for (int i = y; i < MAP_HEIGHT - 1; i++)
                  {
                    if (HasEmptyNeighbours(x, i))
                    {
                      h++;
                    }
                    else
                    {
                      break;
                    }
                  }
    
                  for (int i = y; i < y + h; i++)
                  {
                    map[i, x] = 1;
                  }
                }
    
                if (map[y, x] == 0 &&
                    map[y - 1, x] == 1 &&
                    map[y - 1, x - 1] == 0 &&
                    map[y, x - 1] == 0 &&
                    map[y + 1, x - 1] == 0 &&
                    map[y + 1, x] == 1 &&
                    map[y + 1, x + 1] == 0 &&
                    map[y, x + 1] == 0 &&
                    map[y - 1, x + 1] == 0) //map[y + 1, x + 1] == 0) Oops
                {
                  map[y, x] = 1;
                }
              }
            }
          }    
    
        private bool HasEmptyNeighbours(int x, int y)
        {
          return map[y, x] == 0 &&
                 map[y - 1, x] == 0 &&
                 map[y - 1, x - 1] == 0 &&
                 map[y, x - 1] == 0 &&
                 map[y + 1, x - 1] == 0 &&
                 map[y + 1, x] == 0 &&
                 map[y + 1, x + 1] == 0 &&
                 map[y, x + 1] == 0 &&
                 map[y + 1, x + 1] == 0;
                
        }
    
    
  4. In Topic: How to make a jumping animation

    Posted 29 Oct 2014

    Nope. No. No.

    public class Animation
    {
      Texture2D texture;
      public Vector2 Position; // Because I'm too lazy to put in ctor
      int frameWidth;
      int frameHeight;
      int frameCount;
      int xPos;
      float timer = 0;
      public bool IsActive;
    
      public Animation(Texture2D texture, int frameWidth, int frameHeight)
      {
        this.texture = texture;
        this.frameWidth = frameWidth;
        this.frameHeight = frameHeight;
        this.frameCount = texture.Width / frameWidth;
      }
    }
    
    public void Update(GameTime gameTime)
    {
      if(!IsActive)
        return;
    
      timer += (float)gameTime.TotalElapsedTime.TotalSeconds; // Something like that. I don't have XNA on me right now
    
      if(timer >= 0.2f)
      {
        timer = 0;
        xPos += frameWidth;
        if(frameWidth * xPos > frameCount - 1)
        {
          xPos = 0;
        }
      }
    }
    
    public void Draw(SpriteBatch spriteBatch, bool right)
    {
      if(!IsActive)
        return;
    
      SpriteEffects effect = SpriteEffects.None;
      if(right)
        effect = SpriteEffects.FlipHorizontally;
    
      spriteBatch.Draw(texture, Position, new Rectangle(xPos, 0, frameWidth, frameHeight), Color.White, 0, new Vector2(0, 0), 1f, effect, 0);
    }
    
    


    Game Class
    Animation walk, jump;
    
    LoadContent
    {
      walk = new Animation(Content.Load<Texture2D>("WalkAnimation"), 10, 10);
      jump = new Animation(Content.Load<Texture2D>("JumpAnimation"), 10, 10);
    }
    
    Update
    {
      if(walking)
      {
        walk.IsActive = true;
        jump.IsActive = false;
      } else if(jumping)
      {
        walk.IsActive = false;
        jump.IsActive = true;
      }
    
      walk.Update(gameTime);
      jump.Update(gameTime);
    }
    
    Draw
    {
      spriteBatch.Begin();
      walk.Draw(spriteBatch);
      jump.Draw(spriteBatch);
      spriteBatch.End();
    }
    
    


    A crude implementation, but much better than whatever you've got going on.
    http://www.youtube.c...h?v=41xnVjJsh7M
  5. In Topic: DispatcherTimer - Seconds gone by

    Posted 28 Oct 2014

    View PosttlhIn`toq, on 28 October 2014 - 04:16 PM, said:

    Lets talk about some clean-up.

    A double named "Timer". Really? It isn't a timer is it? How about naming it "SecondsRemaining" so its named what its for?

    Each GameButton instance has its own DispatchTimer. Hmmm... That means they could all be working out of sync with each other if their timers start and stop independently. Is that intentional and needed?

    Personally I'd make one Program scoped timer and have it raise a "HeartBeat" event every 1000ms. That will give you a Heartbeat event every one 1 second that all other classes can sync on. Your GameButton class can subscribe to the event and just count down without having the overhead of its own timer. More important it should be a thread of its own so it isn't thrown off by lots of activity on a shared thread as you are now.

    This is WPF so don't carry over bad WinForms habits like this:
    border.Visibility = System.Windows.Visibility.Collapsed;
    


    Bind the Visibility to the CoolDown property using a converter. It should all happen in XAML and none of this should be happening in the code-behind. When CoolDown is true the control is visible, when CoolDown is false the control is Collapsed: All with no C# code behind.

    Same problem with this:
    textBlock.Text = string.Format("{0:N2}", (timer));
    

    You don't set the text in the code behind, you bind the text to a property such as "string TimerStatus". Then you update the property but you DO NOT directly affect the GUI items from the code behind: It totally violated the foundation concept of WPF binding to object values.

    I suggest you take some time to read up on WPF concepts. Because what you have here is badly formed WinForms design, that just happens to be using WPF to create the GUI - but in no way would this be considered an actual WPF application.


    Hey, man. I appreciate the advice, and I'm sure I will listen to some of it, but the stuff you are mentioning aren't big deals in the grand scheme of things.
    I've never managed to finish a project because I want to have 'perfect' code. Yes, I know I'm using some bad habits from forms when I could be binding, but I spent 3 days trying to create my button through a style, and for the life of my couldn't do it.

    By the end of the project I may come back and sort the little things out, but for now I just want to finish and hopefully (fingers crossed) release it.

    As for the "SecondsRemaining" in the button. I do want them working independently.

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Programming Languages:
C#, C++, Java

Contact Information

E-mail:
Click here to e-mail me

Friends

Comments

Page 1 of 1
  1. Photo

    Shinobi411 Icon

    23 Feb 2013 - 19:52
    Hey, I just saw your post about looking for a project. I might have just the thing but are you looking to deal with strictly xna? My team and I are currently working between Unity and Indielib. If you'd like some more information feel free to email us at Ondayo.Studios@me.com That way we will be able to discuss in further detail if you are up to helping us out. We would greatly appreciate ...
Page 1 of 1