void setupGame(bool loadUpWorld) { currentLevel = 1; // Reset entity manager. memset(&eManager, 0, sizeof(eManager)); sf2d_set_clear_color(RGBA8(0x82, 0x6D, 0x6C, 0xFF)); if (!loadUpWorld) { initNewMap(); initPlayer(); airWizardHealthDisplay = 2000; int i; for (i = 0; i < 5; ++i) { trySpawn(500, i); } addEntityToList(newAirWizardEntity(630, 820, 0), &eManager); player.p.hasWonSaved = false; } else { initPlayer(); loadWorld(currentFileName, &eManager, &player, (u8*) map, (u8*) data); } initMiniMap(loadUpWorld); shouldRenderMap = false; mScrollX = 0; mScrollY = 0; zoomLevel = 2; sprintf(mapText,"x%d",zoomLevel); initGame = 0; }
Entity *getFreeDecoration() { Entity *e; e = malloc(sizeof(Entity)); if (e == NULL) { showErrorAndExit("Failed to allocate %d bytes for a Decoration", (int)sizeof(Entity)); } memset(e, 0, sizeof(Entity)); e->inUse = TRUE; e->active = TRUE; e->frameSpeed = 1; e->alpha = 255; addEntityToList(decoration, e); return e; }
Entity *getFreeEntity() { Entity *e; e = malloc(sizeof(Entity)); if (e == NULL) { showErrorAndExit("Failed to allocate %d bytes for an Entity", (int)sizeof(Entity)); } memset(e, 0, sizeof(Entity)); e->inUse = TRUE; e->active = TRUE; e->frameSpeed = 1; e->weight = 1; e->originalWeight = 1; e->fallout = NULL; e->currentAnim = -1; e->layer = MID_GROUND_LAYER; e->alpha = 255; addEntityToList(entities, e); return e; }
EntityList *throwGibs(char *name, int gibs) { int i; Entity *e; EntityList *list; list = malloc(sizeof(EntityList)); if (list == NULL) { showErrorAndExit("Failed to allocate a whole %d bytes for Entity List", (int)sizeof(EntityList)); } list->next = NULL; for (i=0;i<gibs;i++) { e = addTemporaryItem(name, self->x, self->y, RIGHT, 0, 0); e->x += (self->w - e->w) / 2; e->y += (self->h - e->h) / 2; e->dirX = (prand() % 10) * (prand() % 2 == 0 ? -1 : 1); e->dirY = -12 - (prand() % 4); setEntityAnimationByID(e, i); e->thinkTime = 180 + (prand() % 120); e->draw = &drawGib; addEntityToList(list, e); } playSoundToMap("sound/common/gib", -1, self->x, self->y, 0); self->inUse = FALSE; return list; }
EntityList *getEntitiesByName(char *name) { EntityList *list, *el; list = malloc(sizeof(EntityList)); if (list == NULL) { showErrorAndExit("Failed to allocate a whole %d bytes for Entity List", (int)sizeof(EntityList)); } list->next = NULL; for (el=entities->next;el!=NULL;el=el->next) { if (el->entity->inUse == TRUE && strcmpignorecase(el->entity->name, name) == 0) { addEntityToList(list, el->entity); } } return list; }
void setupGame(bool loadUpWorld){ currentLevel = 1; // Reset entity manager. memset(&eManager, 0, sizeof(eManager)); sf2d_set_clear_color(RGBA8(0x82, 0x6D, 0x6C, 0xFF)); if(!loadUpWorld){ initNewMap(); initPlayer(); airWizardHealthDisplay = 2000; int i; for(i=0;i<5;++i){ trySpawn(500, i); } addEntityToList(newAirWizardEntity(630,820,0), &eManager); } else { initPlayer(); loadWorld(currentFileName, &eManager, &player, (u8*)map, (u8*)data); } initMiniMap(loadUpWorld); initGame = 0; }