Thanks to the Hippoman topic, I decided to post this.You did this just to piss me off didn't you...
I've written a simple C# .NET library that uses Direct X and handles 2D sprites, TTF text and provides a simple interface for keyboard and mouse input. I have a couple test projects that use it and I can post some examples/more info here.
It could be a quick way to write up an 'ASCII' game (it's all bitmaps, of course). By default, it uses a 16x16 tileset that I got for DF and can render any of the tiles in any colour combination for foreground/background. PNG transparency is supported, of course.
So, I'd like to know if anyone would be interested in this?
I made it because I've been thinking of throwing together an adventure-style game with the library. It might be fun to collaborate, if someone wants to do that.
Why C#?
C# uses C-style syntax, it provides very good performance, and it makes things much easier when compared with C/C++. If you're new to programming, it will definitely be easier and faster to learn.
Starting out
Starting a project is very simple. Just click on the template and it makes a default application:
(http://img5.imageshack.us/img5/1837/asciigame.jpg)
Hippoman:C I still wish it was actually in a language I knew...
More like, your thread sparked my interest in posting about a library I had written already. ;)
Well yes, but that'll be in a long while.We're not 7 years old, you don't have to get the last word in every dam time.
Well yes, but that'll be in a long while.We're not 7 years old, you don't have to get the last word in every dam time.
We know all of that already. We were kinda listening!Well yes, but that'll be in a long while.We're not 7 years old, you don't have to get the last word in every dam time.
I was simply stating to him that I wont be using his library becuase i wont be learning C# until a long time from now.
Plus due to my excessive boredom, I have a tendency to try to continue conversations long after they've ended.We know all of that already. We were kinda listening!Well yes, but that'll be in a long while.We're not 7 years old, you don't have to get the last word in every dam time.
I was simply stating to him that I wont be using his library becuase i wont be learning C# until a long time from now.
Furthermore, you probably know enough programming to handle the ASCII lab, though you might struggle a bit learning c# syntax the first week.
You should try spelunky.Plus due to my excessive boredom, I have a tendency to try to continue conversations long after they've ended.We know all of that already. We were kinda listening!Well yes, but that'll be in a long while.We're not 7 years old, you don't have to get the last word in every dam time.
I was simply stating to him that I wont be using his library becuase i wont be learning C# until a long time from now.
Furthermore, you probably know enough programming to handle the ASCII lab, though you might struggle a bit learning c# syntax the first week.
You should try spelunky.
It is awesome. Also made in gamemaker, so I find it a little inspirational.
Holy shit, c# is awesome.
Edit: Wait, do I need to write math. everytime I want to use
math.atan2()?
...by wrapping them up in a shorter function, and supposedly the compiler optimises to the same result as if I just typed out the dam thing by hand. Supposedly.
It complains about importing Grobo,
"GraphicsManager" does not exist in this context.
There is also a GroboLib that has a little exclamation point.
System.Console.WriteLine("What do you know? {1} contains {0}",sss,eee);sss and eee are strings, btw.
Also, if you want a major time waster,
look into "An Untitled Story".
Read to me the exact files you have in that directory.
I have tried both just extracting the first zip, and extracting both.
No diffrence.
public static void DrawASCIIText(int x, int y, string txt, Color col) {
x *= 16; y *= 16;
int drawPos = 0;
foreach(char c in txt) {
GraphicsManager.BlitASCII(x+drawPos, y, (byte)c, col);
drawPos += 16;
}
}
This is kind of hard to explain, but is there a function that prints text in the same way the BlitASCII prints a character?
BlitASCII uses the 16x16 characters and DrawText uses it's own font.
Edit: or maybe I will be simple and use objects...
Classes, because objects are much more convenient than goblin structures.Edit: or maybe I will be simple and use objects...
Classes (that's what you mean by 'objects', right?) would make more sense, probably, for what you are doing.
static void ProcessInput()
{
int previousx=player.X;
int previousy=player.Y;
int dx=0;
int dy=0;
int dother = 0;
// Is the player moving?
if (gamestate >= 0) // changed to operate when key is
{ // released, bug, player can still hold more than one
if (InputManager.IsPressed(Keys.Up))
keypressed_updown = 1;
else if (keypressed_updown == 1)
{ dy -= 1; keypressed_updown = 0; }
if (InputManager.IsPressed(Keys.Down))
keypressed_updown = -1;
else if (keypressed_updown == -1)
{ dy += 1; keypressed_updown = 0; }
if (InputManager.IsPressed(Keys.Left))
keypressed_leftright = -1;
else if (keypressed_leftright == -1)
{ dx -= 1; keypressed_leftright = 0; }
if (InputManager.IsPressed(Keys.Right))
keypressed_leftright = 1;
else if (keypressed_leftright == 1)
{ dx += 1; keypressed_leftright = 0; }
if (InputManager.IsPressed(Keys.Enter))
{
keypressed_leftright = 0;
keypressed_updown = 0;
keypressed_enter = 1;
}
else
{
if (keypressed_enter > 0) { }
keypressed_enter = 0;
dother = 1;
}
if (dy == 0 & dx == 0 & dother == 0)
{
}
else
{
player.X += dx;
player.Y += dy;
goblin h;
for (int i = 0; i < goblins.Length; i++)// player kills goblins
{
h = goblins[i];
if ((h.loc.X == player.X) & (h.loc.Y == player.Y))
{
h.setx(-1);
h.sety(-1);
h.alive = -1;
score++;
}
}
//if ((x == playerx) & (y == playery))
// Keep the player on the screen
if (player.X < 0) player.X = 0;
else if (player.X * 16 > Video.width - 16) player.X = Video.width / 16 - 1;
if (player.Y < 0) player.Y = 0;
else if (player.Y * 16 > Video.height - 16) player.Y = Video.height / 16 - 1;
if (!(previousx - player.X == 0) || !(previousy - player.Y == 0))
gamestate = goblin.update(player.X, player.Y, goblins);
}
}
}
}/*I'm not even sure where the indents are in my body. :(
Cancer of the colon has spread to become cancer of the indents
>.<
So lightman, you mentioned something about cooperating on a game?
Why do you keep using the players location in terms of x +- 16?Because it's a test/show project, and doesn't need a complicated tile setup. :P
I mean, I know it draws that directly to the screen at those positions, but is it really necessary?
Because it's a test/show project, and doesn't need a complicated tile setup. :P
Also, You won't be sharing code directly with me, which blows. Repurposing/reusing code is slow and barely worth it. Though as examples they work pretty well.
Though you seem intent on making code bits, so for suggestions:
Ehhh, Forget it.
I'm in ur library, usin ur code.
And then ASCII Lab became an easily modifiable high-end console emulator.
My mouse doesn't show up, but it's there.
You need the background black and green text.
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 (http://en.wikipedia.org/wiki/Bresenham%27s_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.
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;
}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.
That's what I'm trying to move away from. ;)