void progressBar::setPosition(float x, float y) { _x = x; _y = y; _bgRc = RectMake(_x, _y, _bgRc.right - _bgRc.left, _bgRc.bottom - _bgRc.top); _fgRc = RectMake(_x, _y, _curGauge * _percent, _height); }
void progressBar::setBar(float x, float y, float width, float height) { _x = x; _y = y; _height = height; _percent = width / _maxGauge; _bgRc = RectMake(x, y, width, height); _fgRc = RectMake(x, y, width, height); }
HRESULT gameStudy::init() { gameNode::init(); _up = _down = true; _count = _warningPlayer = _warningEnemy = 0; _playerHp = _enemyHp = 350; _playerFt = _enemyFt = 0; _ptPlayer.x = WINSIZEX / 7; _ptPlayer.y = CENTERY; _ptEnemy.x = WINSIZEX / 7 * 6; _ptEnemy.y = RND->getFromIntTo(110, WINSIZEY - 80); _player = RectMakeCenter(_ptPlayer.x, _ptPlayer.y, 100, 100); _enemy = RectMakeCenter(_ptEnemy.x, _ptEnemy.y, 100, 100); _bgBar[0] = RectMake(10, 10, 350, 30); _bgBar[1] = RectMake(WINSIZEX - 360, 10, 350, 30); _bgBar[2] = RectMake(10, 50, 100, 10); _bgBar[3] = RectMake(WINSIZEX - 110, 50, 100, 10); _enemyHpX = WINSIZEX - 360; _enemyFtX = WINSIZEX - 10; _hpBar[0] = RectMake(10, 10, _playerHp, 30); //플레이어 _fatalBar[0] = RectMake(10, 50, _playerFt, 10); _hpBar[1] = RectMake(_enemyHpX, 10, _enemyHp, 30); //적 _fatalBar[1] = RectMake(_enemyFtX, 50, _enemyFt, 10); return S_OK; }
HRESULT cookStore::init(vector<item*> vItem) { _princess = SCENEMANAGER->getPrincessAddress(); setItem(vItem); _npc.img = IMAGEMANAGER->findImage("peopleFace"); _npc.frameX = 13, _npc.frameY = 0; setDialog("「어서와. 맛있는 요리를 먹고 가라고!」"); _dialogIdx = 0; _type = COOK_NONE; _dialogType = DIALOG_ING; _fin = false; for (int i = 0; i < 2; i++) { _chooseBox[i].rc = RectMake(610, 295 + i * 28, 120, 28); _chooseBox[i].isSelected = _chooseBox[i].isChoose = false; } _chooseBox[0].str = "물건을 산다"; _chooseBox[1].str = "가게를 나선다"; for (int i = 0; i < 3; i++) { _itemImg[i].img = new image; _itemImg[i].img->init("image/item/itemDialog(380x76,2x1).bmp", 380, 76, 2, 1, true, RGB(255, 0, 255)); _itemImg[i].data.rc = RectMake(20 + i * 190, 445, 190, 76); } for (int i = 0; i < 3; i++) { _vItem[i]->setXY(_itemImg[i].data.rc.left + 7, _itemImg[i].data.rc.top + 5); } _quitImg.data.rc = RectMake(600, 445, 120, 40); _quitImg.img = IMAGEMANAGER->findImage("storeQuit"); _selectItem = false; for (int i = 0; i < 3; i++) { _buyBox[i].rc = RectMake(610, 295 + i * 28, 150, 28); _buyBox[i].isSelected = _buyBox[i].isChoose = false; } _buyBox[0].str = "먹는다"; _buyBox[1].str = "그만 둔다"; _buyBox[2].str = "가게를 나선다"; return S_OK; }
HRESULT player1::init() { _x = 100; _y = 100; _isDead = false; _isDamaged = false; _currentHP = _maxHP = 8; _currentMP = _maxMP = 30; _skillUsed = false; _action = JUMP; _state = INAIR; _direction = RIGHT; _skill = NULL; _moveSpeed = SPEED; _gravity = GRAVITY; _jumpPower = 0; _ltBlock = false; _rtBlock = false; _playerRC = RectMake(_x - HIT_BOX_WIDTH / 2, _y - HIT_BOX_HEIGHT, HIT_BOX_WIDTH, HIT_BOX_HEIGHT); IMAGEMANAGER->addFrameImage("Idle", ".\\image\\shovelKnight\\shovelKnightIdle.bmp", 34, 62, 1, 2, true, RGB(255, 0, 255), true); IMAGEMANAGER->addFrameImage("Move", ".\\image\\shovelKnight\\shovelKnightRunning.bmp", 276, 66, 6, 2, true, RGB(255, 0, 255), true); IMAGEMANAGER->addFrameImage("Jump", ".\\image\\shovelKnight\\shovelKnightJump.bmp", 68, 68, 2, 2, true, RGB(255, 0, 255), true); IMAGEMANAGER->addFrameImage("Attack", ".\\image\\shovelKnight\\shovelKnightAttack.bmp", 264, 70, 4, 2, true, RGB(255, 0, 255), true); IMAGEMANAGER->addFrameImage("DownwardThrust", ".\\image\\shovelKnight\\shovelKnightDownAttack.bmp", 24, 70, 1, 2, true, RGB(255, 0, 255), true); IMAGEMANAGER->addFrameImage("Shine", ".\\image\\shovelKnight\\shovelKnightShine.bmp", 102, 62, 3, 2, true, RGB(255, 0, 255), true); IMAGEMANAGER->addFrameImage("Dead", ".\\image\\shovelKnight\\shovelKnightDead.bmp", 126, 68, 3, 2, true, RGB(255, 0, 255), true); IMAGEMANAGER->addFrameImage("Damaged", ".\\image\\shovelKnight\\shovelKnightDamaged.bmp", 40, 76, 1, 2, true, RGB(255, 0, 255), true); IMAGEMANAGER->addFrameImage("Hanging", ".\\image\\shovelKnight\\shovelKnightClimb.bmp", 48, 76, 2, 2, true, RGB(255, 0, 255), true); return S_OK; }
void dragon::attack() { _dist = abs(_x - _player->getX()); //공격 범위 밖이면 return if (_dist > _atkRange) return; //공격 중이거나 데미지 입는 중이면 return if (_state == ES_ATTACK || _state == ES_ATTACK2 || _state == ES_DEAD) return; if (_bubbles[2].getRender()) return; if (_dist < _atkRange && _dist > _atk2Range) { _state = ES_ATTACK; _curFrameX = 0; for (int i = 0; i < 3; ++i) { _bubbles[i].setRender(true, 0.2f * i); } } else if(_dist < _atk2Range) { _state = ES_ATTACK2; _curFrameX = 0; if (IntersectRect(&RectMake(0, 0, 0, 0), &_atk, &_player->getCollRect())) { _player->damage(1); _player->setBounce(true, 5.f); } } }
void WindowNode::OnPaint( PaintStruct* ps ) { render::RenderEngine* engine = render::RenderEngine::GetInstance(); render::Brush* brush = engine->GetBrushFactory()->GetBrush(RGB(0,255,0), render::Brush::StyleSolid); ps->SetBrush(brush); ps->SetStrokeWidth(10.0); ps->SetStrokeStyle(new render::StrokeStyle()); ps->DrawRect(RectMake(20, 20, 200, 80)); //ps->FillRect(RectMake(100, 100, 200, 50)); render::Font* font = render::RenderEngine::GetInstance()->GetFontFactory()->GetFont(L"Consolas", 16, render::Font::StyleRegular); ps->SetFont(font); ps->SetTextColor(RGB(200,200,0)); ps->DrawText(L"Hello World!", RectMake(100, 250, 200, 50), DT_LEFT); }
void boxboy::collision() { if (IntersectRect(&RectMake(0, 0, 0, 0), &_enemy.coll, &_objectMgr->getVObject()[_saveIdx]->getRect())) { if (_objectMgr->getVObject()[_saveIdx]->getState() != DAMAGE && _objectMgr->getVObject()[_saveIdx]->getState() != DEAD) _objectMgr->getVObject()[_saveIdx]->damage(20); } }
void progressBar::increaseBar(int gauge) { _curGauge += gauge; if (_curGauge > _maxGauge) _curGauge = _maxGauge; _fgRc = RectMake(_x, _y, _curGauge * _percent, _height); }
bool Sprite::initWithTexture(Texture2D *texture) { FKAssert(texture != nullptr, "Invalid texture for sprite"); Rect rect = RectMake(0,0,0,0); rect.size = texture->getContentSize(); return initWithTexture(texture, rect); }
void dragon::aware() { if (IntersectRect(&RectMake(0, 0, 0, 0), &_aware, &_player->getCollRect())) { _isAware = true; return; } _isAware = false; }
void inventoryScene::setItem() { _vInven = _princess->getVItem(); _vInvenImg.resize(_vInven.size()); for (int i = 0; i < _vInven.size(); i++) { _vInvenImg[i].img = new image; _vInvenImg[i].img->init("image/item/itemDialog(380x76,2x1).bmp", 380, 76, 2, 1, true, RGB(255, 0, 255)); if((i % 12) < 8) _vInvenImg[i].data.rc = RectMake(20 + (i % 4) * 190, 445 + (i / 4) * 76, 190, 76); else _vInvenImg[i].data.rc = RectMake(590, 369 - ((i % 8) - 8) * 76, 190, 76); } for (int i = 0; i < _vInven.size(); i++) { _vInven[i]->setXY(_vInvenImg[i].data.rc.left + 7, _vInvenImg[i].data.rc.top + 5); } }
HRESULT hospital::init() { _princess = SCENEMANAGER->getPrincessAddress(); _npc.img = IMAGEMANAGER->findImage("peopleFace"); _npc.frameX = 9, _npc.frameY = 1; _sickPer = _princess->getStatus().stress - _princess->getStatus().hp; //_sickPer = 30; if (_sickPer >= 10) _isSick = true; else _isSick = false; if (_isSick) setDialog("「어디어디,내가 진찰해보지」"); else setDialog("「여기는 병원이다. 아프면 오라구.」"); _dialogIdx = 0; _dialogType = DIALOG_ING; _type = HOSPITAL_NONE; _fin = false; for (int i = 0; i < 2; i++) { _chooseBox[i].rc = RectMake(610, 295 + i * 28, 120, 28); _chooseBox[i].isSelected = _chooseBox[i].isChoose = false; } _chooseBox[0].str = "예"; _chooseBox[1].str = "아니오"; _pStress.str = "스트레스", _pStress.data = _princess->getStatus().stress; _pStress.strRc = RectMake(510, 340, 80, 20); _pStress.dataRc = RectMake(590, 340, 30, 20); _pStress.progressBar = new progressBar; _pStress.progressBar->init(620, 340, 110, 20); _pStress.progressBar->setGauge(_pStress.data, 500); return S_OK; }
void dragon::collision() { if (_state == ES_DEAD) return; if (_player->getState() == PS_DIG) { if (IntersectRect(&RectMake(0, 0, 0, 0), &_coll, &_player->getAtkRect()) || IntersectRect(&RectMake(0, 0, 0, 0), &_coll2, &_player->getAtkRect())) { _life -= 1; if (_life <= 0) _life = 0; _state = ES_DEAD; _curFrameX = 0; } } else if (_player->getState() == PS_DIGDOWN) { if (IntersectRect(&RectMake(0, 0, 0, 0), &_coll, &_player->getCollRect()) || IntersectRect(&RectMake(0, 0, 0, 0), &_coll2, &_player->getCollRect())) { _player->setBounce(false, 10.f); _life -= 1; if (_life <= 0) _life = 0; _state = ES_DEAD; _curFrameX = 0; } } else if (_player->getState() == PS_DEAD) { _state = ES_IDLE; _curFrameX = 0; } }
void player1::update() { if (_pause == false) { if (_isDamaged == false) control(); physics(); pixelCollision(); control2(); attack(); invincibilityCount(); CAMERAMANAGER->setSingleFocus(_x, _y, WINSIZEX); } if (_currentHP <= 0 && _isDead == false) { _frameX = 0; _isDead = true; } if (_downwardThrust == true) _playerRC = RectMake(_x - HIT_BOX_WIDTH / 2, _y - HIT_BOX_HEIGHT, HIT_BOX_WIDTH, HIT_BOX_HEIGHT - 5); else _playerRC = RectMake(_x - HIT_BOX_WIDTH / 2, _y - HIT_BOX_HEIGHT, HIT_BOX_WIDTH, HIT_BOX_HEIGHT); if (KEYMANAGER->isOnceKeyDown('R')) { if (_isDead == true) SCENEMANAGER->changeScene("GameTitleScene"); } }
HRESULT cameraManager::init(float minX, float minY, float maxX, float maxY) { // 기본설정 setPivot(0.5f, 0.5f); RECT rt = RectMake(0, 0, WINSIZEX, WINSIZEY); setSize(static_cast<float>(rt.right), static_cast<float>(rt.bottom)); setPos(getHalfSize().width, getHalfSize().height); _minX = minX; _minY = minY; _maxX = maxX; _maxY = maxY; return S_OK; }
void spaceShip::collisionEnemy() { for (int i = 0; i < ENEMYMAX; ++i) { if (_enemy[i]->isDead()) continue; //죽은 적이라면 돌지 말자 //적이랑 충돌하면 죽는다 if (IntersectRect(&RectMake(0, 0, 0, 0), &_rcShip, &_enemy[i]->getEnemyRect())) { die(); break; } } }
void player1::attack() { if (_isDamaged == false && _isDead == false) { if (_action == JUMP && _downwardThrust == true) { _attackRC = RectMakeCenter(_x + (_direction * 2 - 1), _y, 8, 9); } else if (_action == ATTACK) { switch (_frameX) { case(0): _attackRC = RectMakeCenter(_x + (-9) * (_direction * 2 - 1), _y - 4, 10, 8); break; case(1): _attackRC = RectMakeCenter(_x + (-27) * (_direction * 2 - 1), _y - 11, 10, 8); break; case(2): _attackRC = RectMakeCenter(_x + (-16) * (_direction * 2 - 1), _y - 22, 10, 8); break; case(3): _attackRC = RectMakeCenter(_x + (13) * (_direction * 2 - 1), _y - 24, 10, 8); break; } } else { _attackRC = RectMake(0, 0, 0, 0); } } else { _attackRC = RectMake(0, 0, 0, 0); } }
HRESULT chest::init(OBJECTTYPE type, int x, int y) { _image = IMAGEMANAGER->findImage("chest"); image* mapImage = IMAGEMANAGER->findImage("chest_map"); int intervalY; intervalY = _image->getFrameHeight() - mapImage->getFrameHeight(); _type = type; _x = x; _y = y - intervalY; _rc = RectMake(_x, _y, _image->getFrameWidth(), _image->getFrameHeight()); return S_OK; }
HRESULT soldier::init(float x, float y) { unitManager::init(x,y); _image = IMAGEMANAGER->findImage("soldier"); _rc = RectMake(x, y, _image->getFrameWidth(), _image->getFrameHeight()); _currentTime = 0.0f; _currentFrame = 0; _bullet = new bullet; _bullet->init(1.0f,_rc.right,0); _life = 15; return S_OK; }
HRESULT playScene01::init(void) { gameNode::init(); //background 구조체 _background.img = IMAGEMANAGER->findImage("background01"); _background.rc = RectMake(0, 0, _background.img->getWidth(), _background.img->getHeight()); _background.show = false; _background.phase = PHASE_01; _background.broken = false; //캐릭터 동적할당 unitManager* unit = new char01; unit->init(2600, WINSIZEY / 2); _vUnit.push_back(unit); //? 처음 적 init부분 추가 unitManager* e01 = new enemy01; e01->init(2450, WINSIZEY / 2); _vUnit.push_back(e01); unitManager* e02 = new enemy01; e02->init(2600, WINSIZEY / 2 - 50); _vUnit.push_back(e02); unitManager* e03 = new enemy01; e03->init(2750, WINSIZEY / 2); _vUnit.push_back(e03); unitManager* e04 = new enemy01; e04->init(2600, WINSIZEY / 2 + 100); _vUnit.push_back(e04); unitManager* b = new boss; b->init(2900, WINSIZEY / 2); _vUnit.push_back(b); _unitNum = 0; _currentTime = 0.0f; _textState = 0; text = false; _remove = false; SOUNDMANAGER->play("intro", 1.0f); return S_OK; }
HRESULT progressBar::init(int x, int y, int width, int height) { _x = x; _y = y; _rcProgress = RectMake(x, y, width, height); _progressBarTop = IMAGEMANAGER->addImage("frontBar", "hpBarTop.bmp", x, y, width, height, true, RGB(255, 0, 255)); _progressBarBottom = IMAGEMANAGER->addImage("backBar", "hpBarBottom.bmp", x, y, width, height, true, RGB(255, 0, 255)); //설정된 가로크기로! _width = _progressBarTop->getWidth(); return S_OK; }
HRESULT inventoryScene::init() { _princess = SCENEMANAGER->getPrincessAddress(); setItem(); for (int i = 0; i < 2; i++) { _chooseBox[i].img = new image; _chooseBox[i].img->init("image/main/storeQuit(240x40,2x1).bmp", 240, 40, 2, 1, true, RGB(255, 0, 255)); _chooseBox[i].data.rc = RectMake(10, 260 + i * 50, 120, 40); _chooseBox[i].data.isSelected = _chooseBox[i].data.isChoose = false; } _chooseBox[0].data.str = "무기해제"; _chooseBox[1].data.str = "방어해제"; return S_OK; }
HRESULT block::init(OBJECTTYPE type, int x, int y) { if (type == BLOCK_SMALL) { _image = IMAGEMANAGER->findImage("smallBlock"); } else if (type == BLOCK_BIG) { _image = IMAGEMANAGER->findImage("bigBlock"); } _type = type; _x = x; _y = y; _rc = RectMake(_x, _y, _image->getWidth(), _image->getHeight()); return S_OK; }
HRESULT marsPeople::init(float x, float y) { enemyManager::init(x,y); _image = IMAGEMANAGER->findImage("mars"); //_rc = RectMake(500, WINSIZEY / 2 + 50, _image->getFrameWidth(), _image->getFrameHeight()); _rc = RectMake(WINSIZEX+x, WINSIZEY / 2 + 50, _image->getFrameWidth(), _image->getFrameHeight()); _currentTime = 0.0f; _currentFrame = RND->getFromIntTo(0,_image->getMaxFrameX()); _move = true; _life = 3; _currentFireTime = 0.0f; _bullet = new bullet; _bullet->init(1.0f, _rc.left, PI); return S_OK; }
void spaceShip::attack() { for (int i = 0; i < MISSILEMAX; ++i) { if (!_missile->getMissileVec()[i].fire) continue; for (int j = 0; j < ENEMYMAX; ++j) { if (_enemy[j]->isDead()) continue; //죽은 적이라면 돌지 말자 //총이랑 충돌하면 총 지운다 if (IntersectRect(&RectMake(0, 0, 0, 0), &_missile->getMissileVec()[i].rc, &_enemy[j]->getEnemyRect())) { _missile->getMissileVec()[i].fire = false; //미사일의 상태를 미발사로 변경 _enemy[j]->die(); //적이 죽는다! break; } } } }
void gameStudy::update() { _count++; if (KEYMANAGER->isStayKeyDown(VK_UP)) { if(_up) _ptPlayer.y -= 5; } if (KEYMANAGER->isStayKeyDown(VK_DOWN)) { if (_down) _ptPlayer.y += 5; } if (KEYMANAGER->isOnceKeyDown(VK_SPACE)) { //총알 생성 _vBullet.push_back(RectMakeCenter(_ptPlayer.x + 60, _ptPlayer.y, 10, 10)); } //적이 공격하는 범위 if (_ptEnemy.y < _ptPlayer.y + 50 && _ptEnemy.y > _ptPlayer.y - 50) { //0.5초에 한번 총쏴라 if(_count % 10 == 0) _vEBullet.push_back(RectMakeCenter(_ptEnemy.x - 55, _ptEnemy.y, 10, 10)); } //이동 범위를 제한시키자 if (_player.top < 60) { _up = false; _down = true; } else if (_player.bottom > WINSIZEY - 30) { _down = false; _up = true; } else if (_player.top > 60 && _player.bottom < WINSIZEY - 30) { _up = true; _down = true; } if (_ptPlayer.y < _ptEnemy.y) //플레이어가 윗쪽에 있다면 { _ptEnemy.y -= 3; } else if (_ptPlayer.y > _ptEnemy.y) //플레이어가 아랫쪽에 있다면 { _ptEnemy.y += 3; } //플레이어 총알 for (_viBullet = _vBullet.begin(); _viBullet < _vBullet.end();) { _viBullet->left += 5; _viBullet->right += 5; //총알이 밖으로 화면 밖으로 나가면 if (_viBullet->left > WINSIZEX) { //총알을 지우자 _viBullet = _vBullet.erase(_viBullet); } //총알이 적에게 맞으면 else if (IntersectRect(&RectMake(0, 0, 0, 0), &(*_viBullet), &_enemy)) { //적의 HP를 깎자 _enemyHpX += 10; //바 시작 위치 변경 _enemyHp -= 10; //바 크기 변경 _viBullet = _vBullet.erase(_viBullet); _playerFt += 10; } else { _viBullet++; //왜 계속 여기서 걸리니? } } //적 총알 for (_viEBullet = _vEBullet.begin(); _viEBullet < _vEBullet.end();) { _viEBullet->left -= 5; _viEBullet->right -= 5; if (_viEBullet->right < 0) { _viEBullet = _vEBullet.erase(_viEBullet); } //총알이 플레이어에게 맞으면 else if (IntersectRect(&RectMake(0, 0, 0, 0), &(*_viEBullet), &_player)) { //플레이어의 HP를 깎자 _playerHp -= 10; _viEBullet = _vEBullet.erase(_viEBullet); _enemyFt += 25; //스킬 게이지 증가 _enemyFtX -= 25; } else { _viEBullet++; } } //플레이어의 레이저 게이지가 꽉 차면 if (_playerFt >= 100) { _playerFt = 0; //_laser[0] = RectMakeCenter(_ptPlayer.x, _ptPlayer.y, 500, 10); } //적의 레이저 게이지 꽉 차면 if (_enemyFt >= 100) { _enemyFt = 0; _enemyFtX = WINSIZEX - 10; } //플레이어 HP 상태 if (_playerHp < 350 * 0.5) _warningPlayer = 1; if(_playerHp < 350 * 0.1) _warningPlayer = 2; if (_playerHp <= 0) { release(); MessageBox(_hWnd, "Lose!!!", "Result", MB_OK); } //적 HP 상태 if (_enemyHp < 350 * 0.5) _warningEnemy = 1; if (_enemyHp < 350 * 0.1) _warningEnemy = 2; if (_enemyHp <= 0) { release(); MessageBox(_hWnd, "Won!!!", "Result", MB_OK); } //오브젝트 다시 그리자 _player = RectMakeCenter(_ptPlayer.x, _ptPlayer.y, 100, 100); _enemy = RectMakeCenter(_ptEnemy.x, _ptEnemy.y, 100, 100); _hpBar[0] = RectMake(10, 10, _playerHp, 30); _hpBar[1] = RectMake(_enemyHpX, 10, _enemyHp, 30); _fatalBar[0] = RectMake(10, 50, _playerFt, 10); _fatalBar[1] = RectMake(_enemyFtX, 50, _enemyFt, 10); gameNode::update(); }
void progressBar::decreaseBar(int gauge) { _curGauge -= gauge; _fgRc = RectMake(_x, _y, _curGauge * _percent, _height); }