Thread: Trying to start a roguelike

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Location
    CA, USA
    Posts
    466
    Since you're using Win 32 API here's a simple func you can use to resize the console buffer size.
    You should be aware that nothing stops the user from manually resizing the console buffer size after you run this function.
    I searched for a boolean flag or a setter function that allows the programmer to lock the size but I was unable to find anything.
    If anyone else knows of a way, I'd be happy to hear it.

    Code:
    #include <windows.h>
    
    int main()
    {
        setConsoleSize(80, 25);
        system("pause");
    }
    
    int setConsoleSize(int width, int height)
    {
        HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
        COORD scr_dim;
        
        scr_dim.X = width;
        scr_dim.Y = height;
    
        SetConsoleScreenBufferSize(hOut, scr_dim);
    }
    Last edited by MacNilly; 09-18-2006 at 08:44 AM.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    15
    Thanks, that'll do for now, anyway. Here is part of the code I'm working on to randomly generate the dungeon:
    Code:
    void Dungeon_Gen()
    {
         int i;
         int j;
         int k;
         int l;
         int mem_i;
         int mem_j;
         int mem_k;
         int mem_l;
         int o;
         int p;
         
         //Fill screen with walls
         for (i=0;i<80;i++){
             for (j=0;j<24;j++){
                 dungeon[i][j]=1;
                 }
                 }
         //i and j are the coordinates of corner 1, k and l are the coorinates of corner 2, the room should be filled in between them
         i=random_range(2,70);
         j=random_range(2,14);
         mem_i=i;
         mem_j=j;
         o=random_range(3,6);
         p=random_range(3,6);
         k=i+o;
         l=j+p;
         mem_k=k;
         mem_l=l;
         for (i;i<k;i++){
             dungeon[i][j]=0;
             }
             i=mem_i;
         for (j;j<l;j++){
             dungeon[i][j]=0;
             }
         j=mem_j;
         mem_k=k;
         mem_l=l;
         for (k;k>=i;k--){
             dungeon[k][l]=0;
             }
         k=mem_k;
         for (l;l>=j;l--){
             dungeon[k][l]=0;
             }
         dungeon[mem_k-1][mem_l-1]=2;
         p_x=mem_k-2;
         p_y=mem_l-2;
    }
    What this does, currently, is fill the screen with walls, hollow out a rectangle(but only edges, it doesn't fill in the room with floor, which is my current problem), and stick in a stair up and the @. I need to find a way to make the for loops that hollow out the edges of the rectangle hollow out a full room instead. Maybe it's because I've been sitting here working on this all day, because it seems like this should be a simple thing to do.
    Last edited by Dark_Oppressor; 09-18-2006 at 04:12 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  3. C++ gui for windows where to start
    By prixone in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2006, 11:48 PM
  4. GNOME Desktop won't start (Mandriva)
    By psychopath in forum Tech Board
    Replies: 10
    Last Post: 07-19-2006, 01:21 PM
  5. Where do I start?
    By Unregistered in forum Game Programming
    Replies: 2
    Last Post: 04-08-2002, 12:42 AM