Exemplo n.º 1
0
int main()
{
  char fractal;
  int x=width/2,y=height/2,radius=width/3;
  int margin=20;	
  int x1=margin,x2=width-margin,x3=width/2,y1=margin,y2=margin,y3=height-margin;	
  gfx_open(width,height,"Fractals");
  gfx_clear_color(0,0,0);
  gfx_clear();
  gfx_color(255,255,255);
  printf("Which fractal would you like to see?\n1: Sierpinski Triangles\n2: Shrinking Squares\n3: Spiral Squares\n4: Circular Lace\n5: Snowflake\n6: Tree\n7: Fern\n8: Spiral of Spirals\n\n"); 
  while(fractal!='q'){
    fractal=gfx_wait();
    gfx_clear();
    switch(fractal){
      case 'q':
	return 0;
	break;
      case '1':
        printf("Sierpinski Triangles\n\n");
	sierpTriangles(x1,y1,x2,y2,x3,y3);
	break;
      case '2':
        printf("Shrinking Squares\n\n");
	shrinkSquares(x,y,width/4);
	break;
      case '3':
	printf("Spiral Squares\n\n");
        spiralSquares(x,y,-M_PI/4,width*2/3);
	break;
      case '4':
        printf("Circular Lace\n\n");
	circularLace(x,y,width);
	break;
      case '5':
        printf("Snowflake\n\n");
	snowflake(x,y,radius);
	break;
      case '6':
        printf("Tree\n\n");
	tree(x,height,x,height*3/4,0,height/4);
	break;
      case '7':
        printf("Fern\n\n");
	fern(width/2,height-margin,2*height/3,0);
	break;
      case '8':
        printf("Spiral of Spirals\n\n");
	spiralSpirals(x,y,0,width);
	break;
      default:
	printf("Please enter a valid option\n\n");
	break;
    }
  }  
}
Exemplo n.º 2
0
void notmain() {
  led_init();
  gpio_init();
  gfx_init();

  unsigned int index = 0;
  char line[60];
  line[0] = 0;
  
  gpio_set_input(GPIO_PIN23);
  gpio_set_input(GPIO_PIN24);
  gpio_set_pullup(GPIO_PIN23);
  gpio_set_pullup(GPIO_PIN24);
  //  while (1) {}
  while (1) {
    wait_for_clock();
    line[index] = '+';
    line[++index] = 0;
    gfx_clear();
    gfx_draw_string(0xFFFFFFFF, 20, 20, "Button pushes: ");
    gfx_draw_string(0xFFFFFFFF, 210, 20, line);
    gfx_draw();
  }
  
  while (1) {
    unsigned char ch = 0;
    int pinval;

    wait_for_clock();
    pinval = gpio_pin_read(GPIO_PIN24);
    if (pinval != 0) {
      //continue;
    }    

    int i;
    for (i = 0; i < 8; i++) {
      wait_for_clock();
      ch |= gpio_pin_read(GPIO_PIN24) << i;
    }

    wait_for_clock();
    wait_for_clock();

    ch = 'z'; //lookup_table[ch];
    if (index < LINE_SIZE) {
      line[index] = ch;
      line[index++] = 0;
    }
    gfx_clear();
    gfx_draw_string(0xFFFFFFFF, 20, 20, line);
    gfx_draw();
  }
 
}
Exemplo n.º 3
0
int main() {

	int width = 400; 
	int height = 550;
    int gameLoop = 1;
    int highScore = 0;
    
    gfx_open(width, height, "Flappy Bird");
    
    //create two pipes to be recycled
    Pipe* leadPipe = (Pipe*)malloc(sizeof(Pipe));
    Pipe* trailPipe = (Pipe*)malloc(sizeof(Pipe));
    
    while (gameLoop) {
    
        //initialize each pipe
        initializePipe(leadPipe, width, height);
        initializePipe(trailPipe, width, height);
    
        //set background color
        gfx_clear_color(85, 203, 217);
        gfx_clear();
        
        //present game home screen
    
        char c;
        int flap = 0;
        double birdX = 150, birdY = 275, birdR = 12, degrees = 0;
        while (1) {
            gfx_clear();
            if(gfx_event_waiting()){
                if(gfx_wait()==' ') break;
            }
            presentHomeScreen(width, height);
            stationaryBird(&birdY,degrees);
            flap = drawBird(birdX, birdY, birdR, flap);
            gfx_flush();
            usleep(50000);
            degrees+=(2*M_PI)/20;
        }
    
        //begin animation
        int score = startGame(leadPipe, trailPipe, width, height);
        highScore = endGame(score, highScore, width, height);
        char d;
	
    }
 
	return 0; 
}
Exemplo n.º 4
0
int main()
{
  int xsize = 500;
  int ysize = 300;

  char c;

  // Open a new window for drawing.
  gfx_open(xsize, ysize, "Example Graphics Program");

  // Clear the background.
  gfx_clear();

  // Set the current drawing color 
  gfx_color(0,200,100);

  // Draw a triangle on the screen.
  gfx_line(100,100,200,100);
  gfx_line(200,100,150,150);
  gfx_line(150,150,100,100);

  // change color, and draw a circle
  gfx_color(200,100,50);
  gfx_circle(300,150,40);

  while(1) {
    // Wait for the user to press a character.
    c = gfx_wait();

    // Quit if it is the letter q.
    if(c=='q') break;
  }

  return 0;
}
Exemplo n.º 5
0
void sys_driver_init()
{
  //open screen
  gpio_setup(SCREES_DC, GPIO_OUTPUT);
  gpio_write(SCREES_DC, 0);
  //screen reset
  gpio_setup(SCREES_RES, GPIO_OUTPUT);
  gpio_write(SCREES_RES, 1);
  
  //rgb led
  uint8_t led_pin[] = {28, 29, 30};
  light_setup(led_pin, 0);
  

  //init screen
  SSD1306_Init_Struct init_struct;
  init_struct.SCL = 9;
  init_struct.SDA = 8;

  ssd1306_config(&init_struct);
  
  OLED_Init();    
  OLED_Clear();
  
  gfx_init_screen((uint8_t *)&screen, 128, 32, 1);
  gfx_clear();
  OLED_Refresh_all();
  
  //hall task
  gpio_change_point = NULL;
  gpio_watch(HALL, GPIO_FALLING);
  
  //button
  gpio_setup(BUTTON, GPIO_INPUT_PULLUP);
}
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
	if (argc > 1)
		file = fopen(argv[1], "r");
	gfx_open(width*sizex, width*sizey, "Life");
	// cycle through cells to determine next generation state of each, not including edges for simplicity
	while(1){
		if (choice!='p')
			input(&argc);
		system("clear");
		if (choice=='q')
			break;
		neighborcount();
		// display next generation
		for(y=0; y<sizey; y++){
			for(x=0; x<sizex; x++){
				// transfer state data from temp to new generation life grid 
				if (edit != 1)
					life[y][x]=temp[y][x];
				// reset temp grid
				temp[y][x]=0;
				if (life[y][x]==1){
					gfxcell(x, y);
				}
			}
		}
	gfx_flush();
	usleep(75000);
	if (edit != 1)
		gfx_clear();
	}
}
Exemplo n.º 7
0
/**
 *
 *  rct2: 0x006CF8CD
 */
static void window_track_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex)
{
	rct_string_id stringId, stringId2;
	int i, x, y, colour;
	utf8 *trackDesignItem, *trackDesignList = RCT2_ADDRESS(RCT2_ADDRESS_TRACK_LIST, utf8);

	colour = ColourMapA[w->colours[0]].mid_light;
	colour = (colour << 24) | (colour << 16) | (colour << 8) | colour;
	gfx_clear(dpi, colour);

	i = 0;
	x = 0;
	y = 0;

	trackDesignItem = trackDesignList;
	if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) {
		if (*trackDesignItem == 0) {
			// No track designs
			gfx_draw_string_left(dpi, STR_NO_TRACK_DESIGNS_OF_THIS_TYPE, NULL, 0, x, y - 1);
			return;
		}
	} else {
		// Build custom track item
		if (i == w->track_list.var_482) {
			// Highlight
			gfx_fill_rect(dpi, x, y, w->width, y + 9, 0x2000000 | 49);
			stringId = 1193;
		} else {
			stringId = 1191;
		}

		stringId2 = STR_BUILD_CUSTOM_DESIGN;
		gfx_draw_string_left(dpi, stringId, &stringId2, 0, x, y - 1);
		y += 10;
		i++;
	}

	while (*trackDesignItem != 0) {
		if (y + 10 >= dpi->y && y < dpi->y + dpi->height) {
			if (i == w->track_list.var_482) {
				// Highlight
				gfx_fill_rect(dpi, x, y, w->width, y + 9, 0x2000000 | 49);
				stringId = 1193;
			} else {
				stringId = 1191;
			}

			// Draw track name
			window_track_list_format_name((char *)language_get_string(3165), trackDesignItem, 0, 1);
			stringId2 = 3165;
			gfx_draw_string_left(dpi, stringId, &stringId2, 0, x, y - 1);
		}
		y += 10;
		i++;
		trackDesignItem += 128;
	}
}
Exemplo n.º 8
0
/**
*
*  rct2: 0x006BD785
*/
void window_themes_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex)
{
    sint32 y;

    if (_selected_tab == WINDOW_THEMES_TAB_SETTINGS || _selected_tab == WINDOW_THEMES_TAB_FEATURES)
        return;

    if ((w->colours[1] & 0x80) == 0)
        //gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ColourMapA[w->colours[1]].mid_light);
        gfx_clear(dpi, ColourMapA[w->colours[1]].mid_light);
    y = 0;
    for (sint32 i = 0; i < get_colour_scheme_tab_count(); i++) {
        if (y > dpi->y + dpi->height) {
            break;
        }
        if (y + _row_height >= dpi->y) {
            if (i + 1 < get_colour_scheme_tab_count()) {
                sint32 colour = w->colours[1];
                if (colour & COLOUR_FLAG_TRANSLUCENT) {
                    translucent_window_palette windowPalette = TranslucentWindowPalettes[BASE_COLOUR(colour)];

                    gfx_filter_rect(dpi, 0, y + _row_height - 2, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 2, windowPalette.highlight);
                    gfx_filter_rect(dpi, 0, y + _row_height - 1, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 1, windowPalette.shadow);
                }
                else {
                    colour = ColourMapA[w->colours[1]].mid_dark;
                    gfx_fill_rect(dpi, 0, y + _row_height - 2, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 2, colour);
                    colour = ColourMapA[w->colours[1]].lightest;
                    gfx_fill_rect(dpi, 0, y + _row_height - 1, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 1, colour);
                }
            }

            rct_windowclass wc = get_window_class_tab_index(i);
            sint32 numColours = theme_desc_get_num_colours(wc);
            for (uint8 j = 0; j < numColours; j++) {
                gfx_draw_string_left(dpi, theme_desc_get_name(wc), NULL, w->colours[1], 2, y + 4);

                uint8 colour = theme_get_colour(wc, j);
                uint32 image = SPRITE_ID_PALETTE_COLOUR_1(colour & ~COLOUR_FLAG_TRANSLUCENT) | IMAGE_TYPE_TRANSPARENT | SPR_PALETTE_BTN;
                if (i == _colour_index_1 && j == _colour_index_2) {
                    image = SPRITE_ID_PALETTE_COLOUR_1(colour & ~COLOUR_FLAG_TRANSLUCENT) | IMAGE_TYPE_TRANSPARENT | SPR_PALETTE_BTN_PRESSED;
                }
                gfx_draw_sprite(dpi, image, _button_offset_x + 12 * j, y + _button_offset_y, 0);

                gfx_fill_rect_inset(dpi, _button_offset_x + 12 * j, y + _check_offset_y, _button_offset_x + 12 * j + 9, y + _check_offset_y + 10, w->colours[1], INSET_RECT_F_E0);
                if (colour & COLOUR_FLAG_TRANSLUCENT) {
                    gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
                    gfx_draw_string(dpi, (char*)CheckBoxMarkString, w->colours[1] & 0x7F, _button_offset_x + 12 * j, y + _check_offset_y);
                }

            }
        }

        y += _row_height;
    }
}
Exemplo n.º 9
0
int main () {
	int x, y, dx, dy, radius = 100;
	double pi, i = 0.07;
	char c;

	pi = M_PI;

	gfx_open(500,500,"Rotating Animation Emily");

	printf("To speed up display press f key; to slow down display press s key.\n");

	while (1) {
			drawPerson();

			x = radius*cos(i) + 250;
			y = radius*sin(i) + 150;
			gfx_color(0, 0, 255);
			gfx_circle(x, y, 20); //ball 1 (blue)
		
			x = radius*cos(i+1.5) + 250;
			y = radius*sin(i+1.5) + 150;
			gfx_color(0, 255, 0);
			gfx_circle(x, y, 20); //ball 2 (green)

			x = radius*cos(i+3.) + 250;
			y = radius*sin(i+3.) + 150;
			gfx_color(255, 0, 0);
			gfx_circle(x, y, 20); //ball 3 (red)
			

			gfx_flush();
			usleep(10000);
			gfx_clear();
			

			if (gfx_event_waiting()) {
				c = gfx_wait();
				if (c =='s') { //slows down juggling
					i-=0.1;
				} else if (c =='f') { //speeds  juggling
					i+=0.1;
				} else if (c =='q') {
					break;
				}
			}

			i+= 0.01;
		}

	
	

	return 0;
}
Exemplo n.º 10
0
void intro_draw(rct_drawpixelinfo *dpi)
{
	int screenWidth = gScreenWidth;

	switch (gIntroState) {
	case INTRO_STATE_DISCLAIMER_1:
	case INTRO_STATE_DISCLAIMER_2:
		break;
	case INTRO_STATE_PUBLISHER_BEGIN:
		gfx_clear(dpi, BACKROUND_COLOUR_DARK);
		break;
	case INTRO_STATE_PUBLISHER_SCROLL:
		gfx_clear(dpi, BACKROUND_COLOUR_DARK);

		// Draw a white rectangle for the logo background (gives a bit of white margin)
		gfx_fill_rect(dpi,
			(screenWidth / 2) - 320 + 50, _introStateCounter + 50,
			(screenWidth / 2) - 320 + 50 + 540, _introStateCounter + 50 + 425,
			BORDER_COLOUR_PUBLISHER);

		// Draw Infogrames logo
		gfx_draw_sprite(dpi, SPR_INTRO_INFOGRAMES_00, (screenWidth / 2) - 320 + 69, _introStateCounter + 69, 0);
		gfx_draw_sprite(dpi, SPR_INTRO_INFOGRAMES_10, (screenWidth / 2) - 320 + 319, _introStateCounter + 69, 0);
		gfx_draw_sprite(dpi, SPR_INTRO_INFOGRAMES_01, (screenWidth / 2) - 320 + 69, _introStateCounter + 319, 0);
		gfx_draw_sprite(dpi, SPR_INTRO_INFOGRAMES_11, (screenWidth / 2) - 320 + 319, _introStateCounter + 319, 0);
		break;
	case INTRO_STATE_DEVELOPER_BEGIN:
		gfx_clear(dpi, BACKROUND_COLOUR_DARK);
		gfx_transpose_palette(PALETTE_G1_IDX_DEVELOPER, 255);
		break;
	case INTRO_STATE_DEVELOPER_SCROLL:
		gfx_clear(dpi, BACKROUND_COLOUR_DARK);

		// Draw Chris Sawyer logo
		gfx_draw_sprite(dpi, SPR_INTRO_CHRIS_SAWYER_00, (screenWidth / 2) - 320 + 70, _introStateCounter, 0);
		gfx_draw_sprite(dpi, SPR_INTRO_CHRIS_SAWYER_10, (screenWidth / 2) - 320 + 320, _introStateCounter, 0);
		break;
	case INTRO_STATE_LOGO_FADE_IN:
		if (_introStateCounter <= 0xFF00) {
			gfx_transpose_palette(PALETTE_G1_IDX_LOGO, (_introStateCounter >> 8) & 0xFF);
		} else {
Exemplo n.º 11
0
int main() {
	int size = 500;
	int value = 1;
	int wait;
	int counter = 0;

	gfx_open(size, size, "Graphing Calculator");
	
	while(value != 0) {
		gfx_color(255, 255, 255);
		xAxis(size, size);
		yAxis(size, size);
		
		wait = gfx_wait();
		gfx_color(255, 0, 0);
		switch(wait) {
			case 1:
				gfx_clear();
				counter = 0;
				plot(size, size, counter);
				break;
			case '=':
				gfx_clear();
				counter++;
				plot(size, size, counter);
				break;
			case '-':
				gfx_clear();
				counter--;
				plot(size, size, counter);
				break;
			case 'q':
				value = 0;
				break;
			default:
				break;
		}
		printf("%i\n", counter);
	}
	return 0;
}
Exemplo n.º 12
0
/**
 *
 *  rct2: 0x006CF8CD
 */
static void window_track_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex)
{
    uint8 paletteIndex = ColourMapA[w->colours[0]].mid_light;
    gfx_clear(dpi, paletteIndex);

    sint32 x = 0;
    sint32 y = 0;
    size_t listIndex = 0;
    if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
        if (_trackDesignsCount == 0) {
            // No track designs
            gfx_draw_string_left(dpi, STR_NO_TRACK_DESIGNS_OF_THIS_TYPE, NULL, COLOUR_BLACK, x, y - 1);
            return;
        }
    } else {
        // Build custom track item
        rct_string_id stringId;
        if (listIndex == (size_t)w->selected_list_item) {
            // Highlight
            gfx_filter_rect(dpi, x, y, w->width, y + 9, PALETTE_DARKEN_1);
            stringId = STR_WINDOW_COLOUR_2_STRINGID;
        } else {
            stringId = STR_BLACK_STRING;
        }

        rct_string_id stringId2 = STR_BUILD_CUSTOM_DESIGN;
        gfx_draw_string_left(dpi, stringId, &stringId2, COLOUR_BLACK, x, y - 1);
        y += 10;
        listIndex++;
    }

    for (size_t i = 0; i < _trackDesignsCount; i++, listIndex++) {
        if (y + 10 >= dpi->y && y < dpi->y + dpi->height) {
            rct_string_id stringId;
            if (listIndex == (size_t)w->selected_list_item) {
                // Highlight
                gfx_filter_rect(dpi, x, y, w->width, y + 9, PALETTE_DARKEN_1);
                stringId = STR_WINDOW_COLOUR_2_STRINGID;
            } else {
                stringId = STR_BLACK_STRING;
            }

            // Draw track name
            set_format_arg(0, rct_string_id, STR_TRACK_LIST_NAME_FORMAT);
            set_format_arg(2, utf8*, _trackDesigns[i].name);
            gfx_draw_string_left(dpi, stringId, gCommonFormatArgs, COLOUR_BLACK, x, y - 1);
        }
        y += 10;
    }
Exemplo n.º 13
0
int main(void) {
	

	gfx_open(400,400,"Bounce"); 
	int stillGoing = 1; 
	float dt = 0.01;
	float xpos =rand() %400+1;  
	float ypos =rand() %400+1; 
        float xvel =(double)rand()/RAND_MAX * 10.0 - 5.0; 
	float yvel =(double)rand()/RAND_MAX * 10.0 - 5.0; 
	float RIGHT_EDGE = 400; 
	float LEFT_EDGE = 0; 
	float TOP = 0; 
	float BOTTOM = 400; 

	
	
	while(stillGoing){
		xpos += xvel; 
		ypos += yvel; 
			
		if(xpos <= LEFT_EDGE || xpos >= RIGHT_EDGE) xvel *=-1; 
		if(ypos <= TOP || ypos >= BOTTOM) yvel *= -1; 
		gfx_clear(); 
		drawPoly(30,xpos,ypos); 
		gfx_flush(); 
		usleep(10000); 

		
		if(gfx_event_waiting()){
			char c = gfx_wait(); 
			if(c==1){
				xpos = gfx_xpos(); 		
				ypos = gfx_ypos(); 
			        xvel =(double)rand()/RAND_MAX * 10.0 - 5.0; 
				yvel =(double)rand()/RAND_MAX * 10.0 - 5.0;
			}
			else if (c=='q' || c=='Q'){
				break; 
			}

		}

	}	


	return 0; 

}
Exemplo n.º 14
0
  void setpageInfo() {
    if (NextionPage == 0) {
      Pinfo.show();

      #if HAS(TEMP_0)
        Hotend.setValue(1);
      #endif
      #if HAS(TEMP_1)
        Hotend.setValue(2);
      #endif
      #if HAS(TEMP_2)
        Hotend.setValue(3);
      #elif HAS(TEMP_BED)
        Bed.setValue(1);
        Hotend21.setText("BED");
      #endif

      VSpeed.setValue(100);

      #if HAS(FAN)
        Fan.setValue(1);
      #endif

      lcd_setstatus(lcd_status_message);
    }

    Pinfo.show();

    #if ENABLED(NEXTION_GFX)
      #if MECH(DELTA)
        gfx_clear((X_MAX_POS) * 2, (Y_MAX_POS) * 2, Z_MAX_POS);
      #else
        gfx_clear(X_MAX_POS, Y_MAX_POS, Z_MAX_POS);
      #endif
    #endif
  }
Exemplo n.º 15
0
char win(void)
{
  gfx_clear_color(0,0,255); //blue background
  gfx_clear();
  gfx_color(255,255,255); //white letters

  //You
  gfx_fill_rectangle(370,160,40,60);
  gfx_fill_rectangle(470,160,40,60);
  gfx_fill_rectangle(390,220,100,20);
  gfx_fill_rectangle(410,240,60,60);
 
  //yOu
  gfx_fill_rectangle(530,180,40,100);
  gfx_fill_rectangle(630,180,40,100);
  gfx_fill_rectangle(550,160,100,20);
  gfx_fill_rectangle(550,280,100,20);

  //yoU
  gfx_fill_rectangle(690,160,40,120);
  gfx_fill_rectangle(790,160,40,120);
  gfx_fill_rectangle(710,280,100,20);

  //Won
  gfx_fill_rectangle(370,350,40,140);
  gfx_fill_rectangle(470,350,40,140);
  gfx_fill_rectangle(410,430,20,40);
  gfx_fill_rectangle(430,410,20,40);
  gfx_fill_rectangle(450,430,20,40);

  //wOn
  gfx_fill_rectangle(530,370,40,100);
  gfx_fill_rectangle(630,370,40,100);
  gfx_fill_rectangle(550,350,100,20);
  gfx_fill_rectangle(550,470,100,20);

  //woN
  gfx_fill_rectangle(690,350,40,140);
  gfx_fill_rectangle(790,350,40,140);
  gfx_fill_rectangle(730,370,20,40);
  gfx_fill_rectangle(750,390,20,40);
  gfx_fill_rectangle(770,410,20,40);

  gfx_text(450,520,"Press any key to play Frogger. Press \'q\' to quit.");

  return gfx_wait();
}
Exemplo n.º 16
0
//begin main function
int main (void) 
{		
	int xsize = 800, ysize = 800 ;
	gfx_open( xsize, ysize, "Test Graph of Function triangle_waveform" ) ;

	int stillgoing = 1;

	while (stillgoing) {
		gfx_clear() ;
		gfx_color(255, 255, 255) ;	//axis is white		
		draw_axes( xsize, ysize) ;
		gfx_color(150, 0, 255) ;
		plot_triangle(xsize, ysize, -10., 10, .1) ;
		gfx_flush() ;

		char c = gfx_wait() ;
		if (c == 'q') stillgoing = 0 ;
	}
	return 0 ;
}	//end main		
Exemplo n.º 17
0
PROCESS_THREAD(gfx_update_process, ev, data) {
  PROCESS_BEGIN();

  while (1) {
    PROCESS_YIELD();

    gfx_clear();

    if (gfxState == GFX_STATE_MEASURE) {
      gfx_draw_display_measure();
    } else  if (gfxState == GFX_STATE_RECORD) {
      gfx_draw_display_record();
    } else {
      gfx_draw_display_info();
    }

    gfx_redraw();
  }

  PROCESS_END();
}
Exemplo n.º 18
0
int main(){
	
	char c;
	int width = 500, height = 500, num = 1;
	double x = 1;
	gfx_open(width, height, "Taylor Series Graph");
	while(c != 'q'){
		gfx_clear();
		xAxis();
		yAxis();
		plot(num);
		c = gfx_wait();
		switch(c){
			case '=':
				num++;
			break;
			case '-':
				num--;
			break;
		}
	}
}
Exemplo n.º 19
0
void animateMotion(int xtl, int ytl,int boardHeight,int boardWidth,Location *pacman,Location ghosts[],int height,int width, int lives,int state[],int score,int newScore[],int frightenLoop[],int loop){
/* This function is called after pacman is moved, and animates the movement of pacman,
 * and all the ghosts. While the ghosts' new positions are tabulated in moveGhosts, they
 * are not drawn until this function is called after pacman is moved */
  int i,j,loops=2;

  int x=xtl+pacman->x*radius+radius/2;	//first location to draw, will increment 5 times
  int y=ytl+pacman->y*radius+radius/2;

  Location delta;
  delta.x=(pacman->x-pacman->prevX)*radius/loops;
  delta.y=(pacman->y-pacman->prevY)*radius/loops;
/* Currently, pacman only moves one space abruptly, he cannot smoothly move from cell to cell */
  //for(j=1;j<=loops+1;j++){	//this loop allows the pacman movement to be smooth
    gfx_clear();
    if(loop==1){i=3;}
    drawBoard(xtl,ytl,boardHeight,boardWidth,height,width,lives,i,score);
    drawPacman(x,y,pacman->orientation,0);
    //x+=delta.x;
    //y+=delta.y;
    //usleep(10000);
  //}
  for(i=blinky;i<=clyde;i++){
    x=xtl+ghosts[i].x*radius+radius/2;
    y=ytl+ghosts[i].y*radius+radius/2;
    drawGhost(x,y,i,ghosts[i].orientation,state,frightenLoop[i]);
  }
  /* Check if there needs to be a score displayed */
  if(newScore[0]){
        gfx_color(120,120,120);
        gfx_text(xtl+newScore[1]*radius+radius/2,ytl+newScore[2]*radius+radius/2,num2str(newScore[0]));
        newScore[0]=0;
	newScore[1]=0;
	newScore[2]=0;
  }
}
Exemplo n.º 20
0
  void setpageInfo() {
    Pinfo.show();

    PageInfo = true;

    #if ENABLED(NEXTION_GFX)
      gfx_clear(X_MAX_POS, Y_MAX_POS, Z_MAX_POS);
    #endif

    #if HAS_TEMP_0
      Hotend.setValue(1);
    #endif
    #if HAS_TEMP_1
      Hotend.setValue(2);
    #endif
    #if HAS_TEMP_2
      Hotend.setValue(3);
    #elif HAS_TEMP_BED
      Hotend21.setText("BED");
      Bed.setValue(1);
    #endif

    lcd_setstatus(lcd_status_message);
  }
Exemplo n.º 21
0
void death(double astr[][5], double shots[][5], double *x, double *y, int score[])
{
 int i;
 
 gfx_clear();
 gfx_color(255, 0, 0);
 for(i=0; i<10; i++){
 	gfx_flush();
	gfx_color(255, 0, 0);
	drawship(350, 350, 0, 0);	//redraws ship and pauses to allow user time to recover
 	usleep(100000);
 	gfx_color(255, 255, 255);
	drawship(350, 350, 0, 0);
	usleep(100000);
 	
 }
 gfx_flush();
 *x=350;
 *y=350;
 score[1]=score[1]-1;	//subtracts a life 
 initialize(astr);	//resets astroids and shots
 initialize(shots);

}
Exemplo n.º 22
0
static void window_scenarioselect_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex)
{
	int colour;

	uint8 paletteIndex = ColourMapA[w->colours[1]].mid_light;
	gfx_clear(dpi, paletteIndex);

	rct_string_id highlighted_format = (theme_get_flags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT) ? STR_WHITE_STRING : STR_WINDOW_COLOUR_2_STRINGID;
	rct_string_id unhighlighted_format = (theme_get_flags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT) ? STR_WHITE_STRING : STR_BLACK_STRING;

	bool wide = gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_ORIGIN;

	rct_widget *listWidget = &w->widgets[WIDX_SCENARIOLIST];
	int listWidth = listWidget->right - listWidget->left - 12;

	int y = 0;
	for (sc_list_item *listItem = _listItems; listItem->type != LIST_ITEM_TYPE_END; listItem++) {
		if (y > dpi->y + dpi->height) {
			continue;
		}

		switch (listItem->type) {
		case LIST_ITEM_TYPE_HEADING:;
			const int horizontalRuleMargin = 4;
			draw_category_heading(w, dpi, horizontalRuleMargin, listWidth - horizontalRuleMargin, y + 2, listItem->heading.string_id);
			y += 18;
			break;
		case LIST_ITEM_TYPE_SCENARIO:;
			// Draw hover highlight
			const scenario_index_entry *scenario = listItem->scenario.scenario;
			bool isHighlighted = w->highlighted_scenario == scenario;
			if (isHighlighted) {
				gfx_filter_rect(dpi, 0, y, w->width, y + 23, PALETTE_DARKEN_1);
			}

			bool isCompleted = scenario->highscore != NULL;
			bool isDisabled = listItem->scenario.is_locked;

			// Draw scenario name
			char buffer[64];
			safe_strcpy(buffer, scenario->name, sizeof(buffer));
			rct_string_id format = isDisabled ? STR_STRINGID : (isHighlighted ? highlighted_format : unhighlighted_format);
			set_format_arg(0, rct_string_id, STR_STRING);
			set_format_arg(2, char *, buffer);
			colour = isDisabled ? w->colours[1] | COLOUR_FLAG_INSET : COLOUR_BLACK;
			if (isDisabled) {
				gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
			}
			gfx_draw_string_centred(dpi, format, wide ? 270 : 210, y + 1, colour, gCommonFormatArgs);

			// Check if scenario is completed
			if (isCompleted) {
				// Draw completion tick
				gfx_draw_sprite(dpi, SPR_MENU_CHECKMARK, wide ? 500 : 395, y + 1, 0);

				// Draw completion score
				const utf8 *completedByName = "???";
				if (!str_is_null_or_empty(scenario->highscore->name)) {
					completedByName = scenario->highscore->name;
				}
				safe_strcpy(buffer, completedByName, 64);
				set_format_arg(0, rct_string_id, STR_COMPLETED_BY);
				set_format_arg(2, rct_string_id, STR_STRING);
				set_format_arg(4, char *, buffer);
				gfx_draw_string_centred(dpi, format, wide ? 270 : 210, y + 11, COLOUR_BLACK, gCommonFormatArgs);
			}

			y += 24;
			break;
		}
	}
}
Exemplo n.º 23
0
int main(int argc, char* argv[]){
	unsigned int size;/*Tamanho do triangulo*/
	unsigned int default_size;/*Tamanho padrão do triangulo*/
	unsigned int amount; /*Quantidade de triangulos*/
	int quit; /*Verifica se o programa deve ser encerrado*/
	char* msg; /*Auxiliar para colocar as informaçoes na tela*/
	SDL_Event event; /*guarda um evento ocorrido*/
	
	msg = (char*) malloc(sizeof(char) * 30); /*Aloca memoria para a string auxiliar*/
	if(!msg){/*Verifica se foi alocado*/
		printf("Erro ao alocar memoria.\n");
		exit (0);
	}

	amount = 0;/*Inicializa o contador de triangulos*/
	default_size = 100;/*Define o tamanho padrão do triangulo para caso o usuario não tenha definido*/

	if(argc != 1){/*Verifica se foi passado algum argumento na chamada do programa*/
		if(atoi(argv[1]) != 0){/*Se o argumento for um numero ele sera o tamanho padrão do triangulo*/
			default_size = atoi(argv[1]);
		}
	}
	
	size = default_size;/*Define o tamanho com o tamanho padrão*/
	
	gfx_init("Sierpinski");/*Seta o nome da janela*/
	
	sierpinski((gfx_get_width() / 2) - (size / 2), gfx_get_height() - (int)((size * 1.732050808) / 2), size, &amount);/*Desenha o triangulo com o tamanho incial*/
	sprintf(msg, "Lado: %d     Quantidade: %u", size, amount);
	gfx_text(10, 10, msg);/*Imprime as informacões do triangulo*/
	gfx_text(10, 30, "Atalhos: Zoom(i)n - Zoom(o)ut - (C)lear - (esc)ape");/*Imprime o menu*/
	gfx_paint();
	
	while(!quit){/*Loop principal*/
		while(SDL_PollEvent(&event)){/*Verifica se ocorreu algum evento*/
			switch(event.type){/*Seleciona o tipo de evento*/
				case SDL_QUIT:/*Clique no botão de fechar*/
					quit = 1;/*sair do loop principal*/
					break;
				case SDL_KEYDOWN:/*Tecla pressionada*/
					while(event.key.state == SDL_PRESSED && quit == 0){/*Tecla continua pressionada e não é o ESC*/
						switch (event.key.keysym.sym){/*Seleciona a tecla*/
							case SDLK_i:/*Caso seja 'i' os triangulos aumentam*/
								size += 5;/*Incrementa o tamanho do triangulo*/
								gfx_clear();/*Limpa a tela*/
								amount = 0;/*Zera o contador de triangulos*/
								sierpinski((gfx_get_width() / 2) - (size / 2), gfx_get_height() - (int)((size * 1.732050808) / 2), size, &amount);/*Desenha o triangulo de Sierpinski*/
								sprintf(msg, "Lado: %d     Quantidade: %u", size, amount);
								gfx_text(10, 10, msg);/*Imprime as informacões do triangulo*/
								gfx_text(10, 30, "Atalhos: Zoom(i)n - Zoom(o)ut - (C)lear - (esc)ape");/*Imprime o menu*/
								break;

							case SDLK_o:/*Caso seja 'o' os triangulos diminuem*/
								size -= 5;
								gfx_clear();
								amount = 0;
								sierpinski((gfx_get_width() / 2) - (size / 2), gfx_get_height() - (int)((size * 1.732050808) / 2), size, &amount);
								sprintf(msg, "Lado: %d     Quantidade: %u", size, amount);
								gfx_text(10, 10, msg);/*Imprime as informacões do triangulo*/
								gfx_text(10, 30, "Atalhos: Zoom(i)n - Zoom(o)ut - (C)lear - (esc)ape");/*Imprime o menu*/
								break;

							case SDLK_c: /*Caso seja 'c' o triangulo é resetado*/
								size = default_size;/*Define o tamanho com o tamanho padrão*/
								gfx_clear();/*Limpa tela*/
								amount = 0;/*Zera o contador de triangulos*/
								sierpinski((gfx_get_width() / 2) - (size / 2), gfx_get_height() - (int)((size * 1.732050808) / 2), size, &amount);/*Desenha o triangulo com o tamanho padrão*/
								sprintf(msg, "Lado: %d     Quantidade: %u", size, amount);
								gfx_text(10, 10, msg);/*Imprime as informacões do triangulo*/
								gfx_text(10, 30, "Atalhos: Zoom(i)n - Zoom(o)ut - (C)lear - (esc)ape");/*Imprime o menu*/
								break;

							case SDLK_ESCAPE: /*Caso seja 'ESC' encerra o programa*/
								quit = 1;
								break;
							
							default:/*Outra tecla nada é feito*/
								break;
						}
						gfx_refresh();/*Atualiza a tela*/
						usleep(120000);/*Delay para ler um novo evento*/
						SDL_PollEvent(&event);/*Le um novo evento*/
					}
					break;
			}
		}
	}

	gfx_quit();/*Fecha a janela*/
	free(msg);/*Libera a memoria alocada*/
	return 0;
}
Exemplo n.º 24
0
int main(void)			// we will be constructing a symbolic typewriter using a basic graphics library
{
	int mousePosX;		// mouse point position in x and y directions
	int mousePosY;

	int screenX = 900;	// screen resolution in pixels
	int screenY = 900;

	float x1;		// position 1
	float y1;

	float x2;		// position 2
	float y2; 

	float radians;		// need radians and radius when dealing with polar coordinated
	float radius;

	float pi = atan(1)*4;	// pi constant
	
	int min = 0;		// minimum number of degrees
	int c = 0;		// counter for for loops
	int randomDegrees = 0;	// random integer degree
	int polygon = 0;	// place for number of polygon sides

	char user;		// this will be the value of the user input 

	srand(time(NULL));	// random integer seed

	// begin symbolic typewriter

	gfx_open(screenX, screenY, "Symbolic Typewriter");

	while( 1 )
	{
		user = gfx_wait();		// waiting for a user-given symbol

		switch( user )
		{	
			case 1:			// mouse click, we will print a blue square outline
			{
				gfx_color(0, 0, 255);		// changing color to blue

				radius = 25;

				mousePosX = gfx_xpos();		// storing the current mouse position
				mousePosY = gfx_ypos();

				x1 = mousePosX + radius;	// upper right point
				y1 = mousePosY + radius;

				x2 = mousePosX - radius;	// upper left point
				y2 = mousePosY + radius;

				gfx_line((int)x1, (int)y1, (int)x2, (int)y2);	// top line		

				x1 = mousePosX + radius;	// upper right point
				y1 = mousePosY + radius;

				x2 = mousePosX + radius;       	// lower right point
				y2 = mousePosY - radius;

				gfx_line((int)x1, (int)y1, (int)x2, (int)y2);  	// right line

				x1 = mousePosX + radius;       	// lower right point
				y1 = mousePosY - radius;

				x2 = mousePosX - radius;       	// lower left point
				y2 = mousePosY - radius;

				gfx_line((int)x1, (int)y1, (int)x2, (int)y2); 	// lower line

				x1 = mousePosX - radius;       	// lower left point
				y1 = mousePosY - radius;

				x2 = mousePosX - radius;       	// upper left point
				y2 = mousePosY + radius;

				gfx_line((int)x1, (int)y1, (int)x2, (int)y2);	// left line
			
				gfx_flush();		// actually draw the square
			
				break;
			}

			case 't':		// display a green triangle outline	
			{
				gfx_color(0, 255, 0);		// changing color to green

				radius = 25;

                                mousePosX = gfx_xpos();		// storing the current mouse position
                                mousePosY = gfx_ypos();

                                x1 = mousePosX;			// upper point
                                y1 = mousePosY - radius;

                                x2 = mousePosX + radius;	// lower right point
                                y2 = mousePosY + radius;

                                gfx_line((int)x1, (int)y1, (int)x2, (int)y2);   // right line

                                x1 = mousePosX + radius;	// lower right point
                                y1 = mousePosY + radius;

                                x2 = mousePosX - radius;      	// lower left point
                                y2 = mousePosY + radius;

                                gfx_line((int)x1, (int)y1, (int)x2, (int)y2);   // bottom line
			
				x1 = mousePosX - radius;	// lower left point
                                y1 = mousePosY + radius;

                                x2 = mousePosX;             	// upper point
                                y2 = mousePosY - radius;

                                gfx_line((int)x1, (int)y1, (int)x2, (int)y2);   // left line

				gfx_flush();
			
				break;
			}

			case 'c':		// display a white circle outline
			{
				gfx_color(255, 255, 255);	// change the color to white
			
				radius = 25;			// circle radius of 5 pixels

				mousePosX = gfx_xpos();
				mousePosY = gfx_ypos();

				x2 = mousePosX + radius;		// determine the first point
				y2 = mousePosY;
			
				for( c = 0; c <= 360; c++ )		// go through an entire circle (convert to radians)
				{
					x1 = x2;			// assign the last point to be the first point for the next line
					y1 = y2;
		
					x2 = mousePosX + (cos(c*pi/180)*radius);
					y2 = mousePosY + (sin(c*pi/180)*radius);

					gfx_line((int)x1, (int)y1, (int)x2, (int)y2);
				}

				gfx_flush();

				break;
			}	

			case '3': 
			case '4': 
			case '5': 
			case '6': 
			case '7': 
			case '8': 
			case '9':				// print a polygon with the alotted number of sides
			{
				switch ( user )			// find the integer number of sides
				{
					case '3':
					{
						polygon = 3;
						min = 80;	// setting the minimum degrees between each point
						break;		// the angle must be between this min and 360/sides
					}
					case '4':
					{
						polygon = 4;
						min = 65;
						break;
					}
					case '5':
					{
						polygon = 5;
						min = 62;
						break;
					}
					case '6':
					{
						polygon = 6;
						min = 55;
						break;
					}
					case '7':
					{
						polygon = 7;
						min = 50;
						break;
					}
					case '8':
					{
						polygon = 8;
						min = 45;
						break;
					}
					case '9':
					{
						polygon = 9;
						min = 39;
						break;
					}
				}
	
				gfx_color(150, 0, 150);		// change the color to purple

				radius = 50;
				randomDegrees = 0;

				mousePosX = gfx_xpos();
				mousePosY = gfx_ypos();

				x2 = mousePosX + radius;		// determine the first point
				y2 = mousePosY;

				for( c = 1; c < polygon; c++ )		// making only the specified number of points
				{
					x1 = x2;			// assign the last point to be the first point for the next line
					y1 = y2; 
					
					randomDegrees = randomDegrees + (min + (rand() % ((360 / polygon)-min+2)));	// random integer degree limit

					// the degrees added are in the range of min to max, where the max is dependent on the number of sides

					x2 = mousePosX + (cos(randomDegrees*pi/180)*radius);
					y2 = mousePosY + (sin(randomDegrees*pi/180)*radius);

					gfx_line((int)x1, (int)y1, (int)x2, (int)y2);
				}
				
				x1 = x2;			// for the last point we need to make sure it returns to the original point
				y1 = y2;

				x2 = mousePosX + radius;
				y2 = mousePosY;
	
				gfx_line((int)x1, (int)y1, (int)x2, (int)y2);
			
				gfx_flush();

				break;
			}			

			case ' ':		// clear the graphics window
			{
				gfx_clear();
			
				break;
			}

			case 'q':		// quit the graphics window		
			{
				break;
			}
		}

		if( user == 'q' )		// quitting actual while loop
		{
			break;
		}
	}
}
Exemplo n.º 25
0
void background(int w,int h,int level)
{  
	int wnum=50,wseg=w/wnum,hnum=100,hseg=h/hnum,i,ic; //define parameters
   
	gfx_clear_color(0,0,0);
	gfx_clear();
	gfx_color(255,255,255); //white
 	gfx_text(w/2, h-20, "Use arrow keys to navigate frog safely to a lilly pad. Do not get hit by a car or fall in the water.");
 	gfx_text(w/4,h-20,"LEVEL: ");
 	gfx_text(w/4+50,h-20,num2str(level));
 
	gfx_color(20,0,150); //blue color
	gfx_fill_rectangle(0,0,w,h/2); //draws water
    
	gfx_color(20,150,0); //green color
	gfx_fill_rectangle(0,0,w,hseg); //draws top green border
    
	for(i=0;i<6;i++) //draws lily pads
    	for(ic=1;ic<(3*hseg);ic++) //increment radius to fill circle
        	gfx_circle((i*8+5)*wseg,5*hseg,ic);
       	 
	for(i=0;i<wnum;i++){ //draws pad details
    	if((i+2)%4!=0)
        	gfx_fill_rectangle(wseg*i*2,hseg,2*wseg,hseg);
       	 
    	if((i+1)%8<4){
        	switch((i+2)%4){
            	case 1:
                	gfx_fill_rectangle(wseg*i,2*hseg,wseg,hseg);
                	gfx_fill_rectangle(wseg*i,4*hseg,wseg,2*hseg);
                	break;
            	case 2:
                	gfx_fill_rectangle(wseg*i,3*hseg,wseg,2*hseg);
                	gfx_fill_rectangle(wseg*i,6*hseg,wseg,1*hseg);
                	break;
            	case 3:
                	gfx_fill_rectangle(wseg*i,2*hseg,wseg,2*hseg);
                	gfx_fill_rectangle(wseg*i,5*hseg,wseg,2*hseg);
                	break;
            	case 0:
                	gfx_fill_rectangle(wseg*i,2*hseg,wseg,hseg);
                	gfx_fill_rectangle(wseg*i,4*hseg,wseg,2*hseg);
                	break;
        	} //end switch((i+2)%4)
    	} //end if((i+1)%8<4)
   	 
    	switch(i%8){ //draw middle grass
            	case 0:
            	case 1:
            	case 3:
            	case 6:
                	gfx_fill_rectangle(wseg*i,(h/2)-(4*hseg),wseg,5*hseg);
                	break;
            	case 2:
            	case 7:
                	gfx_fill_rectangle(wseg*i,(h/2)-(5*hseg),wseg,7*hseg);
                	break;
            	case 4:
                	gfx_fill_rectangle(wseg*i,(h/2)-(4*hseg),wseg,6*hseg);
                	break;
            	case 5:
                	gfx_fill_rectangle(wseg*i,(h/2)-(5*hseg),wseg,6*hseg);
                	break;
        	} //end switch((i+2)%4)
       	 
    	switch(i%8){ //draw bottom grass
        	case 0:
        	case 1:
        	case 3:
        	case 6:
            	gfx_fill_rectangle(wseg*i,h-(18*hseg),wseg,5*hseg);
            	break;
        	case 2:
        	case 7:
            	gfx_fill_rectangle(wseg*i,h-(19*hseg),wseg,7*hseg);
            	break;
        	case 4:
            	gfx_fill_rectangle(wseg*i,h-(18*hseg),wseg,6*hseg);
            	break;
        	case 5:
            	gfx_fill_rectangle(wseg*i,h-(19*hseg),wseg,6*hseg);
            	break;
    	} //end switch((i+2)%4)
   	 
	} //end for(i=0;i<wnum;i++)
    
	gfx_color(150,75,0); //brown color
	for(i=0;i<wnum;i++){ //draws grass details
    	switch(i%8){ //draw middle grass details
            	case 0:
            	case 1: break;
            	case 3:
            	case 6:
                	gfx_fill_rectangle(wseg*i,(h/2)-(2*hseg),wseg,hseg);
                	break;
            	case 2:
            	case 7:
                	gfx_fill_rectangle(wseg*i,(h/2)-(4*hseg),wseg,hseg);
                	break;
            	case 4:
                	gfx_fill_rectangle(wseg*i,(h/2)-(3*hseg),wseg,hseg);
                	break;
            	case 5:
                	gfx_fill_rectangle(wseg*i,(h/2)-hseg,wseg,hseg);
                	break;
        	} //end switch((i+2)%4)
       	 
        	switch(i%8){ //draw bottom grass details
            	case 0:
            	case 1: break;
            	case 3:
            	case 6:
                	gfx_fill_rectangle(wseg*i,h-(16*hseg),wseg,hseg);
                	break;
            	case 2:
            	case 7:
                	gfx_fill_rectangle(wseg*i,h-(18*hseg),wseg,hseg);
                	break;
            	case 4:
                	gfx_fill_rectangle(wseg*i,h-(17*hseg),wseg,hseg);
                	gfx_fill_rectangle(wseg*i,h-(14*hseg),wseg,hseg);
                	break;
            	case 5:
                	gfx_fill_rectangle(wseg*i,h-(15*hseg),wseg,hseg);
                	break;
        	} //end switch((i+2)%4)
       	 
	} //end for(i=0;i<wnum;i++)
    
} //end background
Exemplo n.º 26
0
char welcome(void)
{
	gfx_clear_color(0,255,0); //green
	gfx_clear();

	gfx_color(255,255,255);

	//Frogger
	gfx_fill_rectangle(50,160,40,140);
	gfx_fill_rectangle(90,160,100,20);
	gfx_fill_rectangle(90,220,80,20);

	//fRogger
	gfx_fill_rectangle(210,160,40,140);
	gfx_fill_rectangle(250,160,80,20);
	gfx_fill_rectangle(310,180,40,60);
	gfx_fill_rectangle(290,220,20,20);
	gfx_fill_rectangle(250,240,60,20);
	gfx_fill_rectangle(270,260,60,20);
	gfx_fill_rectangle(300,280,60,20);

	//frOgger
	gfx_fill_rectangle(370,180,40,100);
	gfx_fill_rectangle(470,180,40,100);
	gfx_fill_rectangle(390,160,100,20);
	gfx_fill_rectangle(390,280,100,20);

	//froGger
	gfx_fill_rectangle(570,160,100,20);  
	gfx_fill_rectangle(550,180,40,20);
	gfx_fill_rectangle(530,200,40,60);
	gfx_fill_rectangle(550,260,40,20);
	gfx_fill_rectangle(570,280,100,20);
	gfx_fill_rectangle(630,260,40,20);
	gfx_fill_rectangle(610,240,60,20);

	//frogGer
	gfx_fill_rectangle(730,160,100,20);  
	gfx_fill_rectangle(710,180,40,20);
	gfx_fill_rectangle(690,200,40,60);
	gfx_fill_rectangle(710,260,40,20);
	gfx_fill_rectangle(730,280,100,20);
	gfx_fill_rectangle(790,260,40,20);
	gfx_fill_rectangle(770,240,60,20);

	//froggEr
	gfx_fill_rectangle(850,160,40,140);
	gfx_fill_rectangle(890,160,100,20);
	gfx_fill_rectangle(890,220,80,20);
	gfx_fill_rectangle(890,280,100,20);

	//froggeR
	gfx_fill_rectangle(1010,160,40,140);
	gfx_fill_rectangle(1050,160,80,20);
	gfx_fill_rectangle(1110,180,40,60);
	gfx_fill_rectangle(1090,220,20,20);
	gfx_fill_rectangle(1050,240,60,20);
	gfx_fill_rectangle(1070,260,60,20);
	gfx_fill_rectangle(1100,280,60,20);

	gfx_text(530,325, "CSE20211: Final Project");
	gfx_text(510,345, "Sara Cunningham and Jenna Wilson");
	gfx_text(470,365, "Press any key to play Frogger. Press \'q\' to quit");

	return gfx_wait();
} //end welcome
Exemplo n.º 27
0
char blood(void)
{
	gfx_clear_color(255,0,0);
	gfx_clear();

	gfx_color(255,255,255);

	//Game over
	gfx_fill_rectangle(330,160,100,20);  
	gfx_fill_rectangle(310,180,40,20);
	gfx_fill_rectangle(290,200,40,60);
	gfx_fill_rectangle(310,260,40,20);
	gfx_fill_rectangle(330,280,100,20);
	gfx_fill_rectangle(390,260,40,20);
	gfx_fill_rectangle(370,240,60,20);

	//gAme over
	gfx_fill_rectangle(450,200,40,100);
	gfx_fill_rectangle(470,180,40,20);
	gfx_fill_rectangle(490,160,60,20);
	gfx_fill_rectangle(530,180,40,20);
	gfx_fill_rectangle(550,200,40,100);
	gfx_fill_rectangle(490,240,60,20);

	//gaMe over
	gfx_fill_rectangle(610,160,40,140);
	gfx_fill_rectangle(650,180,20,40);
	gfx_fill_rectangle(670,200,20,40);
	gfx_fill_rectangle(690,180,20,40);
	gfx_fill_rectangle(710,160,40,140);

	//gamE over
	gfx_fill_rectangle(770,160,40,140);
	gfx_fill_rectangle(810,160,100,20);
	gfx_fill_rectangle(810,220,80,20);
	gfx_fill_rectangle(810,280,100,20);

	//game Over
	gfx_fill_rectangle(290,370,40,100);
	gfx_fill_rectangle(390,370,40,100);
	gfx_fill_rectangle(310,350,100,20);
	gfx_fill_rectangle(310,470,100,20);

	//game oVer
	gfx_fill_rectangle(450,350,40,80);
	gfx_fill_rectangle(550,350,40,80);
	gfx_fill_rectangle(470,430,40,20);
	gfx_fill_rectangle(530,430,40,20);
	gfx_fill_rectangle(490,450,60,20);
	gfx_fill_rectangle(510,470,20,20);

	//game ovEr
	gfx_fill_rectangle(610,350,40,140);
	gfx_fill_rectangle(650,350,100,20);
	gfx_fill_rectangle(650,410,80,20);
	gfx_fill_rectangle(650,470,100,20);

	//game oveR
	gfx_fill_rectangle(770,350,40,140);
	gfx_fill_rectangle(810,350,80,20);
	gfx_fill_rectangle(870,370,40,60);
	gfx_fill_rectangle(850,410,20,20);
	gfx_fill_rectangle(810,430,60,20);
	gfx_fill_rectangle(830,450,60,20);
	gfx_fill_rectangle(860,470,60,20);

	//directions to continue
	gfx_text(450, 520, "Press any key to play Frogger again. Press \'q\' to quit.");

	return gfx_wait();
} //end blood
Exemplo n.º 28
0
int main(){
	int xposS = 370;
	char c; //user input
	int xdist = 0, ydist =0;
	int dx = 1;
	int Bnum = 0;
	int posB[2][10] = {0};
	unsigned int i, j;

	gfx_open(SIZEX, SIZEY, "Space Invaders"); //open window
	initializeBullets(posB);
	
	while(true){
		gfx_clear(); //clear screen

		dispScore();

		uShooter(xposS);
		drawAliens(xdist, ydist);

		if(gfx_event_waiting()){ //if true
			c = gfx_wait(); //find choice
			if (c == 'b'){
				xposS-=10;
				if (xposS <= 0) xposS = 0;
			}else if (c == 'n'){
				xposS +=10;
				if (xposS >= SIZEX-30) xposS = SIZEX-30;
			}else if (c == ' '){
				for(i=0; i<10; i++){
					if(posB[0][i] == -1){
						posB[0][i] = drawBullet(xposS);
						posB[1][i] = YPOS;
					}
				}
			}else if (c == 'q') return 0;		
			else continue;
			
		}
		
		xdist+=dx;

		if(xdist>=370 || xdist <=-100){
			dx*=-1;
		}
		if(xdist == 370 || xdist ==-100){
			ydist +=5;
		}
		if(ydist == 225) return 0; //change lives num	

		
		for(j=0; j<10; j++){
			if(posB[0][j] != -1){
				moveBullet(posB, j);	
			}
			checkBullet(posB,j);
		}



		usleep(25000);
		gfx_flush();
	}
}
int title_screen(const char *commands[100], int *f, double noteinfo[2][1000], char output[1000]){

int xsize=1250;
int ysize=1000;
int xpos;
int ypos;
int height=400;
int width=(xsize-50)/16;
int i,j;
char input[20];
char initial[1000];
char c;
gfx_open(xsize, ysize, "Digital Piano");
quit_button();
draw_title(100);
draw_name(50);
draw_name2(50);
draw_button(295,600,70,310);
draw_button(645,600,70,310);
button_label(60);
button_label2(60);

while (1){

	c=gfx_wait();
	xpos=gfx_xpos();
	ypos=gfx_ypos();
	//user clicks the quit button
	if (xpos>=1110 && xpos<=1210 && ypos>=850 && ypos<=890){
		return 0;
	}

	//user clicks free play button
	if (xpos>=295 && xpos<=605 && ypos>=600 && ypos<=670){
		gfx_clear();
		piano_graphic(commands, f);

	}
	//user clicks load file button
	if (xpos>=645 && xpos<=955 && ypos>=600 && ypos<=670){
		terminal_message();
		printf("Please enter the name of the file, including the extension.\nThe file content should follow the same format as the examples in lab 8:\n");
		scanf("%s", input);
		//scans file name into input
		FILE *music=fopen(input, "r");
		if ((music=fopen(input, "r")) == NULL){
			//returns error if file not found
			puts("File could not be opened");
			return 0;
		}

		else{
			//scans the file into output
			for (j=0; j<1000; j++){
			fscanf(music, "%c", &output[j]);
			if (output[j]=='X'){
				break;
			}
			}
			
		}

		piano2(noteinfo, output);
		//fork to play sound while lighting up keys
		if (fork()){
			system("play sound.wav");
		}
		else{
		gfx_clear();
		draw_piano(width, height);
		draw_arrow(50, f);
		gfx_color(255,255,255);
		draw_box();
		octave_label(30);
		quit_button();
		gfx_flush();
		key_animation(noteinfo, f);
		return 0;
		}
	
	}

}

}
Exemplo n.º 30
0
int update()
{
    if (get_active_screen() == NULL)
    {
        return 1;
    }

    timestamp_t current = {0};
    timestamp_set(&current);
    long dt = timestamp_diff(&current, &timer);
    if (dt > 0)
    {
        timer = current;
        screen_update(dt);
    }

    long fps_dt = timestamp_diff(&current, &fps_timer);
    LOGD("DT: %ld", fps_dt);
    if (fps_dt > 500)
    {
        fps = frames * 1000.0f / (float)fps_dt;
        fps_timer = current;
        frames = 0;
        LOGI("FPS: %.2f", fps);
    }
    else
    {
        ++frames;
    }

    char fps_str[32] = {0};
    sprintf(fps_str, "FPS: %.2f", fps);

    const rect_t fps_rect = { 8.0f, 8.0f, 256.0f, 32.0f };
    const rgba_t fps_color = { 1.0f, 0.0f, 0.0f, 0.8f };

    mat4f_t transform = {0};
    mat4_mult(&transform, &camera.proj, &camera.view);

    rect_t screen = { 0, 0, screen_size.x, screen_size.y };

    rgba_t color = {0.7f, 0.7f, 0.0f, 1.0f };

    gfx_set_target(gfx, "test_target", &screen);
    gfx_enable_depth_buffer(gfx, 1);

    gfx_clear(gfx);
    screen_render(gfx, &camera);
    gfx_set_shader(gfx, "text");
    gfx_set_uniform_mat4f(gfx, "uMVP", 1, &transform);
    draw_text(fps_str, &fps_rect, 0.0f, 4.9f, &fps_color);
    gfx_flush(gfx);

    static int take_screenshot = 0;
    if (take_screenshot && frames == 0)
    {
        take_screenshot = 0;

        image_t* img = NULL;
        if (gfx_take_screenshot(gfx, &img) == 0)
        {
            image_save_to_png(img, "screenshot.png");
            image_free(img);
        }
    }

    gfx_set_target(gfx, NULL, &screen);
    gfx_enable_depth_buffer(gfx, 0);
    gfx_clear(gfx);

    int32_t sampler = 0;
    rect_t uv = { 0, screen.height/buffer_size.y, screen.width/buffer_size.x, -screen.height/buffer_size.y };

    gfx_set_shader(gfx, "postprocess");
    gfx_set_uniform_mat4f(gfx, "uMVP", 1, &transform);
    gfx_set_uniform_1i(gfx, "uTex", 1, &sampler);
    gfx_set_texture(gfx, "test_texture", sampler);
    gfx_render_textured_rect(gfx, &screen, 1.0f, &uv);
    gfx_set_texture(gfx, NULL, sampler);

    gfx_flush(gfx);

    return 0;
}