示例#1
0
文件: title.c 项目: jordanthayer/mid
Scrn *titlescrnnew(Gfx *g){
	static Tit t = {0};
	static Scrn s = {0};

	t.title = resrcacq(imgs, "img/title.png", 0);
	if(!t.title)
		return NULL;

	Txtinfo ti = { TxtSzMedium };
	t.f = resrcacq(txt, TxtStyleMenu, &ti);
	if(!t.f)
		return NULL;

	ti.size = TxtSzSmall;
	Txt *f = resrcacq(txt, TxtStyleMenu, &ti);
	if(!f)
		return NULL;

	t.copy = txt2img(g, f, "Copyright 2011 Steve McCoy and Ethan Burns");
	if(!t.copy)
		return NULL;

	t.titlepos = (Point){
		gfxdims(g).x / 2 - imgdims(t.title).x / 2,
		0
	};

	Point sd = txtdims(t.f, "Press 'x' to Start a new game");
	t.startpos = (Point){
		gfxdims(g).x / 2 - sd.x / 2,
		t.titlepos.y + imgdims(t.title).y
	};

	Point ld = txtdims(t.f, "Press 'x' to Load the saved game");
	t.loadpos = (Point){
		gfxdims(g).x / 2 - ld.x / 2,
		t.startpos.y + sd.y + 16
	};

	Point od = txtdims(t.f, "Press 'x' for Options");
	t.optspos = (Point){
		gfxdims(g).x / 2 - od.x / 2,
		t.loadpos.y + ld.y + 16
	};

	t.copypos = (Point){
		gfxdims(g).x / 2 - imgdims(t.copy).x / 2,
		gfxdims(g).y - imgdims(t.copy).y - 8
	};

	s.mt = &titmt;
	s.data = &t;
	return &s;
}
示例#2
0
文件: gfx_sdl2.c 项目: eaburns/mid
void imgdrawscale(Gfx *g, Img *img, Point p, float s){
	float ps = img->posscale;
	float ss = img->sizescale;
	Point wh = imgdims(img);
	SDL_Rect r = { p.x*ps, p.y*ps, wh.x*ss*s, wh.y*ss*s };
	SDL_RenderCopy(g->rend, img->tex, 0, &r);
}
示例#3
0
void imgdraw(Gfx *g, Img *img, Point p){
	Point wh = imgdims(img);
	SDL_Rect r = { p.x, p.y, wh.x, wh.y };
	SDL_RenderCopy(g->rend, img->tex, 0, &r);
}