help with door position

This is a discussion on help with door position within the C++ Programming forums, part of the General Programming Boards category; ok right now im working on a roguelike. and i need to draw the room door. i have a class ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    196

    help with door position

    ok right now im working on a roguelike. and i need to draw the room door. i have a class called room which has the integer width and height as private ofcoarse and in main i have the object MyRoom. but i have the function for the doorposition which is
    Code:
    void room::DoorPosition(int DX,int DY)
    {
         DX = getWidth();
         DY = getBreadth();
         
         DoorPositionX = Width;
         DoorPositionY = DY;
         console.Draw(DoorPositionX,DoorPositionY,FloorTileASCII);
         }
    this would be all fine and good.. but i need the ROOM width and height.. so im looking for something like

    room.getWidth();
    room.getHeight();

    so what im looking for is a way to get the width and height of every room in the game without the hassle of

    room1.getwidth();
    room2.getwidth();

    etc etc,

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Why not outside Room?
    Code:
    console.Draw(myRoom.getWidth(), myRoom.getHeight(), FloorTileASCII);
    Or inside Room:
    Code:
    void room::Draw(Console& console) const
    {
        ....
        console.Draw(DoorPositionX, DoorPositionY, FloorTileASCII);
    }
    
    ...
    myRoom.Draw(console);
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21