コード例 #1
0
ファイル: ntetris.c プロジェクト: BadrElh/microwindows
void move_block(nstate *state, int direction)
{
	if(direction == 0) {
 		if(!state->current_shape.x) return;
		else {
			if(!will_collide(state, (state->current_shape.x - 1),
						state->current_shape.y,
					state->current_shape.orientation)) {
				draw_shape(state, state->current_shape.x,
						state->current_shape.y, 1);
				state->current_shape.x--;
				draw_shape(state, state->current_shape.x,
						state->current_shape.y, 0);
				draw_well(state, 0);
			}
		}
	} else {
		if(!will_collide(state, (state->current_shape.x + 1),
						state->current_shape.y,
					state->current_shape.orientation)) {
			draw_shape(state, state->current_shape.x,
					state->current_shape.y, 1);
			state->current_shape.x++;
			draw_shape(state, state->current_shape.x,
					state->current_shape.y, 0);
			draw_well(state, 0);
		}
	}
}
コード例 #2
0
ファイル: ntetris.c プロジェクト: Joel397/Ongoing_work_files
int will_collide(nstate *state, int x, int y, int orientation)
{
	int r, c, xx, yy;
	char ch = 0;

	draw_shape(state, state->current_shape.x, state->current_shape.y, 1);
	for(r = 0; ch < 3; r++) {
		ch = 0;
		for(c = 0; ch < 2; c++) {
			ch = shapes[state->current_shape.type]
				[orientation][r][c];
			if(ch == 1) {
				yy = y + r;
				xx = x + c;
				if((yy == WELL_HEIGHT) || (xx == WELL_WIDTH) ||
						(state->blocks[0][yy][xx])) {
					draw_shape(state,
						state->current_shape.x,
						state->current_shape.y, 0);
					return 1;
				}
			}
		}
	}
	draw_shape(state, state->current_shape.x, state->current_shape.y, 0);

	return 0;
}
コード例 #3
0
ファイル: canvas.C プロジェクト: elthariel/non-sequencer
/** callback used by Grid::draw()  */
void
Canvas::draw_dash ( int x, int y, int l, int shape, int color, bool selected )
{
    draw_shape( x, y, shape, FULL, color, selected );
    for ( int i = x + l - 1; i > x; i-- )
    {
        draw_shape( i, y, shape, CONTINUED, 0, selected );
    }
}
コード例 #4
0
ファイル: textris.c プロジェクト: biirdy/textris
void draw_hold(int h_s, int hold_cnt, hold_x, hold_y){

	int j;
	
	h_border(hold_y, hold_x, 10);
	h_border(hold_y + 5, hold_x, 10);
	v_border(hold_y, hold_x, 6);
	v_border(hold_y, hold_x + 9, 6);
	mvprintw(hold_y + 6, hold_x, "   Hold");

	//clear
	for(j=0; j<4; j++)
		mvprintw(j + hold_y + 1, hold_x + 1, "        ");	

	if(h_s != -1){
		shape s;
		s.type = h_s;
		s.rotation = 0;
		s.x = 0;
		s.y = 1;

		draw_shape(s, hold_x, hold_y);

	}
}
コード例 #5
0
ファイル: textris.c プロジェクト: biirdy/textris
//TODO - eliminate most white space - only a single block between shapes 
//     - maybe rotate them differently
void draw_bucket(bucket * b, int bucket_x, int bucket_y){
	
	int i, j;
	
	//clear
	for(i = 0; i < 4; i++){
		for(j=0; j<4; j++){
			mvprintw(i*4 + j + bucket_y, bucket_x + 1, "        ");	
		}	
	}

	for(i =0; i<4; i++){

		shape s;
		s.rotation = 0;
		s.type = b->bucket1[i];
		s.x = 0;
		s.y = i*4;

		draw_shape(s, bucket_x, bucket_y);
	}

	//borders
    v_border(bucket_y, bucket_x - 1, 4 * 4);
    v_border(bucket_y, bucket_x + 10, 4 * 4);
    h_border(bucket_y, bucket_x - 1, 12);
    h_border(bucket_y + (4 * 4) - 1, bucket_x - 1, 12);
    mvprintw(bucket_y + (4 * 4), bucket_x, "   Next");	
}
コード例 #6
0
ファイル: textris.c プロジェクト: biirdy/textris
void draw_menu(WINDOW *win, MENU *menu){

	int i;

	int MENU_WIDTH = 20;
	int SCREEN_WIDTH = 100;

	clear();

	/* Print a border around the main window and print a title */
	box(win, 0, 0);

	print_in_middle(win, 1, 0, MENU_WIDTH, "Game mode", COLOR_PAIR(0));
	mvwaddch(win, 2, 0, ACS_LTEE);
	mvwhline(win, 2, 1, ACS_HLINE, MENU_WIDTH);
	mvwaddch(win, 2, MENU_WIDTH + 1, ACS_RTEE);
	mvprintw(3, (SCREEN_WIDTH/2) - (36/2), "textris - An ASCII based Tetris game");

	//decorative shapes
	for(i =0; i<7; i++){
		shape s;
		s.rotation = 0;
		s.type = i;
		s.x = 0;
		s.y = 0;
		draw_shape(s, (i*10) + (SCREEN_WIDTH/2) - ((10*7)/2), 15);
	}
	wrefresh(win);
	refresh();
}
コード例 #7
0
ファイル: gl_state.cpp プロジェクト: LibreGames/bear
/**
 * \brief Asks OpenGL to draw the vertices of the state.
 */
void bear::visual::gl_state::draw() const
{
  if ( m_elements.empty() )
    draw_shape();
  else
    draw_textured();
} // gl_state::draw()
コード例 #8
0
ファイル: fireworks-7.c プロジェクト: Zaxcoding/fireworks
void draw_objects(SHAPE *my_objects, int num_objects) {
  
  int i;

  // this for loop draws the nozzles
  for(i = 0; i < num_objects; i++) {
    SHAPE *cur;
    cur = &my_objects[i];

    switch(cur->shape_id) {
      case CUBE: //cube
      {
        curr_rs = CUBE_RS;
        curr_vs = CUBE_VS;
      }break;
      case CYLINDER: // cylinder
      {
        curr_rs = CYLINDER_RS;
        curr_vs = CYLINDER_VS;
      }break;
    }
    draw_shape(cur, BLUE);

  }

}
コード例 #9
0
ファイル: gltetris.c プロジェクト: nixxcode/gltetris
static void glut_display_callback()
{
	glClear(GL_COLOR_BUFFER_BIT);

	for (int x=0; x<GRID_WIDTH; x++) {
		for (int y=0; y<GRID_HEIGHT; y++) {
			if (grid_fill[x][y]) {
				draw_block(x, y, grid_fill[x][y]);
			}
		}
	}
	
	if (!game_over) {
		draw_shape();
	}

	glColor3f(0.2f, 0.2f, 0.2f);
	glBegin(GL_LINES);
	for (int x=1; x<GRID_WIDTH; x++) {
		glVertex2f(x * GRID_SIZE, 0.0f);
		glVertex2f(x * GRID_SIZE, GRID_HEIGHT * GRID_SIZE);
	}
	for (int y=1; y<GRID_HEIGHT; y++) {
		glVertex2f(0.0f,                    y * GRID_SIZE);
		glVertex2f(GRID_HEIGHT * GRID_SIZE, y * GRID_SIZE);
	}
	glEnd();

	glFlush();

	glutSwapBuffers();
}
コード例 #10
0
ファイル: ntetris.c プロジェクト: Joel397/Ongoing_work_files
int drop_block_1(nstate *state)
{
	if(will_collide(state, state->current_shape.x,
				(state->current_shape.y + 1),
				state->current_shape.orientation)) {
		block_reached_bottom(state);
		return 1;
	}

	draw_shape(state, state->current_shape.x, state->current_shape.y, 1);
	state->current_shape.y++;
	draw_shape(state, state->current_shape.x, state->current_shape.y, 0);

	draw_well(state, 0);

	return 0;
}
コード例 #11
0
ファイル: box_demo.c プロジェクト: 0pointr/le-Snake-Mod
void draw_stuff(_shape_book *s_book)
{
    erase();
    int i;
    for (i=0; i<s_book->t_blocade; i++)
        draw_shape(s_book->shape_ptr[i]);
    refresh();
}
コード例 #12
0
ファイル: multimona.c プロジェクト: Gerathain/ImageGenerate
void draw_dna(shape_t * dna, cairo_t * cr)
{
    cairo_set_source_rgb(cr, 1, 1, 1);
    cairo_rectangle(cr, 0, 0, WIDTH, HEIGHT);
    cairo_fill(cr);
    for(int i = 0; i < NUM_SHAPES; i++)
        draw_shape(dna, cr, i);
}
コード例 #13
0
ファイル: canvas.c プロジェクト: shouya/bar
void draw_shape_center(struct canvas_t* cvs, int x, int y,
                       int boxw, int boxh, int sz, int shp,
                       unsigned long outln, int alpha) {
  int shpx, shpy;
  if (shp == -1) return;
  shpx = (boxw - g_shps[shp].w * sz) / 2 + x;
  shpy = (boxh - g_shps[shp].h * sz) / 2 + y;
  draw_shape(cvs, shpx, shpy, sz, shp, outln, alpha);
}
コード例 #14
0
ファイル: fireworks-13.c プロジェクト: Choino/school
void draw_particles() 
{
  int i;
  for (i = 0; i < NUM_NOZZLES; i++) {
    PARTICLE *cur;
    cur = &particles[i];

    curr_rs = CUBE_RS;
    curr_vs = CUBE_VS;

    draw_shape(&(cur->shape), RED);
  }
}
コード例 #15
0
ファイル: fireworks-7.c プロジェクト: Zaxcoding/fireworks
void draw_nozzles() {
  int i;

  for (i = 0; i < NUM_NOZZLES; i++) {
    NOZZLE *cur;
    cur = &nozzles[i];

    curr_rs = CYLINDER_RS;
    curr_vs = CYLINDER_VS;

    draw_shape(&(cur->Shape), BLUE);
  }

}
コード例 #16
0
ファイル: ntetris.c プロジェクト: BadrElh/microwindows
void rotate_block(nstate *state, int direction)
{
	int neworientation = 0;

	if(direction == 0) {
		if(!state->current_shape.orientation)
			neworientation = MAXORIENTATIONS - 1;
		else neworientation = state->current_shape.orientation - 1;
	} else {
		neworientation = state->current_shape.orientation + 1;
		if(neworientation == MAXORIENTATIONS) neworientation = 0;
	}

	if(!will_collide(state, state->current_shape.x, state->current_shape.y,
							neworientation)) {
		draw_shape(state, state->current_shape.x,
				state->current_shape.y, 1);
		state->current_shape.orientation = neworientation;
		draw_shape(state, state->current_shape.x,
				state->current_shape.y, 0);
		draw_well(state, 0);
	}
}
コード例 #17
0
ファイル: fireworks-13.c プロジェクト: Choino/school
void draw_explosion()
{
  int i, j;
  for (j = 0; j < NUM_NOZZLES; j++) {
    for (i = 0; i < (&explosions[j])->quantity; i++) {
      PARTICLE *cur;
      cur = &((&explosions[j])->particles[i]);

      curr_rs = CUBE_RS;
      curr_vs = CUBE_VS;

      draw_shape(&(cur->shape), RED);
    }
  }
}
コード例 #18
0
ファイル: fireworks-24.c プロジェクト: Zaxcoding/fireworks
void draw_explosion()
{
  int i, j;
  for (j = 0; j < MAX_FIREWORKS; j++) {
    for (i = 0; i < (&explosions[j])->quantity; i++) {
      PARTICLE *cur;
      cur = &((&explosions[j])->particles[i]);

      curr_rs = CUBE_RS;
      curr_vs = CUBE_VS;

      draw_shape(&(cur->shape), cur->init_color);
    }
  }
}
コード例 #19
0
ファイル: main.c プロジェクト: jonasj76/gltetris
void render_scene (void)
{
   int x, y;
   color_t red   = {1.0, 0.0, 0.0};
   color_t green = {0.0, 1.0, 0.0};

   glClear (GL_COLOR_BUFFER_BIT);
   for (x=0; x<BOARD_COLS; x++)
      for (y=0; y<BOARD_ROWS; y++)
      {
         if ((x+y)%2)
            draw_block (x + y*BOARD_COLS, red);
      }

   draw_shape (shapes[cur_shape], shape_x, shape_y, green);
}
コード例 #20
0
ファイル: clockapp.cpp プロジェクト: bbidulock/dockapps
void ClockDraw::draw_hand_shapes(double angle, const ClockConfig::Hand& h)
{
	typedef std::vector<ClockConfig::Shape>::const_iterator SIT;

	// exact option
	if (h.exact)
	{
		angle -= std::fmod(angle, 6.0);
	}

	double a = (angle+180)*M_PI/180;
	for (SIT sp = h.shapes.begin(); sp != h.shapes.end(); ++sp)
	{
		draw_shape(a, *sp);
	}
}
コード例 #21
0
ファイル: fireworks-24.c プロジェクト: Zaxcoding/fireworks
void draw_nozzles() {
  int i;
  GLfloat v1[4];
  GLfloat v2[4];

  for (i = 0; i < NUM_NOZZLES; i++) {
    NOZZLE *cur;
    cur = &nozzles[i];
 
    curr_rs = CYLINDER_RS;
    curr_vs = CYLINDER_VS;

    draw_shape(&(cur->shape), colors[BLUE]);
  }

}
コード例 #22
0
ファイル: fireworks-30.c プロジェクト: Choino/school
void draw_fuse()
{
  int i, j;
  for (j = 0; j < MAX_FIREWORKS; j++) {
    if ((&fuses[j]) -> hangtime > 0) {
      for (i = 0; i < ((&fuses[j])->trail_size); i++) {
        PARTICLE *cur;
        cur = &((&fuses[j])->trail[i]);

        curr_rs = CUBE_RS;
        curr_vs = CUBE_VS;

        draw_shape(&(cur->shape), cur->init_color);
      }
    }
  }
}
コード例 #23
0
ファイル: textris.c プロジェクト: biirdy/textris
double twenty_lines(){

	clear();

	int board_x = 15;
	int board_y = 1;
	int board_width = 10;
	int board_height = 20;

	//board boarders
	int i;
	for(i = 0; i < board_height; i++){
		mvprintw(i + board_y, board_x, "|");
		mvprintw(i + board_y, (board_width * 2) + (board_x) + 1, "|", i);
	}

	mvprintw(board_y + board_height, board_x, "+");	
	for(i = 1; i < (board_width * 2) + 1; i++)
		mvprintw(board_y + board_height, i + board_x, "-");	
	mvprintw(board_y + board_height, board_x + (board_width * 2) + 1, "+");	

	//bucket
	init_bucket(&bu);

	//shape
	new_shape(&s, &bu);

	//board
	b = init_board(board_width, board_height);

	int running = 1;
	int lines = 0;

	//drop loop params
	thread_params tp;
	tp.b = &b;
	tp.s = &s;
	tp.bucket = &bu;
	tp.hold_cnt = &hold_cnt;
	tp.drop_speed = &drop_speed;
	tp.running = &running; 
	tp.lines_cleared = &lines;

	pthread_t pth;
    pthread_create(&pth, NULL, drop_loop, (void * ) &tp);

    struct timeval tval_before, tval_after, tval_result;
    gettimeofday(&tval_before, NULL);

   	char tmbuf[64];

	// game loop
	while(running > 0 && lines < 10){

		timeout(100);

		draw_board(b, board_x, board_y);
		draw_hold(h_s, hold_cnt, 1, 1);
		draw_shape(s, board_x, board_y);
		draw_bucket(&bu, 45, 1);

		mvprintw(10, 2, "Lines: %d", lines);

		gettimeofday(&tval_after, NULL);
		timersub(&tval_after, &tval_before, &tval_result);
		strftime(tmbuf, sizeof tmbuf, "%M:%S", localtime(&tval_result.tv_sec));
		mvprintw(14, 2, "        ");
		mvprintw(14, 2, "%s.%02d", tmbuf, tval_result.tv_usec/10000);

		int ch = getch();
		if(ch != ERR){

			//hold - temporarily cycles trough
			if(ch == 'x'){
				s.type++;
				if(s.type == 7)
					s.type = 0;

			//left
			}else if(ch == KEY_LEFT && check_move(s, b, -1, 0, 0)){
				s.x--;

			//right
			}else if(ch == KEY_RIGHT && check_move(s, b, 1, 0, 0)){
				s.x++;

			//rotate
			}else if(ch == KEY_UP && check_move(s, b, 0, 0, 1)){
				s.rotation++;
				if(s.rotation == 4)
					s.rotation = 0;

			//hard drop
			}else if(ch == ' '){
				while(true){
					if(!check_move(s, b, 0, 1, 0))
						break;
					s.y++;
				}
			//hold
			}else if(ch == 'z' && hold_cnt < 1){
				hold(&s, &h_s, &bu);
				hold_cnt++;
			}
		}

		refresh();

		if(DEBUG_CNT == 20)
			DEBUG_CNT = 0;
	}

	//stop drop loop
	running = -1;

	//delay for drop loop to stop
	usleep(1000000);

	clear();

	return 1;
}
コード例 #24
0
static int ScrollbarProc(HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
    /** IDC of SCROLLBAR control */
    static int _my_scroll_idc = 100;

    /** scrollbar handle of main window  */
    static HWND hwnd_sb_main;

    /** scrollbar handle of control */
    HWND hwnd_sb_ctrl;

    switch (message)
    {
        case MSG_CREATE:
            {
                _rect_invalid.left   = SEP;
                _rect_invalid.top    = 0;
                _rect_invalid.right  = g_rcScr.right;
                _rect_invalid.bottom = g_rcScr.bottom;

                SCROLLINFO scinfo = {0};
                scinfo.fMask = SIF_ALL;
                scinfo.nMin = SB_MIN;
                scinfo.nMax = SB_MAX;
                scinfo.nPage = SB_PAGE;
                scinfo.nPos = SB_MIN;

                calc_circle_pos (scinfo.nPos);
                calc_box_pos (scinfo.nPos);

                /** classic VSCROLL with SBS_NOTNOTIFYPARENT */

                hwnd_sb_main = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                        | SBS_NOTNOTIFYPARENT
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 50, 20, 150, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_main, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_main, MSG_SETFOCUS, 0, 0);

                /** flat VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        43, 50, 20, 150, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        66, 50, 20, 150, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE |
                        SBS_VERT | SBS_LEFTALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        92, 50, 20, 150, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** classic NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        120, 50, 20, 34, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** flat NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        140, 50, 20, 34, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        160, 50, 20, 34, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny NOSHAFT VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOSHAFT | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        184, 50, 20, 34, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** classic NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        210, 50, 20, 150, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** flat NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        232, 50, 20, 150, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        254, 50, 20, 150, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny NOARROW VSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_VERT | SBS_NOARROW | SBS_LEFTALIGN 
                       ,
                        0,
                        ++_my_scroll_idc,
                        276, 50, 20, 150, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** classic HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 220, 150, 20, hwnd, 
                        "classic", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** flat HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 240, 150, 20, hwnd, 
                        "flat", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** fashion HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 260, 150, 20, hwnd, 
                        "fashion", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);

                /** tiny HSCROLL */

                hwnd_sb_ctrl = CreateWindowEx2 (CTRL_SCROLLBAR, "",
                        WS_VISIBLE | SBS_HORZ 
                        | SBS_TOPALIGN
                       ,
                        0,
                        ++_my_scroll_idc,
                        20, 280, 150, 20, hwnd, 
                        "tiny", 0,
                        0);

                SendMessage (hwnd_sb_ctrl, SBM_SETSCROLLINFO, (WPARAM)&scinfo, TRUE);
                SendMessage (hwnd_sb_ctrl, MSG_SETFOCUS, 0, 0);
            }
            break;

        case MSG_COMMAND:
            {
                int code = HIWORD(wParam);
                HWND scroll = (HWND)lParam;
                int pos = 0;

                switch (code) 
                {
                    case SB_LINELEFT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, --pos, TRUE);
                        }

                        break;

                    case SB_LINERIGHT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGELEFT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGERIGHT:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_LINEUP:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, --pos, TRUE);
                        }

                        break;

                    case SB_LINEDOWN:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            SendMessage (scroll, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGEUP:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGEDOWN:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (scroll, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_THUMBPOSITION:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);
                        }
                        break;

                    case SB_THUMBTRACK:
                        {
                            pos = SendMessage (scroll, SBM_GETPOS, 0, 0);
                        }
                        break;

                    case SB_TOP:
                        {
                            pos = SB_MIN;
                        }
                        break;

                    case SB_BOTTOM:
                        {
                            pos = SB_MAX;
                        }
                        break;

                    default:
                        break;
                }

                draw_shape (hwnd, pos);
            }
            break;

        case MSG_HSCROLL:
            {
                int pos = 0;
                switch (wParam)
                {
                    case SB_LINELEFT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, --pos, TRUE);
                        }

                        break;

                    case SB_LINERIGHT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGELEFT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGERIGHT:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;
                    case SB_THUMBPOSITION:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_THUMBTRACK:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_TOP:
                        {
                            pos = SB_MIN;
                        }
                        break;

                    case SB_BOTTOM:
                        {
                            pos = SB_MAX;
                        }
                        break;

                    default:
                        break;
                }
                draw_shape (hwnd, pos);
            }
            break;

        case MSG_VSCROLL:
            {
                int pos = 0;
                switch (wParam)
                {
                    case SB_LINEUP:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, --pos, TRUE);
                            
                        }

                        break;

                    case SB_LINEDOWN:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            SendMessage (hwnd_sb_main, SBM_SETPOS, ++pos, TRUE);
                        }
                        break;

                    case SB_PAGEUP:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos -= SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;

                    case SB_PAGEDOWN:
                        {
                            pos = SendMessage (hwnd_sb_main, SBM_GETPOS, 0, 0);

                            pos += SB_PAGE;
                            SendMessage (hwnd_sb_main, SBM_SETPOS, pos, TRUE);
                        }
                        break;
                    case SB_THUMBPOSITION:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_THUMBTRACK:
                        {
                            pos = (int)lParam;
                        }
                        break;

                    case SB_TOP:
                        {
                            pos = SB_MIN;
                        }
                        break;

                    case SB_BOTTOM:
                        {
                            pos = SB_MAX;
                        }
                        break;
                    default:
                        break;
                }
                draw_shape (hwnd, pos);
            }
            break;

        case MSG_PAINT:
            {
                HDC hdc = BeginPaint(hwnd); 

                /** separator */
                MoveTo (hdc, SEP, 0);
                LineTo (hdc, SEP, g_rcScr.bottom);

                /** circle */
                Circle (hdc, CC_CENTER_X, CC_CENTER_Y, _radius);

                /** top and bottom line of box */
                MoveTo (hdc, SEP + 20, BOX_Y_MIN);
                LineTo (hdc, SEP + 20 + BOX_WIDTH + 40, BOX_Y_MIN);

                MoveTo (hdc, SEP + 20, BOX_Y_MAX);
                LineTo (hdc, SEP + 20 + BOX_WIDTH + 40, BOX_Y_MAX);

                /** box */
                SetBrushColor (hdc, PIXEL_black);
                FillBox (hdc, SEP + 40, _box_pos_y, BOX_WIDTH, BOX_HEIGHT);

                EndPaint (hwnd, hdc);
            }
            break;

        case MSG_CLOSE:
            {
                DestroyMainWindow (hwnd);
                PostQuitMessage (hwnd);
                return 0;
            }
    }

    return DefaultMainWinProc(hwnd, message, wParam, lParam);
}
コード例 #25
0
ファイル: glmain.c プロジェクト: Choino/school
void draw_objects() {
	
	int i;
	for(i=0; i<num_objects; i++){
		OBJECT *cur;
		cur = &my_objects[i];
		
		glMaterialfv(GL_FRONT, GL_AMBIENT, cur->amb);
		glMaterialfv(GL_FRONT, GL_DIFFUSE, cur->diff);
		glMaterialfv(GL_FRONT, GL_SPECULAR, cur->spec);
		glMaterialfv(GL_FRONT, GL_SHININESS, &cur->shine);
		//glMaterialfv(GL_FRONT, GL_EMISSION, cur->emi);
		
		switch(cur->sid){
			
			case 0: // house
			{
				crt_rs = 3;
				crt_vs = 2;
				glBindTexture(GL_TEXTURE_2D, tex_names[WINDOWIMG_TEX]);
				glEnable(GL_TEXTURE_2D);
				glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
				draw(cur);
				glDisable(GL_TEXTURE_2D);
				
			}break;
			case 1: //cube
			{
				crt_rs = 3;
				crt_vs = 1;
				glBindTexture(GL_TEXTURE_2D, tex_names[BRICKIMG_TEX]);
				glEnable(GL_TEXTURE_2D);
				glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
				draw(cur);
				glDisable(GL_TEXTURE_2D);
			}break;
			case 2: // sphere
			{
				crt_rs = crt_vs = 90;
				glBindTexture(GL_TEXTURE_2D, tex_names[PLANETIMG_TEX]);
				glEnable(GL_TEXTURE_2D);
				glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
				draw_shape(cur);
				glDisable(GL_TEXTURE_2D);
			}break;
			case 3: // cone
			{
				crt_rs = crt_vs = 90;
				glBindTexture(GL_TEXTURE_2D, tex_names[SMALLIMG_TEX]);
				glEnable(GL_TEXTURE_2D);
				glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
				draw_shape(cur);
				glDisable(GL_TEXTURE_2D);
			}break;
			case 4: // torus
			{
				crt_rs = crt_vs = 90;
				glBindTexture(GL_TEXTURE_2D, tex_names[TANIMG_TEX]);
				glEnable(GL_TEXTURE_2D);
				glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
				draw_shape(cur);
				glDisable(GL_TEXTURE_2D);
			}break;
		}
		
	}
}
コード例 #26
0
ファイル: ntetris.c プロジェクト: Joel397/Ongoing_work_files
void block_reached_bottom(nstate *state)
{
	int x, y;

	if(!block_is_all_in_well(state)) {
		state->state = STATE_STOPPED;
		return;
	}

	for(y = WELL_HEIGHT - 1; y; y--) {
		for(x = 0; x < WELL_WIDTH; x++)
			if(!state->blocks[0][y][x]) goto nr;
		msleep(DELETE_LINE_DELAY);
		delete_line(state, y);
		state->score += SCORE_INCREMENT;
		if((LEVELS > (state->level + 1)) && (((state->level + 1) *
					LEVEL_DIVISOR) <= state->score))
			state->level++;
		draw_score(state);
		y++;
		nr:
	}

	choose_new_shape(state);
	draw_next_shape(state);
}

void move_block(nstate *state, int direction)
{
	if(direction == 0) {
 		if(!state->current_shape.x) return;
		else {
			if(!will_collide(state, (state->current_shape.x - 1),
						state->current_shape.y,
					state->current_shape.orientation)) {
				draw_shape(state, state->current_shape.x,
						state->current_shape.y, 1);
				state->current_shape.x--;
				draw_shape(state, state->current_shape.x,
						state->current_shape.y, 0);
				draw_well(state, 0);
			}
		}
	} else {
		if(!will_collide(state, (state->current_shape.x + 1),
						state->current_shape.y,
					state->current_shape.orientation)) {
			draw_shape(state, state->current_shape.x,
					state->current_shape.y, 1);
			state->current_shape.x++;
			draw_shape(state, state->current_shape.x,
					state->current_shape.y, 0);
			draw_well(state, 0);
		}
	}
}

void rotate_block(nstate *state, int direction)
{
	int neworientation = 0;

	if(direction == 0) {
		if(!state->current_shape.orientation)
			neworientation = MAXORIENTATIONS - 1;
		else neworientation = state->current_shape.orientation - 1;
	} else {
		neworientation = state->current_shape.orientation + 1;
		if(neworientation == MAXORIENTATIONS) neworientation = 0;
	}

	if(!will_collide(state, state->current_shape.x, state->current_shape.y,
							neworientation)) {
		draw_shape(state, state->current_shape.x,
				state->current_shape.y, 1);
		state->current_shape.orientation = neworientation;
		draw_shape(state, state->current_shape.x,
				state->current_shape.y, 0);
		draw_well(state, 0);
	}
}