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

Reputation: 28 Craftsman
Group:
Active Members
Active Posts:
198 (0.09 per day)
Joined:
26-April 10
Profile Views:
6,606
Last Active:
User is offline Dec 18 2015 08:02 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: if condition, multiple options

    Posted 18 Dec 2015

    Yeah, there is that, I just wish I there was something implemented already, or maybe something in the .Net framework like the below for each of the value types in C#.. But I don't know!
    public static bool Equals(this string value, params string[] values)
    {
     return values.Contains(value);
    }
    
    
  2. 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!
  3. 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: 9

    Bug:
    It's possible to get an instance were there is a segregated area of the dungeon. But that's okay.
  4. 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;
                
        }
    
    
  5. 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

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 [email protected] 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