示例#1
0
// Example main function and loop
int main() {
  // Initialize the display with (pixel size, pixel padding) (pixel padding not
  // implemented yet)
  lcdsim_init(3, 0);

  // Ascii display example
  char *cp, test0[] = "Static test string", test1[] = "Another string";
  cp = test0;
  ascii_gotoxy(0,0);
  while (*cp)
    ascii_write_char(*cp++);
  cp = test1;
  ascii_gotoxy(0,1);
  while (*cp)
    ascii_write_char(*cp++);
  
  int i = 0;
  while(1) {
    keyb(c);

    // Show pressed down key
    draw_byte((c[0]) ? 0xFF : 0, 63, 3);
    draw_byte((c[1]) ? 0xFF : 0, 63, 5);
    draw_byte((c[2]) ? 0xFF : 0, 58, 4);
    draw_byte((c[3]) ? 0xFF : 0, 68, 4);

    // Moving byte
    draw_byte(0, (i % 128), 7);
    draw_byte(0xFF, (++i % 128), 7);

    delay_milli(40);    
  }
  return 0;
}
示例#2
0
void difficulty(void){
	if(snakeLength<5){
		delay_milli(200);
	}
	else if(snakeLength<10){
		delay_milli(100);
	}
	else{
		delay_milli(50);
	}
	xRand+=8;
	yRand+=4;
	if(xRand >= 256){
		xRand=8;
	}
	if(yRand >= 64){
		yRand=8;
	}
}