1. Collision Detection.

Warning: Fixed width font required to see the 2d MAP.

I am working with Cells and SubCells.
Take for example the following tiny 2D map.

<PRE>--Vain attempt to force fixed width. :)
1234567
#######
#  #  #
## # ##
#  #  #
# ### #
#     #
#######

</PRE>

Every # is a wall and every space is open floor.

Each # and space is a cell.
Each cell is represented as taking up 4x4 SubCells.
Thus, CellSize = 4.
In other words.  The above map is internally represented
as this next map.

<PRE>--Vain attempt to force fixed width. :)

############################
############################
############################
############################
####        ####        ####
####        ####        ####
#### p      ####        ####
####        ####        ####
########    ####    ########
########    ####    ########
########    ####    ########
########    ####    ########
####        ####        ####
####        ####        ####
####        ####        ####
####        ####        ####
####    ############    ####
####    ############    ####
####    ############    ####
####    ############    ####
####                    ####
####                    ####
####                    ####
####                    ####
############################
############################
############################
############################

</PRE>

Within each cell a player can in any one of 16 places.
I use {x,y} to represent the position of a player.
player positions are zero based.
There is a 'p' in the above map.  It's {x, y} value is
{6, 7}..  this means that
x = 6 -- and
y = 7

I calculate positions as follow:
--Actually, I use an optimized set of equivalent calculations

XCell = floor(x/CellSize)
YCell = floor(y/CellSize)
XSubCell = x - (XCell * CellSize)
YSubCell = y - (YCell * CellSize)

Keep in mind that the player can make diagonal moves.
My goal is to have the player navigate the maze a bound by
the walls.  My current collision detection works quite well
but is apparently flawed.

        Lucius L. Hilley III
        lhilley at cdc.net
+----------+--------------+--------------+
| Hollow   | ICQ: 9638898 | AIM: LLHIII  |
|  Horse   +--------------+--------------+
| Software | http://www.cdc.net/~lhilley |
+----------+-----------------------------+

new topic     » topic index » view message » categorize

2. Re: Collision Detection.

On Sun, 23 Apr 2000 17:18:10 -0400, Lucius L. Hilley III <lhilley at CDC.NET>
wrote:

><PRE>--Vain attempt to force fixed width. :)
>
>############################
>############################
>############################
>############################
>####        ####        ####
>####        ####        ####
>#### p      ####        ####  <<<<< ------------------------------<<
>####        ####        ####        Lucius: Shouldn't these walls
>########    ####    ########                be 4 wide ?
>########    ####    ########
>########    ####    ########
>########    ####    ########
>####        ####        ####
>####        ####        ####
>####        ####        ####
>####        ####        ####
>####    ############    ####
>####    ############    ####
>####    ############    ####
>####    ############    ####
>####                    ####
>####                    ####
>####                    ####
>####                    ####
>############################
>############################
>############################
>############################

new topic     » goto parent     » topic index » view message » categorize

3. Re: Collision Detection.

Bernie,  It should be obvious that the walls "#" are 4 wide.  Are you
referring to the spaces?

    If the walls you are pointing to aren't aligning with the walls above
them, then you aren't using a fixed width font.  Please try saving the
message to your desktop and loading the message using
Notepad.  NOT Write.  Notepad always uses a fixed width font.

    You could also try changing your Email program to use Courier, Courier
New, Lucinda Console, Fixedsys,
or any other fixed width font.


        Lucius L. Hilley III
        lhilley at cdc.net
+--------------+--------------+
| ICQ: 9638898 | AIM: LLHIII  |
+--------------+--------------+
| http://www.cdc.net/~lhilley |
+-----------------------------+
> ---------------------- Information from the mail
header -----------------------
> Sender:       Euphoria Programming for MS-DOS
<EUPHORIA at LISTSERV.MUOHIO.EDU>
> Poster:       Bernie Ryan <xotron at BUFFNET.NET>
> Subject:      Re: Collision Detection.
> --------------------------------------------------------------------------
-----
>
> On Sun, 23 Apr 2000 17:18:10 -0400, Lucius L. Hilley III <lhilley at CDC.NET>
> wrote:
>
> ><PRE>--Vain attempt to force fixed width. :)
> >
> >############################
> >############################
> >############################
> >############################
> >####        ####        ####
> >####        ####        ####
> >#### p      ####        ####  <<<<< ------------------------------<<
> >####        ####        ####        Lucius: Shouldn't these walls
> >########    ####    ########                be 4 wide ?
> >########    ####    ########
> >########    ####    ########
> >########    ####    ########
> >####        ####        ####
> >####        ####        ####
> >####        ####        ####
> >####        ####        ####
> >####    ############    ####
> >####    ############    ####
> >####    ############    ####
> >####    ############    ####
> >####                    ####
> >####                    ####
> >####                    ####
> >####                    ####
> >############################
> >############################
> >############################
> >############################
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu