Esempio n. 1
0
void CPaused::Loop(float time_step) {
	CControl *ctrl = g_game.player->ctrl;
	int width = Winsys.resolution.width;
	int height = Winsys.resolution.height;

	ClearRenderContext();
	Env.SetupFog();
	update_view(ctrl, 0);
	SetupViewFrustum(ctrl);

	if (sky) Env.DrawSkybox(ctrl->viewpos);
	if (fog) Env.DrawFog();
	Env.SetupLight();
	if (terr) RenderCourse();
	DrawTrackmarks();
	if (trees) DrawTrees();

	DrawSnow(ctrl);

	if (param.perf_level > 2) draw_particles(ctrl);
	g_game.character->shape->Draw();

	DrawHud(ctrl);
	Reshape(width, height);
	Winsys.SwapBuffers();
}
Esempio n. 2
0
void Screen::Draw()
{
	CalculateFps();

	// Reset screen buffer
	memset(buffer, 0, width * height * sizeof(uint));

	DrawSkybox();
	renderer->Render();
	DrawHud();

	if (core->menu)
		core->menu->Draw(drawer);

	// Debug
	sprintf(debug, "fps: %d", frameRate);
	drawer->Draw(debug, 10, 10, 0xffffff);

	if (showMessageTime)
	{
		drawer->Fill(0, 0, width, height - core->art->gamepanel->h, Color::Black);
		drawer->Draw(message, width / 2 - drawer->TextWidth(message) / 2, (height - core->art->gamepanel->h) / 2, 0xffff80);
		--showMessageTime;
	}

	BufferToScreen();
}
void GameClass::DrawGame () const {
  al_draw_bitmap_region(level, VisibleX, VisibleY,
      cWindowWidth, cWindowHeight, VisibleX, VisibleY, 0);
  hero->Draw();
  {
    std::list<Enemy*>::const_iterator iter = enemies.begin(),
      iterEnd = enemies.end();
    while (iter != iterEnd) {
      (*iter)->Draw();
      iter++;
    }
  }
  {
    std::list<Seed*>::const_iterator iter = seeds.begin(),
      iterEnd = seeds.end();
    while (iter != iterEnd) {
      (*iter)->Draw();
      iter++;
    }
  }
  for (std::list<Upgrade*>::const_iterator iter = upgrades.begin();
       iter != upgrades.end(); iter++) {
    (*iter)->Draw();
  }
  if (doubleJump)
    doubleJump->Draw();
  if (wallJump)
    wallJump->Draw();

  regionExit->Draw();
  regionSpiderBoss->Draw();
  regionCricketBoss->Draw();

  DrawHud();
}
Esempio n. 4
0
void racing_loop (double time_step){
    CControl *ctrl = Players.GetCtrl (g_game.player_id);
	double ycoord = Course.FindYCoord (ctrl->cpos.x, ctrl->cpos.z);
	bool airborne = (bool) (ctrl->cpos.y > (ycoord + JUMP_MAX_START_HEIGHT));

    check_gl_error();
    ClearRenderContext ();
	Env.SetupFog ();
	Music.Update ();    

	CalcTrickControls (ctrl, time_step, airborne);

	if (!g_game.finish) CalcSteeringControls (ctrl, time_step);
		else CalcFinishControls (ctrl, time_step, airborne);
	PlayTerrainSound (ctrl, airborne);

//  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	ctrl->UpdatePlayerPos (time_step); 
//  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

	if (g_game.finish) IncCameraDistance (time_step);
	update_view (ctrl, time_step);
	UpdateTrackmarks (ctrl);

    SetupViewFrustum (ctrl);
	if (sky) Env.DrawSkybox (ctrl->viewpos);
	if (fog) Env.DrawFog ();
	void SetupLight ();
	if (terr) RenderCourse ();
	DrawTrackmarks ();
	if (trees) DrawTrees ();
	if (param.perf_level > 2) {
		update_particles (time_step);
		draw_particles (ctrl);
    }
	Char.Draw (g_game.char_id);
	UpdateWind (time_step, ctrl);
	UpdateSnow (time_step, ctrl);
	DrawSnow (ctrl);
	DrawHud (ctrl);
	
	Reshape (param.x_resolution, param.y_resolution);
    Winsys.SwapBuffers ();
	if (g_game.finish == false) g_game.time += time_step;
} 
void Game::Draw()
{
	if(!m_inMainMenu)
	{
		// draw the hud first so that no transformations will affect it
		DrawHud();
		
		// transform everything by the camera
		m_basicCam.Update();
		 
		// draw the track
		m_track->Draw();

		// draw start and finish checkpoints
		glPushMatrix();
			m_start->Draw();
		glPopMatrix();
		glPushMatrix();
			m_midCheckpoint->Draw();
		glPopMatrix();
		glPushMatrix();
			m_finish->Draw();
		glPopMatrix();

		glPushMatrix();
			m_pOtherCar->Draw();
		glPopMatrix();

		glPushMatrix();
			// draw the car
			m_pMyCar->Draw();
		glPopMatrix();

		// temp
		if(m_packetTransferState == DEADRECKONING)
		{
			glPushMatrix();
			m_pMyCarRemote->Draw();
			glPopMatrix();
		}
	}
}
Esempio n. 6
0
void GameOverLoop (double time_step) {
    CControl *ctrl = Players.GetCtrl (g_game.player_id);
    int width, height;
    width = param.x_resolution;
    height = param.y_resolution;
    check_gl_error();

    Music.Update ();

    ClearRenderContext ();
    Env.SetupFog ();

    update_view (ctrl, 0);

    if (final_frame != NULL) final_frame->Update (time_step, ctrl);

    SetupViewFrustum (ctrl);
    Env.DrawSkybox (ctrl->viewpos);
    Env.DrawFog ();
    Env.SetupLight ();

    RenderCourse ();
    DrawTrackmarks ();
    DrawTrees ();

    UpdateWind (time_step, ctrl);
    UpdateSnow (time_step, ctrl);
    DrawSnow (ctrl);

    Char.Draw (g_game.char_id);

    set_gl_options (GUI);
    SetupGuiDisplay ();
    if (final_frame != NULL) {
        if (!final_frame->active) GameOverMessage (ctrl);
    } else GameOverMessage (ctrl);
    DrawHud (ctrl);
    Reshape (width, height);
    Winsys.SwapBuffers ();
}
Esempio n. 7
0
void Game::Start() {

    if(_gameState != Uninitialized) {
        return;
    }

    /* Initialize all prototype arrays and game objects */

    /* Load resources and xml files */
    ConstructResources();   // load all files into memory
    ConstructPrototypes();  // construct entity prototypes (from xml raw files)

    _gameState = Playing;
    _inventoryConsole = NULL;
    _inventoryInfo = NULL;
    Turns = 0;

    // Initialize player:
    player.cam_follow = true;
    player.speed = 100.0f;
    player.viewinginventory = false;

    player.Message("Have a secure day!", TCODColor::green, TCODColor::black);

    GameMap.Initialize(100, 100, getTurf("t_wall"), this);
    RandomGen = new TCODRandom();


    const char* smap[] = {
		"##############################################",
		"#######################      #################",
		"#####################    #     ###############",
		"######################  ###        ###########",
		"##################      #####             ####",
		"################       ########    ###### ####",
		"###############      #################### ####",
		"################    ######                  ##",
		"########   #######  ######   #     #     #  ##",
		"########   ######      ###                  ##",
		"########                                    ##",
		"####       ######      ###   #     #     #  ##",
		"#### ###   ########## ####                  ##",
		"#### ###   ##########   ########### ##########",
		"#### ##################   #####          #####",
		"#### ###             #### #####          #####",
		"####           #     ####                #####",
		"########       #     #### #####          #####",
		"########       #####      #######      #######",
		"#########++ ++####################++++########",
		"##                                          ##",
		"#                                            #",
		"#                                      g     #",
		"#                                     g g    #",
		"#       M                                    #",
		"#                        @                   #",
		"#                                      g     #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                S                           #",
		"#              S S S                         #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#   //////////////////// /  //////////////// #",
		"#                    /   /      [            #",
		"#                       / ?                  #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#",
		"##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##",
		"##############################################",


	};
    for (int y=0; y < 54; y++ ) {
        for (int x=0; x < 46; x++ ) {
            if ( smap[y][x] == '#' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_wall"));
            }
            else if ( smap[y][x] == '~' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_water"));
            }
            else if ( smap[y][x] == 'g' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnMob(x, y, getMob("m_goat"));
            }
            else if ( smap[y][x] == 'M' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnMob(x, y, getMob("m_kelrah"));
            }
            else if ( smap[y][x] == 'S' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnMob(x, y, getMob("m_skeleton"));
            }
            else if ( smap[y][x] == '+' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_window"));
            }
            else if ( smap[y][x] == '@' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.InsertMob(x, y, &player);
                player.x = x;
                player.y = y;
                player.cam_x = player.x;
                player.cam_y = player.y;
            }
            else if ( smap[y][x] == '/' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnItem(x, y, getItem("i_shortsword"));
            }
            else if ( smap[y][x] == '[' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnItem(x, y, getItem("i_backpack"));
            }
            else if ( smap[y][x] == '?' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnItem(x, y, getItem("i_flail"));
            }
            else {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
            }
        }
    }
    Test = "Lol!";

    // Initialize TCOD
    //TCODConsole::setCustomFont("terminal12x12.png", TCOD_FONT_LAYOUT_ASCII_INROW);
    TCODConsole::initRoot(VIEW_WIDTH, VIEW_HEIGHT, "Origin: Tales of Anarchy", false);
    TCODSystem::setFps(15);
    TCODConsole::setKeyboardRepeat(30, 5);

    DrawHud(true);

    std::cout << "Game Started" << std::endl << std::endl;
    LoadGame();

    while(!IsExiting()) {
        GameLoop();
    }
    SaveGame();
}
Esempio n. 8
0
void Game::GameLoop() {
    // Game is going: handle all rendering! Listens for player input to update game.

    // Compute the FoV
    GameMap.Field->computeFov(player.x, player.y, 0, true, FOV_DIAMOND); // basic FoV

    // Loop through all turfs and draw them
    std::vector<Turf*> Turfs = GameMap.TurfRange(player.cam_x, player.cam_y, 44);

    // Apply gradual fade as appropriate
    if(player.viewinginventory) {
        fade -= 0.02f;
        if(fade < 0.0f) {
            fade = 0.0f;
        }
    }
    else {
        fade = 1.0f;
    }

    for(int i = 0; i < Turfs.size(); i++) {

        Turf* turfchosen = Turfs[i]; // select the turf
        // Calculate the scrolling offset
        int x = (turfchosen->x - player.cam_x) + VIEW_WIDTH / 2;
        int y = (turfchosen->y - player.cam_y) + (VIEW_HEIGHT-(UI_BOTTOM_DIV-(VIEW_HEIGHT/2))) / 2;

        if(y > UI_BOTTOM_DIV)       // do not draw anything on the bottom 16 cells
            continue;

        // Draw the turf

        if( GameMap.Field->isInFov(turfchosen->x, turfchosen->y) && (x >= 0 && y >= 0) && (x < VIEW_WIDTH && y < VIEW_HEIGHT) ) {

            if(fade != 1.0f) {
                TCODConsole::root->setDefaultForeground(TCODColor::lerp(TCODColor::darkGrey, turfchosen->color, fade));
            }
            else {
                TCODConsole::root->setDefaultForeground(turfchosen->color);
            }

            if(turfchosen->c_symbol > 0) {
                TCODConsole::root->putChar(x, y, turfchosen->c_symbol);
            } else {
                TCODConsole::root->putChar(x, y, turfchosen->symbol);
            }



            // Draw all visible entities

            for(int j = 0; j < turfchosen->contents.size(); j++) {
                Entity* entity = turfchosen->contents[j];
                if(entity->symbol != ' ') {


                    if(fade != 1.0f) {
                        TCODConsole::root->setDefaultForeground(TCODColor::lerp(TCODColor::darkGrey, entity->color, fade));
                    }
                    else {
                        TCODConsole::root->setDefaultForeground(entity->color);
                    }

                    if(entity->c_symbol > 0) {
                        TCODConsole::root->putChar(x, y, entity->c_symbol);
                    } else {
                        TCODConsole::root->putChar(x, y, entity->symbol);
                    }

                }
            }

        }
    }

    // Draw the hud!
    DrawHud(false); // draw the borders and whatnot
    DrawHud(true);  // draw the messages, stats, etc

    // Draw the inventory if necessary
    DrawInv();

    if(debug_a_code > 0) {
        TCODConsole::root->putChar(5, 5, debug_a_code); // just for easy character mapping
    }
    TCODConsole::flush(); // apply changes

    // Handle user input:
    TCOD_key_t key = {TCODK_NONE,0};
    TCOD_mouse_t mouse;
    TCODSystem::checkForEvent((TCOD_event_t)(TCOD_EVENT_KEY_PRESS|TCOD_EVENT_MOUSE),&key,&mouse);
    ProcessInput(key, mouse);

    // Release unnecessary gui pointers
    if(_inventoryConsole != NULL && !player.viewinginventory) {
        delete _inventoryConsole;
        _inventoryConsole = NULL;
    }
    if(_inventoryInfo != NULL && (!player.viewinginventory || player.selecteditem == NULL)) {
        delete _inventoryInfo;
        _inventoryInfo = NULL;
    }

    // Clear the screen:
    TCODConsole::root->clear();
}
Esempio n. 9
0
void Game::ApplyTime(float time) {
    // Update the game
    UpdateLogic(time);

    DrawHud(true); // Update the hud
}
Esempio n. 10
0
void CReset::Loop(double time_step) {
	CControl *ctrl = Players.GetCtrl (g_game.player_id);
    double elapsed_time = Winsys.ClockTime () - reset_start_time;
    static bool tux_visible = true;
    static int tux_visible_count = 0;

    check_gl_error();
	ClearRenderContext ();
    Env.SetupFog ();
    ctrl->UpdatePlayerPos (EPS);
    update_view (ctrl, EPS);
    SetupViewFrustum (ctrl);
    Env.DrawSkybox (ctrl->viewpos);
    Env.DrawFog ();
	Env.SetupLight ();	// and fog
    RenderCourse();
    DrawTrackmarks ();
    DrawTrees ();

    if ((elapsed_time > BLINK_IN_PLACE_TIME) && (!position_reset)) {
		TObjectType* object_types = &Course.ObjTypes[0];
		TItem* item_locs  = &Course.NocollArr[0];
		size_t num_item_types = Course.ObjTypes.size();
		size_t first_reset = 0;
		size_t last_reset = 0;
		for (size_t i = 0; i < num_item_types; i++) {
		    if (object_types[i].reset_point == true) {
				last_reset = first_reset + object_types[i].num_items - 1;
				break;
		    } else {
				first_reset += object_types[i].num_items;
		    }
		} // for

		if (last_reset == 0) {
		    ctrl->cpos.x = Course.GetDimensions().x/2.0;
		    ctrl->cpos.z = min(ctrl->cpos.z + 10, -1.0);
		} else {
			int best_loc = -1;
		    for (size_t i = first_reset; i <= last_reset; i++) {
				if (item_locs[i].pt.z > ctrl->cpos.z) {
				    if (best_loc == -1 || item_locs[i].pt.z < item_locs[best_loc].pt.z) {
						best_loc = (int)i;
				    } // if
				} // if
		    } // for

		    if (best_loc == -1) {
				ctrl->cpos.x = Course.GetDimensions().x/2.0;
				ctrl->cpos.z = min (ctrl->cpos.z + 10, -1.0);
		    } else if (item_locs[best_loc].pt.z <= ctrl->cpos.z) {
				ctrl->cpos.x = Course.GetDimensions().x/2.0;
				ctrl->cpos.z = min (ctrl->cpos.z + 10, -1.0);
		    } else {
				ctrl->cpos.x = item_locs[best_loc].pt.x;
				ctrl->cpos.z = item_locs[best_loc].pt.z;
		    } // if
		}

		ctrl->view_init = false;
		ctrl->Init ();
		position_reset = true;
    } // if elapsed time

    if (tux_visible) Char.Draw (g_game.char_id);

    if (++tux_visible_count > 3) {
		tux_visible = (bool) !tux_visible;
		tux_visible_count = 0;
    }

    DrawHud (ctrl);
	Reshape (Winsys.resolution.width, Winsys.resolution.height);
    Winsys.SwapBuffers ();
    g_game.time += time_step;

    if (elapsed_time > TOTAL_RESET_TIME) {
		State::manager.RequestEnterState (Racing);
    }
}