Open main menu

CDOT Wiki β

OOP344 20102 IOFrame test main

Revision as of 06:37, 23 June 2010 by Fardad (talk | contribs) (Created page with '<big><syntaxhighlight lang=cpp> #include "iotext.h" #include "ioframe.h" int main(){ int ro = 0; int co = 0; bool done = false; int key = 0; iof_init(); int rows = iā€¦')
(diff) ā† Older revision | Latest revision (diff) | Newer revision ā†’ (diff)
#include "iotext.h"
#include "ioframe.h"

int main(){
  int ro = 0;
  int co = 0;
  bool done = false;
  int key = 0;
  iof_init();
  int rows = iof_rows();
  int cols = iof_cols();
  IOFrame ioframe(8, 30, 5, 10, true);
  while(!done){
    iof_clrscr();
    ioframe.draw(ro, co);
    key = iof_getch();
    switch(key){
      case RIGHT_KEY:
        if(co + 40 < cols)
          co++;
        break;
      case LEFT_KEY:
        if(co + 30 > 0)
          co--;
        break;
      case DOWN_KEY:
        if(ro + 13 < rows )
          ro++;
        break;
      case UP_KEY:
        if(ro + 8 > 0 )
          ro--;
        break;
      case ESCAPE_KEY:
        done = true;
        break;
    }
  }
  iof_end();
  return 0;  
}