Example #1
0
void gamelib_mainmenu(){
	int n,j;
	int t = 0;
	double d=0;
	char *text;

	time_t current_time;
	struct tm * time_info;
	char timeString[8];



	while(nunchuck_read()){
		nunchuck_init();
		//nunchuck_read();
		mvprintw(6,0,"nunchuck reinited\n");
	}
	while(buttonC && buttonZ){
		while(nunchuck_read()){
			nunchuck_init();
			//nunchuck_read();
			mvprintw(6,0,"nunchuck reinited\n");
		}
		
		if(t%800 < 100){
			text = "PLAY";
			d = 3.03;
		}
		else if(t%800 < 200) {
			text = "GAMES";
			d = 0.03;
		}	
		else{
			time(&current_time);
			time_info = localtime(&current_time);
			strftime(timeString, 8, "%H:%M", time_info);
			
			if(current_time%2){
				timeString[2] = ' ';
			}
			text = timeString;
			d=0.03;
		}
		
		n=0;
		while(text[n] && n < 6){
			draw_char(n*6+d, text[n]);
			n++;
		}
		blit();
		update();
		
		t++;
	}


}	
Example #2
0
void setup()
{
    Serial.begin(19200);
    nunchuck_setpowerpins();
    nunchuck_init(); // send the initilization handshake
    
}
Example #3
0
File: main.c Project: qartis/dori
int main(void)
{
    uint8_t rc;

    node_init();

    sei();

    i2c_init(I2C_FREQ(400000));

    rc = hmc_init();
    if (rc) {
//        puts_P(PSTR("hmc init"));
    }

    rc = mpu_init();
    if (rc) {
//        puts_P(PSTR("mpu init"));
    }

    rc = nunchuck_init();
    if (rc) {
//        puts_P(PSTR("nunch init"));
    }

    hmc_set_continuous();

    node_main();
}
void setup()
{
    Serial.begin(57600);
    nunchuck_setpowerpins();
    nunchuck_init(); // send the initilization handshake
    
    Serial.print("WiiChuckDemo ready\n");
}
void setup()
{
    areaSize = screenSize/3;

    Serial.begin(115200);
    nunchuck_setpowerpins();
    nunchuck_init(); // send the initilization handshake

    defineAreas();
}
Example #6
0
int main(void){

        int in;

	ctr = 0;
	lastmove = 0;
	
	pos = 0;
	dir = 0;
	nextdir = 0;
	
	tick_delay = 10;
	
	spi_init();

        initscr();                      /* Start curses mode              */
        keypad(stdscr, TRUE);
        nodelay(stdscr, TRUE);
        cbreak();
        noecho();

	nunchuck_init();
	effect_init(); 
      
	welcome();
 
	snakesetup();


	logfile = fopen("snakelog.txt","a+");
	fprintf(logfile, "snake inited\n");

        while(42){
                in = getch();
              	do{ 
			while(nunchuck_read()){
				nunchuck_init();
				//nunchuck_read();
				mvprintw(6,0,"nunchuck reinited\n");
			}
		}while(joyX < 10 || joyX == 255 || joyY < 10 || joyY == 255);
		if (dir != 1 && (in == KEY_LEFT || (joyX < XCENTER - JOYDEADZONE && joyX > 10 ))){
			nextdir = 0;
                }
                else if (dir != 0 && (in == KEY_RIGHT || (joyX > XCENTER + JOYDEADZONE && joyX < 240))){
			nextdir = 1;
                }
                else if (dir != 3 && (in == KEY_UP || joyY > YCENTER + JOYDEADZONE)){
			nextdir = 2;
                }
                else if (dir != 2 && (in == KEY_DOWN || (joyY < YCENTER - JOYDEADZONE && joyY > 10))){
			nextdir = 3;
                }

		if (joyX > 150){

		}


		if(lastmove+tick_delay <= ctr){
			lastmove = ctr;
			dir = nextdir;
			snake_do(dir);
			
			//if(!buttonC && tick_delay > 0) tick_delay--; 
			//if(!buttonZ && tick_delay < 30) tick_delay++; 
                }
		
		
				
		//setpixel((accelX-512)/10+WIDTH/2,(accelY-512)/20+6,127,32,16);

		
		mvprintw(0,2,"pos: %d\n", pos);
		mvprintw(1,0,"joy X,Y: %d, %d\n", joyX, joyY);
		mvprintw(2,0,"Accel X,Y,Z: %d, %d, %d\n", accelX, accelY, accelZ);
		mvprintw(3,0,"Button C,Z: %d, %d\n", buttonC, buttonZ);
		calc_score();
		mvprintw(4,5,"Score: %d     ", score);	
		refresh();  //ncurses
		
		snake_draw();
		effect_draw(ctr);
		buffer[nompos*3+1] = 127;
		
		blit();    
        	update();
		ctr++;
		}


        endwin();                       /* End curses mode                */

        return 0;


}
Example #7
0
int main(void) {

    int in;

    int ctr = 0, lastmove = 0;

    pos = 0;
    dir = 0;

    tick_delay = 20;

    spi_init();

    initscr();                      /* Start curses mode              */
    keypad(stdscr, TRUE);
    nodelay(stdscr, TRUE);
    cbreak();
    noecho();

    nunchuck_init();

    snakesetup();

    while(42) {
        in = getch();

        while(nunchuck_read()) nunchuck_init();

        if (in == KEY_LEFT || (joyX < XCENTER - JOYDEADZONE && joyX > 10)) {
            dir = 0;
        }
        else if (in == KEY_RIGHT || joyX > XCENTER + JOYDEADZONE) {
            dir = 1;
        }
        else if (in == KEY_UP || joyY > YCENTER + JOYDEADZONE) {
            dir = 2;
        }
        else if (in == KEY_DOWN || (joyY < YCENTER - JOYDEADZONE && joyY > 10)) {
            dir = 3;
        }




        /*
        if(lastmove+tick_delay <= ctr){
        	lastmove = ctr;
        	snake_do(dir);

        	if(!buttonC && tick_delay > 0) tick_delay--;
        	if(!buttonZ && tick_delay < 30) tick_delay++;
                }
        */



        setpixel((accelX-512)/10+WIDTH/2,(accelY-512)/20+6,127,32,16);


        mvprintw(0,2,"pos: %d\n", pos);
        mvprintw(1,0,"joy X,Y: %d, %d\n", joyX, joyY);
        mvprintw(2,0,"Accel X,Y,Z: %d, %d, %d\n", accelX, accelY, accelZ);
        mvprintw(3,0,"Button C,Z: %d, %d\n", buttonC, buttonZ);
        refresh();

        //snake_draw();
        buffer[nompos*3+1] = 127;

        blit();
        update();
        ctr++;
    }


    endwin();                       /* End curses mode                */

    return 0;


}