How to make a VERY basic interface

This is a discussion on How to make a VERY basic interface within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hi, I'm currently making a hangman game. I basically want to format a standard looking menu/game interface. Just crap things ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    3

    How to make a VERY basic interface

    Hi,

    I'm currently making a hangman game. I basically want to format a standard looking menu/game interface. Just crap things like a row of asterisks around the title, edge of boarder etc.

    When hangman is played I want the screen to have set areas for displaying the man etc. That way I just use gotoxy.

    What I need to know is, are there any commands that can align output to the screen? So I could for example put asterisks to the far right of the screen etc. Or is there an easier way.

    I'm only a beginner coder so nothing majorly nice looking or difficult please I get confused easily enough.

  2. #2
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    this is taken from one of my projects when from when i was studying.

    (note : It will not compile)

    this is basicly what you can do.
    this is the intro for my banking system. It displays a rotating yin-yang, the time(updates every second) abd a message that flickers. both of these three items all refreshes at a different time

    Code:
    void Driver::intro()
    {
       int gd,gm;
       int yrad  = 100;
       int xrad  = 100;
       int flag1 = 0;
       int flag2 = 0;
       int counter = 0,counter2 = 0;
       float rad;
       char* text = "Press any key to continue";
       void far* buffer;
       void far* buffTime;
       void far* buffContinue;
       SysInfo info;
    
       rad=12.5;
       detectgraph(&gd,&gm);    //initgrpah
       initgraph(&gd,&gm,"");
       //get memory for buffers
       buffer = farmalloc(imagesize(1,1,205,205));
       buffTime = farmalloc(imagesize(1,1,100,50));
       buffContinue = farmalloc(imagesize(1,1,400,100));
       //getimage for buffers
       getimage(1,1,205,205,buffer);
       getimage(1,1,100,50,buffTime);
       settextstyle(1,0,2);
       outtextxy(320-(textwidth(text)/2),420,text); //prints message
       getimage(320-(textwidth(text)/2),420,320+textwidth(text)/2,
       			420+textheight("H")*1.5,buffContinue);
       setcolor(GREEN);
       outtextxy(320-(textwidth("CopyRight 2001, Ernst Bleeker")/2),10,
       			"CopyRight 2001, Ernst Bleeker");
       settextstyle(1,0,5);
       setcolor(BLUE);
       introRead();   //calls the inroread function
       setcolor(WHITE);
       settextstyle(1,0,3);
       setcolor(RED);
       info.dateG(465,150);    //gets the date
       if (gd == 9)
       {
          outtextxy(490-textheight("Video Mode :"),300,"Video Mode :");
       	switch(gm)
          {
          	case 0: outtextxy(530-(textwidth("640x200x16")/2)+15,340,"640x200x16");
             		  break;
             case 1: outtextxy(530-(textwidth("640x200x16")/2)+15,340,"640x350x16");
             		  break;
             case 2: outtextxy(530-(textwidth("640x200x16")/2)+15,330,"640x480x16");
          }
       }
       else
       {
          outtextxy(530-(textwidth("Unknown Mode")/2)+15,340,"Unknown Mode");
       }
       info.time(495,240);	//get the time
       setcolor(WHITE);
    	do
    	{ // do
    
          if (counter2 == 9)
          {
          	settextstyle(1,0,2);
          	putimage(320-(textwidth(text)/2),420,buffContinue,1);
          	settextstyle(1,0,3);
          	counter2 = 0;
          }
          counter2++;
       	if (counter == 15)
          {
             setcolor(RED);
          	putimage(495,240,buffTime,0);
             info.time(495,240);
             setcolor(WHITE);
          	counter = 0;
          }
          counter++;
    		ellipse(320,240,0,360,xrad,yrad);
    		ellipse(320,185,0,360,(xrad/8)+1,rad);
    		ellipse(320,290,0,360,xrad/8,rad);
    		floodfill(320,290,WHITE);
    		switch (flag2)
    		{ // switch
    			case 0 :
    				ellipse(320,240-yrad/2,90,270,xrad/2,yrad/2);
    				ellipse(320,240+yrad/2,270,90,xrad/2,yrad/2);
    				floodfill(320,240-1,WHITE);
    				break;
    			case 1 :
    				ellipse(320,240+yrad/2,90,270,xrad/2,yrad/2);
    				ellipse(320,240-yrad/2,270,90,xrad/2,yrad/2);
    				floodfill(320-xrad+1,240,WHITE);
    		} // switch
    		if (xrad == 0)
    		{ // if
    			if (flag2 == 0)
    			{ // if
    				flag2 = 1;
    			} // if
    			else
    			{ // else
    				flag2 = 0;
    			} // else
    		} // if
    		if (xrad % 100 == 0)
    		{ // if
    			if (flag1==0)
    			{ // if
    				flag1 = 1;
    			} // if
    			else
    			{ // else
    				flag1 = 0;
    			} // else
    		} // if
    		if (flag1 == 0)
    		{ // if
    			xrad++;
    		} // if
    		else
    		{ // else
    			xrad--;
    		} // else
          delay(15);
          putimage(220,140,buffer,0);
    	} // do
    	while (!kbhit());
       getch();
    	closegraph();
       //free the momory for the buffer
       free(buffer);
       free(buffTime);
       free(buffContinue);
    }
    The knack of flying is learning to throw yourself at the ground and miss.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Establishing 'make clean' with GNU make
    By Jesdisciple in forum C Programming
    Replies: 9
    Last Post: 04-11-2009, 10:10 AM
  2. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 09:51 PM
  3. Replies: 20
    Last Post: 12-09-2004, 07:52 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  5. "Cannot make pipe"
    By crepincdotcom in forum C Programming
    Replies: 5
    Last Post: 08-16-2004, 01:43 PM

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