shoot action in demo
This commit is contained in:
@@ -66,26 +66,31 @@ void GameState::update() {
|
||||
}
|
||||
|
||||
skybox->update(player->getPosition());
|
||||
auto cameraInfo = player->getCameraInfo();
|
||||
engine->renderer.beginFrame(cameraInfo);
|
||||
|
||||
dbgObj->setPosition(*cameraInfo.looksAt);
|
||||
|
||||
player->update(terrain->heightmap);
|
||||
enemyManager->update(terrain->heightmap, player->getPosition());
|
||||
|
||||
renderer.clear();
|
||||
{
|
||||
renderer.add(skybox->pair); // First, because of ALLPASS
|
||||
renderer.add(ship->pair);
|
||||
renderer.add(dbgObj->pair);
|
||||
|
||||
renderer.add(player->pair);
|
||||
renderer.add(enemyManager->getPairs());
|
||||
renderer.add(terrain->pair);
|
||||
auto shootAction = player->getShootAction();
|
||||
if (shootAction.isShooting) {
|
||||
shootAction.ray.value().print();
|
||||
}
|
||||
renderer.render();
|
||||
|
||||
auto cameraInfo = player->getCameraInfo();
|
||||
dbgObj->setPosition(*cameraInfo.looksAt);
|
||||
|
||||
engine->renderer.beginFrame(cameraInfo);
|
||||
{
|
||||
renderer.clear();
|
||||
{
|
||||
renderer.add(skybox->pair); // First, because of ALLPASS
|
||||
renderer.add(ship->pair);
|
||||
renderer.add(dbgObj->pair);
|
||||
|
||||
renderer.add(player->pair);
|
||||
renderer.add(enemyManager->getPairs());
|
||||
renderer.add(terrain->pair);
|
||||
}
|
||||
renderer.render();
|
||||
}
|
||||
engine->renderer.endFrame();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,11 @@ void Player::update(const Heightmap& heightmap) {
|
||||
|
||||
PlayerShootAction Player::getShootAction() const {
|
||||
PlayerShootAction action;
|
||||
action.isShooting = weapon.isShooting;
|
||||
|
||||
if (action.isShooting) {
|
||||
action.ray = Ray(camera.position, camera.lookAt);
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
@@ -77,10 +77,10 @@ u8 Weapon::getShootChannel() {
|
||||
}
|
||||
|
||||
void Weapon::update() {
|
||||
isShooting = false;
|
||||
|
||||
if (!isShootAnimation1 && !isShootAnimation2 && pad->getPressed().Cross) {
|
||||
shootTimer.prime();
|
||||
audio->adpcm.tryPlay(shootAdpcm, getShootChannel());
|
||||
isShootAnimation1 = true;
|
||||
shoot();
|
||||
}
|
||||
|
||||
auto* position = mesh->getPosition();
|
||||
@@ -105,14 +105,19 @@ void Weapon::update() {
|
||||
isShootAnimation2 = false;
|
||||
*position = initialPosition;
|
||||
if (pad->getPressed().Cross) {
|
||||
shootTimer.prime();
|
||||
audio->adpcm.tryPlay(shootAdpcm, getShootChannel());
|
||||
isShootAnimation1 = true;
|
||||
shoot();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Weapon::shoot() {
|
||||
isShooting = true;
|
||||
shootTimer.prime();
|
||||
audio->adpcm.tryPlay(shootAdpcm, getShootChannel());
|
||||
isShootAnimation1 = true;
|
||||
}
|
||||
|
||||
void Weapon::allocateOptions() {
|
||||
options = new StaPipOptions();
|
||||
options->textureMappingType = Tyra::TyraNearest;
|
||||
|
||||
Reference in New Issue
Block a user