/** * This routine stores Data in the K-D tree specified by Tree * using Key as an access key. * * @param Tree K-D tree in which data is to be stored * @param Key ptr to key by which data can be retrieved * @param Data ptr to data to be stored in the tree * * @note Exceptions: none * @note History: 3/10/89, DSJ, Created. * 7/13/89, DSJ, Changed return to void. */ void KDStore(KDTREE *Tree, FLOAT32 *Key, void *Data) { int Level; KDNODE *Node; KDNODE **PtrToNode; PtrToNode = &(Tree->Root.Left); Node = *PtrToNode; Level = NextLevel(Tree, -1); while (Node != NULL) { if (Key[Level] < Node->BranchPoint) { PtrToNode = &(Node->Left); if (Key[Level] > Node->LeftBranch) Node->LeftBranch = Key[Level]; } else { PtrToNode = &(Node->Right); if (Key[Level] < Node->RightBranch) Node->RightBranch = Key[Level]; } Level = NextLevel(Tree, Level); Node = *PtrToNode; } *PtrToNode = MakeKDNode(Tree, Key, (void *) Data, Level); } /* KDStore */
/** * Walk a tree, calling action once on each node. * * Operation: * This routine walks through the specified sub_tree and invokes action * action at each node as follows: * action(context, data, level) * data the data contents of the node being visited, * level is the level of the node in the tree with the root being level 0. * @param tree root of the tree being walked. * @param action action to be performed at every node * @param context action's context * @param sub_tree ptr to root of subtree to be walked * @param level current level in the tree for this node */ void Walk(KDTREE *tree, void_proc action, void *context, KDNODE *sub_tree, inT32 level) { (*action)(context, sub_tree->Data, level); if (sub_tree->Left != NULL) Walk(tree, action, context, sub_tree->Left, NextLevel(tree, level)); if (sub_tree->Right != NULL) Walk(tree, action, context, sub_tree->Right, NextLevel(tree, level)); }
//Update void GameWorld::Update() { //Update Game Grid for(int y = 0; y < 11; y++) { for(int x = 0; x < 17; x++) { if(m_gamegrid[x][y].ent == NULL){continue;} m_gamegrid[x][y].ent->Update(); } } //Randomy place a well during gameplay if(m_gamemode == 0) { if(GetTicks() > well_regulator+well_nextshow) { AddWell(); well_regulator = GetTicks(); well_nextshow = qRand(120000, 360000); } //Randomy place a hat during gameplay if(GetTicks() > hat_regulator+hat_nextshow) { AddHat(); hat_regulator = GetTicks(); hat_nextshow = qRand(180000, 420000); } } //Generate a new level? if(gentoggle == 1){NextLevel(); gentoggle=0;} }
void CGame::OnUpdate(float time) { CApp::OnUpdate(time); if(!pause) { live_obj=0; for(int i=0;i<npcs.size();i++) { if(npcs[i]->isLive()) { live_obj++; } } ObjectsCheck(); if(player->isLive() && live_obj==0) { NextLevel(); } if(player->isLive()==false) { Restart(); } } }
void Vote_ChangeMap_Init() { int f1; gedict_t* voteguard; f1 = CountPlayers(); if(f1 == 1) { G_bprint(2, "%s changes map\n",self->s.v.netname); current_vote = -1; NextLevel(); return; // in case we get back here } G_bprint(2, "%s votes for mapchange\n",self->s.v.netname); if(f1/2 !=1) G_bprint(2, "%d total votes needed\nType ",f1/2); else G_bprint(2, "%d total vote needed\nType ",f1/2); G_bprint(3, "γνδ φοτε ωεσ"); G_bprint(2, " in console to approve\n"); k_vote = 1; self->k_voted = 1; voteguard = spawn(); // Check the 1 minute timeout for voting voteguard->s.v.owner = EDICT_TO_PROG(world); voteguard->s.v.classname = "voteguard"; voteguard->s.v.think = (func_t) VoteThink; voteguard->s.v.nextthink = g_globalvars.time + votes[current_vote].timeout; }
//called one time; sets up game objects void NewGame(void) { if(g_hisct_delay) return; g_keys = 0; g_level = 0; g_score = 0; g_ships = 3; NextLevel(); }
/** * Recursively accumulate the k_closest points to query_point_ into results_. * @param Level level in tree of sub-tree to be searched * @param SubTree sub-tree to be searched */ void KDTreeSearch::SearchRec(int level, KDNODE *sub_tree) { if (level >= tree_->KeySize) level = 0; if (!BoxIntersectsSearch(sb_min_, sb_max_)) return; results_->insert(DistanceSquared(tree_->KeySize, tree_->KeyDesc, query_point_, sub_tree->Key), sub_tree->Data); if (query_point_[level] < sub_tree->BranchPoint) { if (sub_tree->Left != NULL) { FLOAT32 tmp = sb_max_[level]; sb_max_[level] = sub_tree->LeftBranch; SearchRec(NextLevel(tree_, level), sub_tree->Left); sb_max_[level] = tmp; } if (sub_tree->Right != NULL) { FLOAT32 tmp = sb_min_[level]; sb_min_[level] = sub_tree->RightBranch; SearchRec(NextLevel(tree_, level), sub_tree->Right); sb_min_[level] = tmp; } } else { if (sub_tree->Right != NULL) { FLOAT32 tmp = sb_min_[level]; sb_min_[level] = sub_tree->RightBranch; SearchRec(NextLevel(tree_, level), sub_tree->Right); sb_min_[level] = tmp; } if (sub_tree->Left != NULL) { FLOAT32 tmp = sb_max_[level]; sb_max_[level] = sub_tree->LeftBranch; SearchRec(NextLevel(tree_, level), sub_tree->Left); sb_max_[level] = tmp; } } }
void LevelManager::SetContinueType() { int state = dynamic_cast<Level*>(m_pCurrent.get())->GetContinueState();//Get the Continue State switch(state)//Call the method based on the continue state { case Continue::CONTINUE_STATE::NEXT: NextLevel(); break; case Continue::CONTINUE_STATE::QUIT: MenuReturn(); break; case Continue::CONTINUE_STATE::AGAIN: PlayAgain(); break; case Continue::CONTINUE_STATE::NONE: MessageBox(Global::GetHWND(), L"MAJOR ERROR I DON'T KNOW HOW YOU GOT HERE!!!!!", L"Error", MB_OK); FLAG_EXIT = true; break; } }
/** * This routine deletes a node from Tree. The node to be * deleted is specified by the Key for the node and the Data * contents of the node. These two pointers must be identical * to the pointers that were used for the node when it was * originally stored in the tree. A node will be deleted from * the tree only if its key and data pointers are identical * to Key and Data respectively. The tree is re-formed by removing * the affected subtree and inserting all elements but the root. * * @param Tree K-D tree to delete node from * @param Key key of node to be deleted * @param Data data contents of node to be deleted * * @note Exceptions: none * * @note History: 3/13/89, DSJ, Created. * 7/13/89, DSJ, Specify node indirectly by key and data. */ void KDDelete (KDTREE * Tree, FLOAT32 Key[], void *Data) { int Level; KDNODE *Current; KDNODE *Father; /* initialize search at root of tree */ Father = &(Tree->Root); Current = Father->Left; Level = NextLevel(Tree, -1); /* search tree for node to be deleted */ while ((Current != NULL) && (!NodeFound (Current, Key, Data))) { Father = Current; if (Key[Level] < Current->BranchPoint) Current = Current->Left; else Current = Current->Right; Level = NextLevel(Tree, Level); } if (Current != NULL) { /* if node to be deleted was found */ if (Current == Father->Left) { Father->Left = NULL; Father->LeftBranch = Tree->KeyDesc[Level].Min; } else { Father->Right = NULL; Father->RightBranch = Tree->KeyDesc[Level].Max; } InsertNodes(Tree, Current->Left); InsertNodes(Tree, Current->Right); FreeSubTree(Current); } } /* KDDelete */
void Vote_ChangeMap_Yes() { int f1, f2; gedict_t* p = world; if(!k_vote) return; if(self->k_voted) { G_sprint(self, 2, "--- your vote is still good ---\n"); return; } // register the vote k_vote ++; G_bprint(2, "%s votes for mapchange\n",self->s.v.netname); f1 = CountPlayers(); f2 = f1 / 2 + 1; if(k_vote >= f2) { G_bprint(3, "Map changed by majority vote\n"); k_vote = 0; current_vote = -1; while((p = trap_find(p, FOFS(s.v.classname), "player"))) { if(p->s.v.netname[0] ) p->k_voted = 0; } p = trap_find(world, FOFS(s.v.classname), "voteguard"); if(p) { p->s.v.classname = ""; dremove(p); } NextLevel(); return; } // calculate how many more votes are needed self->k_voted = 1; f1 = f2 - k_vote; if(f1>1) G_bprint(2, "%d more votes needed\n",f1); else G_bprint(2, "%d more vote needed\n",f1); }
void GameLayer::onEventCustom_TankDeath(EventCustom* event) { auto tank = static_cast<Tank*>(event->getUserData()); if (tank->getObjType() == PlayerTank) { _playerTank[0] = NULL; _enemyAI->mTank = NULL; _tileMapInfo->getTileMap()->removeChild(tank); _iplife--; if (_iplife <= 0) { GameOver(); } this->scheduleOnce(schedule_selector(GameLayer::createNewPlayer), 1.0f); ////在已有的地图上,创建玩家坦克 //_playerTank[0] = Tank::createTankWithTankType("player2U.png", _tileMapInfo); ////设置坦克类型为玩家坦克 //_playerTank[0]->setObjType(PlayerTank); //_playerTank[0]->getBullet(); ////放到地图中初始化位置 //CCSize tileSize = _tileMapInfo->getTileMap()->getTileSize(); //CCSize mapSize = _tileMapInfo->getTileMap()->getContentSize(); //_playerTank[0]->setPosition(ccp(mapSize.width / 2 - tileSize.width * 3, tileSize.height)); //_playerTank[0]->setMovedRect(_playerTank[0]->boundingBox()); //_enemyAI->mTank = _playerTank[0]; } else { _enemyAI->mEnemyTanks->removeObject(tank); _tileMapInfo->getTileMap()->removeChild(tank); _enemyCount--; if (_enemyCount<=0) { NextLevel(); } } }
void GameLayer::menuCallback_NextLevel(cocos2d::Ref* pSender) { NextLevel(); }
Meteorites::Meteorites() : Client(), Message(){ SetName("MeteoritesGame"); printf("------------------------------------------------------------------------\n"); printf("Initializing TV-Meteorites, Copyright (C) RealityMakers Entertainment as\n"); printf("------------------------------------------------------------------------\n"); // char *str = new char[strlen(GetCurrentProcess()->GetName())+]; // SetName(); extern Host *host; // AttatchHook = host->CreateHook("Attatch"); // DetatchHook = host->CreateHook("Detatch"); // ShutDownHook = host->CreateHook("ShutDown"); View1 = new View(Rect(0,0,1,1)); View1->SetClearState(false); /* ScoreView = new View(Rect(.8f,0,1,.5f)); ScoreView->SetClearState(false); ScoreView->ConsoleStream::Clear(); ScoreView->Print(" 1: 1261\n 2: 8726\n"); ScoreView->Print(" 3: 8145\n 4: 6923\n"); ScoreView->Print(" 5: 1261\n 6: 8726\n"); ScoreView->Print(" 7: 8145\n 8: 6923\n"); ScoreView->Print(" 9: 1261\n10: 8726\n"); ScoreView->Print("11: 8145\n12: 6923\n"); ScoreView->Print("13: 1261\n14: 8726\n"); ScoreView->Print("15: 8145\n16: 6923\n"); font = new Font("Fonts/Swiss"); ScoreView->ConsoleStream::Apply(font); View1->Apply(ScoreView); */ // View2 = new View(Rect(.8f,0,1,.5f)); View4 = new View(Rect(.75f,0,1,.8f)); // View2->SetClearState(false); // View4->SetClearState(false); // MeteoritesBitmap = new Bitmap("Textures/interface/divider"/*Textures/Title/title"*/,BITMAP_RGB); //Titletv4"); // View *LoadView = new View(Rect(.2f,.2f,1-.2f,1-.2f)); // View4->Apply(MeteoritesBitmap); //View1->Apply(View4); // Initialize scene // Bitmap *DividerBitmap = new Bitmap("Textures/interface/divider"/*Textures/Title/title"*/,BITMAP_RGB); //Titletv4"); Bitmap *ShadowBM = new Bitmap("Textures/Interface/Shipshadow",BITMAP_ARGB); View *Shadow = new View(Rect(.7f,0,1,1)); // View1->Apply(Shadow); ScoreViews = new DynamicArray(); font = new Font("Fonts/Swiss"); for(int n=0; n<4; n++){ // 12.5 x 23.3, 54.2 x 23.3 #define xofs .01f #define yofs .1f #define width (.233f*.8f) #define height (((.125f+.542f)/16.0f)*.8f) #define spacing ((0.1666667f/100.0f)*5.0f) // View *DividerView = new View(Rect(1-width,float(n)*height,1,float(n)*height+height-spacing)); // DividerView->Apply(DividerBitmap); // DividerView->SetClearState(false); // View1->Apply(DividerView); char str[1024]; sprintf(str,"Textures/interface/playernum/no%d",n+1); Bitmap *PlayerNBitmap = new Bitmap(str,BITMAP_RGB); //Titletv4"); View *PlayerNView = new View(Rect(1-width-height+xofs,float(n)*height+yofs,1-width-spacing+xofs,float(n)*height+height-spacing+yofs)); PlayerNView->Apply(PlayerNBitmap); PlayerNView->SetClearState(false); View1->Apply(PlayerNView); float scl = 1-width-height*2.0f+xofs; float sct = float(n)*height+yofs; float scr = 1-width-height+xofs; float scb = float(n)*height+height+yofs; float xs = (scr-scl)*.2f; float ys = (scb-sct)*.2f; scl+=xs; scr-=xs; sct+=ys; scb-=ys; switch(n){ Bitmap *PlaceBitmap; View *PlaceView; case 0: PlaceBitmap = new Bitmap("Textures/interface/first",BITMAP_RGB); //Titletv4"); PlaceView = new View(Rect(scl,sct,scr,scb)); PlaceView->Apply(PlaceBitmap); PlaceView->SetClearState(false); View1->Apply(PlaceView); break; case 1: PlaceBitmap = new Bitmap("Textures/interface/second",BITMAP_RGB); //Titletv4"); PlaceView = new View(Rect(scl,sct,scr,scb)); PlaceView->Apply(PlaceBitmap); PlaceView->SetClearState(false); View1->Apply(PlaceView); break; case 2: PlaceBitmap = new Bitmap("Textures/interface/third",BITMAP_RGB); //Titletv4"); PlaceView = new View(Rect(scl,sct,scr,scb)); PlaceView->Apply(PlaceBitmap); PlaceView->SetClearState(false); View1->Apply(PlaceView); break; } #define fontscale 0 View *v = new View(Rect(1-width+xofs,float(n)*height+fontscale+yofs,1+xofs,float(n)*height+height-spacing-fontscale+yofs)); v->ConsoleStream::Apply(font); v->SetClearState(false); v->Print("0 ..."); /* switch(n){ case 0: v->SetColor(ARGB(1,0,0)); break; case 1: v->SetColor(ARGB(0,0,1)); break; case 2: v->SetColor(ARGB(1,1,0)); break; case 3: v->SetColor(ARGB(0,1,0)); break; case 4: v->SetColor(ARGB(1,.5f,.5f)); break; case 5: v->SetColor(ARGB(0,1,1)); break; case 6: v->SetColor(ARGB(.5f,.5f,.5f)); break; case 7: v->SetColor(ARGB(1,0,0)); break; case 8: v->SetColor(ARGB(1,0,0)); break; case 9: v->SetColor(ARGB(1,0,0)); break; case 10: v->SetColor(ARGB(1,0,0)); break; case 11: v->SetColor(ARGB(1,0,0)); break; case 12: v->SetColor(ARGB(1,0,0)); break; case 13: v->SetColor(ARGB(1,0,0)); break; case 14: v->SetColor(ARGB(1,0,0)); break; case 15: v->SetColor(ARGB(1,0,0)); break; } */ v->SetColor(ARGB(1,1,1)); View1->Apply(v); ScoreViews->Add(v); } // 191,189 // 101 // 85 Info1 = new Bitmap("Textures/Interface/Instructions/Inntasting",BITMAP_RGB); Info2 = new Bitmap("Textures/Interface/Instructions/Kontroll",BITMAP_RGB); Info3 = new Bitmap("Textures/Interface/Instructions/Pickups",BITMAP_RGB); printf("%d,%d\n",Info1->GetWidth(),Info1->GetHeight()); printf("%d,%d\n",Info2->GetWidth(),Info2->GetHeight()); printf("%d,%d\n",Info3->GetWidth(),Info3->GetHeight()); View *InfoView = new View(Rect(.75f,.7f,.95f,.9f)); InfoView->SetClearState(false); View *v1 = new View(Rect(0,0,1,1.3f)); View *v2 = new View(Rect(0,0,1,101.0f/189.0f*1.3f)); View *v3 = new View(Rect(0,0,1,85.0f/189.0f*1.3f)); v1->Apply(Info1); v2->Apply(Info2); v3->Apply(Info3); v1->SetClearState(false); v2->SetClearState(false); v3->SetClearState(false); InfoView->Apply(v1); InfoView->Apply(v2); InfoView->Apply(v3); View1->Apply(InfoView); Info3->SetTranslusency(.8f); null = new Geometry(); null->SetPosition(Vector(0,0,1000000)); Back = new Geometry(); Back->Node::Apply(new Background(Back)); Back->SetPosition(Vector(0,0,800000)); Back->Post(); null->Node::Apply(Back); new Planet(null); cam = new Camera(); cam->SetName("Camera"); null->Node::Apply(cam); camAI = new CameraAI(cam); cam->Apply(camAI); View1->Attatch(cam); PlayerGeometries = new DynamicArray(); for(n=0; n<4; n++){ Geometry *Ship = new Geometry(); char name[1024]; sprintf(name,"Player%d",n); Ship->SetName(name); //Ship->SetPosition(Vector(0,0,-800000)); Ship->Post(); PlayerGeometries->Add(Ship); //AI_Player1 = new PlayerAI(Ship); null->Node::Apply(Ship); Ship->Node::Apply(new PlayerAI(Ship,(View*)ScoreViews->GetItem(n))); } // printf("Initializing levels.\n"); //#ifndef _DEBUG InitLevels(2); NextLevel(10); //#endif printf("Done.\n"); printf("------------------------------------------------------------------------\n"); printf(" TV-Meteorites initalized\n"); printf("------------------------------------------------------------------------\n"); Initialized = true; }
Meteorites::Meteorites() : Client(), Message(){ SetName("MeteoritesGame"); printf("------------------------------------------------------------------------\n"); printf("Initializing TV-Meteorites, Copyright (C) RealityMakers Entertainment as\n"); printf("------------------------------------------------------------------------\n"); // char *str = new char[strlen(GetCurrentProcess()->GetName())+]; // SetName(); extern Host *host; AttatchHook = host->CreateHook("Attatch"); DetatchHook = host->CreateHook("Detatch"); ShutDownHook = host->CreateHook("ShutDown"); View1 = new View(Rect(0,0,1,1)); View1->SetClearState(false); ScoreViews = new DynamicArray(); font = new Font("Fonts/Swiss"); for(int n=0; n<16; n++){ View *v = new View(Rect(.8f,float(n)*.6f/16.0f,1,float(n+1)*.6f/16.0f)); v->ConsoleStream::Apply(font); v->SetClearState(false); v->Print("0"); switch(n){ case 0: v->SetColor(ARGB(1,0,0)); break; case 1: v->SetColor(ARGB(0,0,1)); break; case 2: v->SetColor(ARGB(1,1,0)); break; case 3: v->SetColor(ARGB(0,1,0)); break; case 4: v->SetColor(ARGB(1,.5f,.5f)); break; case 5: v->SetColor(ARGB(0,1,1)); break; case 6: v->SetColor(ARGB(.5f,.5f,.5f)); break; case 7: v->SetColor(ARGB(1,0,0)); break; case 8: v->SetColor(ARGB(1,0,0)); break; case 9: v->SetColor(ARGB(1,0,0)); break; case 10: v->SetColor(ARGB(1,0,0)); break; case 11: v->SetColor(ARGB(1,0,0)); break; case 12: v->SetColor(ARGB(1,0,0)); break; case 13: v->SetColor(ARGB(1,0,0)); break; case 14: v->SetColor(ARGB(1,0,0)); break; case 15: v->SetColor(ARGB(1,0,0)); break; } View1->Apply(v); ScoreViews->Add(v); } /* ScoreView = new View(Rect(.8f,0,1,.5f)); ScoreView->SetClearState(false); ScoreView->ConsoleStream::Clear(); ScoreView->Print(" 1: 1261\n 2: 8726\n"); ScoreView->Print(" 3: 8145\n 4: 6923\n"); ScoreView->Print(" 5: 1261\n 6: 8726\n"); ScoreView->Print(" 7: 8145\n 8: 6923\n"); ScoreView->Print(" 9: 1261\n10: 8726\n"); ScoreView->Print("11: 8145\n12: 6923\n"); ScoreView->Print("13: 1261\n14: 8726\n"); ScoreView->Print("15: 8145\n16: 6923\n"); font = new Font("Fonts/Swiss"); ScoreView->ConsoleStream::Apply(font); View1->Apply(ScoreView); */ // View2 = new View(Rect(.8f,0,1,.5f)); View4 = new View(Rect(.75f,0,1,.8f)); // View2->SetClearState(false); // View4->SetClearState(false); MeteoritesBitmap = new Bitmap("Textures/test"/*Textures/Title/title"*/,BITMAP_RGB); //Titletv4"); View *LoadView = new View(Rect(.2f,.2f,1-.2f,1-.2f)); View4->Apply(MeteoritesBitmap); View1->Apply(View4); // Initialize scene null = new Geometry(); null->SetPosition(Vector(0,0,1000000)); Back = new Geometry(); Back->Node::Apply(new Background(Back)); Back->SetPosition(Vector(0,0,1000000)); Back->Post(); null->Node::Apply(Back); cam = new Camera(); cam->SetName("Camera"); null->Node::Apply(cam); camAI = new CameraAI(cam); cam->Apply(camAI); View1->Attatch(cam); PlayerGeometries = new DynamicArray(); for(n=0; n<5; n++){ Geometry *Ship = new Geometry(); char name[1024]; sprintf(name,"Player%d",n); Ship->SetName(name); //Ship->SetPosition(Vector(0,0,-800000)); Ship->Post(); PlayerGeometries->Add(Ship); //AI_Player1 = new PlayerAI(Ship); null->Node::Apply(Ship); Ship->Node::Apply(new PlayerAI(Ship,(View*)ScoreViews->GetItem(n))); } // printf("Initializing levels.\n"); //#ifndef _DEBUG InitLevels(2); NextLevel(10); //#endif printf("Done.\n"); printf("------------------------------------------------------------------------\n"); printf(" TV-Meteorites initalized\n"); printf("------------------------------------------------------------------------\n"); Initialized = true; }
Meteorites::Meteorites() : Client(), Message(){ ViewBunch = new DynamicArray(); BitmapBunch = new DynamicArray(); SetName("MeteoritesGame"); printf("------------------------------------------------------------------------\n"); printf("Initializing TV-Meteorites, Copyright (C) RealityMakers Entertainment as\n"); printf("------------------------------------------------------------------------\n"); View1 = new View(Rect(0,0,1,1)); View1->SetClearState(false); /* Scores = new ScoreViews(View1); */ // 191,189 // 101 // 85 #ifdef TV2 tv2bm = new Bitmap("Textures/tv2/tv2",BITMAP_RGB); tv2v = new View(Rect( 1-.075f*.8f-.01f, .01f, 1-.01f, .1f*.8f+.01f)); tv2bm->SetTranslusency(.5f); tv2v->Apply(tv2bm); tv2v->SetClearState(false); View1->Apply(tv2v); #endif #ifdef SCHIBSTED tv2bm = new Bitmap("Textures/tv2/slogo",BITMAP_RGB); tv2v = new View(Rect( 1-.09f*.8f*1.5f-.01f, .01f, 1-.01f, .1f*.8f+.01f)); tv2bm->SetTranslusency(.5f); tv2v->Apply(tv2bm); tv2v->SetClearState(false); View1->Apply(tv2v); #endif #ifdef JANCO Bitmap *tv2bm = new Bitmap("Textures/tv2/janco",BITMAP_RGB); View *tv2v = new View(Rect( .9f, 0, 1, .1f)); tv2bm->SetTranslusency(.5f); tv2v->Apply(tv2bm); tv2v->SetClearState(false); View1->Apply(tv2v); #endif Info1 = new Bitmap("Textures/Interface/Instructions/Inntasting",BITMAP_RGB); Info2 = new Bitmap("Textures/Interface/Instructions/Kontroll",BITMAP_RGB); Info3 = new Bitmap("Textures/Interface/Instructions/Pickups",BITMAP_RGB); //printf("%d,%d\n",Info1->GetWidth(),Info1->GetHeight()); //printf("%d,%d\n",Info2->GetWidth(),Info2->GetHeight()); //printf("%d,%d\n",Info3->GetWidth(),Info3->GetHeight()); View *InfoView = new View(Rect(.75f,.7f,.95f,.9f)); InfoView->SetClearState(false); View *v1 = new View(Rect(0,0,1,1.3f)); View *v2 = new View(Rect(0,0,1,101.0f/189.0f*1.3f)); View *v3 = new View(Rect(0,0,1,85.0f/189.0f*1.3f)); InfoViews = new DynamicArray(); InfoViews->Add(InfoView); InfoViews->Add(v1); InfoViews->Add(v2); InfoViews->Add(v3); v1->Apply(Info1); v2->Apply(Info2); v3->Apply(Info3); v1->SetClearState(false); v2->SetClearState(false); v3->SetClearState(false); InfoView->Apply(v1); InfoView->Apply(v2); InfoView->Apply(v3); View1->Apply(InfoView); // Info3->SetTranslusency(.8f); #if 1 scene = new Scene(View1); #else Scores = new ScoreViews(View1); null = new Geometry(); null->SetPosition(Vector(0,0,10000)); Back = new Geometry(); Back->Node::Apply(new Background(Back)); Back->SetPosition(Vector(0,0,8000*3)); Back->Post(); null->Node::Apply(Back); new Nebula(null); new Sun(null); // new Planet(null); cam = new Camera(); cam->SetName(String("Camera")); null->Node::Apply(cam); camAI = new CameraAI(cam); cam->Apply(camAI); View1->Attatch(cam); /* // PlayerGeometries = new DynamicArray(); for(int n=0; n<16; n++){ Geometry *Ship = new Geometry(); char name[1024]; sprintf(name,"Player%d",n); Ship->SetName(String(name)); // fixme: Optimize! //Ship->SetPosition(Vector(0,0,-800000)); Ship->Post(); // PlayerGeometries->Add(Ship); //AI_Player1 = new PlayerAI(Ship); null->Node::Apply(Ship); Ship->Node::Apply(new PlayerAI(Ship,Scores,Scores->GetPlayer(n),0)); } */ //#if 0 for(int n=0; n<10; n++){ Geometry *Rock = new Geometry(); Rock->SetName("Rock"); Rock->Add(Vector(-400,-400,0)); Rock->Add(Vector( 400,-400,0)); Rock->Add(Vector( 400, 400,0)); Rock->Add(Vector(-400, 400,0)); Rock->Add(Vertex(0,0,0)); Rock->Add(Vertex(1,1,0)); Rock->Add(Vertex(2,1,1)); Rock->Add(Vertex(3,0,1)); IndexedPolygon *pol = Rock->NewIndexedPolygon(); pol->Add(0); pol->Add(1); pol->Add(2); pol->Add(3); RockAI *AI_Rock = new RockAI(/*this,*/Rock,400.0f); Rock->Node::Apply(AI_Rock); null->Node::Apply(Rock); } //#endif // #if 0 printf("Initializing levels.\n"); //#ifndef _DEBUG InitLevels(2); NextLevel(10); //#endif printf("Done.\n"); #endif #endif printf("------------------------------------------------------------------------\n"); printf(" TV-Meteorites initalized\n"); printf("------------------------------------------------------------------------\n"); Initialized = true; }
bool CAbfTraceIdealization::DownTransition(int nI0, int nLag, short stLevel, int nLevelBeginning, short &stNextLevel, int &nLevelEnd, float &fAmpMean, float &fAmpDev, float &fAmpMin, float & fAmpMax, bool &bAnchor) { bool bDownTransition=false; int nI1=m_pnLMaxima[nI0]; int nI2=m_pnLMinima[nI0+1+nLag]; float fAmp1=m_pfData[nI1]; float fAmp2=m_pfData[nI2]; float fAmp3; if(nI2>0) fAmp3=m_pfData[nI2-1]; else fAmp3=m_pfData[nI2]; float fDelta=0.f; float fDeltaC=0.f; float fThreshold=0.f; float fTemp; int nSign; for(int i=stLevel;i>0;i--) { fThreshold=m_vstructLTC[i].fDTMax; if(fAmp1>fThreshold) { bDownTransition=true; stNextLevel=i-1; } else { if(m_bLTCFromTraces) { fTemp=0.5*(m_vstructSegMinimaHist[i].f5_thBin+m_vstructSegMinimaHist[i-1].f5_thBin)-4.*m_vstructSegMinimaHist[i].fInterval; if(fAmp1>fTemp) { fDelta=m_pfData[m_pnLMinima[nI0+nLag]]-fAmp1; fDeltaC=m_vstructLTC[stLevel].fDTDelta; if(fabs(fDelta)>fabs(fDeltaC)) { nSign=-1; bDownTransition=true; NextLevel(stLevel, stNextLevel, fAmp1, m_fThreshold, nSign); } break; } } } } int nDelta=1; int nLevelLength=0; if(bDownTransition) { m_fThreshold=0.5*(fAmp1+fAmp3); nLevelEnd=LevelEnd(stLevel, stNextLevel, nI1); nLevelLength=nLevelEnd-nLevelBeginning+1; if(nLevelLength>0) { structSemNode aSemNode=CalSem_Amp(m_pfData,nLevelBeginning,nLevelLength,nDelta); fAmpMean=aSemNode.fMean; fAmpDev=aSemNode.fSem; fAmpMax=aSemNode.fMax; fAmpMin=aSemNode.fMin; } else { bDownTransition=false; stNextLevel=stLevel; m_fThreshold0=m_fThreshold; } } if(bDownTransition) { if(nI0-m_nLMaxI>m_nLTCWindowSize&&stLevel==0) { CalRunTimeLTC(stLevel,nI0); if(stLevel==0) bAnchor=true; else bAnchor=false; } else { bAnchor=false; } //RuntimeLTC should not include nI0 m_nLMaxI=nI0; } return bDownTransition; }
//updates the world one tick void UpdateGame(void) { int numbigasteroids = 0, nummedasteroids = 0; LIST * cur; LIST * next; static unsigned int fpsframes = 0; static unsigned int last_fps_time = 0; unsigned int t; char hiscore_name[HS_NAME_LENGTH]; if(g_paused) return; UpdateStarfield(&g_starfield); for(cur = g_asteroid_list; cur; cur = cur->next) { if(((ASTEROID *)cur->d)->scale == 4.0f) numbigasteroids++; else if(((ASTEROID *)cur->d)->scale == 2.0f) nummedasteroids++; } t = 1500*numbigasteroids + 500*nummedasteroids + (int)(16384.0/pow((double)g_score, 0.3010299956639811952)); if(g_ships && !g_time_to_reset && g_level > 2 && !(rand() % t)) { NewAlien(g_score >= 10000 ? (rand() % 3) : 1); } t = (g_ships + 1) * 1000; if(g_ships && g_ships < 11 && !g_time_to_reset && !(rand() % t)) { NewPowerup(); } for(cur = g_asteroid_list; cur; cur = cur->next) UpdateAsteroid(cur->d); if(g_ships) UpdatePlayer(&g_player, g_keys); for(cur = g_alien_list; cur; cur = next) { next = cur->next; UpdateAlien(cur->d, (g_ships ? &g_player : NULL), g_asteroid_list); if(((ALIEN *)cur->d)->pos.x < 0.0f || ((ALIEN *)cur->d)->pos.x > 40.0f) RemoveNode(cur, &g_alien_list); } for(cur = g_shot_list; cur; cur = next) { next = cur->next; UpdateShot(cur->d); if(!(((SHOT *)cur->d)->life)) RemoveNode(cur, &g_shot_list); } for(cur = g_explosion_list; cur; cur = next) { next = cur->next; UpdateExplosion(cur->d); if(!(((EXPLOSION *)cur->d)->life)) RemoveNode(cur, &g_explosion_list); } for(cur = g_burst_list; cur; cur = next) { next = cur->next; UpdateBurst(cur->d); if(!(((BURST *)cur->d)->life)) RemoveNode(cur, &g_burst_list); } for(cur = g_powerup_list; cur; cur = next) { next = cur->next; UpdatePowerup(cur->d); if(((POWERUP *)cur->d)->pos.x < 0.0f || ((POWERUP *)cur->d)->pos.x > 40.0f) RemoveNode(cur, &g_powerup_list); } Clipping(); g_frame++; //next frame if(g_time_to_reset && !(--g_time_to_reset)) NextLevel(); if(!g_ships && g_hisct_delay && !(--g_hisct_delay) && IsScoreHi(&g_hisct, g_score) && GetHiScoreName(hiscore_name)) AddHiScore(&g_hisct, hiscore_name, g_score, g_level); fpsframes++; t = glutGet(GLUT_ELAPSED_TIME); if(t >= last_fps_time + 1000) { g_fps = (float)fpsframes / (float)(t - last_fps_time) * 1000.0f; fpsframes = 0; last_fps_time = t; } glutPostRedisplay(); }
/** Game event loop. */ void EventLoop() { struct timeval last, current; unsigned long elapsedTime; int repeat; XEvent event; SetFirstLevel(); XSelectInput(display, mainWindow, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask); shouldExit = 0; DoStartDelay(); gettimeofday(&last, NULL); while(!shouldExit) { if(didWin) { WinLoop(); NextLevel(); moveRight = 0; moveLeft = 0; gettimeofday(&last, NULL); } if(didLose) { Redraw(); DoStartDelay(); break; } while(XPending(display) > 0) { XNextEvent(display, &event); switch(event.type) { case Expose: HandleExposeEvent(&event.xexpose); break; case KeyPress: HandleKeyPressEvent(&event.xkey); break; case KeyRelease: HandleKeyReleaseEvent(&event.xkey); break; case ButtonPress: HandleButtonPressEvent(); break; default: break; } } if(isPaused) { gettimeofday(&last, NULL); continue; } gettimeofday(¤t, NULL); elapsedTime = (current.tv_sec - last.tv_sec) * 1000000; elapsedTime += current.tv_usec - last.tv_usec; if(elapsedTime >= SPEED) { last = current; EraseBall(); repeat = (int)(((float)elapsedTime / SPEED) + 0.5); do { if(moveRight && !moveLeft) { MoveBallRight(); } else if(moveLeft && !moveRight) { MoveBallLeft(); } MoveBall(); --repeat; } while(repeat); DrawBall(); Redraw(); if(didDie) { didDie = 0; DoStartDelay(); gettimeofday(&last, NULL); } } } }
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE, LPSTR, int nCmdShow) { HWND hwnd; /* This is the handle for our window */ WNDCLASSEX wincl; /* Data structure for the windowclass */ /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default colour as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0; int width = windowWidth + GetSystemMetrics(SM_CXFIXEDFRAME) * 2; int height = windowHeight + GetSystemMetrics(SM_CYFIXEDFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION); /* The class is registered, let's create the program*/ hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ "IF, THEN", /* Title Text */ WS_CAPTION, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ width, /* The programs width */ height, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow (hwnd, SW_SHOW); /* Run the message loop. It will run until GetMessage() returns 0 */ HDC hdc = GetDC(hwnd); hBufferDC = CreateCompatibleDC(hdc); hBufferBmp = CreateCompatibleBitmap(hdc, windowWidth, windowHeight); hOldBufferBmp = (HBITMAP)SelectObject(hBufferDC, hBufferBmp); DWORD lastTime = GetTickCount(); NextLevel(); while (!bGameOver) { MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) bGameOver = true; TranslateMessage(&msg); DispatchMessage(&msg); } if (bGameOver) break; if (GetAsyncKeyState(VK_ESCAPE)) break; updateGame(); PaintGame(hBufferDC); BitBlt(hdc, 0, 0, windowWidth, windowHeight, hBufferDC, 0, 0, SRCCOPY); do Sleep(0); while (GetTickCount() - lastTime < 15); lastTime = GetTickCount(); } SelectObject(hBufferDC, hOldBufferBmp); DeleteObject(hBufferBmp); DeleteObject(hBufferDC); ReleaseDC(hwnd, hdc); /* The program return-value is 0 - The value that PostQuitMessage() gave */ return 0; }
void Engine::NewGame(){ m_level_of_game=0; NextLevel(); }
int pacman_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile ) { struct timeval tv; int x; int jumplevel=-1; if ( FBInitialize( 720, 576, 8, fdfb ) < 0 ) return -1; setup_colors(); if ( RcInitialize( fdrc ) < 0 ) return -1; InitLevel( 0 ); while( doexit != 3 ) { MazeInitialize(); DrawMaze( ); /* 0 = all */ DrawFill(); DrawGhosts( ); DrawPac( ); MazePig(); doexit=0; while( !doexit ) { tv.tv_sec = 0; #ifdef HAVE_DREAMBOX_HARDWARE tv.tv_usec = 8000; #else tv.tv_usec = 1000; #endif x = select( 0, 0, 0, 0, &tv ); /* 10ms pause */ MovePac( ); MoveGhosts( ); DrawGhosts( ); DrawPac( ); #if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE) FBFlushGrafic(); #endif RcGetActCode( ); CheckGhosts( ); } if ( doexit != 3 ) { actcode=0xee; if ( score ) DrawScore(); if ( !gametime ) DrawGameOver(); #if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE) FBFlushGrafic(); #endif doexit=0; jumplevel=-1; while(( actcode != RC_OK ) && !doexit ) { tv.tv_sec = 0; tv.tv_usec = 100000; x = select( 0, 0, 0, 0, &tv ); /* 100ms pause */ RcGetActCode( ); if ( actcode == RC_HELP ) { while( realcode != 0xee ) RcGetActCode( ); actcode=0xee; while(( actcode == 0xee ) && !doexit ) { tv.tv_sec = 0; tv.tv_usec = 100000; x = select( 0, 0, 0, 0, &tv ); /* 100ms pause */ RcGetActCode( ); } if ( actcode <= RC_9 ) { jumplevel=actcode; actcode=RC_OK; } } } if ( gametime ) NextLevel(); else InitLevel( jumplevel ); } } Fx2StopPig(); /* fx2 */ /* buffer leeren, damit neutrino nicht rumspinnt */ realcode = RC_0; while( realcode != 0xee ) { tv.tv_sec = 0; tv.tv_usec = 300000; x = select( 0, 0, 0, 0, &tv ); /* 300ms pause */ RcGetActCode( ); } RcClose(); FBClose(); return 0; }
void BrickBreaker(void) { uint8_t temp; uint16_t i = 0; uint16_t j = 0; uint8_t level = 4; uint8_t random = 0; uint16_t non_paddle_hits = 0; uint16_t num_blocks = 0; struct Solid solids[NUM_BRICKS]; uint16_t ballSpeed = BALL_SPEED; uint32_t score = 0; uint8_t balls = 4; uint16_t blocks_destroyed = 0; char vertical = 0; char horizontal = 0; char item_flame = 0; char item_long_paddle = 0; char item_short_paddle = 0; char ball_speed_fast = 0; char ball_speed_slow = 0; char item_bullets = 0; uint16_t bullet_index = 0; uint16_t paddle_width = 25; uint16_t item_buffer[200]; struct DropItem items[10]; //Items that get dropped struct MovingSolid bullets[15]; struct Solid paddle; struct MovingSolid ball; setBgColor(COLOR_GREEN); printf_setFont_properties(2, 0, COLOR_BLUE, COLOR_GREEN); printf_setFont_location(5, 300); _printf("Ball %d", balls); printf_setFont_location(5, 200); _printf("Score 0"); for (i = 0; i < NUM_BRICKS; i++) { solids[i].status = 0; } //Initialize the items for (i = 0; i < 10; i++) { items[i].sprite.status = 0; items[i].sprite.type = 0; } for (i = 0; i < 15; i++) { bullets[i].solid.status = 0; } #if READ_EEPROMLEVEL == 1 //Load the last level from memory SetClockSpeed(0); //Clock Speed must be < 10Mhz to support EEProm __disable_interrupt(); level = EEProm_Read(BRICK_BREAKER_LEVEL); if (level == 0 || level > 4) { level = 1; EEProm_Write(BRICK_BREAKER_LEVEL, level); } __enable_interrupt(); SetClockSpeed(5); //Clock Speed must be < 10Mhz to support EEProm #endif num_blocks = loadLevel(solids, level); build_solid(&paddle, 200, 160, 5, paddle_width, COLOR_DRKGREY); build_moving_solid(&ball, 200, 167, 7, 7, COLOR_DRKGREY, SOLID_AUTOUP | SOLID_AUTOLEFT, 4); solid_setScreenBounds(0x0f); StartTimer(0, PADDLE_SPEED + 21); StartTimer(1, ballSpeed + 31); StartTimer(2, PAUSE_CHECK); StartTimer(4, ITEM_DROP_SPEED); StartTimer(5, ITEM_RANDOM_DROP); for (;;) { //Check the joystick if (CheckTimer(0)) { if (GetLeft()) { solid_fastMoveLeft(&paddle, GetJoystickXMag() + 5, 0); } else if (GetRight()) { solid_fastMoveRight(&paddle, GetJoystickXMag() + 5, 0); } StartTimer(0, PADDLE_SPEED); } //Auto-move the ball, check if it has hit any bricks. if (CheckTimer(1)) { temp = solid_autoMove(&ball); if (temp != 0) { play_sound(0); } if (temp == 3) { balls--; printf_setFont_location(5, 300); _printf("Ball %d", balls); display_moving_solid(&ball, 1); ballSpeed = BALL_SPEED;// Reset the ball speed build_moving_solid(&ball, 200, 167, 7, 7, COLOR_DRKGREY, SOLID_AUTOUP | SOLID_AUTOLEFT, 4); if (balls == 0) { AddHighScore(score, BRICK_BREAKER_SCORE_ADDR); setBgColor(COLOR_GREEN); display_solid(&paddle, 1); display_moving_solid(&ball, 1); balls = 4; score = 0; printf_setFont_location(5, 300); _printf("Ball %d", balls); printf_setFont_location(5, 200); _printf("Score 0"); build_solid(&paddle, 200, 160, 5, 25, COLOR_DRKGREY); build_moving_solid(&ball, 200, 167, 7, 7, COLOR_DRKGREY, SOLID_AUTOUP | SOLID_AUTOLEFT, 4); num_blocks = loadLevel(solids, level); StartTimer(0, PADDLE_SPEED); StartTimer(1, ballSpeed); StartTimer(2, SCORE_UPDATE); } } if (solid_checkIntersectionPaddle(&ball, &paddle) != 0) { non_paddle_hits = 0; play_sound(0); } for (i = 0; i < NUM_BRICKS; i++) { if (solid_checkIntersectionBrick(&ball, &solids[i], &vertical, &horizontal, random) != 0) { if (solids[i].color == 0x0000 || item_flame == 0) { solid_verticalBounce(&ball, vertical, random); solid_horizontalBounce(&ball, horizontal, random); } StartTimer(3, 1011);//A block was hit, schedule a block redraw if (random == 1) { random = 0; } if (solids[i].color == 0x0000) { non_paddle_hits++; if (non_paddle_hits == 5) { random = 1; non_paddle_hits = 0; } break;//Only allow one brick to be hit at once } else { blocks_destroyed = DropRandomItem(items, item_buffer, solids, blocks_destroyed, i); blocks_destroyed++; display_solid(&solids[i], 1); solids[i].status = 0; score++; printf_setFont_location(5, 128); _printf("%d", score); num_blocks--; play_sound(0); if (ballSpeed > 20) { ballSpeed--; } //This game has been finished, reset for the next if (num_blocks == 0) { level = NextLevel(&ball, &paddle, solids, &balls, &num_blocks, &ballSpeed, level); } break; //Only allow one brick to be hit at once } } } StartTimer(1, ballSpeed); } //Auto-move the bullets and check if bullets have intersected any bricks if (CheckTimer(7)) { for (i = 0; i < 15; i++) { if (bullets[i].solid.status > 0) { if (solid_autoMove(&bullets[i]) == 2) { bullets[i].solid.status = 0; display_moving_solid(&bullets[i], 0); } else { for (j = 0; j < NUM_BRICKS; j++) { if (solid_checkIntersectionSolid(&bullets[i].solid, &solids[j]) != 0) { bullets[i].solid.status = 0; //Black brick, do nothing if (solids[j].color == 0x0000) { } else { blocks_destroyed = DropRandomItem(items, item_buffer, solids, blocks_destroyed, i); blocks_destroyed++; display_solid(&solids[j], 1); solids[j].status = 0; score++; printf_setFont_location(5, 128); _printf("%d", score); num_blocks--; play_sound(0); if (ballSpeed > 20) { ballSpeed--; } //This game has been finished, reset for the next if (num_blocks == 0) { level = NextLevel(&ball, &paddle, solids, &balls, &num_blocks, &ballSpeed, level); } break; //Only allow one brick to be hit at once } } } } } //Re-display the bullet if it is still moving if (bullets[i].solid.status == 1) { display_moving_solid(&bullets[i], 0); } } StartTimer(7, 40); } //Launch a new bullet (if the bullet item is currently in use if (CheckTimer(6)) { build_moving_solid(&bullets[bullet_index], paddle.y_pos - 5, paddle.x_pos + 5, 4, 4, COLOR_BLACK, SOLID_AUTOUP, 4); bullet_index++; if (bullet_index == 15) { bullet_index = 0; } StartTimer(6, 400); } //Check for pause (center joystick) button if (CheckTimer(2)) { if (GetJoystickBtn()) { if (Pause(BRICK_BREAKER_SCORE_ADDR) == 1) { AddHighScore(score, BRICK_BREAKER_SCORE_ADDR); break; } printf_setFont_location(5, 300); _printf("Ball %d", balls); printf_setFont_location(5, 200); _printf("Score %d", score); StartTimer(3, 100); //Redraw the screen } StartTimer(2, PAUSE_CHECK); } //Redraw blocks timer if (CheckTimer(3)) { for (i = 0; i < NUM_BRICKS; i++) { if (solids[i].status == 1) { display_solid(&solids[i], 0); } } StopTimer(3); } //Auto-move items and check to see if the user has obtained one. if (CheckTimer(4)) { for (i = 0; i < 10; i++) { //Item was captured, enabled it if (drop_item_autoMove(&items[i], &paddle) == 2) { if (items[i].sprite.type == 0) { //Easy break condition to prevent a lot of work on this } else if (items[i].sprite.type == SPRITE_ITEMFLAMEBALL) { item_flame = 1; ball.solid.color = COLOR_RED; } else if (items[i].sprite.type == SPRITE_ITEMBULLET) { item_bullets = 1; StartTimer(6, 300); StartTimer(7, 40); bullet_index = 0; } else if (items[i].sprite.type == SPRITE_ITEMSHORTPADDLE) { item_short_paddle = 1; display_solid(&paddle, 1); //Clear the old paddle paddle_width = 15; build_solid(&paddle, paddle.y_pos, paddle.x_pos, 5, paddle_width, COLOR_DRKGREY); } else if (items[i].sprite.type == SPRITE_ITEMLONGPADDLE) { item_long_paddle = 1; display_solid(&paddle, 1); //Clear the old paddle paddle_width = 40; build_solid(&paddle, paddle.y_pos, paddle.x_pos, 5, paddle_width, COLOR_DRKGREY); } else if (items[i].sprite.type == SPRITE_ITEMFASTBALL) { ball_speed_fast = 1; ballSpeed = 50; //(50ms per move) StartTimer(1, ballSpeed + 31); } else if (items[i].sprite.type == SPRITE_ITEMSLOWBALL) { ball_speed_slow = 1; ballSpeed = 200; //(50ms per move) StartTimer(1, ballSpeed + 31); } } //Item is not active, if it is, disable it else if (items[i].sprite.status == 0) { if (items[i].sprite.type == 0) { //Easy break condition to prevent a lot of work on this } else if (item_flame == 1 && items[i].sprite.type == SPRITE_ITEMFLAMEBALL) { item_flame = 0; items[i].sprite.type = 0; ball.solid.color = COLOR_DRKGREY; } else if (items[i].sprite.type == SPRITE_ITEMBULLET && item_bullets) { item_bullets = 0; items[i].sprite.type = 0; StopTimer(6); //StopTimer(7); } else if (items[i].sprite.type == SPRITE_ITEMSHORTPADDLE && item_short_paddle) { item_short_paddle = 0; items[i].sprite.type = 0; display_solid(&paddle, 1); //Clear the old paddle paddle_width = 25; build_solid(&paddle, paddle.y_pos, paddle.x_pos, 5, paddle_width, COLOR_DRKGREY); } else if (items[i].sprite.type == SPRITE_ITEMLONGPADDLE && item_long_paddle) { item_long_paddle = 0; items[i].sprite.type = 0; display_solid(&paddle, 1); //Clear the old paddle paddle_width = 25; build_solid(&paddle, paddle.y_pos, paddle.x_pos, 5, paddle_width, COLOR_DRKGREY); } else if (items[i].sprite.type == SPRITE_ITEMFASTBALL && ball_speed_fast) { ball_speed_fast = 0; items[i].sprite.type = 0; ballSpeed = BALL_SPEED; StartTimer(1, ballSpeed + 31); } else if (items[i].sprite.type == SPRITE_ITEMSLOWBALL && ball_speed_slow) { ball_speed_slow = 0; items[i].sprite.type = 0; ballSpeed = BALL_SPEED; StartTimer(1, ballSpeed + 31); } } } StartTimer(4, ITEM_DROP_SPEED); } } }
/** Walk a given Tree with action. */ void KDWalk(KDTREE *Tree, void_proc action, void *context) { if (Tree->Root.Left != NULL) Walk(Tree, action, context, Tree->Root.Left, NextLevel(Tree, -1)); }
void StateManager::Update() { while(System::isActive) { if(state == STATE_NEWLEVEL) { level = new TileLevel(levelName); prevState = state; state = STATE_LEVEL; nextState = state; } else if(state == STATE_START) { level = new StartScreen(); prevState = state; state = STATE_LEVEL; nextState = state; } while(state == nextState) { glfwPollEvents(); InputManager::Update(); GraphicsRender->BeginRender(); if (level) level->Update(GraphicsRender->GetDt()); else nextState = STATE_QUIT; fprintf(stderr, "DT: %f\n", GraphicsRender->GetDt()); if(InputManager::IsKeyPressed(GLFW_KEY_R)) nextState = STATE_RELOAD; if(InputManager::IsKeyPressed(GLFW_KEY_N)) NextLevel(); for(auto it = gameObjectList->begin(); it != gameObjectList->end(); ++it) { (*it)->Update(GraphicsRender->GetDt()); } GraphicsRender->EndRender(); if( glfwWindowShouldClose(System::window) ){ nextState = STATE_QUIT; } } delete level; level = 0; for(auto it = gameObjectList->begin(); it != gameObjectList->end(); ++it) { delete *it; } gameObjectList->clear(); if(nextState == STATE_RELOAD) { nextState = STATE_NEWLEVEL; } prevState = state; state = nextState; if(nextState == STATE_QUIT) System::isActive = false; } }
void Engine::PlayLevel(ushort Lp){ m_level_of_game=Lp-1; NextLevel(); }