mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-10-20 10:37:37 -04:00
Merge pull request #258 from westonCoder/portalgun-firing-updates
Various Tweaks to Portal Gun Mechanics
This commit is contained in:
commit
1858d4f14a
|
@ -3,13 +3,11 @@
|
|||
|
||||
#include "../../build/src/audio/clips.h"
|
||||
|
||||
unsigned short soundsSkippable[10] = {
|
||||
unsigned short soundsSkippable[8] = {
|
||||
SOUNDS_PORTAL_ENTER1,
|
||||
SOUNDS_PORTAL_ENTER2,
|
||||
SOUNDS_PORTAL_EXIT1,
|
||||
SOUNDS_PORTAL_EXIT2,
|
||||
SOUNDS_PORTALGUN_SHOOT_RED1,
|
||||
SOUNDS_PORTALGUN_SHOOT_BLUE1,
|
||||
SOUNDS_CONCRETE1, //left foot
|
||||
SOUNDS_CONCRETE2, //right foot
|
||||
SOUNDS_CONCRETE3, //land
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __AUDIO_CLIPS_H__
|
||||
#define __AUDIO_CLIPS_H__
|
||||
|
||||
extern unsigned short soundsSkippable[10];
|
||||
extern unsigned short soundsSkippable[8];
|
||||
|
||||
extern unsigned short soundsPortalEnter[2];
|
||||
extern unsigned short soundsPortalExit[2];
|
||||
|
|
|
@ -136,7 +136,9 @@ void controllerActionRead() {
|
|||
if (sourceIndex == ControllerActionSourceCUpButton || sourceIndex == ControllerActionSourceDUpButton) {
|
||||
sourceIndex += 3;
|
||||
}
|
||||
} else if (controllerGetButtonDown(controllerIndex, gActionSourceButtonMask[sourceIndex])) {
|
||||
}else if (IS_HOLDABLE_ACTION(action) && controllerGetButton(controllerIndex, gActionSourceButtonMask[sourceIndex])){
|
||||
controllerActionApply(action);
|
||||
}else if (controllerGetButtonDown(controllerIndex, gActionSourceButtonMask[sourceIndex])) {
|
||||
controllerActionApply(action);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ enum ControllerAction {
|
|||
};
|
||||
|
||||
#define IS_DIRECTION_ACTION(action) ((action) >= ControllerActionMove && (action) <= ControllerActionRotate)
|
||||
#define IS_HOLDABLE_ACTION(action) ((action) >= ControllerActionOpenPortal0 && (action) <= ControllerActionOpenPortal1)
|
||||
#define IS_VALID_SOURCE(source) ((source) >= 0 && (source) < ControllerActionSourceCount)
|
||||
|
||||
#define MAX_DEADZONE 0.25f
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "../../build/assets/models/portal_gun/v_portalgun.h"
|
||||
#include "../../build/assets/materials/static.h"
|
||||
|
||||
#define PORTAL_GUN_RECOIL_TIME (0.18f)
|
||||
#define PORTAL_GUN_RECOIL_TIME (0.22f)
|
||||
|
||||
#define PORTAL_GUN_NEAR_PLANE 0.05f
|
||||
|
||||
|
@ -52,6 +52,7 @@ void portalGunInit(struct PortalGun* portalGun, struct Transform* at){
|
|||
portalGun->rigidBody.angularVelocity = gZeroVec;
|
||||
portalGun->portalGunVisible = 0;
|
||||
portalGun->shootAnimationTimer = 0.0;
|
||||
portalGun->shootTotalAnimationTimer = 0.0;
|
||||
|
||||
portalGunCalcTargetPosition(portalGun, at, &portalGun->rigidBody.transform.position, 0);
|
||||
|
||||
|
@ -180,6 +181,7 @@ void portalGunUpdate(struct PortalGun* portalGun, struct Player* player) {
|
|||
|
||||
if (player->flags & PlayerJustShotPortalGun && portalGun->shootAnimationTimer <= 0.0f) {
|
||||
portalGun->shootAnimationTimer = PORTAL_GUN_RECOIL_TIME;
|
||||
portalGun->shootTotalAnimationTimer = PORTAL_GUN_RECOIL_TIME * 2.0f;
|
||||
}
|
||||
|
||||
if (portalGun->shootAnimationTimer >= 0.0f) {
|
||||
|
@ -189,6 +191,12 @@ void portalGunUpdate(struct PortalGun* portalGun, struct Player* player) {
|
|||
player->flags &= ~PlayerJustShotPortalGun;
|
||||
}
|
||||
}
|
||||
if (portalGun->shootTotalAnimationTimer >= 0.0f) {
|
||||
portalGun->shootTotalAnimationTimer -= FIXED_DELTA_TIME;
|
||||
if (portalGun->shootTotalAnimationTimer <= 0.0f){
|
||||
portalGun->shootTotalAnimationTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
struct PortalGunProjectile* projectile = &portalGun->projectiles[i];
|
||||
|
@ -258,4 +266,10 @@ void portalGunFire(struct PortalGun* portalGun, int portalIndex, struct Ray* ray
|
|||
vector3Add(&projectile->effectOffset, &ray->origin, &fireFrom);
|
||||
|
||||
portalTrailPlay(&projectile->trail, &fireFrom, &hit.at);
|
||||
}
|
||||
int portalGunIsFiring(struct PortalGun* portalGun){
|
||||
if (portalGun->shootTotalAnimationTimer > 0.0f){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -31,6 +31,7 @@ struct PortalGun {
|
|||
struct RigidBody rigidBody;
|
||||
int portalGunVisible;
|
||||
float shootAnimationTimer;
|
||||
float shootTotalAnimationTimer;
|
||||
|
||||
struct PortalGunProjectile projectiles[2];
|
||||
};
|
||||
|
@ -41,5 +42,6 @@ void portalGunUpdate(struct PortalGun* portalGun, struct Player* player);
|
|||
void portalGunRenderReal(struct PortalGun* portalGun, struct RenderState* renderState, struct Camera* fromCamera);
|
||||
|
||||
void portalGunFire(struct PortalGun* portalGun, int portalIndex, struct Ray* ray, struct Vector3* playerUp, int roomIndex);
|
||||
int portalGunIsFiring(struct PortalGun* portalGun);
|
||||
|
||||
#endif
|
|
@ -347,14 +347,14 @@ void sceneCheckPortals(struct Scene* scene) {
|
|||
sceneFirePortal(scene, &scene->savedPortal.ray, &scene->savedPortal.transformUp, scene->savedPortal.portalIndex, scene->savedPortal.roomIndex, 0, 0);
|
||||
}
|
||||
|
||||
if (fireOrange && hasOrange && !playerIsGrabbing(&scene->player)) {
|
||||
if (fireOrange && !fireBlue && hasOrange && !playerIsGrabbing(&scene->player) && !portalGunIsFiring(&scene->portalGun)) {
|
||||
portalGunFire(&scene->portalGun, 0, &raycastRay, &playerUp, scene->player.body.currentRoom);
|
||||
scene->player.flags |= PlayerJustShotPortalGun;
|
||||
hudPortalFired(&scene->hud, 0);
|
||||
soundPlayerPlay(soundsPortalgunShoot[0], 1.0f, 1.0f, NULL, NULL);
|
||||
}
|
||||
|
||||
if ((fireBlue || (!hasOrange && fireOrange)) && hasBlue && !playerIsGrabbing(&scene->player)) {
|
||||
if ((fireBlue || (!hasOrange && fireOrange)) && !fireOrange && hasBlue && !playerIsGrabbing(&scene->player) &&!portalGunIsFiring(&scene->portalGun)) {
|
||||
portalGunFire(&scene->portalGun, 1, &raycastRay, &playerUp, scene->player.body.currentRoom);
|
||||
scene->player.flags |= PlayerJustShotPortalGun;
|
||||
hudPortalFired(&scene->hud, 1);
|
||||
|
|
Loading…
Reference in a new issue