OOP344 20102 IOFrame test main

From CDOT Wiki
Jump to: navigation, search
#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;  
}