void promptSDcard(struct Env* p, alt_up_sd_card_dev* device_reference) { /* * Loading Screen if SD card is not presented */ int frame = 25; struct animation* b = initAnimation((int*)pacman01, 1); addImage(b, initAnimation((int*)pacman02, 0)); addImage(b, initAnimation((int*)pacman03, 0)); addImage(b, initAnimation((int*)pacman04, 0)); struct Object *face; face= initObject(80, 120, 10, b, NULL); addToEnv(p, face); alt_alarm_start (&alarm,alt_ticks_per_second(),my_alarm_callback,(void*)p); while(!loadSDCard(device_reference)) { displayString("Please insert the SD card to start", frame, 30); frame++; setXY(face, face->x+4, face->y); if(face->x >245) face->x = 0; if(frame > 61) frame = 0; usleep(300000); }alt_up_char_buffer_clear(char_buffer); killAnimation(b); removeFromEnv(p, face); alt_alarm_stop(&alarm); alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0); }
/* * An abstract function that allows to load all images with same prefix * index is the number of characters that are prefix */ struct animation* loadSDImageSeq(char* filename, int index, int size) { int i = 0, j = 0; swap = 0; char temp[30],buffer[30]; char buff[20]; char* prefix = (char*)malloc(sizeof(char)*(index+1)); prefix[index] = '\0'; int* ptr = NULL; strncpy(prefix, filename, index); struct animation* a = NULL; struct animation* b = NULL; while(i < size) { strcpy(temp, prefix); buffer[0] = 0; sprintf(buffer, "%d.BMP ", i); if(i < 10) { strncat(temp, buffer, 5); strcpy(buff, temp); for(j = 0; j < i%5; j++) { buff[index+5+j] = '.'; } buff[index+5+j] = ' ';buff[index+6+j] = ' ';buff[index+7+j] = ' ';buff[index+8+j] = ' ';buff[index+9+j] = '\0'; }else { strncat(temp, buffer, 6); strcpy(buff, temp); for(j = 0; j < i%5; j++) { buff[index+6+j] = '.'; } buff[index+6+j] = ' ';buff[index+6+j+1] = ' ';buff[index+6+j+2] = ' ';buff[index+9+j] = '\0'; } if(info.start == 1) { alt_up_char_buffer_string(char_buffer, buff, 48, 30); //show reading file name because we are in loading page } while(!loadSDImage(temp, &ptr)){ printf("Loading File Error: %s\n", temp); } if(i == 0) { a = initAnimation(ptr, 1); imageInDisk(a); } else { b = initAnimation(ptr, 0); imageInDisk(b); addImage(a, b); } i++; } free(prefix); prefix = NULL; return a; }
//----------------------------------------------------------------------------- //! コンストラクタ //----------------------------------------------------------------------------- EnemyLeader::EnemyLeader() : EnemyBase(Man::KEY_LEADER) { // 操作方法設定(今は仮で自分をリーダとしてる) //_key = new KeyAttacker(this, this); // 当たり判定初期化 _myCollision.setCollisionState(&_hitSphere, myName); _attackCollision.setCollisionState(&_attackSphere, myAttackName); // モデルサイズ変更 _modelScale = 1.5f; // モデル読み込み(リーダーは少し大きめにする) loadModel("../Model/Enemy/Attacker/Enemy.x", CHARA_SCALE * _modelScale); // キーの作成 createKey(this, this); // 防衛座標設定 // _deffencePos = IObjDataManager()->_deffencePos[0]; // 初期化 // Initialize(); // アニメーション初期化 initAnimation(); }
Heavy_Unit(b2Vec2 pos, int w, int h, bool dir, b2World* wrd, Renderer &r) { m_active = true; m_texture = loadTexture("Assets/heavy.png", r.getRender()); //Define a b2body b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody; bodyDef.position = b2Vec2(pos.x, pos.y); bodyDef.userData = this; //Ask the b2Worldto create our body m_box_body = wrd->CreateBody(&bodyDef); m_geometry = { (int)(m_box_body->GetPosition().x - (w / 2)), (int)(m_box_body->GetPosition().y - (h / 2)), w, h }; //Define the shape of the body b2PolygonShape shape; shape.SetAsBox(m_geometry.w * 0.5f, m_geometry.h * 0.5f); m_box_body->CreateFixture(&shape, 0.0f); m_box_body->GetFixtureList()->SetFriction(0.0f); m_box_body->GetFixtureList()->SetRestitution(0.0f); m_attack = 30; m_health = 20; m_speed = .1f; m_is_moving = false; m_is_fighting = false; m_direction = dir; initAnimation(); frame = 0; frameDelay = 50; IdleTimer = 50; returnIdle = 0; frameCountdown = 0; }
SmallDeviceView::SmallDeviceView(const QString &name, const QString &uid, DeviceType type, bool available, QWidget *parent) : AbstractDeviceView(name, uid, available, parent), ui(new Ui::SmallDeviceView), _horizontalSnap(false), _verticalSnap(false), _wasClosed(false), _type(type) { ui->setupUi(this); setWindowFlags(Qt::Window | Qt::FramelessWindowHint); setWindowOpacity(WIDGET_OPACITY); setAttribute(Qt::WA_TranslucentBackground); loadStyle(QString::number(WIDGET_OPACITY * 255), SettingsManager::availableDeviceColor()); // Context menu setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onHistoryViewContextMenuRequested(const QPoint&))); setAvailable(available); setDeviceName(name); initAnimation(); updateWindowFlags(); createContextMenuActions(); }
void IOHandler::startLoadingAnimation(HWND window) { RECT rect; GetWindowRect(window, &rect); if (GameValueProvider::get()->isFullScreen()) { rect.right = (int)GetSystemMetrics(SM_CXSCREEN); rect.bottom = (int)GetSystemMetrics(SM_CYSCREEN); } SetWindowPos(animWindow, NULL, rect.left, rect.top, rect.right, rect.bottom, SWP_NOREDRAW | SWP_SHOWWINDOW | SWP_NOACTIVATE ); //set animWindow to Foreground (to paint over other windows which were activated while playing the game) SendMessageTimeout(animWindow, WM_LOADINGSCREEN, 0, 0, SMTO_NORMAL, 3000, NULL); //set this window to foreground again setWindowToForeground(window); SetWindowLong(window, GWL_EXSTYLE, GetWindowLong(window, GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(window, RGB(0, 0, 0), (255 * 2) / 100, LWA_ALPHA); initAnimation(animWindow); ShowCursor(false); }
void IconStorage::insertAutoIcon(QObject *AObject, const QString &AKey, int AIndex, int AAnimate, const QString &AProperty) { IconStorage *oldStorage = FObjectStorage.value(AObject); if (oldStorage!=NULL && oldStorage!=this) oldStorage->removeAutoIcon(AObject); if (AObject!=NULL && !AKey.isEmpty()) { IconUpdateParams *params; if (oldStorage!=this) { params = new IconUpdateParams; FObjectStorage.insert(AObject,this); FUpdateParams.insert(AObject,params); } else { params = FUpdateParams.value(AObject); } params->key = AKey; params->index = AIndex; params->prop = AProperty; params->animate = AAnimate; initAnimation(AObject,params); updateObject(AObject); connect(AObject,SIGNAL(destroyed(QObject *)),SLOT(onObjectDestroyed(QObject *))); } else if (AObject!=NULL) { removeAutoIcon(AObject); } }
bool HeroFrog::init(){ if (Sprite::init()) { this->initWithSpriteFrameName("hero_static_0.png"); initAnimation(); initData(); return true; } return false; }
void Game::replay(){ //Mostrar filme do jogo this->x = points[ind_plays].x; this->y = points[ind_plays].y; this->letter = points[ind_plays].letter; this->number = points[ind_plays].number; animation = true; initAnimation(); stop_x = this->gameboard->cell_size *(this->x + 0.5); stop_z = this->gameboard->cell_size *(this->y + 0.5); }
void Game::processAnswer(char* ans){ int i=3; if((strncmp(ans, "ok", 2) == 0) && (strncmp(ans, "no", 2) != 0)) //Resposta recebida com sucesso { int tabSize = 0; //Ler tabuleiro while(true){ if(ans[i] == ']' && tabSize < this->gameboard->size) tabSize++; else if(ans[i] == ']' && tabSize >= this->gameboard->size){ this->tabProlog[i-3] = ans[i]; i++; break; } this->tabProlog[i-3] = ans[i]; i++; } this->tabProlog[i-3] = '\0'; //Ler coordenada x i++; this->x = (int)ans[i] - '0'; //Ler coordenada y i=i+2; this->y = (int)ans[i] - '0'; //Guardar no vector de pontos Point point; point.x = this->x; point.y = this->y; i=i+3; letter = ans[i]; i=i+3; number = (int)ans[i] - '0'; point.letter = letter; point.number = number; points.push_back(point); char* buf = (char*)malloc(sizeof(char)*256); strcpy(buf, this->tabProlog); this->gameboardsProlog.push(buf);//adicionar à pilha de tabuleiros Prolog animation = true; initAnimation(); stop_x = this->gameboard->cell_size *(this->x + 0.5); stop_z = this->gameboard->cell_size *(this->y + 0.5); } }
bool Hero::init() { if (!Role::initWithSpriteFrameName("stand.png")) return false; if (!initAnimation()) return false; global->hero = this; setHalfBodyWidth(getContentSize().width / 4); setHP(100); setAP(5); setRunSpeed(10); setWalkSpeed(5); return true; }
Enemy::Enemy() { mAttackPoint = 0; mHealthPoint = 0; mRunSpeed = 0; mState = E_NONE; mDirState = RIGHT; mHitBox.actual = CCRectZero; mHitBox.original = CCRectZero; mAttackBox.actual = CCRectZero; mAttackBox.original = CCRectZero; init(); initAnimation(); }
//----------------------------------------------------------------------------- //! コンストラクタ //----------------------------------------------------------------------------- AllyHealer::AllyHealer() : AllyBase (Man::KEY_HEALLER) , _SeverityMax ( 10 ) , _isHeal (false) { // 当たり判定初期化 _myCollision.setCollisionState(&_hitSphere, myName); _attackCollision.setCollisionState(&_attackSphere, myAttackName); // モデル読み込み loadModel("../Model/Ally/Healer/Ally_high.x", CHARA_SCALE); // 初期化 // Initialize(); // アニメーション初期化 initAnimation(); }
bool AirPlane::init() { if (!GoodNPC::init() || !initWithSpriteFrameName("pet2_0.png")) { return false; } setRotation(90); setWalkSpeed(1); setRunSpeed(2); setAttackRate(2); setHalfBodyWidth(getContentSize().width / 2); setHP(50.0f); setAP(5.0f); setAttackRect(Rect(0, 0, 150, getContentSize().height)); initAnimation(); return true; }
ResourceEntity::ResourceEntity(int x, int y, int cur_amount, SModel* model, Ogre::SceneManager* sceneMgr, int total_amount) { static int i = 0; int cur; type = ET_RESOURCE; m_total_amount = total_amount; m_current_amount = cur_amount; for (vector<SMesh*>::iterator it = model->meshes.begin(); it != model->meshes.end(); it++) { cur = i++; SMesh* mesh = (*it); entity = sceneMgr->createEntity(Ogre::String("resourceEntity") + Ogre::StringConverter::toString(cur), mesh->name); node = sceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String("resourceNode") + Ogre::StringConverter::toString(cur), Ogre::Vector3(x, 0, y)); node->attachObject(entity); } initAnimation("shrink"); updateAmount(cur_amount); }
// on "init" you need to initialize your instance bool GameScene::init() { if ( !Layer::init() ) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); auto bg = Sprite::create("GameBackground.png"); bg->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); this->addChild(bg, -1); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("GameSceneSprite.plist","GameSceneSprite.png"); playerSprite = Sprite::createWithSpriteFrameName("planeBlue1.png"); playerSprite->setPosition(Point(visibleSize.width * 0.2 + origin.x, visibleSize.height/2 + origin.y)); this->addChild(playerSprite); // Test function initAction(); initAnimation(); return true; }
Player::Player(thor::ResourceHolder<sf::Texture, std::string>& holder, thor::ActionMap<std::string>& actionMap, thor::ActionMap<std::string>::CallbackSystem& callbackSystem, sf::Vector2f initPos) : sprite(holder["tilemap"]) { // create the animation frames and put it into animator initAnimation(); setPosition(initPos); // set the initial player state to StandingState state = new StandingState(0, -1); state->enter(*this); // set action maps actionMap["up"] = thor::Action(sf::Keyboard::Up) || thor::Action(sf::Keyboard::W); actionMap["down"] = thor::Action(sf::Keyboard::Up) || thor::Action(sf::Keyboard::W); actionMap["left"] = thor::Action(sf::Keyboard::Up) || thor::Action(sf::Keyboard::W); actionMap["right"] = thor::Action(sf::Keyboard::Up) || thor::Action(sf::Keyboard::W); actionMap["stop"] = !(actionMap["up"] || actionMap["down"] || actionMap["left"] || actionMap["right"]); /* actionMap["up"] = thor::Action(sf::Keyboard::Up, thor::Action::PressOnce) || thor::Action(sf::Keyboard::W, thor::Action::PressOnce); actionMap["down"] = thor::Action(sf::Keyboard::Down, thor::Action::PressOnce) || thor::Action(sf::Keyboard::S, thor::Action::PressOnce); actionMap["left"] = thor::Action(sf::Keyboard::Left, thor::Action::PressOnce) || thor::Action(sf::Keyboard::A, thor::Action::PressOnce); actionMap["right"] = thor::Action(sf::Keyboard::Right, thor::Action::PressOnce) || thor::Action(sf::Keyboard::D, thor::Action::PressOnce); actionMap["up_r"] = thor::Action(sf::Keyboard::Up, thor::Action::ReleaseOnce) || thor::Action(sf::Keyboard::W, thor::Action::ReleaseOnce); actionMap["down_r"] = thor::Action(sf::Keyboard::Down, thor::Action::ReleaseOnce) || thor::Action(sf::Keyboard::S, thor::Action::ReleaseOnce); actionMap["left_r"] = thor::Action(sf::Keyboard::Left, thor::Action::ReleaseOnce) || thor::Action(sf::Keyboard::A, thor::Action::ReleaseOnce); actionMap["right_r"] = thor::Action(sf::Keyboard::Right, thor::Action::ReleaseOnce) || thor::Action(sf::Keyboard::D, thor::Action::ReleaseOnce); actionMap["quit"] = thor::Action(sf::Event::Closed) || thor::Action(sf::Keyboard::Escape, thor::Action::PressOnce); */ callbackSystem.connect("up", [this](thor::ActionContext<std::string> context) { // if currently not RunningState then set to RunningState(0,-1) // if is RunningState ... // if not RunningState(0,-1) then change to RunningState(0,-1) }); callbackSystem.connect("down", [this](thor::ActionContext<std::string> context) { }); callbackSystem.connect("left", [this](thor::ActionContext<std::string> context) { }); callbackSystem.connect("right", [this](thor::ActionContext<std::string> context) { }); callbackSystem.connect("stop", [this](thor::ActionContext<std::string> context) { delete state; // not the best solution here... later we have to check if state is in AliveState // if state is in RunningState... state = new StandingState(static_cast<AliveState*>(state)->xDir, static_cast<AliveState*>(state)->yDir); state->enter(*this); }); // bind actions to state transitions /* callbackSystem.connect("up", [this](thor::ActionContext<std::string> context) { delete state; state = new RunningState(0, -1); state->enter(*this); }); callbackSystem.connect("down", [this](thor::ActionContext<std::string> context) { delete state; state = new RunningState(0, 1); state->enter(*this); }); callbackSystem.connect("left", [this](thor::ActionContext<std::string> context) { delete state; state = new RunningState(-1, 0); state->enter(*this); }); callbackSystem.connect("right", [this](thor::ActionContext<std::string> context) { delete state; state = new RunningState(1, 0); state->enter(*this); }); callbackSystem.connect("up_r", [this](thor::ActionContext<std::string> context) { delete state; state = new StandingState(0, -1); state->enter(*this); }); callbackSystem.connect("down_r", [this](thor::ActionContext<std::string> context) { delete state; state = new StandingState(0, 1); state->enter(*this); }); callbackSystem.connect("left_r", [this](thor::ActionContext<std::string> context) { delete state; state = new StandingState(-1, 0); state->enter(*this); }); callbackSystem.connect("right_r", [this](thor::ActionContext<std::string> context) { delete state; state = new StandingState(1, 0); state->enter(*this); }); */ }
void CGameMain::init() { LuaMgr::Instance().Init(); LuaMgr::Instance().Test(); _gui.Init(); m_pTest = CreateSprite(/*ST_3D*/ ST_MX); m_SpriteWhiteCube = CreateSprite(/*ST_3D*/ ST_MX); m_SpriteWhiteCube->LoadAImage("", g_pDevice); m_SpriteWhiteCube->setTexture(NULL); m_SpriteWhiteCube->SetColor(0xffffffff); m_SpriteWhiteCube->setWidth(36); m_SpriteWhiteCube->setHeight(36); m_SpriteWhiteCube->SetX(40); for (int i = 0; i < TEST_SIZE; ++i) { m_sp[i] = CreateSprite(ST_MX); } srand(time(NULL)); //设置种子 //m_test.Clip(); //// 加载一些纹理.. CTextureMgr& T = CTextureMgr::instance(); T.addTexture("MyRes/empty.png", "empty"); T.addTexture("MyRes/0016.tga", "m1"); T.addTexture("MyRes/0017.tga", "m2"); T.addTexture("MyRes/0018.tga", "m3"); T.addTexture("MyRes/0019.tga", "m4"); T.addTexture("MyRes/0020.tga", "m5"); T.addTexture("MyRes/0021.tga", "m6"); T.addTexture("MyRes/0022.tga", "m7"); T.addTexture("MyRes/0023.tga", "m8"); T.addTexture("MyRes/SpinningPeas.png", "greenHead"); //绿头 T.addTexture("MyRes/hammerMan.jpg", "hammerMan"); //锤男 //锤男 单个的 T.addTexture("MyRes/Riven_Splash_0.jpg", "Riven"); //瑞雯 T.addTexture("MyRes/moxia.jpg", "moxia"); //魔侠 T.addTexture("MyRes/0020关闭1.tga", "close1");//关闭按钮 T.addTexture("MyRes/0021关闭2.tga", "close2"); T.addTexture("MyRes/0022关闭3.tga", "close3"); T.addTexture("MyRes/0023关闭4.tga", "close4"); T.addTexture("MyRes/提示框底子.tga", "dlg"); //对话框底子 T.addTexture("MyRes/0113包裹标题.tga", "lable1"); T.addTexture("MyRes/+1.tga", "+1"); T.addTexture("MyRes/+2.tga", "+2"); T.addTexture("MyRes/+3.tga", "+3"); T.addTexture("MyRes/+4.tga", "+4"); T.addTexture("MyRes/-1.tga", "-1"); T.addTexture("MyRes/-2.tga", "-2"); T.addTexture("MyRes/-3.tga", "-3"); T.addTexture("MyRes/-4.tga", "-4"); T.addTexture("MyRes/0605大血条底.tga", "pB"); T.addTexture("MyRes/0607大血条绿.tga", "pF"); T.addTexture("MyRes/cube.tga", "cube"); T.addTexture("MyRes/cubeBlend.tga", "cubeBlend"); T.addTexture("MyRes/font_kai.bmp", "font_kai"); // 楷体字体 T.addTexture("MyRes/scroll_btn_down1.tga", "scroll_btn_down1");// 滚动条 T.addTexture("MyRes/scroll_btn_down2.tga", "scroll_btn_down2"); T.addTexture("MyRes/scroll_btn_down3.tga", "scroll_btn_down3"); T.addTexture("MyRes/scroll_btn_down4.tga", "scroll_btn_down4"); T.addTexture("MyRes/scroll_btn_up1.tga", "scroll_btn_up1"); T.addTexture("MyRes/scroll_btn_up2.tga", "scroll_btn_up2"); T.addTexture("MyRes/scroll_btn_up3.tga", "scroll_btn_up3"); T.addTexture("MyRes/scroll_btn_up4.tga", "scroll_btn_up4"); T.addTexture("MyRes/scroll_btn_mid1.tga", "scroll_btn_mid1"); T.addTexture("MyRes/scroll_btn_mid2.tga", "scroll_btn_mid2"); T.addTexture("MyRes/scroll_btn_mid3.tga", "scroll_btn_mid3"); T.addTexture("MyRes/scroll_btn_mid4.tga", "scroll_btn_mid4"); T.addTexture("MyRes/slide_btn.tga", "slide_btn"); T.addTexture("MyRes/slide_bar.tga", "slide_bar"); T.addTexture("MyRes/slide_background.tga", "slide_background"); T.addTexture("MyRes/gui_edit3.tga", "gui_edit3"); //ctrl edit m_SpriteWhiteCube->setTexture(T.getTexture("greenHead")); // 加载纹理 end m_pTest->LoadAImage("", g_pDevice); m_pTest->setTexture(T.getTexture( "moxia"/*"Riven"*/)); m_pTest->setWidth(1024); m_pTest->setHeight(768); //画正到屏幕 m_pTest->setVisible(false); // // m_test.SetX(100.f); // // m_test.SetY(200.f); // m_pTest->setStretchX(0.8f); // m_pTest->setStretchY(0.8f); //m_pTest->setTextureU1(0.5f); // 动画 initAnimation(); const int perLine = 30; //每行画几个 for (int i = 0; i < TEST_SIZE; ++i) { //m_sp[i]->LoadImage("MyRes/SpinningPeas.png", g_pDevice); m_sp[i]->LoadAImage("", g_pDevice); //先这样。。 if(/*true*/ rand()%2) { m_sp[i]->setTexture(T.getTexture("greenHead")); m_sp[i]->setWidth(37); m_sp[i]->setHeight(37); } else { m_sp[i]->setTexture(T.getTexture("m8" /*"hammerMan"*/)); m_sp[i]->setWidth(384/* 90*/); m_sp[i]->setHeight(384/*115*/); } m_sp[i]->SetX(i%perLine * 40); m_sp[i]->SetY(i/perLine * 20); //m_sp[i]->Clip();//做裁剪 } //// load gui config CRegisterGui one; //CGuiLayoutFileMgr::Instance().LoadAllLayoutFile(); // m_pDlgTest = new CTestLogicDlg(&_gui);/*cGuiControl*/; m_pDlgTest->SetOffSet(250,250); //m_pDlgTest->SetPos(50, 50); // 如果是子控件的话,这个位置就需要加上父控件的偏移 m_pDlgTest->SetWidth(328); m_pDlgTest->SetHeight(232); m_pDlgTest->SetTexture("dlg"); m_pDlgTest->Show(true); m_pCtrlTest = new cGuiButton(m_pDlgTest); m_pCtrlTest->SetOffSet(300, 10); m_pCtrlTest->SetWidth(27); m_pCtrlTest->SetHeight(27); m_pCtrlTest->SetID(110); m_pCtrlTest->SetBtnStateImage(cGuiButton::kBS_Normal, "close1"); m_pCtrlTest->SetBtnStateImage(cGuiButton::kBS_MouseOn, "close2"); m_pCtrlTest->SetBtnStateImage(cGuiButton::kBS_Clicked, "close3"); m_pCtrlTest->SetBtnStateImage(cGuiButton::kBS_Disable, "close4"); m_pCtrlTest->Show(); cGuiProgress* pPro = new cGuiProgress(m_pDlgTest); pPro->SetOffSet(0, 0); pPro->SetWidth(140); pPro->SetHeight(9); pPro->SetBackImage("pB"); pPro->SetBarImage("pF"); pPro->SetProgress(40); pPro->SetID(11000001); cGuiButton *pBtnTemp = new cGuiButton(m_pDlgTest); pBtnTemp->SetWidth(18); pBtnTemp->SetHeight(18); pBtnTemp->SetTexture("+1"); pBtnTemp->SetBtnStateImage(cGuiButton::kBS_Normal, "+1"); pBtnTemp->SetBtnStateImage(cGuiButton::kBS_MouseOn, "+2"); pBtnTemp->SetBtnStateImage(cGuiButton::kBS_Clicked, "+3"); pBtnTemp->SetBtnStateImage(cGuiButton::kBS_Disable, "+4"); pBtnTemp->SetPressedMouseMoveFun([](cGuiButton* pBtn, const int& x, const int &y){ // printf("he (%d, %d)\n", x, y); // CGameMain::Instance().SetPos(x, y); }); pBtnTemp->Show(); //pBtnTemp->SetDrag(true); pBtnTemp->SetOffSet(100, 90); pBtnTemp->SetID(111); cGuiControl *pC = new cGuiLable(m_pDlgTest); pC->SetWidth(55); pC->SetHeight(24); pC->Show(); pC->SetTexture("lable1"); //pC->SetPos(185, 65); pC->SetOffSet(135, 15); FRECT fr; fr.left = 0.0f; fr.top = 0.0f; fr.right = 0.8f; fr.bottom = 1.0f; //pC->SetClip(fr);//裁剪test 【Bug】 (不应该拿固定位置来裁剪, 应该要拿百分比) cGuiText *pLable = new cGuiText(m_pDlgTest); pLable->SetText("test"); //文字 pLable->SetOffSet(0, 200); cGuiScroll *pScroll = new cGuiScroll(m_pDlgTest); //滚动条 pScroll->SetScrollType(cGuiScroll::kST_Up_Down); pScroll->SetWidth(100); pScroll->SetHeight(112); pScroll->SetOffSet(0, 80); cGuiSlide *pSlide = new cGuiSlide(m_pDlgTest); //滑块 pSlide->SetOffSet(215, 100); cGuiList *pListGui = new cGuiList(m_pDlgTest); //列表 pListGui->SetWidth(75); pListGui->SetHeight(100); stCustomCtrlPack pack; cGuiLable *pLableList1 = new cGuiLable(pListGui); pLableList1->SetTexture("close1"); //如果有通过纹理得到宽高的接口~ pLableList1->SetWidth(27); pLableList1->SetHeight(27); pack.listCtrl.push_back(pLableList1); pListGui->AddAListCtrl(pack); pack.listCtrl.clear(); cGuiLable *pLableList2 = new cGuiLable(pListGui); pLableList2->SetTexture("close2"); pLableList2->SetWidth(27); pLableList2->SetHeight(27); pack.listCtrl.push_back(pLableList2); pListGui->AddAListCtrl(pack); cGuiEdit *pEdit = new cGuiEdit(m_pDlgTest); // 编辑框 pEdit->SetID(108); pEdit->SetTexture("gui_edit3"); pEdit->SetWidth(90); pEdit->SetHeight(22); pEdit->SetOffSet(150,40); pBtnTemp->SetClickFun([pEdit](cGuiButton*){ CWinClipBoard::Instance().Copy(pEdit->GetText()); }); m_pDlgTest->AddControl(m_pCtrlTest); //关闭按钮 m_pDlgTest->AddControl(pPro); m_pDlgTest->AddControl(pBtnTemp); m_pDlgTest->AddControl(pC); m_pDlgTest->AddControl(pLable); m_pDlgTest->AddControl(pScroll); m_pDlgTest->AddControl(pSlide); m_pDlgTest->AddControl(pListGui); m_pDlgTest->AddControl(pEdit); // 对话框2 // m_pCtrlDlg2 = new cGuiForm; // m_pCtrlDlg2->SetOffSet(50, 50); // m_pCtrlDlg2->SetWidth(328); // m_pCtrlDlg2->SetHeight(232); // m_pCtrlDlg2->SetTexture("dlg"); // m_pCtrlDlg2->Show(true); //m_pCtrlDlg2->SetDrag(false); //设置不可拖动 _gui.AddCtrl(m_pDlgTest); //对话框加入管理器 //_gui.AddCtrl(m_pCtrlDlg2); ((CTestLogicDlg*)m_pDlgTest)->Init(); ////test _pTWorld = new /*Tetris::*/TetrisWorldView; _pTWorld->setCubeImage("cube"); //todo: 设置view需要的一些纹理 _pTWorld->setWCubeImage("cubeBlend"); _pTWorld->setCubeSize(36); //要根据纹理的宽高!! _pTWorld->SetWorldSize(10, 20); //几行几列 //_pTWorld->setViewRect(0, 0, 36) _pTWorld->init(); //_pTWorld->Start(); //开始逻辑 (开放注释即可) ////// test UIEditor UIEditor::CUIEditorHelper uiHelper; uiHelper.GenFormatFile(m_pDlgTest); const char *p = typeid(m_pDlgTest).name(); cGuiControl * pTP = uiHelper.GenFormFromFile(); if (pTP) { pTP->SetTexture("dlg"); pTP->Show(); _gui.AddCtrl(pTP); } }
/* * Main Game Loop */ int main() { // Use the name of your pixel buffer DMA core pixel_buffer =alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer_dma_0"); initVGA(); usleep(5000000); ps2 = alt_up_ps2_open_dev("/dev/ps2_0"); ps2->timeout = 2000000; alt_up_ps2_clear_fifo(ps2); alt_up_ps2_init(ps2); unsigned char byte1; while(alt_up_ps2_read_data_byte(ps2, &byte1)!=0); char_lcd_dev = alt_up_character_lcd_open_dev ("/dev/character_lcd_0"); alt_up_character_lcd_init (char_lcd_dev); char_buffer = alt_up_char_buffer_open_dev("/dev/char_drawer"); alt_up_char_buffer_init(char_buffer); alt_up_sd_card_dev *device_reference = NULL; struct Env* p = initEnv(); initGameInfo(); struct Collidable* collisionChecker = initCollidable(); addCollisionToEnv(p, collisionChecker); promptSDcard(p, device_reference); usleep(1000); alt_up_char_buffer_string(char_buffer, "Loading ", 40, 30); unsigned end_time, start_time; int count = 0; lock = 0; struct animation* starAnimation = loadSDImageSeq("ST0.BMP", 2, 8); struct animation* star2Animation = loadSDImageSeq("ST00.BMP", 3, 7); struct animation* alien0 = loadSDImageSeq("A100.BMP", 2, 2); //2 images where first 2 characters are prefix struct animation* alien1 = loadSDImageSeq("A000.BMP", 2, 15); struct animation* ship0 = loadSDImageSeq("S00.BMP", 2, 16); struct animation* ship1 = loadSDImageSeq("S10.BMP", 2, 27); struct animation* bossAnimate = loadSDImageSeq("BO00.BMP", 2, 28); struct animation* ship2 = loadSDImageSeq("S20.BMP", 2, 35); struct animation* ship3 = loadSDImageSeq("S30.BMP", 2, 30); struct animation* ship4 = loadSDImageSeq("S40.BMP", 2, 10); struct animation* explode1 = initAnimation((int*)explode01, 1); addImage(explode1, initAnimation((int*)explode02, 0)); addImage(explode1, initAnimation((int*)explode03, 0)); addImage(explode1, initAnimation((int*)explode04, 0)); addImage(explode1, initAnimation((int*)explode05, 0)); struct animation** shipAnimationCollection = (struct animation**)malloc(sizeof(struct animation*)*5); shipAnimationCollection[0] = ship0; shipAnimationCollection[1] = ship1; shipAnimationCollection[2] = ship2; shipAnimationCollection[3] = ship3; shipAnimationCollection[4] = ship4; initWeapon(collisionChecker, p); struct Cursor* mouse = initCursor(p, collisionChecker); addToEnv(p, mouse->super); addObjToCollide(collisionChecker, mouse->super); setCursor(p, mouse); struct KeyController* keyController = initKeyController(); struct SwitchController* switchController = initSwitchController(); struct CursorController* ctrl = initCursorController(mouse->super, switchController, keyController); alt_up_char_buffer_string(char_buffer, "Loading Sounds ", 30, 30); audioController = initAudioController(); loadSound( audioController, LOOP_ONE ); loadSound( audioController, LASER_SOUND ); alt_irq_register(AUDIO_IRQ, audioController, (void*) audio_ISR); alt_irq_enable(AUDIO_IRQ); play_background_loop( audioController, LOOP_ONE ); enableAudioController( audioController ); printhex(info.score); mainMenu(mouse, ctrl, p); disableAudioController(audioController); stop_background_loop(audioController); unloadSoundById(audioController, LASER_SOUND); unloadSoundById(audioController, LOOP_ONE); alt_up_char_buffer_string(char_buffer, "Loading Sounds ", 30, 30); //loadSound(audioController, WIN_SOUND); //loadSound(audioController, LOSE_SOUND); loadSound( audioController, TOWER_UPGRADE_SOUND ); loadSound( audioController, LOOP_TWO ); play_background_loop(audioController, LOOP_TWO); enableAudioController( audioController ); alt_up_char_buffer_clear(char_buffer); //usleep(1000); struct Alien* testAlienCollection[60]; gameSetup(p, shipAnimationCollection, mouse, starAnimation, star2Animation); usleep(500000); //time delay for panel to be drawn // char LPS[50]; float lps_; int n = 0; for(n = 0; n < 20; n++) { testAlienCollection[n] =initAlien(n, 10*n, 10, alien0, explode1, "IdontKnow", 1.4, 150, 500, collisionChecker); addToEnvNR(p, testAlienCollection[n]->super); } for(n = 0; n < 20; n++) { testAlienCollection[n+20] =initAlien(10*n, n, 10, alien1, explode1, "whatName", 1.4, 190, 850, collisionChecker); addToEnvNR(p, testAlienCollection[n+20]->super); } for(n = 0; n < 20; n++) { testAlienCollection[n+40] =initAlien(10*n, n, 20, bossAnimate, explode1, "IamBoss", 1.6, 800, 1500, collisionChecker); testAlienCollection[n+40]->score = 300; addToEnvNR(p, testAlienCollection[n+40]->super); } int stage = 0; /* * Game Starts!!!!!! */ alt_alarm_start (&alarm,alt_ticks_per_second(),my_alarm_callback,(void*)p); int startTimer = 0; char second_row1[15]; alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1); sprintf(second_row1, "wave# %d ", stage); alt_up_character_lcd_string(char_lcd_dev, second_row1); while(1) { alt_timestamp_start(); start_time = (unsigned)alt_timestamp(); /*-----------------------------------------------------------------------------------------------*/ checkCollision(collisionChecker); //a major function that check each collision happen between each object updateCursorController(ctrl, 1); count++; if (startTimer > count) info.startButton = false; else { if(stage == 7) info.isWin = true; else if(startTimer == count){ //play_background_loop(audioController, LOOP_TWO); enableAudioController( audioController ); } } if (info.startButton){ disableAudioController(audioController); //stop_background_loop(audioController); startTimer = count + 15000; checkStages(testAlienCollection, stage%7, collisionChecker); stage++; //if(stage > 6) stage = 0; info.startButton = false; alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1); sprintf(second_row1, "wave# %d ", stage); alt_up_character_lcd_string(char_lcd_dev, second_row1); } if(info.isEnd || info.isWin) { disableAudioController(audioController); stop_background_loop(audioController); endGame(testAlienCollection, collisionChecker, p, mouse, ctrl, keyController); } /*-----------------------------------------------------------------------------------------------*/ end_time = (unsigned)alt_timestamp(); lps_ = (float)alt_timestamp_freq()/(float)(end_time - start_time); sprintf(LPS, "The current LPS is %.2f", lps_); alt_up_char_buffer_string(char_buffer, LPS, 3, 2); } return 0; }
void demo(MGLDC *dc) { int numpages,aPage,vPage; int sizex,sizey,bits; rect_t fullView,oldView; pixel_format_t pf; palette_t pal[256]; MGLDC *memdc; /* The first way to do simple page flipping is using two display * pages for 'double' buffering. The MGL has functions to set the * system into double buffered modes and flip pages for you, so * this method is very easy. We use MGL_doubleBuffer() to change * to double buffered mode and MGL_swapBuffers() to change display * pages. */ if (!MGL_doubleBuffer(dc)) MGL_fatalError("Double buffereing not available!"); mainWindow(dc,"Page Flip Demo"); statusLine("Method 1: Double buffering with two pages"); MGL_swapBuffers(dc,true); /* Draw to the hidden page */ mainWindow(dc,"Page Flip Demo"); statusLine("Method 1: Double buffering with two pages"); initAnimation(); do { /* Clear the entire display device before drawing the next frame */ MGL_clearViewport(); /* Draw the clock at the current location and move it */ drawClock(); moveClock(); /* Swap the display buffers */ MGL_swapBuffers(dc,true); } while (!checkEvent()); waitEvent(); /* Return to single buffered mode */ MGL_singleBuffer(dc); /* The second way to use page flipping is with multiple display * pages (3+) to do multi-buffering. Because we are using multiple * display pages, we can turn off the wait for retrace flag when we * swap visual pages. In order for triple buffering to work properly, * we need to be doing a complete re-paint of the screen each frame * without doing a screen clear (otherwise you will see flicker). * Games like Quake and Duke3D repaint the entire frame from top to * bottom without any overdraw, which allows them to use triple * buffering techniques like this. We simulate this here by rendering * to a system buffer and blitting to the screen constantly to achieve * a similar effect for this sample program. * * Note that VBE/Core 3.0 and VBE/AF 2.0 include full support for * hardware triple buffering that can be used to eliminate this problem. * When these standards are ratified, the MGL will be updated to support * this and you will be able to do 'real' triple buffering without * any flicker on the screen. */ numpages = MGL_maxPage(dc)+1; if (numpages < 3) return; /* Get the display device size, color depth and pixel format so that we * can create a compatible memory device context. Note that we also * need to copy the palette from the display DC to the memory DC. */ sizex = MGL_sizex(dc); sizey = MGL_sizey(dc); bits = MGL_getBitsPerPixel(dc); MGL_getPixelFormat(dc,&pf); if ((memdc = MGL_createMemoryDC(sizex+1,sizey+1,bits,&pf)) == NULL) MGL_fatalError(MGL_errorMsg(MGL_result())); if (bits == 8) { MGL_getPalette(dc,pal,256,0); MGL_setPalette(memdc,pal,256,0); MGL_realizePalette(memdc,256,0,true); } MGL_makeCurrentDC(memdc); /* Make the fullViewport for the display DC the full screen, as the * above code has changed it to a smaller value. */ fullView.left = 0; fullView.top = 0; fullView.right = sizex+1; fullView.bottom = sizey+1; MGL_setViewportDC(dc,fullView); /* Draw the main window display on the memory buffer */ mainWindow(memdc,"Page Flip Demo"); statusLine("Method 2: Multi-buffering with 3+ pages"); initAnimation(); MGL_setActivePage(dc,aPage = 1); MGL_setVisualPage(dc,vPage = 0,false); MGL_getViewport(&oldView); do { /* Clear the fullViewport before drawing the next frame */ MGL_clearViewport(); /* Draw the clock at the current location and move it */ drawClock(); moveClock(); /* Copy the memory device to the display device */ MGL_setViewport(fullView); MGL_bitBlt(dc,memdc,fullView,0,0,MGL_REPLACE_MODE); MGL_setViewport(oldView); /* Swap the hardware display buffers */ aPage = (aPage+1) % numpages; vPage = (vPage+1) % numpages; MGL_setActivePage(dc,aPage); MGL_setVisualPage(dc,vPage,false); } while (!checkEvent()); waitEvent(); }
DebuggerMainWnd::DebuggerMainWnd() : KXmlGuiWindow(), m_debugger(0), #ifdef GDB_TRANSCRIPT m_transcriptFile(GDB_TRANSCRIPT), #endif m_outputTermCmdStr(defaultTermCmdStr), m_outputTermProc(new QProcess), m_ttyLevel(-1), /* no tty yet */ m_popForeground(false), m_backTimeout(1000), m_tabWidth(0), m_sourceFilter(defaultSourceFilter), m_headerFilter(defaultHeaderFilter), m_animation(0), m_statusActive(i18n("active")) { setDockNestingEnabled(true); m_filesWindow = new WinStack(this); setCentralWidget(m_filesWindow); QDockWidget* dw1 = createDockWidget("Stack", i18n("Stack")); m_btWindow = new QListWidget(dw1); dw1->setWidget(m_btWindow); QDockWidget* dw2 = createDockWidget("Locals", i18n("Locals")); m_localVariables = new ExprWnd(dw2, i18n("Variable")); dw2->setWidget(m_localVariables); QDockWidget* dw3 = createDockWidget("Watches", i18n("Watches")); m_watches = new WatchWindow(dw3); dw3->setWidget(m_watches); QDockWidget* dw4 = createDockWidget("Registers", i18n("Registers")); m_registers = new RegisterView(dw4); dw4->setWidget(m_registers); QDockWidget* dw5 = createDockWidget("Breakpoints", i18n("Breakpoints")); m_bpTable = new BreakpointTable(dw5); dw5->setWidget(m_bpTable); QDockWidget* dw6 = createDockWidget("Output", i18n("Output")); m_ttyWindow = new TTYWindow(dw6); dw6->setWidget(m_ttyWindow); QDockWidget* dw7 = createDockWidget("Threads", i18n("Threads")); m_threads = new ThreadList(dw7); dw7->setWidget(m_threads); QDockWidget* dw8 = createDockWidget("Memory", i18n("Memory")); m_memoryWindow = new MemoryWindow(dw8); dw8->setWidget(m_memoryWindow); m_debugger = new KDebugger(this, m_localVariables, m_watches->watchVariables(), m_btWindow); connect(m_debugger, SIGNAL(updateStatusMessage()), SLOT(slotNewStatusMsg())); connect(m_debugger, SIGNAL(updateUI()), SLOT(updateUI())); connect(m_debugger, SIGNAL(breakpointsChanged()), SLOT(updateLineItems())); connect(m_debugger, SIGNAL(debuggerStarting()), SLOT(slotDebuggerStarting())); m_bpTable->setDebugger(m_debugger); m_memoryWindow->setDebugger(m_debugger); setStandardToolBarMenuEnabled(true); initKAction(); initStatusBar(); connect(m_watches, SIGNAL(addWatch()), SLOT(slotAddWatch())); connect(m_watches, SIGNAL(deleteWatch()), m_debugger, SLOT(slotDeleteWatch())); connect(m_watches, SIGNAL(textDropped(const QString&)), SLOT(slotAddWatch(const QString&))); connect(&m_filesWindow->m_findDlg, SIGNAL(closed()), SLOT(updateUI())); connect(m_filesWindow, SIGNAL(newFileLoaded()), SLOT(slotNewFileLoaded())); connect(m_filesWindow, SIGNAL(toggleBreak(const QString&,int,const DbgAddr&,bool)), this, SLOT(slotToggleBreak(const QString&,int,const DbgAddr&,bool))); connect(m_filesWindow, SIGNAL(enadisBreak(const QString&,int,const DbgAddr&)), this, SLOT(slotEnaDisBreak(const QString&,int,const DbgAddr&))); connect(m_debugger, SIGNAL(activateFileLine(const QString&,int,const DbgAddr&)), m_filesWindow, SLOT(activate(const QString&,int,const DbgAddr&))); connect(m_debugger, SIGNAL(executableUpdated()), m_filesWindow, SLOT(reloadAllFiles())); connect(m_debugger, SIGNAL(updatePC(const QString&,int,const DbgAddr&,int)), m_filesWindow, SLOT(updatePC(const QString&,int,const DbgAddr&,int))); // value popup communication connect(m_filesWindow, SIGNAL(initiateValuePopup(const QString&)), m_debugger, SLOT(slotValuePopup(const QString&))); connect(m_debugger, SIGNAL(valuePopup(const QString&)), m_filesWindow, SLOT(slotShowValueTip(const QString&))); // disassembling connect(m_filesWindow, SIGNAL(disassemble(const QString&, int)), m_debugger, SLOT(slotDisassemble(const QString&, int))); connect(m_debugger, SIGNAL(disassembled(const QString&,int,const std::list<DisassembledCode>&)), m_filesWindow, SLOT(slotDisassembled(const QString&,int,const std::list<DisassembledCode>&))); connect(m_filesWindow, SIGNAL(moveProgramCounter(const QString&,int,const DbgAddr&)), m_debugger, SLOT(setProgramCounter(const QString&,int,const DbgAddr&))); // program stopped connect(m_debugger, SIGNAL(programStopped()), SLOT(slotProgramStopped())); connect(&m_backTimer, SIGNAL(timeout()), SLOT(slotBackTimer())); // tab width connect(this, SIGNAL(setTabWidth(int)), m_filesWindow, SIGNAL(setTabWidth(int))); // connect breakpoint table connect(m_bpTable, SIGNAL(activateFileLine(const QString&,int,const DbgAddr&)), m_filesWindow, SLOT(activate(const QString&,int,const DbgAddr&))); connect(m_debugger, SIGNAL(updateUI()), m_bpTable, SLOT(updateUI())); connect(m_debugger, SIGNAL(breakpointsChanged()), m_bpTable, SLOT(updateBreakList())); connect(m_debugger, SIGNAL(breakpointsChanged()), m_bpTable, SLOT(updateUI())); connect(m_debugger, SIGNAL(registersChanged(const std::list<RegisterInfo>&)), m_registers, SLOT(updateRegisters(const std::list<RegisterInfo>&))); connect(m_debugger, SIGNAL(memoryDumpChanged(const QString&, const std::list<MemoryDump>&)), m_memoryWindow, SLOT(slotNewMemoryDump(const QString&, const std::list<MemoryDump>&))); connect(m_debugger, SIGNAL(saveProgramSpecific(KConfigBase*)), m_memoryWindow, SLOT(saveProgramSpecific(KConfigBase*))); connect(m_debugger, SIGNAL(restoreProgramSpecific(KConfigBase*)), m_memoryWindow, SLOT(restoreProgramSpecific(KConfigBase*))); // thread window connect(m_debugger, SIGNAL(threadsChanged(const std::list<ThreadInfo>&)), m_threads, SLOT(updateThreads(const std::list<ThreadInfo>&))); connect(m_threads, SIGNAL(setThread(int)), m_debugger, SLOT(setThread(int))); // popup menu of the local variables window m_localVariables->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_localVariables, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotLocalsPopup(const QPoint&))); makeDefaultLayout(); setupGUI(KXmlGuiWindow::Default, "kdbgui.rc"); restoreSettings(KGlobal::config()); // The animation button is not part of the restored window state. // We must create it after the toolbar was loaded. initAnimation(); updateUI(); m_bpTable->updateUI(); }