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; }
_Bool enemyldresrc(void){ untihit = resrcacq(sfx, "sfx/hit.wav", 0); if(!untihit) return 0; untiinfo.hit = untihit; untiimg = resrcacq(imgs, "img/unti.png", 0); if(!untiimg) return 0; thuimg = resrcacq(imgs, "img/thu.png", 0); if(!thuimg) return 0; thuinfo.hit = untihit; splatimg = resrcacq(imgs, "img/splat.png", 0); if(!splatimg) return 0; splatinfo.hit = untihit; nousimg = resrcacq(imgs, "img/nous.png", 0); if(!nousimg) return 0; nousinfo.hit = untihit; grenduimg = resrcacq(imgs, "img/grendu.png", 0); if(!grenduimg) return 0; grenduinfo.hit = untihit; daimg = resrcacq(imgs, "img/da.png", 0); if(!daimg) return 0; dainfo.hit = untihit; rnginit(&rng, 666); //TODO: use the game seed return 1; }
_Bool enemyldresrc(unsigned seed) { untihit = resrcacq(sfx, "sfx/hit.wav", 0); if(!untihit) return 0; untiinfo.hit = untihit; untiimg = resrcacq(imgs, "img/unti.png", 0); if(!untiimg) return 0; thuimg = resrcacq(imgs, "img/thu.png", 0); if(!thuimg) return 0; thuinfo.hit = untihit; splatimg = resrcacq(imgs, "img/splat.png", 0); if(!splatimg) return 0; splatinfo.hit = untihit; nousimg = resrcacq(imgs, "img/nous.png", 0); if(!nousimg) return 0; nousinfo.hit = untihit; grenduimg = resrcacq(imgs, "img/grendu.png", 0); if(!grenduimg) return 0; grenduinfo.hit = untihit; daimg = resrcacq(imgs, "img/da.png", 0); if(!daimg) return 0; dainfo.hit = untihit; tihgtimg = resrcacq(imgs, "img/tihgt.png", 0); if(!tihgtimg) return 0; tihgtinfo.hit = untihit; heartimg = resrcacq(imgs, "img/placeholder.png", 0); if(!heartimg) return 0; heartinfo.hit = untihit; rnginit(&rng, seed); return 1; }
void playerinit(Player *p, int x, int y) { p->lives = 3; bodyinit(&p->body, x * Twidth + hboff.x, y * Theight + hboff.y, 21, 29); p->hitback = 0; armorinit(); ow = resrcacq(sfx, "sfx/ow.wav", NULL); assert(ow != NULL); for(int i = 0; i < ArmorMax; i++){ loadanim(&p->as[Left][Stand][i], 0, 1, 1, i); loadanim(&p->as[Left][Walk][i], 1, 4, 100, i); loadanim(&p->as[Left][Jump][i], 2, 1, 1, i); loadanim(&p->as[Right][Stand][i], 3, 1, 1, i); loadanim(&p->as[Right][Walk][i], 4, 4, 100, i); loadanim(&p->as[Right][Jump][i], 5, 1, 1, i); } p->dir = Right; p->act = Stand; p->imgloc = (Point){ x * Twidth, y * Theight }; p->bi.x = p->bi.y = p->bi.z = -1; p->stats[StatHp] = 10; p->stats[StatDex] = 5; p->stats[StatStr] = 5; p->stats[StatMag] = 5; p->stats[StatGuts] = 5; p->stats[StatLuck] = 5; p->sw.row = 0; p->sw.dir = Mvright; p->sw.cur = -1; invitinit(&p->wear[EqpWep], ItemSilverSwd); invitinit(&p->wear[EqpHead], ItemIronHelm); invitinit(&p->wear[EqpBody], ItemIronBody); invitinit(&p->wear[EqpArms], ItemIronGlove); invitinit(&p->wear[EqpLegs], ItemIronBoot); resetstats(p); p->curhp = p->stats[StatHp] + p->eqp[StatHp]; mvsw(p); }
Scrn *statscrnnew(Game *g, Player *p, Env *sh){ static Statup sup = {0}; static Scrn s = {0}; sup.g = g; sup.p = p; sup.shrine = sh; Txtinfo ti = { TxtSzMedium }; sup.txt = resrcacq(txt, TxtStyleMenu, &ti); if(!sup.txt) die("Failed to load stat screen font"); for(size_t i = 0; i < Maxinv; i++) if(p->inv[i].id == ItemStatup) sup.norbs++; s.mt = &statupmt; s.data = ⊃ return &s; }