Example #1
0
static void draw(Scrn *s, Gfx *g){
	gfxclear(g, (Color){ 240, 240, 240 });
	Tit *t = s->data;
	imgdraw(g, t->title, t->titlepos);
	txtdraw(g, t->f, t->startpos, "Press '%c' to Start a new game", kmap[Mvinv]);
	if (saveavailable())
		txtdraw(g, t->f, t->loadpos, "Press '%c' to Load the saved game", kmap[Mvjump]);
	txtdraw(g, t->f, t->optspos, "Press '%c' for Options", kmap[Mvact]);
	imgdraw(g, t->copy, t->copypos);
	gfxflip(g);
}
Example #2
0
static void draw(Scrn *s, Gfx *g){
	extern char *statname[];

	Statup *sup = s->data;

	gfxclear(g, (Color){ 127, 200, 255 });

	enum { Bufsz = 256 };
	char buf[Bufsz];

	int mh = TxtSzMedium/2;
	int Pad = 4;
	Point sloc = { Pad, Pad };
	for(int i = StatHp; i < StatMax; i++){
		Meter meter = {
			.base = sup->p->stats[i],
			.extra = sup->p->eqp[i],
			.max = statmax[i],
			.xscale = 2,
			.h = mh,
			.cbg = {0x65, 0x65, 0x65},
			.cbase = {0x1E, 0x94, 0x22},
			.cextra = {0x1B, 0xAF, 0xE0},
			.cborder = {}
		};

		Point mloc = { sloc.x + mh*2, sloc.y };
		Rect ma = meterarea(&meter, mloc);

		if(rectcontains(ma, sup->mouse))
			meter.cbg = (Color){ 255, 219, 0 };

		txtdraw(g, sup->txt, sloc, statname[i]);
		meterdraw(g, &meter, mloc);

		if(rectcontains(ma, sup->mouse) && sup->inc && sup->p->stats[i] < statmax[i]){
			if(i == StatHp){
				sup->p->stats[i] += 5;
				sup->p->curhp += 5;
			}else
				sup->p->stats[i]++;

			sup->norbs--;
			sup->uorbs++;
			sup->inc = 0;
		}

		sloc = vecadd(sloc, (Point){0, mh + Pad});
	}

	snprintf(buf, Bufsz, "Orbs: %d", sup->norbs);
	Point o = txtdims(sup->txt, buf);
	txtdraw(g, sup->txt, (Point){ Scrnw - o.x, 1 }, buf);

	gfxflip(g);
}

static void handle(Scrn *s, Scrnstk *stk, Event *e){
	Statup *sup = s->data;

	if(e->type == Mousemv){
		sup->mouse = projpt((Point){ e->x, e->y });
		sup->inc = 0;
		return;
	}

	if(e->type == Mousebt && sup->uorbs == 0){
		if(sup->norbs == 0)
			return;
		sup->mouse = projpt((Point){ e->x, e->y });
		sup->inc = 1;
		return;
	}

	if(e->type != Keychng || e->repeat)
		return;

	if(e->down && e->key == kmap[Mvinv]){
		Player *p = sup->p;
		int u = 0;
		for(Invit *i = p->inv; i != p->inv + Maxinv && u < sup->uorbs; i++){
			if(i->id == ItemStatup){
				i->id = 0;
				sup->norbs--;
				u++;
			}
		}
		gamesave(sup->g);
		scrnstkpop(stk);
		return;
	}
}