コード例 #1
0
ファイル: arne.c プロジェクト: h4xxel/arne
int main(int argc, char **argv) {
	DARNIT_PLATFORM platform;
	DARNIT_TILE *tile;
	DARNIT_TILESHEET *ts;
	unsigned int *pixbuf;
	int w, h, x, y;//, t;
	//int sinc_1, sinc_2, sinc_3, sinc_4;

	sinetable_init();
	if (!darnitInit("Arne", "arne"))
		return -1;
	platform = darnitPlatformGet();

	w = platform.screen_w / SCALE;
	h = platform.screen_h / SCALE;

	ts = darnitRenderTilesheetNew(1, 1, w, h, DARNIT_PFORMAT_RGB5A1);
	tile = darnitRenderTileAlloc(1);

	darnitRenderTileMove(tile, 0, ts, 0, 0);
	darnitRenderTileSetTilesheetCoord(tile, 0, ts, 0, 0, w, h);
	darnitRenderTileSizeSet(tile, 0, platform.screen_w, platform.screen_h);
	pixbuf = malloc(sizeof(unsigned int) * w * h);
	if (!ts || !pixbuf)
		darnitQuit();
	
	memset(pixbuf, 0, w * h * sizeof(unsigned int));
	darnitRenderTilesheetUpdate(ts, 0, 0, w, h, pixbuf);
	
	int mov1, mov2, c1, c2, c3;

	int t = 0;

	for (;;) {
		if(t&1) {
			for (y = 0; y < h; y++)
				for (x = 0; x < w; x++) {
					//int mov0=x+y+cosine((2*sine(t/2))/10)+sine(360*x/100);
					mov1=360*y/h+(t>>1);
					mov2=360*x/w;
					c1=sine(mov1+(t>>1))/2+((mov2>>1)-mov1-mov2+(t>>1));
					//int c2=sine((c1+sine(mov0+t/10)+sine(y/40+t/2)+sine((x+y)/100)));
					c2=sine((c1+sine((y>>2)+(t>>1))+sine((x+y)))/10);
					c3=sine((c2+(cosine(mov1+mov2+c2/10)>>2)+cosine(mov2)+sine(x))/10);
					pixbuf[y * w + x] = (c1+c2+c3)/150+64;///0x10+128;
				}
			darnitRenderTilesheetUpdate(ts, 0, 0, w, h, pixbuf);
		}
		t++;
		
		darnitRenderBegin();
		darnitRenderTileDraw(tile, ts, 1);
		darnitRenderEnd();
		darnitLoop();
	}

	return 0;
}
コード例 #2
0
ファイル: rpgdarnit.c プロジェクト: slaeshjag/libRPGDarnit
int rpg_main() {
	MAIN *m;
	int i;

	if ((m = malloc(sizeof(MAIN))) == NULL) {
		fprintf(stderr, "Error: Unable to allocate memory for the main struct!\n");
		return -1;
	}
	
	
	m->darnit = darnitInit("RPG Darnit!");
	if (init(m) != 0)
		return -1;

	mapLoad(m, "TESTMAP");
	textboxActivate(m, "123456789012345678901234567890123456789012345678901234567890", -1, 0, 0, NULL, "Yes\nNo\nMaybe");
	darnitRenderBlendingEnable(m->darnit);
	cameraFollowNPC(m, 0);

	/* Temporary, this will be replaced with gameInit() or something */
	m->party.coins = 1234;
	partyAddMember(m, m->party.member, 0, 400);
	partyAddMember(m, m->party.member, 0, 500000);
	for (i = 0; i < 15; i++) {
		itemGiveToParty(m, 0, 1);
		itemGiveToParty(m, 1, 1);
	}


	for (;;) {
		loop(m);

		darnitRenderBegin();
		
		state(m);
		
		darnitRenderEnd();
		darnitLoop(m->darnit);
	}

	return 0;
}