Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 3 4 [5]

Author Topic: ASCII Lab  (Read 7482 times)

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: ASCII Lab
« Reply #60 on: January 15, 2010, 12:23:49 am »

You need the background black and green text.

That's what I'm trying to move away from.  ;)
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

Bricks

  • Bay Watcher
  • Because you never need one brick.
    • View Profile
Re: ASCII Lab
« Reply #61 on: January 15, 2010, 01:09:40 pm »

Eerr, you may already know of it, and I might not understand what your issue is, but have you looked at Bresenham's line algorithm?  It seems to be the standard raster line drawing algorithm, although it doesn't naturally allow for the double-width walls that most roguelikes require.
Logged
EMPATHY - being able to feel other peoples' stuff.

eerr

  • Bay Watcher
    • View Profile
Re: ASCII Lab
« Reply #62 on: January 15, 2010, 02:13:25 pm »

Eerr, you may already know of it, and I might not understand what your issue is, but have you looked at Bresenham's line algorithm?  It seems to be the standard raster line drawing algorithm, although it doesn't naturally allow for the double-width walls that most roguelikes require.
I think I just implemented my version by hand.
Code: [Select]
public static loc[] makeline(loc l, loc V)
        {
           

            double slope = ((double)l.X-V.X) / ((double)l.Y-V.Y);

            //int x =             
            int dx = (l.X - V.X);
            int absdx = Math.Abs(dx);
            int dy = (l.Y - V.Y);
            int absdy = Math.Abs(dy);
            int i;
            loc[] array;
            slope = (((double)dy) / ((double)dx));//dx/dy
            double altslope = (((double)dx) / ((double)dy));//dx/dy

            if (absdx > absdy)
            {
                array = new loc[absdx+1];

                if (dx <= 0)
                {
                    //i = dx;

                    for (i = dx; i <= 0; i++)
                    {
                        loc G;
                        G.X = i;
                        G.Y = (int)((double)i * slope -.5);

                        array[Math.Abs(i)] = G+V;

                    }
                    array[0] = V;
                    array[array.Length-1] = l;
               
                }
                else
                {
                    //absdx = dx;
                    for (i = 0; i <= absdx; i++)
                    {
                        loc G;
                        G.X = i;
                        G.Y = (int)((double)i * slope +.5);
                        array[i] = G+V;

                    }
                    array[0] = V;
                    array[array.Length - 1] = l;
                }
            }


            else
            {
                array = new loc[absdy+1];
                if (dy <= 0)
                {


                    for (i = dy; i <= 0; i++)
                    {
                        loc G;
                        G.Y = i;
                        G.X = (int)((double)i * altslope -.5);

                        array[Math.Abs(i)] = G+V;

                    }
                    array[0] = V;
                    array[array.Length - 1] = l;
                }
                else
                {
                    for (i = 0; i < absdy; i++)
                    {
                        loc G;
                        G.Y = i;
                        G.X = (int)((double)i * altslope +.5 );
                        array[i] = G+V;

                    }
                    array[0] = V;
                    array[array.Length - 1] = l;

                }

                //return Math.Abs(l.X - V.X);
            }

            return array;
        }

You can substitute point for loc without any changes if you sub
Code: [Select]
array[i] = G+V; for array[i].X = G.X+V.X; and array[i].Y = G.Y+V.Y;. I slowed down the algorithm further by operator overloading loc+loc. The last two points are copied over by hand. I am currently in fear of using mouse.x and mouse.y because I screwed up something which hung the computer. And then later the IDE crashed.


Actually, Bresenham's algorithm looks really good for making thick walls. Whenever the y increases, you either need an extra wall next to that point or at the point before.

Edit 2: Algorithm fixed for center-ness.
Edit 3: Algorithm fixed for further center-ness.
« Last Edit: January 15, 2010, 08:10:17 pm by eerr »
Logged

Bricks

  • Bay Watcher
  • Because you never need one brick.
    • View Profile
Re: ASCII Lab
« Reply #63 on: January 15, 2010, 06:52:28 pm »

Actually, Bresenham's algorithm looks really good for making thick walls. Whenever the y increases, you either need an extra wall next to that point or at the point before.

Good call, I didn't consider that.
Logged
EMPATHY - being able to feel other peoples' stuff.

eerr

  • Bay Watcher
    • View Profile
Re: ASCII Lab
« Reply #64 on: January 15, 2010, 08:28:20 pm »

Spoiler (click to show/hide)
Just my imagination. I failed to see the full black tip of the mouse properly against that rainbow background.
I changed it to dwarves and saw it fine.
« Last Edit: January 18, 2010, 06:11:13 pm by eerr »
Logged

Lightman

  • Bay Watcher
  • The groboclones are looking for you.
    • View Profile
Re: ASCII Lab
« Reply #65 on: January 17, 2010, 05:51:26 pm »

That's what I'm trying to move away from.  ;)

Fair enough :)

Binary demo added to the original post. It adds a few things.
Logged

eerr

  • Bay Watcher
    • View Profile
Re: ASCII Lab
« Reply #66 on: January 18, 2010, 06:47:54 pm »

Ok, I figured out what I want to make, finally.
Logged

eerr

  • Bay Watcher
    • View Profile
Re: ASCII Lab
« Reply #67 on: January 20, 2010, 11:29:08 pm »

And it has nothing to do with Dwarf fortress.
Logged

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: ASCII Lab
« Reply #68 on: February 21, 2010, 10:37:13 pm »

how's this going, lightman?

I never actually made myself the time to try it properly because I figured I didn't have time to fiddle with c# but that may change soon enough in april depending on the bosses in my chain of command :P

So... If this is still alive by then I might get involved for learning purposes.
Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.

eerr

  • Bay Watcher
    • View Profile
Re: ASCII Lab
« Reply #69 on: February 22, 2010, 01:44:14 pm »

Lightman has no time, nor does he have any time in the near future.

Though features for the lab like something new to do with images wouldn't be out of the question, I think.

The lab for drawing ASCII text is sufficiently completed to draw most every symbol in dwarf fortress, in a DIY manner.

I'm surprised more people haven't posted about using it actually.

Logged

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: ASCII Lab
« Reply #70 on: February 22, 2010, 02:20:05 pm »

This game itself is mostly meant to be a private project for friends based on the world and characters we've developed together, but I guess posting screens wouldn't be too egregious.


Spoiler (click to show/hide)

I'm planning to use elements of the source later in a more public project.
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: ASCII Lab
« Reply #71 on: February 23, 2010, 12:51:04 am »

That looks really nice.

I would like to see more of this.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream
Pages: 1 ... 3 4 [5]