/** * This is the main drawing pump. It will determine which hud we need to draw (Game or PostGame). Any drawing that should occur * regardless of the game state should go here. */ void AStrategyHUD::DrawHUD() { if (bBlackScreenActive) { FCanvasTileItem TileItem( FVector2D( 0.0f, 0.0f ), FVector2D( Canvas->ClipX,Canvas->ClipY ), FLinearColor( 0.0f, 0.0f, 0.0f, 1.0f ) ); TileItem.BlendMode = SE_BLEND_Translucent; Canvas->DrawItem( TileItem ); return; } if ( GEngine && GEngine->GameViewport ) { FVector2D ViewportSize; GEngine->GameViewport->GetViewportSize(ViewportSize); UIScale = ViewportSize.X / 2048.0f; } Super::DrawHUD(); bool bConsoleOpen = false; AStrategyGameState const* const MyGameState = GetWorld()->GetGameState<AStrategyGameState>(); if (MyGameState) { //Builds the widgets if they are not yet built BuildMenuWidgets(); if (MyGameState->IsGameActive()) { DrawActorsHealth(); } DrawMiniMap(); DrawLives(); if (IsPauseMenuUp()) { /*FCanvasTileItem TileItem( FVector2D( 0.0f, 0.0f ), FVector2D( Canvas->ClipX,Canvas->ClipY ), FLinearColor( 0.0f, 0.0f, 0.0f, 0.25f ) ); TileItem.BlendMode = SE_BLEND_Translucent; Canvas->DrawItem( TileItem );*/ } if (SelectedActor.IsValid()) { ActionGridPos = FVector2D(Canvas->Project(SelectedActor->GetActorLocation())) / UIScale - (MyHUDMenuWidget->ActionButtonsWidget->GetDesiredSize())/2; } } }
void Dungeon::Draw() { //カメラの移動 //target_camera = VGet(pos_x * 100 + (muki % 2 ? (muki - 1 ? 0 : 100) : 50), y * 100 - 50, (pos_z * 100 + (muki % 2 ? 50 : (muki ? 0 : 100)))); //player_camera = VGet(pos_x * 100 + (muki % 2 ? (muki - 1 ? 100 : 0) : 50), y * 100 - 50, (pos_z * 100 + (muki % 2 ? 50 : (muki ? 100 : 0)))); SetCameraPositionAndTarget_UpVecY(player_camera, target_camera); //メイン描画 DrawMap_c(map_data, x_max, z_max); DrawEvent(); if (!menuflag) { //ミニマップ DrawMiniMap(); } else { menu->Draw(); } player->drawState(); }
void BemGame::DrawFrame() { AddText( engine ); int i; // The whole demo works because it takes exactly 12 ticks for a // Drone or Brain to walk one tile. So every 12 subticks // we calculate a new direction for the actor. subtick++; tick++; teleFrame++; if ( subtick == SUBTICK ) { subtick = 0; for ( i=0; i<numActors; i++ ) { ProcessMap( &actor[i] ); } } // calculate the tinting, from map 4.5,4.5 float rad = float( tick ) / 45.0; float fred = fabs( sin( rad*1.5 ) ) * 0.5; float fgreen = fabs( sin( rad*2.5 ) ) * 0.5; float fblue = fabs( sin( rad*3.5 ) ) * 0.5; float falpha = fabs( sin( rad ) ) * 0.3; KrColorTransform gizmoColor; gizmoColor.TintRed( U8( fred * 255.0 )); gizmoColor.TintGreen( U8( fgreen * 255.0 )); gizmoColor.TintBlue( U8( fblue * 255.0 )); gizmoColor.TintAlpha( U8( falpha * 255.0 )); gizmo->SetColor( gizmoColor ); // update all the actors. for( i=0; i<numActors; i++ ) { KrColorTransform actorColor; float d = DistanceFromCenter( &actor[i] ); if ( d < 3.0 ) { float fraction = 1.0 - d / 3.0; actorColor.TintRed( U8( fred * 255.0 * fraction )); actorColor.TintGreen( U8( fgreen * 255.0 * fraction )); actorColor.TintBlue( U8( fblue * 255.0 * fraction )); actorColor.TintAlpha( U8( falpha * 255.0 * fraction )); } actor[i].sprite->SetColor( actorColor ); actor[i].sprite->DoStep(); // In order to sort with the particles, sort with // the world Y. GlFixed wx, wy, wz, tx, ty; isoMath->ScreenToFlatTile( actor[i].sprite->X(), actor[i].sprite->Y(), 0, &tx, &ty ); isoMath->TileToWorld( tx, ty, 0, &wx, &wy, &wz ); actor[i].sprite->SetZDepth( -wy.v ); } // The teleport in and out special effect. Done "by hand" // counting frames with a switch. Looks cool and tests // the visibility stuff. if ( teleFrame > 9 && numActors > 0 ) { KrColorTransform cform; switch ( teleFrame ) { case 10: teleSprite = actor[ random.Rand( numActors ) ].sprite; cform.Brighten( 128 ); break; case 11: cform.Brighten( 200 ); cform.SetAlpha( 220 ); break; case 12: case 13: cform.Brighten( 255 ); cform.SetAlpha( 200 ); break; case 14: { GlFixed x, y; isoMath->ScreenToFlatTile( teleSprite->X(), teleSprite->Y(), 0, &x, &y ); AddParticles( x, y ); teleSprite->SetVisible( false ); } break; case 35: case 36: case 37: case 38: case 39: case 40: teleSprite->SetVisible( true ); cform.TintBlue( 240 - 30 * ( teleFrame - 35 ) ); cform.SetAlpha( 100 + 20 * ( teleFrame - 35 ) ); break; case 41: teleFrame = 0; break; default: break; } teleSprite->SetColor( cform ); } MoveParticles(); // Since the map coordinates only change if the subtick rolled // over, we only change the mini map every 12 frames. if ( subtick == 0 ) DrawMiniMap(); if ( UseWindows() ) ProcessRightWindow(); engine->Draw(); }
BemGame::BemGame( SDL_Surface* screen, bool useWindows ) { random.SetSeed( 0 ); KrRGBA green; green.Set( 0, 200, 0 ); if ( useWindows ) { KrRect rects[5]; const int lW = 280; const int lH = 180; const int r = 200; const int pad = 10; rects[0].Set( 0, 0, screen->w - 1 - pad - r, r + pad - 1 ); rects[1].Set( 0, r + pad, screen->w-1, screen->h - 1 - pad - lH ); rects[2].Set( lW + pad, screen->h - pad - lH, screen->w-1, screen->h - 1 ); rects[3].Set( 0, screen->h - lH, lW-1, screen->h - 1 ); rects[4].Set( screen->w - r, 0, screen->w-1, r-1 ); engine = new KrEngine( screen, 5, rects, &green ); } else { engine = new KrEngine( screen ); } GLASSERT( engine ); // The vault contains all the resources used by this // demo. if (!engine->Vault()->LoadDatFile( "bem.dat" ) ) { GLOUTPUT(( "Error loading dat file: 'bem.dat'!\n" )); exit( 100 ); } KrRGBA black; black.Set( 0, 0, 0 ); if ( useWindows ) { engine->FillBackgroundWindow( 0, 0 ); // main engine->FillBackgroundWindow( 1, 0 ); // main engine->FillBackgroundWindow( 2, 0 ); // main engine->FillBackgroundWindow( 3, &black ); // zoomed out engine->FillBackgroundWindow( 4, &black ); // moving zoom } else { // We have a space image so the engine should not draw // the background. Performance enhancement. engine->FillBackground( 0 ); } // Set up some depth categories: backgroundTree = new KrImNode; underTree = new KrImNode; floorTree = new KrImNode; standingTree = new KrImNode; overTree = new KrImNode; // Depth sort by order of addition. All the z-depths are // left at 0. In other words, when added at the same Z-depth (0 // in this case) the object added most recently is on top. engine->Tree()->AddNode( 0, backgroundTree ); engine->Tree()->AddNode( 0, underTree ); engine->Tree()->AddNode( 0, floorTree ); engine->Tree()->AddNode( 0, standingTree ); engine->Tree()->AddNode( 0, overTree ); // Store the floor size. Due to the way the sprites are defined, // the size in terms of positioning the tiles is slightly different // than the size in terms of the tile bitmap. KrSpriteResource* resource = engine->Vault()->GetSpriteResource( BEM_ROOM | BEM_FLOOR ); GLASSERT( resource ); tileWidth = resource->GetActionByIndex( 0 )->Frame( 0 ).Width() +2; tileHeight = resource->GetActionByIndex( 0 )->Frame( 0 ).Height(); isoMath = new GlIsoMath( tileWidth, tileHeight ); isoMath->SetScreenCenterToTile( screen->w, screen->h, MAPX / 2, MAPY / 2, 0 ); AddSpaceTiles(); AddFloor(); AddRoomObjects(); AddActors( useWindows ); // Add the mini-map KrCanvasResource* canvasResource = new KrCanvasResource( "minimap", 140, 140, true ); GLASSERT( canvasResource ); // An example of a user-defined resource getting added to a vault. engine->Vault()->AddResource( canvasResource ); canvas = new KrCanvas( canvasResource ); canvas->SetPos( screen->w - canvasResource->Width(), screen->h - canvasResource->Height() ); engine->Tree()->AddNode( overTree, canvas ); subtick = 0; tick = 0; teleFrame = 0; teleSprite = 0; DrawMiniMap(); if ( useWindows ) { // Set the 3 "band" windows to be positioned // to the first. engine->Tree()->Root()->SetPos( 0, 0, 0 ); engine->Tree()->Root()->SetPos( -engine->ScreenBounds(1).min.x, -engine->ScreenBounds(1).min.y, 1 ); engine->Tree()->Root()->SetPos( -engine->ScreenBounds(2).min.x, -engine->ScreenBounds(2).min.y, 2 ); SetupLeftWindow(); SetupRightWindow(); } }