/** Draw the player object. Could be a simple shape but this makes a fake ball shape and labels it. */ void BouncingBall::Draw() { // Do not draw if it should not be visible if ( !IsVisible() ) return; unsigned int uiColourMult = 0x010001; unsigned int uiColourText = 0xffffff; // Choose one of 8 colours: switch( m_iColour % 8 ) { case 1: uiColourMult = 0x010000; uiColourText = 0xffffff; break; case 2: uiColourMult = 0x000100; uiColourText = 0xffffff; break; case 3: uiColourMult = 0x000001; uiColourText = 0xffffff; break; case 4: uiColourMult = 0x010001; uiColourText = 0; break; case 5: uiColourMult = 0x010100; uiColourText = 0; break; case 6: uiColourMult = 0x000101; uiColourText = 0; break; case 7: uiColourMult = 0x010101; uiColourText = 0; break; default: uiColourMult = 0x000000; break; } // Concentric circles for pseudo-sphere int iRadiusSquared = (m_iDrawWidth/2) * (m_iDrawWidth/2); int iCentreX = m_iCurrentScreenX + m_iStartDrawPosX + m_iDrawWidth/2; int iCentreY = m_iCurrentScreenY + m_iStartDrawPosY + m_iDrawHeight/2; for ( int iX = m_iCurrentScreenX + m_iStartDrawPosX ; iX < (m_iCurrentScreenX + m_iStartDrawPosX + m_iDrawWidth) ; iX++ ) for ( int iY = m_iCurrentScreenY + m_iStartDrawPosY ; iY < (m_iCurrentScreenY + m_iStartDrawPosY + m_iDrawHeight) ; iY++ ) if ( ( (iX-iCentreX)*(iX-iCentreX) + (iY-iCentreY)*(iY-iCentreY) ) <= iRadiusSquared ) { // 0xB0 is the range of values, 0xff is the brightest value. unsigned int uiColour = (0xB0 * ((iX-iCentreX)*(iX-iCentreX) + (iY-iCentreY)*(iY-iCentreY))) / iRadiusSquared; uiColour = 0xff - uiColour; GetEngine()->SafeSetScreenPixel( iX, iY, uiColourMult * uiColour ); } // If there is a label then draw the text if ( (m_szLabel!=NULL) && (strlen(m_szLabel)>0) ) { //GetEngine()->DrawString( iCentreX+m_iXLabelOffset+1, iCentreY+m_iYLabelOffset+1, m_szLabel, 0xffffff ); GetEngine()->DrawScreenString( iCentreX+m_iXLabelOffset, iCentreY+m_iYLabelOffset, m_szLabel, uiColourText ); } // Store the position at which the object was last drawn // You MUST do this to ensure that the screen is updated when only drawing movable objects // This tells the system where to 'undraw' the object from StoreLastScreenPositionAndUpdateRect(); }
void EngineRunningBase::DrawLensflare() { // Lensflare: draw if the sparkling sun is on screen. if (!m_pLevel->IsCurrentRoomIndoors() && GetEngine()->GetDayNightSky()->IsSparkleVisible()) { // Make a bounding sphere around the sun coords. Vec3f sunPos = GetEngine()->GetDayNightSky()->GetSunPosition(); BoundingSphere sunBs(sunPos, 50.0f); // sun's "radius" // Find out if the sun intersects the view frustum if (Frustum::Instance()->Contains(sunBs)) { PCamera pCam = GetCamera(); Assert(pCam.GetPtr()); Vec3f eyePos(pCam->GetOrientation()->GetX(), pCam->GetOrientation()->GetY(), pCam->GetOrientation()->GetZ()); // We have to draw the lens flare, unless the sun is obscured by part of // the scene. // Test the line from camera to sun for obstructions. //Mgc::Segment3 seg; //seg.Origin() = Mgc::Vector3(eyePos.x, eyePos.y, eyePos.z); //seg.Direction() = Mgc::Vector3( // sunPos.x - eyePos.x, // sunPos.y - eyePos.y, // sunPos.z - eyePos.z); // Do intersection test on the scenery for the current room. if (m_pLevel->GetScene()->LineIntersects(eyePos, sunPos, 1.0f /* some radius */ )) { return; // Sun is obscured. } // We should draw the lens flare. Get the Camera eye position and // "look at" position (some point along the line we are pointing at). GetEngine()->PushColour(1.0f, 1.0f, 1.0f, 1.0f); //GetEngine()->GetLensflare()->Draw( // GetEngine()->GetDayNightSky()->GetSunPosition(), // eyePos, // pCam->GetLookAtPos() ); GetEngine()->PopColour(); } } }
// Called frequently, this should move the item // In this case we also accept cursor key presses to change the speed // Space will set the speed to zero void DoUpdate( int iCurrentTime ) { // Change speed if player presses a key if ( GetEngine()->IsKeyPressed( SDLK_UP ) ) m_dSY -= 0.001; if ( GetEngine()->IsKeyPressed( SDLK_DOWN ) ) m_dSY += 0.001; if ( GetEngine()->IsKeyPressed( SDLK_LEFT ) ) m_dSX -= 0.001; if ( GetEngine()->IsKeyPressed( SDLK_RIGHT ) ) m_dSX += 0.001; if ( GetEngine()->IsKeyPressed( SDLK_SPACE ) ) m_dSX = m_dSY = 0; // Alter position for speed m_dX += m_dSX; m_dY += m_dSY; // Check for bounce off the edge if ( (m_dX+m_iStartDrawPosX) < 0 ) { m_dX = - m_iStartDrawPosX; if ( m_dSX < 0 ) m_dSX = -m_dSX; } if ( (m_dX+m_iStartDrawPosX+m_iDrawWidth) > (GetEngine()->GetScreenWidth()-1) ) { m_dX = GetEngine()->GetScreenWidth() -1 - m_iStartDrawPosX - m_iDrawWidth; if ( m_dSX > 0 ) m_dSX = -m_dSX; } if ( (m_dY+m_iStartDrawPosY) < 0 ) { m_dY = -m_iStartDrawPosY; if ( m_dSY < 0 ) m_dSY = -m_dSY; } if ( (m_dY+m_iStartDrawPosY+m_iDrawHeight) > (GetEngine()->GetScreenHeight()-1) ) { m_dY = GetEngine()->GetScreenHeight() -1 - m_iStartDrawPosY - m_iDrawHeight; if ( m_dSY > 0 ) m_dSY = -m_dSY; } // Set current position - you NEED to set the current positions m_iCurrentScreenX = (int)(m_dX+0.5); m_iCurrentScreenY = (int)(m_dY+0.5); printf("Position %f, %f\n", m_dX, m_dY ); // Ensure that the object gets redrawn on the display, if something changed RedrawObjects(); }
void CMessageBoxScene::Enter() { mpJoy=GetEngine()->FindComponent<CJoystickComponent>(); mPopup=true; mTransOnTime=mTransOffTime=0.2f; mpTexture=LoadSpriteTex(GetDevice(),mBgName.c_str()); }
int Ardb::FlushScripts() { KeyObject start(Slice(), SCRIPT, ARDB_GLOBAL_DB); Iterator* iter = FindValue(start, false); BatchWriteGuard guard(GetEngine()); while (NULL != iter && iter->Valid()) { Slice tmpkey = iter->Key(); KeyObject* kk = decode_key(tmpkey, NULL); if (NULL != kk) { if (kk->type == SCRIPT) { DelValue(*kk); } else { break; } } DELETE(kk); iter->Next(); } DELETE(iter); return 0; }
void LocationDlg::OnReset( wxCommandEvent &event ) { vtAnimPathEngine *engine = GetEngine(m_iAnim); engine->Reset(); if (m_bActive) engine->UpdateTargets(); }
void LocationDlg::RefreshAnimsText() { wxTreeItemIdValue cookie; wxTreeItemId id; uint i, num = m_pAnimPaths->size(); for (i = 0; i < num; i++) { vtAnimEntry &entry = m_pAnimPaths->at(i); vtAnimPath *anim = GetAnim(i); vtAnimPathEngine *eng = GetEngine(i); if (id.IsOk()) id = GetAnimTree()->GetNextChild(m_root, cookie); else id = GetAnimTree()->GetFirstChild(m_root, cookie); wxString str(entry.m_Name, wxConvUTF8); wxString str2; str2.Printf(_T(" (%.1f/%.1f, %d)"), eng->GetTime(), (float) anim->GetLastTime(), anim->NumPoints()); str += str2; GetAnimTree()->SetItemText(id, str); } }
CLREnvelopeEditorCtrl::CLREnvelopeEditorCtrl() { InitializeIIDs(&IID_DLREnvelopeEditor, &IID_DLREnvelopeEditorEvents); //control data m_lFirstKeyPosition=0; m_lLastKeyPosition=60; m_lMouseMode=0; m_fLowValue=0.0f; m_fHighValue=1.0f; m_lEnvelopeType=LR::SHAPE_TCB; m_bDirtyValues=m_bDirtyPositions=FALSE; m_lDragMode=0; m_bHasSelection=FALSE; m_lFirstSelectedPosition=0; m_lLastSelectedPosition=0; //does not really matter since OnDraw will update it before any mouse //events get to the control but ... m_RCCtrlArea.left=0; m_RCCtrlArea.right=1; m_RCCtrlArea.top=0; m_RCCtrlArea.bottom=1; m_bMouseOverKeyRange=FALSE; m_lKeyUnderMouse=-1; m_lDraggedKey=-1; m_lSelectedKey=-1; m_bIsDragging=FALSE; m_CurveColor=RGB(255,0,0); LR::Engine *pEngine=NULL; GetEngine(&pEngine); pEngine->createEnvelope(m_pEnvelope); pEngine->Release(); }
void ScriptController::onKeyRelease( const KeyEvent& event ) { if( !enabled || !state ) return; Engine* engine = GetEngine(); }
void ScriptController::createState() { Engine* engine = GetEngine(); ScriptManager* scripts = engine->getScriptManager(); state = scripts->createScriptInstance(script.Resolve()); }
LONG CSkinItemEdit::GetBorderHelper(LONG clrNormal, LONG clrHover, LONG clrFocus, LONG clrReadOnly, LONG clrDisabled) { LONG color = 0; if (IsReadOnly() && m_bReadOnlyBorder) { color = clrReadOnly; } else if (IsFocused() && m_bFocusBorder) { color = clrFocus; } else if (IsHot()) { color = clrHover; } else { color = clrNormal; } if (GetDisabled()) color = clrDisabled; if (color == -1) color = clrNormal; if (color == -1) return -1; if (GetColorTransform()) { GetEngine()->TransformColor(color, color); } return color; }
void EngineRunningBase::SetPlayerRoom(int roomId) { // Reset orientation of moving Game Objects (NPCs) in the room the player // just entered: // Get the game objects which are in the same room as the player. int levelId = m_pLevel->GetId(); GameObjectMap& objs = GetEngine()->GetGameObjects(levelId, roomId); // This sets the level to point to the new room. Do this before telling // the game objects, so the new room is valid! m_pLevel->SetRoomId(roomId); for (GameObjectMap::iterator it = objs.begin(); it != objs.end(); ++it) { PPoolGameObject pGo = it->second; pGo->SetLevel(m_pLevel.GetPtr()); //GetEngine()->GetEngineState()->GetState(gameObjId, &s); //if (s != OUT_OF_PLAY) //{ pGo->OnRoomEntry(); //} } //GetCamera()->Reset(); }
void EngineRunningBase::DrawGameObjectShadows() { Assert(m_pLevel.GetPtr()); // Iterate over the game objects which are in the current level/room. int levelId = m_pLevel->GetId(); int roomId = m_pLevel->GetRoomId(); // Get the game objects which are in the same room as the player. GameObjectMap& objs = GetEngine()->GetGameObjects(levelId, roomId); // Iterate through map of Game Objects. Check each one in the Game State // to see if it has been collected/killed/whatever. for (GameObjectMap::iterator it = objs.begin(); it != objs.end(); ++it) { PPoolGameObject pGo = it->second; if (pGo->IsVisible()) { VisibleGameObject* pVgo = dynamic_cast<VisibleGameObject*>(pGo.GetPtr()); // Check state of object. State s = pVgo->GetState(); //Engine::Instance()->GetEngineState()->GetState(gameObjId, &s); // POOL: some pool-specific states here if (s != OUT_OF_PLAY && s != BALL_IN_POCKET && s != BALL_OUT_OF_BOUNDS) { pVgo->DrawShadow(); } } } }
void CreditScene::Enter() { std::cout << "HelpScene::enter\n"; mTransOnTime = 2; // slow fade in mTransOffTime = 0; // slow fade out // load the media mpFont = CreateD3DFont(GetDevice(), "Arial", 24, true); mpButtonTex[0] = LoadSpriteTex(GetDevice(), "../media/scene/Back1.png"); mpButtonTex[1] = LoadSpriteTex(GetDevice(), "../media/scene/Back2.png"); mpBG = LoadSpriteTex(GetDevice(), "../media/scene/Credits.png"); mpButtonB = LoadSpriteTex(GetDevice(), "../media/scene/ButtonB.png"); mpCreditSFX = GetEngine()->FindComponent<CSoundComponent>(); mpGamepad = GetEngine()->FindComponent<CGamepadComponent>(); }
Super::Super(BaseEngine* pEngine ) : PowerupProperties( pEngine ) { // Current and previous coordinates for the object - set them the same //initially m_iCurrentScreenX = m_iPreviousScreenX = (rand() % GetEngine()->GetScreenWidth()); m_iCurrentScreenY = m_iPreviousScreenY = (rand() % GetEngine()->GetScreenHeight()); // The object coordinate will be the top left of the object m_iStartDrawPosX = 0; m_iStartDrawPosY = 0; setPowerupType(SUPER); // And make it visible SetVisible(true); }
DGLE_DYNAMIC_FUNC #define APP_CAPTION "Asteroids Game" #ifdef _DEBUG # define DLL_PATH "..\\..\\..\\..\\bin\\windows\\DGLE.dll" #else # define DLL_PATH "..\\..\\DGLE.dll" #endif #define SCREEN_WIDTH 1024u #define SCREEN_HEIGHT 768u int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { IEngineCore *pEngineCore = NULL; if (GetEngine(DLL_PATH, pEngineCore)) { CGame game(pEngineCore); if (SUCCEEDED(pEngineCore->InitializeEngine(NULL, APP_CAPTION, TEngineWindow(SCREEN_WIDTH, SCREEN_HEIGHT, false, false, MM_4X)))) pEngineCore->StartEngine(); FreeEngine(); } else MessageBox(NULL,"Couldn't load \""DLL_PATH"\"!", APP_CAPTION, MB_OK | MB_ICONERROR | MB_SETFOREGROUND); return 0; }
void SetSearchDirection(V3 direction) { searchDirection = direction; if (Equals(searchDirection, V3(0.0f))) { LogError("GJK Set searchDirection to [0, 0, 0]"); GetEngine()->isPaused = true; } }
void SetSimplex(V3 p0, V3 p1) { simplex[0] = p0; simplex[1] = p1; simplexCount = 2; auto& vis = GetEngine()->physicsSimulation.collisionVisualization; vis.AddGJKStep(simplex, simplexCount); }
void Player::CheckKeys(int iCurrentTime) { // Get the amount of time since the last update int delta = iCurrentTime - _previousTime; // Detects if the space bar has been lifted bool spaceWasDown = _spaceIsDown; _spaceIsDown = GetEngine()->IsKeyPressed(SDLK_SPACE); if (spaceWasDown && _spaceIsDown == false) { // On space bar up, cylce colour of the player switch (_colour) { case 0xff0000: _colour = 0x00ff00; break; case 0x00ff00: _colour = 0x0000ff; break; case 0x0000ff: _colour = 0xff0000; break; } } }
int Ardb::ZClear(const DBID& db, const Slice& key) { KeyLockerGuard keyguard(m_key_locker, db, key); ZSetMetaValue meta; if (0 != GetZSetMetaValue(db, key, meta)) { return 0; } Slice empty; ZSetKeyObject sk(key, empty, meta.min_score, db); BatchWriteGuard guard(GetEngine()); struct ZClearWalk: public WalkHandler { Ardb* z_db; int OnKeyValue(KeyObject* k, ValueObject* value, uint32 cursor) { ZSetKeyObject* sek = (ZSetKeyObject*) k; ZSetScoreKeyObject tmp(sek->key, sek->value, sek->db); z_db->DelValue(*sek); z_db->DelValue(tmp); return 0; } ZClearWalk(Ardb* db) : z_db(db) { } } walk(this); Walk(sk, false, &walk); KeyObject k(key, ZSET_META, db); DelValue(k); return 0; }
static VALUE ossl_engine_get_name(VALUE self) { ENGINE *e; GetEngine(self, e); return rb_str_new2(ENGINE_get_name(e)); }
/** Handle the update action, moving the object and/or handling any game logic */ void BouncingBall1::DoUpdate( int iCurrentTime ) { // Work out current position m_oMovement.Calculate(iCurrentTime); m_iCurrentScreenX = m_oMovement.GetX(); m_iCurrentScreenY = m_oMovement.GetY(); // If movement has finished then request instructions if ( m_oMovement.HasMovementFinished( iCurrentTime ) ) { m_oMovement.Reverse(); m_oMovement.Calculate(iCurrentTime); m_iCurrentScreenX = m_oMovement.GetX(); m_iCurrentScreenY = m_oMovement.GetY(); } if ( m_pTileManager->IsValidTilePosition( m_iCurrentScreenX, m_iCurrentScreenY ) ) { int iTileX = m_pTileManager->GetTileXForPositionOnScreen(m_iCurrentScreenX); int iTileY = m_pTileManager->GetTileYForPositionOnScreen(m_iCurrentScreenY); int iCurrentTile = m_pTileManager->GetValue( iTileX, iTileY ); m_pTileManager->UpdateTile( GetEngine(), iTileX, iTileY, iCurrentTile+1 ); } // Ensure that the object gets redrawn on the display, if something changed RedrawObjects(); }
bool UAmethystGameInstance::LoadFrontEndMap(const FString& MapName) { bool bSuccess = true; // if already loaded, do nothing UWorld* const World = GetWorld(); if (World) { FString const CurrentMapName = *World->PersistentLevel->GetOutermost()->GetName(); //if (MapName.Find(TEXT("Highrise")) != -1) if (CurrentMapName == MapName) { return bSuccess; } } FString Error; EBrowseReturnVal::Type BrowseRet = EBrowseReturnVal::Failure; FURL URL( *FString::Printf(TEXT("%s"), *MapName) ); if (URL.Valid && !HasAnyFlags(RF_ClassDefaultObject)) //CastChecked<UEngine>() will fail if using Default__AmethystGameInstance, so make sure that we're not default { BrowseRet = GetEngine()->Browse(*WorldContext, URL, Error); // Handle failure. if (BrowseRet != EBrowseReturnVal::Success) { UE_LOG(LogLoad, Fatal, TEXT("%s"), *FString::Printf(TEXT("Failed to enter %s: %s. Please check the log for errors."), *MapName, *Error)); bSuccess = false; } } return bSuccess; }
int Ardb::ZAdd(const DBID& db, const Slice& key, DoubleArray& scores, const SliceArray& svs) { KeyLockerGuard keyguard(m_key_locker, db, key); ZSetMetaValue meta; GetZSetMetaValue(db, key, meta); BatchWriteGuard guard(GetEngine()); int count = 0; bool metachange = false; for (uint32 i = 0; i < scores.size(); i++) { int tryret = TryZAdd(db, key, meta, scores[i], svs[i]); if (tryret == 2) { count++; } if (!metachange && tryret > 0) { metachange = true; } } if (metachange) { SetZSetMetaValue(db, key, meta); } return count; }
static VALUE ossl_engine_get_id(VALUE self, SEL sel) { ENGINE *e; GetEngine(self, e); return rb_str_new2(ENGINE_get_id(e)); }
void FileSystemThread::process(void) { while (isRunning()) { GetEngine()->getInstance<FileSystem>()->update(); } }
void UGameInstance::StartGameInstance() { UEngine* const Engine = GetEngine(); // Create default URL. // @note: if we change how we determine the valid start up map update LaunchEngineLoop's GetStartupMap() FURL DefaultURL; DefaultURL.LoadURLConfig(TEXT("DefaultPlayer"), GGameIni); // Enter initial world. EBrowseReturnVal::Type BrowseRet = EBrowseReturnVal::Failure; FString Error; TCHAR Parm[4096] = TEXT(""); const TCHAR* Tmp = FCommandLine::Get(); #if UE_BUILD_SHIPPING // In shipping don't allow an override Tmp = TEXT(""); #endif // UE_BUILD_SHIPPING const UGameMapsSettings* GameMapsSettings = GetDefault<UGameMapsSettings>(); const FString& DefaultMap = GameMapsSettings->GetGameDefaultMap(); if (!FParse::Token(Tmp, Parm, ARRAY_COUNT(Parm), 0) || Parm[0] == '-') { FCString::Strcpy(Parm, *(DefaultMap + GameMapsSettings->LocalMapOptions)); } FURL URL(&DefaultURL, Parm, TRAVEL_Partial); if (URL.Valid) { BrowseRet = Engine->Browse(*WorldContext, URL, Error); } // If waiting for a network connection, go into the starting level. if (BrowseRet != EBrowseReturnVal::Success && FCString::Stricmp(Parm, *DefaultMap) != 0) { const FText Message = FText::Format(NSLOCTEXT("Engine", "MapNotFound", "The map specified on the commandline '{0}' could not be found. Would you like to load the default map instead?"), FText::FromString(URL.Map)); // the map specified on the command-line couldn't be loaded. ask the user if we should load the default map instead if (FCString::Stricmp(*URL.Map, *DefaultMap) != 0 && FMessageDialog::Open(EAppMsgType::OkCancel, Message) != EAppReturnType::Ok) { // user canceled (maybe a typo while attempting to run a commandlet) FPlatformMisc::RequestExit(false); return; } else { BrowseRet = Engine->Browse(*WorldContext, FURL(&DefaultURL, *(DefaultMap + GameMapsSettings->LocalMapOptions), TRAVEL_Partial), Error); } } // Handle failure. if (BrowseRet != EBrowseReturnVal::Success) { UE_LOG(LogLoad, Fatal, TEXT("%s"), *FString::Printf(TEXT("Failed to enter %s: %s. Please check the log for errors."), Parm, *Error)); } }
/** Handle the update action, moving the object and/or handling any game logic */ void BouncingBall2::DoUpdate( int iCurrentTime ) { if ( GetEngine()->IsKeyPressed( SDLK_UP ) ) m_dSY -= 0.01; if ( GetEngine()->IsKeyPressed( SDLK_DOWN ) ) m_dSY += 0.01; if ( GetEngine()->IsKeyPressed( SDLK_LEFT ) ) m_dSX -= 0.01; if ( GetEngine()->IsKeyPressed( SDLK_RIGHT ) ) m_dSX += 0.01; if ( GetEngine()->IsKeyPressed( SDLK_SPACE ) ) m_dSX = m_dSY = 0; m_dX += m_dSX; m_dY += m_dSY; if ( (m_dX+m_iStartDrawPosX) < 0 ) { m_dX = - m_iStartDrawPosX; if ( m_dSX < 0 ) m_dSX = -m_dSX; } if ( (m_dX+m_iStartDrawPosX+m_iDrawWidth) > (GetEngine()->GetScreenWidth()-1) ) { m_dX = GetEngine()->GetScreenWidth() -1 - m_iStartDrawPosX - m_iDrawWidth; if ( m_dSX > 0 ) m_dSX = -m_dSX; } if ( (m_dY+m_iStartDrawPosY) < 0 ) { m_dY = -m_iStartDrawPosY; if ( m_dSY < 0 ) m_dSY = -m_dSY; } if ( (m_dY+m_iStartDrawPosY+m_iDrawHeight) > (GetEngine()->GetScreenHeight()-1) ) { m_dY = GetEngine()->GetScreenHeight() -1 - m_iStartDrawPosY - m_iDrawHeight; if ( m_dSY > 0 ) m_dSY = -m_dSY; } // Work out current position m_iCurrentScreenX = (int)(m_dX+0.5); m_iCurrentScreenY = (int)(m_dY+0.5); // Ensure that the object gets redrawn on the display, if something changed RedrawObjects(); }
float pVehicle::getRPM() { if (isValidEngine()) { return GetEngine()->GetRPM(); } return -1.0f; }
bool pVehicle::isStalled() { if (isValidEngine()) { return GetEngine()->IsStalled(); } return false; }