void FreePause(void) { FreeSprite(PauseText); FreeSprite(SFXSliderGuide); FreeSprite(BGMSliderGuide); FreeSprite(SFXSliderBack); FreeSprite(BGMSliderBack); FreeSprite(PauseBackground); FreeSprite(EnableCheats); FreeSprite(CheckMark); FreeButton(CheatsButton); FreeSprite(EnableLookAt); FreeSprite(LookAtCheckMark); FreeButton(LookAtButton); FreeButton(SFXSlider); FreeButton(BGMSlider); FreeButton(ResumeButton); FreeButton(MainMenuButton); if(GetCurrentState() != GS_MapLevel) FreeButton(RestartButton); FreeText(SFXText); FreeText(BGMText); FreeText(SFXLabel); FreeText(BGMLabel); FreeMyAlloc(volumestring); ReleaseSound(BackgroundSnd.Sound); //Keep this here otherwise sound exists foreverrrrrrrr }
void FreeButton(attackButton* ab1, blockButton* bb1) /** Free the buttons from memory */ { FreeSprite(ab1->sprite_c); FreeSprite(bb1->sprite_c); memset(ab1,0,sizeof(attackButton)); memset(bb1,0,sizeof(blockButton)); }
void DeInit() { // Set the back buffer to it's original bitmap (This is necessary for clean-up) SelectObject(gBuffer.hdcBack, gBuffer.hOldBitmap); // Free the 2 sprites we created FreeSprite(&gSprite); FreeSprite(&gSprite2); // Show the cursor again ShowCursor(TRUE); // Post the QUIT message to the window (0 = WM_QUIT) PostQuitMessage(0); }
void FreeButton(Button *button) { button->inuse = 0; if(button->sprite != NULL)FreeSprite(button->sprite); button->sprite = NULL; button->text[0] = '\0'; }
void FreeWindow(Window *window) { window->inuse = 0; if(window->sprite != NULL)FreeSprite(window->sprite); window->sprite = NULL; window->title[0] = '\0'; }
void freeEntity(entity *ent) { numents--; ent->used = 0; if(ent->texture!=NULL)FreeSprite(ent->texture); ent->texture = NULL; if(ent->texture2!=NULL)FreeSprite(ent->texture2); ent->texture2 = NULL; ent->think = NULL; ent->ngemodel = NULL; ent->update = NULL; ent->owner = NULL; ent->self=NULL; ent->skel=NULL; ent = NULL; }
void GameOptions(Game *game,int options) /*new game, quit, select difficulty*/ { Uint8 *keys; Sprite *menu; int done = 0; menu = LoadSprite("images/menu.png",640,480); do { ResetBuffer(); SDL_PumpEvents(); MouseThink(); keys = SDL_GetKeyState(NULL); if(keys[SDLK_ESCAPE] == 1) { exit(0); } if(keys[SDLK_RETURN] == 1) { FreeSprite(menu); SDL_PumpEvents(); return; } if(keys[SDLK_F2] == 1) { NewGame(game); NewLevel(game,8,4); /*sets up a new level*/ done = 1; FreeSprite(menu); } DrawMessages(); DrawSprite(menu,screen,(screen->w - 640)/2,(screen->h - 480)/2,0); DrawText("New Game : F2",screen,(screen->w - 640)/2 + 50,(screen->h - 480)/2 + 160,IndexColor(LightGreen),F_Medium); DrawText("Quit : Escape",screen,(screen->w - 640)/2 + 50,(screen->h - 480)/2 + 200,IndexColor(LightGreen),F_Medium); if(options == 0) { DrawText("This Menu : F1",screen,(screen->w - 640)/2 + 50,(screen->h - 480)/2 + 180,IndexColor(LightGreen),F_Medium); } else { DrawText("Cancel : Enter",screen,(screen->w - 640)/2 + 50,(screen->h - 480)/2 + 180,IndexColor(LightGreen),F_Medium); DrawText("Game Paused",screen,(screen->w / 2) - 80,(screen->h - 480)/2 + 440,IndexColor(LightRed),F_Small); } DrawMouse(); NextFrame(); }while(!done); }
void FreeEnt(Entity* ent) { FreeSprite(ent->spr); ent->x = NULL; ent->y = NULL; ent->flag = NULL; ent->spr = NULL; ent->used = 0; }
void KillHUD() { int i = 0; for(i = 0; i < 3;i++) { FreeSprite(buttonsprites[i]); buttonsprites[i] = NULL; } }
void Sprite::FreeAnimatedSprite( Animated_Sprite_Template* templat ) { for( int index = 0; index < templat->n_frames; index++ ) { FreeSprite( &templat->frames[ index ] ); } free( templat->frames ); }
void CloseSprites() { int i; for(i = 0;i < MaxSprites;i++) { /*it shouldn't matter if the sprite is already freed, FreeSprite checks for that*/ FreeSprite(&SpriteList[i]); } }
void InitEntList() { int i; numents = 0; memset(EntityList,0,sizeof(entity) * MAXENTITIES); for(i = 0 ;i < MAXENTITIES ;i++) { EntityList[i].used = 0; EntityList[i].think = NULL; if(EntityList[i].texture!=NULL)FreeSprite(EntityList[i].texture); EntityList[i].texture=NULL; if(EntityList[i].texture2!=NULL)FreeSprite(EntityList[i].texture2); EntityList[i].texture2=NULL; EntityList[i].update = NULL; EntityList[i].ngemodel=NULL; EntityList[i].self=NULL; EntityList[i].owner = NULL; EntityList[i].skel=NULL; } }
void entity_free(Entity *ent) { if (!ent) { slog("passed a null entity"); return; } ent[0].inuse = 0; obj_free(ent->objModel); FreeSprite(ent->texture); }
void PopUpWindow(Sprite *splash,char *text,Uint32 Color,int frame) { Sprite *popup; Uint8 *keys; int len = strlen(text); popup = LoadSprite("images/popup.png",400,300); DrawSprite(popup,screen,(screen->w - 400)/2,(screen->h - 300)/2,0); if(splash != NULL) DrawSprite(splash,screen,(screen->w - splash->w)/2,(screen->h - splash->h)/2,frame); if(text != NULL) DrawText(text,screen,(screen->w - (len *11))/2 ,(screen->h - 300)/2 + 50,Color,F_Large); DrawText("Hit Spacebar to continue",screen,(screen->w)/2 - 136 ,(screen->h/2) + 100,Color,F_Large); NextFrame(); FreeSprite(splash); FreeSprite(popup); do { SDL_PumpEvents(); keys = SDL_GetKeyState(NULL); } while(keys[SDLK_SPACE] != 1); }
void DeInit() { // Free the sprite we created FreeSprite(&gMonster); // Free the background image DeleteObject(hBackground); // Free the back buffer FreeBuffers(&gBuffer); // Post the QUIT message to the window (0 = WM_QUIT) PostQuitMessage(0); }
int playVideo(char *directory, int x, int y, int w, int h, int numFrames) { char temp[80]; Sprite *tempSprite; static int i = 1; sprintf(temp, "%s/%04d.png",directory, i); tempSprite=LoadFrame( temp, w, h); DrawFrame(tempSprite, x, y, 0, 2.0f ); FreeSprite(tempSprite); if(i >= numFrames)return 1; i++; return 0; }
void DeadZombie(Game *game) /*sets the game info to he beone less zombie.. possible game over.*/ { Sprite *grave; int frame; int channel; game->NumGraves--; if(game->NumGraves + game->NumZombies < game->NumVillagers) { if(rand()%2 == 1) { grave = LoadSprite("images/grave1.png",64,96); frame = 3; } else { grave = LoadSprite("images/skelrise.png",32,48); frame = 15; } Mix_HaltMusic(); channel = Mix_PlayChannel(-1,gamesounds[1]->sound,0); PopUpWindow(grave,"The Villagers live, You LOSE!",IndexColor(Red),frame); GameOptions(game,0); Mix_HaltChannel(channel); FreeSprite(grave); } else if(game->NumGraves == 0)/*then we must have won already*/ { grave = LoadSprite("images/levelup.png",96,96); Mix_HaltMusic(); channel = Mix_PlayChannel(-1,gamesounds[0]->sound,0); PopUpWindow(grave,"The Villagers Die!!",IndexColor(LightViolet),0); NewLevel(game,(game->level * 4) + 8,(game->level * 3) + 2); /*sets up a new level*/ Mix_HaltChannel(channel); FreeSprite(grave); } }
void GrownZombie(Game *game) { Sprite *levelup; int channel; game->NumZombies++; game->NumGraves--; if((game->NumZombies >= game->NumVillagers)&&(game->NumGraves == 0)) { Mix_HaltMusic(); levelup = LoadSprite("images/levelup.png",96,96); channel = Mix_PlayChannel(-1,gamesounds[0]->sound,0); PopUpWindow(levelup,"The Villagers Die!!",IndexColor(LightViolet),0); NewLevel(game,(game->level * 4) + 8,(game->level * 3) + 2); /*sets up a new level*/ Mix_HaltChannel(channel); FreeSprite(levelup); } }
void IntroScreen() { int done; int keyn; Uint8 *keys; static float fadein =0.1f; static int delay=190; Sprite *zfactory; zfactory=LoadSprite("images/logowhitefont7.png",800,800); done = 0; do { ResetBuffer(); if(fadein < 1) fadein += 0.01f; if(fadein < 1 && delay > 80) { fadein += 0.03f; }else if(fadein > 0 && delay < 80)fadein -= 0.02f; glColor4f(fadein,fadein,fadein,fadein); DrawSprite(zfactory,(S_Data.xres*0.5f)-480,(S_Data.yres*0.5f)-450,0,0.5f); glColor4f(1,1,1,1); if(delay > 0) delay--; if(delay == 0) { done = 1; } DrawMessages(); NextFrame(); SDL_PumpEvents(); keys = SDL_GetKeyState(&keyn); if(keys[SDLK_ESCAPE])exit(1); if(keys[SDLK_SPACE]||keys[SDLK_RETURN]||SDL_GetMouseState(NULL,NULL))done=1; }while(!done); FreeSprite(zfactory); mainMenu(); }
void FreeText(TextGlyphs *FirstLetter) { int i; TextGlyphs *NextLetter = FirstLetter; //Find the pointer in the list that is the first letter for(i = 0; i < COLLIDEAMOUNT; i++) if (staticTextList[i] == FirstLetter) break; //Go through all the letters and free my people while(NextLetter) { NextLetter = FirstLetter->NextLetter; if(FirstLetter->Glyph) FreeSprite(FirstLetter->Glyph); FreeMyAlloc(FirstLetter); FirstLetter = NextLetter; } //Now remove that pointer. if(i < COLLIDEAMOUNT) staticTextList[i] = NULL; }
void FreeMage(mage* m1) { FreeSprite(m1->msprite); memset(m1,0,sizeof(mage)); }
void FreeFighter(fighter* f1) { FreeSprite(f1->fsprite); memset(f1,0,sizeof(fighter)); }
void FreeCharacter(character* c1) { FreeSprite(c1->csprite); memset(c1,0,sizeof(character)); }
void ChangeTextString(TextGlyphs* FirstLetter, char* newString) { TextGlyphs* nextLetter = FirstLetter; TextGlyphs* prevLetter = FirstLetter; int i = 0; while(*newString) { if(nextLetter && nextLetter->Glyph) { nextLetter->letter = *newString; if(*newString >= 'A' && *newString <= 'Z') nextLetter->Glyph->CurrentFrame = (int)*newString - 65; else if(*newString >= '0' && *newString <= '9') nextLetter->Glyph->CurrentFrame = (int)*newString - 22; else if(*newString >= 'a' && *newString <= 'z') nextLetter->Glyph->CurrentFrame = (int)*newString - 97; else { switch(*newString) { case '-': nextLetter->Glyph->CurrentFrame = 36; break; case '+': nextLetter->Glyph->CurrentFrame = 37; break; case '!': nextLetter->Glyph->CurrentFrame = 38; break; case '.': nextLetter->Glyph->CurrentFrame = 39; break; case ',': nextLetter->Glyph->CurrentFrame = 40; break; case '%': nextLetter->Glyph->CurrentFrame = 41; break; case '(': nextLetter->Glyph->CurrentFrame = 42; break; case ')': nextLetter->Glyph->CurrentFrame = 43; break; default: FreeSprite(nextLetter->Glyph); nextLetter->Glyph = NULL; break; } } } else if(nextLetter) { nextLetter->letter = *newString; nextLetter->Glyph = ConvertToGlyph(*newString, (int)(FirstLetter->Glyph->Height), FirstLetter->Glyph->Position.x + (i * FirstLetter->Glyph->Height * 0.4f), FirstLetter->Glyph->Position.y, FirstLetter->textTexture); } else { nextLetter = (TextGlyphs *) CallocMyAlloc(1, sizeof(TextGlyphs)); prevLetter->NextLetter = nextLetter; nextLetter->letter = *newString; nextLetter->Glyph = ConvertToGlyph(*newString, (int)(FirstLetter->Glyph->Height), FirstLetter->Glyph->Position.x + (i * FirstLetter->Glyph->Height * 0.4f), FirstLetter->Glyph->Position.y, FirstLetter->textTexture); nextLetter->NextLetter = NULL; if(nextLetter->Glyph) nextLetter->Glyph->ZIndex = FirstLetter->Glyph->ZIndex; } if(nextLetter->Glyph) { nextLetter->Glyph->Position.x = FirstLetter->Glyph->Position.x + (i * nextLetter->Glyph->Height * 0.4f); nextLetter->Glyph->Tint = FirstLetter->Glyph->Tint; nextLetter->Glyph->Visible = FirstLetter->Glyph->Visible; nextLetter->Glyph->AnimationActive = FALSE; } i++; prevLetter = nextLetter; nextLetter = nextLetter->NextLetter; *(newString++); } if(nextLetter) { FreeText(nextLetter); prevLetter->NextLetter = NULL; } }
void CloseMouse() { FreeSprite(Mouse.sprite); }