/* this is a little messy, but it's heirarchical. Build a player, then give * it a brain, then add it to the list of enemies in a flock */ void AIFlockLoadAll(aiflock_t *flock, const char *md2File, const char *skinFile, int nBots){ /* this function uses sizeX, sizeY which are globals */ player_t *chump1, *chump2; ai_t *enemy; float sPosX, sPosY, sPosZ, sYaw; float centerX, centerZ; int i; if(nBots < 1) return; /* pick a random center somewhere on the map */ centerX = (sizeX - 20)*IRMAX*(rand()) + 10; centerZ = (sizeZ - 20)*IRMAX*(rand()) + 10; /* setup the first bot and then make all others use his skin */ sPosX = 20*UNIRAND(1.0) + centerX; sPosZ = 20*UNIRAND(1.0) + centerZ; sPosY = TerrainGetHeight(ground, sPosX, sPosZ) + MOD_HEIGHT2; sYaw = (180)*IRMAX*rand(); chump1 = PlayerNew(); PlayerLoad(chump1, md2File, skinFile); PlayerSetPosition(chump1, sPosX, sPosY, sPosZ); PlayerSetForwardByAngle(chump1, 0, sYaw); PlayerSetUpVector(chump1, 0.0, 1.0, 0.0); PlayerSetAnimation(chump1, PLAYER_ANIM_IDLE0); enemy = AINew(chump1); enemy->threshold = (rand()%4)+1; /* give him an attack threshold between * one and 5 */ EListAppend(flock->bots, enemy); flock->nBots++; /* now repeat for all other bots */ for(i = 1; i < nBots; i++){ sPosX = 20*(UNIRAND(1.0)) + centerX; sPosZ = 20*(UNIRAND(1.0)) + centerZ; sPosY = TerrainGetHeight(ground, sPosX, sPosZ) + MOD_HEIGHT2; sYaw = (180)*IRMAX*rand(); chump2 = PlayerNew(); PlayerLoadUseSameModel(chump2, chump1); PlayerSetPosition(chump2, sPosX, sPosY, sPosZ); PlayerSetForwardByAngle(chump2, 0, 180); PlayerSetUpVector(chump2, 0.0, 1.0, 0.0); PlayerSetAnimation(chump2, PLAYER_ANIM_IDLE0); enemy = AINew(chump2); enemy->threshold = (rand()%4)+1; EListAppend(flock->bots, enemy); flock->nBots++; } return; }
//----------------------------------------Methods void SetupGame() { DISPLAY_OFF; SPRITES_8x8; //set sprite size BackgroundLoad(); //load background stuff SHOW_BKG; set_sprite_data(0, 48, SpriteTiles); //load sprites PlayerLoad(); //load player stuff MonsterLoad(); //loads the monster SpriteNum += 4; SHOW_SPRITES; DISPLAY_ON; }
void UpdateTitleButtons() { GList *elem,*elem2; Button *ref; Editor_Panel* panel; int n,i,j; int x,y; if(g_list_length(MainEditorPanels) != 0){ for(n = 0; n < g_list_length(MainEditorPanels);++n) { elem = g_list_nth(MainEditorPanels,n); panel = (Editor_Panel*)elem->data; for(i = 0; i < g_list_length(panel->buttons);++i) { elem2 = g_list_nth(panel->buttons,i); ref = (Button*)elem2->data; SDL_GetMouseState(&x,&y); if( x > ref->rect.x && x < (ref->rect.x + ref->rect.w) && y > ref->rect.y && y < (ref->rect.y + ref->rect.h)) { if(ref->inside == 0) Mix_PlayChannel (1,ref->soundEffect, 0); ref->inside = 1; ref->frame = 1; } else{ ref->inside = 0; ref->frame = 0; } if(ref->inside == true){ printf("Mouse inside a button.."); if(mainEvent->type == SDL_MOUSEBUTTONDOWN && ButtonDown == 0) { printf("Button Executed\n"); if(strcmp(ref->name,"NewGame") == 0) { FreeEveryThing(); CreateNewPlayerSave("playerData"); PlayerLoad("playerData"); SetGameState(StateGame); } else if(strcmp(ref->name,"Continue") == 0) { FreeEveryThing(); PlayerLoad("playerData"); SetGameState(StateGame); } else if(strcmp(ref->name,"Editor") == 0) { FreeEveryThing(); SetGameState(StateEditor); } return; } } } } } }