Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Towers

121 views
Skip to first unread message

sirpigme...@googlemail.com

unread,
Feb 26, 2013, 4:23:06 AM2/26/13
to
Anybody know of any ASCII roguelikes with round towers in them? I'm writing a game where you climb a sorcerers tower and i'd like to see how someone else might have done it... in case i'm missing some obvious, simple way to do it.
cheers

Mikera

unread,
Feb 26, 2013, 5:42:42 AM2/26/13
to
On Tuesday, 26 February 2013 17:23:06 UTC+8, sirpigme...@googlemail.com wrote:
> Anybody know of any ASCII roguelikes with round towers in them? I'm writing a game where you climb a sorcerers tower and i'd like to see how someone else might have done it... in case i'm missing some obvious, simple way to do it.
>
> cheers

The algorithm is pretty easy: just test if (x-cx)^2 + (y-cy)^2 < r^2 for a tower with centre (cx,cy) and radius r. This defines which squares are in the interior of the tower. You can then make a "wall" around the interior space of the tower by filling outwards one square in all directions.

For a tower which slowly gets thinner as you climb upwards, just decrease r on each level.

sirpigme...@googlemail.com

unread,
Feb 26, 2013, 9:02:31 AM2/26/13
to
Cheers, I was looking at circle algorithm stuff and that's the best i've seen it explained so far. Although i think I may need an ellipse instead of a circle because with my ASCII graphics each 'square' is taller than it is wide, (that is so # walls join up better horizontally) so a circle would come out looking a bit flat. I'm sure I can tweak it...
I'm just using a data file with the the walls and floor tiles marked out at the moment, it works fine but its a bit inelegant...
I don't know if i'll be changing the towers size or not yet as the hero is going to be able to scale the walls... but its good to have this stuff in the bag if I need it.

oot...@hot.ee

unread,
Feb 26, 2013, 3:01:38 PM2/26/13
to
On Tuesday, 26 February 2013 16:02:31 UTC+2, sirpigme...@googlemail.com wrote:
> On Tuesday, February 26, 2013 10:42:42 AM UTC, Mikera wrote:
> > On Tuesday, 26 February 2013 17:23:06 UTC+8, sirpigme...@googlemail.com wrote:
> >
> > > Anybody know of any ASCII roguelikes with round towers in them? I'm
> > > writing a game where you climb a sorcerers tower and i'd like to see
> > > how someone else might have done it... in case i'm missing some obvious,
> > > simple way to do it.
> >
> > The algorithm is pretty easy: just test if (x-cx)^2 + (y-cy)^2 < r^2 for
> > a tower with centre (cx,cy) and radius r. This defines which squares are
> > in the interior of the tower. You can then make a "wall" around the
> > interior space of the tower by filling outwards one square in all
> > directions.
> >
> > For a tower which slowly gets thinner as you climb upwards, just decrease
> > r on each level.
>
> Cheers, I was looking at circle algorithm stuff and that's the best i've
> seen it explained so far. Although i think I may need an ellipse instead of
> a circle because with my ASCII graphics each 'square' is taller than it is
> wide, (that is so # walls join up better horizontally) so a circle would
> come out looking a bit flat. I'm sure I can tweak it...


Here is code to fill elliptic area:

w2 = width*width;
h2 = height*height;
h2w2 = h2*w2;
for ( int y=-height; y<=height; y++ )
{
y2w2 = y*y*w2;

for ( int x=-width; x<=width; x++ )
{
if ( x*x*h2 + y2w2 <= h2w2 )
setInside(center.x+x, center.y+y);
}
}

Here is code that tests if point is inside elliptic area:

x = center.x - point.x;
y = center.y - point.y;
if(x*x*height*height+y*y*width*width <= height*height*width*width)
return true;

> I'm just using a data file with the the walls and floor tiles marked out
> at the moment, it works fine but its a bit inelegant...

If it works fine then why to repair it?

> I don't know if i'll be changing the towers size or not yet as the hero
> is going to be able to scale the walls... but its good to have this stuff
> in the bag if I need it.

Full bag is always good ... indeed. ;)

sirpigme...@googlemail.com

unread,
Feb 27, 2013, 2:59:50 AM2/27/13
to
Thanks i'll wire that bad boy in!
I don't know if its a good or a bad habit but i tend to spend five minutes writing code that does the job fine and then several hours trying to make it better...

Gerry Quinn

unread,
Feb 27, 2013, 6:23:04 AM2/27/13
to
In article <3305d8a9-eaac-451a...@googlegroups.com>,
sirpigme...@googlemail.com says...
> On Tuesday, February 26, 2013 10:42:42 AM UTC, Mikera wrote:
> > On Tuesday, 26 February 2013 17:23:06 UTC+8, sirpigme...@googlemail.com wrote:
> >
> > > Anybody know of any ASCII roguelikes with round towers in them? I'm writing a game where you climb a sorcerers tower and i'd like to see how someone else might have done it... in case i'm missing some obvious, simple way to do it.
> >

> > For a tower which slowly gets thinner as you climb upwards, just decrease r on each level.
>
> Cheers, I was looking at circle algorithm stuff and that's the best i've seen it explained so far. Although i think I may need an ellipse instead of a circle because with my ASCII graphics each 'square' is taller than it is wide, (that is so # walls join up better horizontally) so a circle would come out looking a bit flat. I'm sure I can tweak it...
> I'm just using a data file with the the walls and floor tiles marked out at the moment, it works fine but its a bit inelegant...
> I don't know if i'll be changing the towers size or not yet as the hero is going to be able to scale the walls... but its good to have this stuff in the bag if I need it.

Or you could use a square tower - with wrapping around the corners if
need be.

[And if corners are obstacles, that could be tactically significant too,
if we assume that the player character climbs out some windows and in
others, as i am imagining).

- Gerry Quinn

sirpigme...@googlemail.com

unread,
Feb 27, 2013, 1:02:09 PM2/27/13
to
On Tuesday, February 26, 2013 9:23:06 AM UTC, sirpigme...@googlemail.com wrote:
> Anybody know of any ASCII roguelikes with round towers in them? I'm writing a game where you climb a sorcerers tower and i'd like to see how someone else might have done it... in case i'm missing some obvious, simple way to do it.
>
> cheers

I've thought of doing a square tower a few times... It would be alot easier, everything i've tried so far has been 10 times the work because of the roundness... but I think i'll hack on until I find a problem I can't fix or get advice for... I guess i'm just an old fashioned masochist!

Yeah hes definitely gonna be doing some climbing out of window stuff... batting off flying enemies as he goes... I also thought of making different wall sections harder to climb or slime covered or something... That way he can slip down...

paul-d...@sbcglobal.net

unread,
Feb 28, 2013, 11:06:43 AM2/28/13
to
Consider a hex grid if you want round towers. If you're doing ASCII you
can get a pretty good hex grid by doing double-character map cells. Also
I've found that a simple algorithm where you draw walls from the center
of a circular room to the edge of the room along grid axes does a pretty
good job of subdividing rooms. It would look something like the picture
below, where [] is a door. Looks better with a slightly bigger room
though.

######
####..##
##..[]..##
##...#####
##......##
##....##
######

sirpigme...@googlemail.com

unread,
Mar 1, 2013, 2:15:05 AM3/1/13
to
Yeah I could see that looking pretty cool...
I'm hoping to do a follow up to this game with six different towers spread over a large game map... with each tower being generated a different way...
I'm probly going to stick with the data file version for now as i've figured out a way to add random balconies with it...

I've got a java console version on the go at the moment, with rooms and doors and stairs for the little @ to wonder about... i'll put it up soon and see what people think.

I'll probly do a C++ windows console version at some point too...
0 new messages