void draw_ball(pixbuf_t *pixbuf, int x, int y, int color)
{
	x = scale_input(x);
	y = scale_input(y);
	graphics_draw_rectangle(pixbuf, x-1, y+3, x+1, y+3, color);
	graphics_draw_rectangle(pixbuf, x-2, y+2, x+2, y+2, color);
	graphics_draw_rectangle(pixbuf, x-3, y-1, x+3, y+1, color);
	graphics_draw_rectangle(pixbuf, x-2, y-2, x+2, y-2, color);
	graphics_draw_rectangle(pixbuf, x-1, y-3, x+1, y-3, color);
}
void draw_field(pixbuf_t *pixbuf)
{
	//black background
	//graphics_draw_rectangle(pixbuf, 0, 0, 640-1, 480-1, 0xFF);
	//Top and bottom white walls
	graphics_draw_rectangle(pixbuf, 0, 0, 640-1, 10, 0x00);
	graphics_draw_rectangle(pixbuf, 0, 480-11, 640-1, 480-1, 0x00);
	//dashed line down center court
	int i;
	for (i = 0; i < 16; i++){
		graphics_draw_rectangle(pixbuf, 317, i*30 + 13, 321, i*30 + 17, 0x00);
	}
}
void draw_wall(pixbuf_t *pixbuf){
	//138 = brown, 14 = grey, 120=dark grey
	graphics_draw_rectangle(pixbuf, (280), (11), (360), (468), 14);
	int i, j, k;
	//Lines slow down the game speed by a fair bit.
	for (i = 0; i < 45; i++){
		graphics_draw_line(pixbuf,280, 20+i*10, 360, 20+i*10, 138);
		if (i%2 == 0){
			for (j = 0; j < 3; j++)
				graphics_draw_line(pixbuf, 300+j*20, 10+i*10, 300+j*20, 20+i*10, 120);
		}
		else{
			for (j = 0; j < 4; j++)
				graphics_draw_line(pixbuf,290+j*20, 10+i*10, 290+j*20, 20+i*10, 120);
		}
	}
}
Beispiel #4
0
static void
cursor_draw_do(struct cursor *this_, int lazy)
{
	struct point p;
	int speed=this_->speed;
	int angle=this_->angle;

	if (!this_->attrs || !this_->gra)
		return;
	if (!this_->gra)
		return;
	transform_set_yaw(this_->trans, -this_->angle);
	graphics_draw_mode(this_->gra, draw_mode_begin);
	p.x=0;
	p.y=0;
	graphics_draw_rectangle(this_->gra, this_->bg, &p, this_->w, this_->h);
	for (;;) {
		struct attr **attr=this_->attrs;
		int sequence=this_->sequence;
		int match=0;
		while (*attr) {
			if ((*attr)->type == attr_itemgra) {
				struct itemgra *itm=(*attr)->u.itemgra;
				dbg(1,"speed %d-%d %d\n", itm->speed_range.min, itm->speed_range.max, speed);
				if (speed >= itm->speed_range.min && speed <= itm->speed_range.max &&  
				    angle >= itm->angle_range.min && angle <= itm->angle_range.max &&  
				    sequence >= itm->sequence_range.min && sequence <= itm->sequence_range.max) {
					graphics_draw_itemgra(this_->gra, itm, this_->trans);
					match=1;
				}
			}
			attr++;
		}
		if (match) {
			break;
		} else {
			if (this_->sequence) 
				this_->sequence=0;
			else
				break;
		}
	}
	graphics_draw_drag(this_->gra, &this_->cursor_pnt);
	graphics_draw_mode(this_->gra, lazy ? draw_mode_end_lazy : draw_mode_end);
}
Beispiel #5
0
int main()
{
	unsigned int row, col;
	unsigned int i = 0;
	unsigned int j = 0;
	pixbuf_t *pixbuf;

	graphics_init();
	pixbuf = graphics_get_final_buffer();

	alt_putstr("Restoring default palette\n");
	switch_palette(&palette_332);

	graphics_clear_screen();

	// Draw to edges of screen
	graphics_draw_rectangle(pixbuf, 0, 0, 640-1, 480-1, 0xE0);
	graphics_draw_rectangle(pixbuf, 1, 1, 640-2, 480-2, 0xFF);
	ALT_CI_CI_FRAME_DONE_0;

	// Draw the colors at the top of the screen
	for (i = 0; i < sizeof(color_array); i++)
	{
		graphics_draw_rectangle(pixbuf, i, 0, i, 0, color_array[i]);
	}

	// Cycle through a pattern
	for (i = 0; i < 256; i++)
	{
		graphics_draw_rectangle(pixbuf, 300, 50, 301, 127, color_array[i % sizeof(color_array)]);
		graphics_draw_rectangle(pixbuf, 201, 111, 400, 230, color_array[(i+4) % sizeof(color_array)]);
		graphics_draw_rectangle(pixbuf, 100, 200, 500, 430, color_array[(i+8) % sizeof(color_array)]);
		ALT_CI_CI_FRAME_DONE_0;
		for (j = 0; j < 10000; j++)
		{
			// Do nothing
		}
	}

	graphics_clear_screen();

	// Draw a geometric pattern in the most inefficient way possible...
	for (row = 0; row < 480; row++)
	{
		for (col = 0; col < 640; col++)
		{
			if (row == col) {
				graphics_draw_rectangle(pixbuf, col, row, col, row, 0xFF);
			}
			if (row == col - 160) {
				graphics_draw_rectangle(pixbuf, col, row, col, row, 0xFF);
			}
			if (480 - row - 1 == col) {
				graphics_draw_rectangle(pixbuf, col, row, col, row, 0xFF);
			}
			if (480 - row - 1 == col - 160) {
				graphics_draw_rectangle(pixbuf, col, row, col, row, 0xFF);
			}
		}
	}
	ALT_CI_CI_FRAME_DONE_0;
	for ( i = 0; i < 100000; i++)
	{
		//wait for a while
	}
	graphics_clear_screen();
	int genesis_value;
	while(1)
	{
		genesis_value = IORD_32DIRECT(GENESIS_0_BASE, 0);
		if ((genesis_value)& (1 << 4)){
			graphics_draw_rectangle(pixbuf, 100, 100, 150, 150, 0x1A);
			  }
		else
			graphics_draw_rectangle(pixbuf, 100, 100, 150, 150, 0x0);
			  if ((genesis_value)& (1 << 5)){
				  graphics_draw_rectangle(pixbuf, 200, 200, 250, 250, 0xE0);
			  }
			  else
				  graphics_draw_rectangle(pixbuf, 200, 200, 250, 250, 0x0);
			  if ((genesis_value)& (1 << 6)){
				  graphics_draw_rectangle(pixbuf, 300, 300, 350, 350, 0x03);
			  }
			  else
				  graphics_draw_rectangle(pixbuf, 300, 300, 350, 350, 0x0);

			  ALT_CI_CI_FRAME_DONE_0;
		// Do nothing
	}

	return 0;
}
void draw_int(pixbuf_t *pixbuf, int x, int y, int value, int color){
	/*
	 * Fonts based on https://saelaenx.files.wordpress.com/2012/10/emon-font-size-04-01.png
	 */
	if (value > 9 || value < 0)
		return;
	else if (value == 0){
		graphics_draw_rectangle(pixbuf, (x+2), (y+0), (x+12), (y+0), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+1), (x+13), (y+1), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+2), (x+14), (y+3), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+4), (x+3), (y+23), color);
		graphics_draw_rectangle(pixbuf, (x+11), (y+4), (x+14), (y+21), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+22), (x+14), (y+23), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+24), (x+13), (y+24), color);
		graphics_draw_rectangle(pixbuf, (x+2), (y+25), (x+12), (y+25), color);
	}

	else if (value == 1){
		graphics_draw_rectangle(pixbuf, (x+2), (y+0), (x+8), (y+0), color);
		graphics_draw_rectangle(pixbuf, (x+2), (y+1), (x+9), (y+1), color);
		graphics_draw_rectangle(pixbuf, (x+2), (y+2), (x+10), (y+3), color);
		graphics_draw_rectangle(pixbuf, (x+5), (y+4), (x+10), (y+21), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+22), (x+14), (y+25), color);
	}

	else if (value == 2){
		graphics_draw_rectangle(pixbuf, (x+0), (y+0), (x+12), (y+0), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+1), (x+13), (y+1), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+2), (x+14), (y+3), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+4), (x+14), (y+10), color);

		graphics_draw_rectangle(pixbuf, (x+2), (y+11), (x+14), (y+11), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+12), (x+14), (y+12), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+13), (x+13), (y+13), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+14), (x+12), (y+14), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+15), (x+3), (y+21), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+22), (x+14), (y+23), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+24), (x+14), (y+24), color);
		graphics_draw_rectangle(pixbuf, (x+2), (y+25), (x+14), (y+25), color);
	}

	else if (value == 3){
		graphics_draw_rectangle(pixbuf, (x+0), (y+0), (x+12), (y+0), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+1), (x+13), (y+1), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+2), (x+14), (y+3), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+4), (x+14), (y+10), color);

		graphics_draw_rectangle(pixbuf, (x+2), (y+11), (x+14), (y+14), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+15), (x+14), (y+21), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+22), (x+14), (y+23), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+24), (x+13), (y+24), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+25), (x+12), (y+25), color);
	}

	else if (value == 4){
		graphics_draw_rectangle(pixbuf, (x+0), (y+0), (x+3), (y+10), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+0), (x+14), (y+10), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+11), (x+14), (y+12), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+13), (x+14), (y+13), color);
		graphics_draw_rectangle(pixbuf, (x+2), (y+14), (x+14), (y+14), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+15), (x+14), (y+25), color);
	}

	else if (value == 5){
		graphics_draw_rectangle(pixbuf, (x+2), (y+0), (x+14), (y+0), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+1), (x+14), (y+1), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+2), (x+14), (y+3), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+4), (x+3), (y+10), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+11), (x+12), (y+11), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+12), (x+13), (y+12), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+13), (x+14), (y+13), color);
		graphics_draw_rectangle(pixbuf, (x+2), (y+14), (x+14), (y+14), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+15), (x+14), (y+21), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+22), (x+14), (y+23), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+24), (x+13), (y+24), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+25), (x+12), (y+25), color);
	}

	else if (value == 6){
		graphics_draw_rectangle(pixbuf, (x+2), (y+0), (x+12), (y+0), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+1), (x+12), (y+1), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+2), (x+12), (y+3), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+4), (x+3), (y+10), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+11), (x+12), (y+12), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+13), (x+13), (y+13), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+14), (x+14), (y+14), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+15), (x+14), (y+21), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+15), (x+3), (y+21), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+22), (x+14), (y+23), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+24), (x+13), (y+24), color);
		graphics_draw_rectangle(pixbuf, (x+2), (y+25), (x+12), (y+25), color);
	}

	else if (value == 7){
		graphics_draw_rectangle(pixbuf, (x+0), (y+0), (x+12), (y+0), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+1), (x+13), (y+1), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+2), (x+14), (y+3), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+4), (x+14), (y+25), color);
	}

	else if (value == 8){
		graphics_draw_rectangle(pixbuf, (x+2), (y+0), (x+12), (y+0), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+1), (x+13), (y+1), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+2), (x+14), (y+3), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+4), (x+3), (y+10), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+4), (x+14), (y+10), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+11), (x+14), (y+14), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+15), (x+14), (y+21), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+15), (x+3), (y+21), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+22), (x+14), (y+23), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+24), (x+13), (y+24), color);
		graphics_draw_rectangle(pixbuf, (x+2), (y+25), (x+12), (y+25), color);
	}

	else if (value == 9){
		graphics_draw_rectangle(pixbuf, (x+2), (y+0), (x+12), (y+0), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+1), (x+13), (y+1), color);
		graphics_draw_rectangle(pixbuf, (x+0), (y+2), (x+14), (y+3), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+4), (x+3), (y+10), color);

		graphics_draw_rectangle(pixbuf, (x+11), (y+4), (x+14), (y+10), color);

		graphics_draw_rectangle(pixbuf, (x+0), (y+11), (x+14), (y+12), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+13), (x+14), (y+13), color);
		graphics_draw_rectangle(pixbuf, (x+2), (y+14), (x+14), (y+14), color);


		graphics_draw_rectangle(pixbuf, (x+11), (y+15), (x+14), (y+21), color);


		graphics_draw_rectangle(pixbuf, (x+0), (y+22), (x+14), (y+23), color);
		graphics_draw_rectangle(pixbuf, (x+1), (y+24), (x+13), (y+24), color);
		graphics_draw_rectangle(pixbuf, (x+2), (y+25), (x+12), (y+25), color);
	}

	else
		return;
}
void draw_paddle(pixbuf_t *pixbuf, int x, int y)
{
	x = scale_input(x);
	y = scale_input(y);
	graphics_draw_rectangle(pixbuf, x-5, y-18, x+5, y+18, 0x00);
}