コード例 #1
0
ファイル: events.c プロジェクト: bernardobelchior1/feup-lcom
void tick() {
	switch (state) {
	case main_menu:
		start_menu_draw();
		break;
	case singleplayer:
		singleplayer_tick();
		break;
	case multiplayer:
		versus_mp_game_tick();
		break;
	case highscore:
		highscore_tick();
		mouse_draw();
		break;
	case game_over:
		game_over_menu_tick();
		mouse_draw();
		break;
	case options:
		options_tick();
		mouse_draw();
		break;
	}

	vg_update_screen();
	//printf("Tick.\n");
}
コード例 #2
0
ファイル: mouse.c プロジェクト: happychen/wang
int mouse_test(pinfo_t fb)
{
    int fd;
    if ((fd = mouse_open("/dev/input/mice")) < 0) 
    {
        fprintf(stderr, "Error mouse open: %s\n", strerror(errno));    
        exit(1);
    }
    mevent_t mevent;

    int m_x = fb->w / 2;
    int m_y = fb->h / 2;
    mouse_draw(fb, m_x, m_y);

    u8_t buf[] = {0xF3, 0xC8, 0xF3, 0x64, 0xF3, 0x50};
    if (write(fd, buf, sizeof(buf)) < sizeof(buf)) 
    {
        fprintf(stderr, "Error write to mice devie:%s\n", strerror(errno));
        fprintf(stderr, "鼠标将不支持滚轮\n");
    }

    while(1)
    {
        if (mouse_parse(fd, &mevent) == 0) 
        {
            printf("dx= %d\tdy=%d\tdz=%d\t", mevent.dx, mevent.dy, mevent.dz);
            mouse_restore(fb, m_x, m_y);

            m_x += mevent.dx;
            m_y += mevent.dy;

            mouse_draw(fb, m_x, m_y);
            printf("mx= %d\tmy= %d\n", m_x, m_y);

            switch(mevent.button)
            {
                case 1 :
                        printf("left button\n");
                        break;
                case 2 :
                        printf("right button\n");
                        break;
                case 4 :
                        printf("middle button\n");
                        break;
                case 0 :
                        printf("no button\n");
                        break;
                default :
                        break;
            }
        }
        else
            ;
    }
    close(fd);
    return 0;
}
コード例 #3
0
void mouse_update()
{
	int mouseX, mouseY;
	Vect2d mousePosition;
	SDL_Event click_event;
	Entity *cam = camera_get();
	Actor *actor = NULL;
	
	SDL_GetMouseState(&mouseX, &mouseY);
	mousePosition = vect2d_new(mouseX, mouseY);

	if(cam)
	{
		mousePosition.x += cam->position.x;
		mousePosition.y += cam->position.y;
	}

	mouse->position = mousePosition;

	SDL_PollEvent(&click_event);
	if(click_event.type == SDL_MOUSEBUTTONDOWN)
	{
		mouse->clicked = 1;
		if(editor && mouse->position.y < HUD_HEIGHT)
		{
			actor = actor_new(mouse->position, currentType);
		}
	}
	else
	{
		mouse->clicked = 0;
	}

	if(mouse->frameNumber < mouse->sprite->fpl)
	{
		mouse->frameNumber++;
	}
	else
	{
		mouse->frameNumber = 0;
	}
	
	mouse_draw();
}
コード例 #4
0
void start_menu_draw(){
	bitmap_draw(title, get_h_res()/2, 25, ALIGN_CENTER);
	menu_draw(start_menu);
	mouse_draw();
}
コード例 #5
0
ファイル: mouseop.c プロジェクト: zhiweijiang/c-note
int mouse_test(pinfo_t fb)
{
    int fd;
    mevent_t mevent;
    int m_x = fb->w/2;
    int m_y = fb->h/2;
    int i,j;
    int flag = 0;
    int mouse_flag = 0;

    if((fd = mouse_open("/dev/input/mice")) < 0)
    {
        perror("open");
        exit(1);
    }
    mouse_draw(fb, m_x, m_y);

//  u8_t buf[] = {0xf3,0xc8,0xf3,0x64,0xf3,0x50};

//    if(write(fd, buf, sizeof(buf)) < sizeof(buf))
//   {
//        perror("write");
//        fprintf(stderr, "鼠标将不知支持滚轮\n");
//   }
    while(!flag)
    {
        if(mouse_parse(fd, &mevent) == 0)
        {
  //        printf("dx = %d\tdy = %d\tdz = %d\t", mevent.dx, mevent.dy, mevent.dz);
            mouse_restore(fb, m_x, m_y);
            m_x += mevent.dx;
            m_y += mevent.dy;
            m_x=((m_x<0)? 0:m_x);
            m_y=((m_y<0)? 0:m_y);
            if(m_x > (fb->w - C_WIDTH))
            {
                m_x = fb->w -C_WIDTH;
            }
            if(m_y > (fb->h - C_HIGHT))
            {
                m_y = fb->h - C_HIGHT;
            }
  //        printf("mx = %d\tmy = %d\n", m_x, m_y);
            switch(mevent.button)
            {
                case 0:
                    switch(mouse_flag)
                    {
                        case 1:
                            i = 50;
                            while(i > 25)
                            {
                                fb_cirle(fb, m_x, m_y, i, 0x0fff);
                                i--;
                            }
                            for (j = m_y -1; j < m_y+2; j++) 
                            {
                                for (i = m_x - 25; i < m_x + 25; i++) 
                                {
                                    fb_pixel(fb, i, j, 0xff00);
                                }
                            } 
                            for (j = m_y -25; j < m_y+25; j++) 
                            {
                                for (i = m_x - 1; i < m_x + 2; i++) 
                                {
                                    fb_pixel(fb, i, j, 0xff00);
                                }
                            }   
                            mouse_flag = 0;
                            break;
                        case 2:
                            for (j = m_y -50; j < m_y + 50; j++) 
                            {
                              for (i = (m_y-j-50)/2; i <= (50+j-m_y)/2; i++) 
                                {
                                    fb_pixel(fb, m_x+i/2, j, 0xff000);
                                }
                            }
                            fb_cirle(fb, m_x, m_y, 250, 0x0fff); 
                            mouse_flag = 0;
                            break;
                        case 4:
                            flag = 1;
                            for (j = m_y - 12; j < m_y + 12; j++) 
                            {
                                for (i = -75; i < 75; i++) 
                                {
                                    fb_pixel(fb, m_x+i, j, 0x0ff);
                                }
                            }
                            mouse_flag = 0;
                            break;
                        default:
                            break;
                    }
                    break;
                case 1:
                    mouse_flag = 1;
                    break;   
                case 2:
                    mouse_flag = 2;
                    break;
                case 4:
                    mouse_flag = 4;
                    break;
                default:
                    break;
            }
            mouse_draw(fb, m_x, m_y);
        }
    }
    close(fd);

    return 0;
}