⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bounce.c

📁 libfxb是linux下只写操作framebuffer的一个轻量级的库。
💻 C
字号:
/* bounce.c - Bouncing ball test for libfbx * * By Michael Bourgeous <nitrogen@u4xlabs.com> * * $Id: bounce.c,v 1.5 2001/02/25 20:40:07 lethal Exp $ */#include <libfbx/libfbx.h>#include <stdlib.h>#include <unistd.h>#include <config.h>int main(){	int x, y;	int dx, dy;	int frame = 0;	fb_surface *ball;	fb_init();	fb_handle_signals();	ball = fb_load_ppm(IMAGEDIR "/smiley.ppm");	x = rand() % fb_screen->width;	y = rand() % fb_screen->height;	dx = rand() % 4 + 1;	dy = rand() % 4 + 1;	while(frame < 4000)	{		/* fb_fill_rect(x, y, ball->width, ball->height, 0, 0, 0, fb_screen); */		x += dx;		y += dy;		if(x < 0 || x >= fb_screen->width - ball->width)			dx = -dx + rand() % 1;		if(y < 0 || y >= fb_screen->height - ball->height)			dy = -dy + rand() % 1;				fb_draw_image(ball, fb_screen, x, y);		frame++;	}	frame = 0;	while(frame < 4000)	{		x += dx;		y += dy;		if(x < 0 || x >= fb_screen->width - ball->width)			dx = -dx + rand() % 1;		if(y < 0 || y >= fb_screen->height - ball->height)			dy = -dy + rand() % 1;				fb_fill_rect(x, y, x + ball->width, y + ball->height, 255, 255, 255, fb_screen);		frame++;	}		fb_cleanup();	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -