Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize lookup/lookdown between resolutions #75

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rott/_rt_play.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "rt_fixed.h"

#define YZANGLELIMIT (30*FINEANGLES/360)
#define YZTILTSPEED 20
#define SNAPBACKSPEED 10
#define YZHORIZONSPEED 4
#define HORIZONYZOFFSET (FINEANGLES/4)

extern int YZANGLELIMIT;

#define SetPlayerHorizon(ps,hlevel) \
{ \
if ((hlevel)>YZANGLELIMIT) \
Expand Down
125 changes: 3 additions & 122 deletions rott/rt_playr.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ static const int SHROOMYZANGLE = (15*FINEANGLES/360);
static const int FALLINGYZANGLE = -(15*FINEANGLES/360);
static const int NORMALYZANGLE = 0;

int YZANGLELIMIT = (30*FINEANGLES/360);

/*
=============================================================================
Expand Down Expand Up @@ -236,7 +237,6 @@ void CheckWeaponChange (objtype * ob);
void PlayerMissileAttack(objtype* );
void Cmd_Use(objtype*);
//void ComError (char *error, ...);
int FinddTopYZANGLELIMITvalue(objtype *ob);

statetype s_free = {false,0,0,T_Free,0,&s_free};
statetype s_inelevator = {false,0,420,T_Player,0,&s_player};
Expand Down Expand Up @@ -3728,8 +3728,6 @@ void SetNormalHorizon (objtype * ob)
=
===================
*/
extern int iG_playerTilt;
extern double dTopYZANGLELIMIT;
void PlayerTiltHead (objtype * ob)
{
playertype * pstate;
Expand Down Expand Up @@ -3865,133 +3863,16 @@ void PlayerTiltHead (objtype * ob)
if ((abs(yzangle-pstate->horizon))<SNAPBACKSPEED)
yzangle=pstate->horizon;
}
//SetTextMode();

if (yzangle != 512){
FinddTopYZANGLELIMITvalue(ob);
}


yzangle+=dyz;
if (yzangle-HORIZONYZOFFSET>YZANGLELIMIT)
yzangle=HORIZONYZOFFSET+YZANGLELIMIT;
/* else if (yzangle-HORIZONYZOFFSET<-TopYZANGLELIMIT)//bnafix
yzangle=HORIZONYZOFFSET-TopYZANGLELIMIT;//bnafix
dTopYZANGLELIMIT*/
else if (yzangle-HORIZONYZOFFSET<-dTopYZANGLELIMIT)//bnafix
yzangle=HORIZONYZOFFSET-dTopYZANGLELIMIT;//bnafix
else if (yzangle-HORIZONYZOFFSET<-YZANGLELIMIT)
yzangle=HORIZONYZOFFSET-YZANGLELIMIT;
ob->yzangle=yzangle-HORIZONYZOFFSET;
Fix(ob->yzangle);

iG_playerTilt = ob->yzangle;

}

//----------------------------------------------------------------------
// bna added function
// if a player is to close to wall, looking down max
//,this func limit the dTopYZANGLELIMIT value when
// facing a wall
#define SMALLANGLE 90
//there is small angles where didnt work
//so we check for them to = 90/2048 = aprox, 15 degrees
int FinddTopYZANGLELIMITvalue(objtype *ob)
{/*


checkx = ob->tilex + 1;
checky = ob->tiley + 1;
if (actorat[checkx][checky]){
return 0;
}
return 1;

checkx = ob->tilex ;
checky = ob->tiley;

// find which direction the player is facing
//and check if it is a wall

*/

//use lowest down angle
dTopYZANGLELIMIT = (26*FINEANGLES/360);

if (ob->angle < 256 || ob->angle > 1792) {
if ((tilemap[ob->tilex + 1][ob->tiley])!=0){

return 0;
}
//ob->dir = east;
}else if (ob->angle < 768) {
if ((tilemap[ob->tilex][ob->tiley-1])!=0){
return 0;
}
}else if (ob->angle < 1280) {
if ((tilemap[ob->tilex-1][ob->tiley])!=0){
return 0;
}
}else{
if ((tilemap[ob->tilex][ob->tiley+1])!=0){
return 0;
}
}


//use middle down angle
dTopYZANGLELIMIT = (42*FINEANGLES/360);

if ((ob->angle > 768-SMALLANGLE)&&(ob->angle <= 768)) {
if ((tilemap[ob->tilex -1][ob->tiley])!=0){//ob->tiley-1
return 0;
}
}
if ((ob->angle < 1280+SMALLANGLE)&&(ob->angle >= 1280)) {
if ((tilemap[ob->tilex - 1][ob->tiley])!=0){//ob->tiley+1
return 0;
}
}
if ((ob->angle > 256)&&(ob->angle <= 256+SMALLANGLE)) {
if ((tilemap[ob->tilex + 1][ob->tiley])!=0){//ob->tiley-1
return 0;
}
}
if ((ob->angle < 1792)&&(ob->angle >= 1792-SMALLANGLE)) {
if ((tilemap[ob->tilex + 1][ob->tiley])!=0){//ob->tiley+1
return 0;
}
}
if ((ob->angle < 1280)&&(ob->angle >= 1280-SMALLANGLE)) {
if ((tilemap[ob->tilex ][ob->tiley+1])!=0){//ob->tilex-1
return 0;
}
}
if ((ob->angle > 1792)&&(ob->angle <= 1792+SMALLANGLE)) {
if ((tilemap[ob->tilex ][ob->tiley+1])!=0){//ob->tiley+1
return 0;
}
}
if ((ob->angle > 768)&&(ob->angle <= 768+SMALLANGLE)) {
if ((tilemap[ob->tilex][ob->tiley-1])!=0){//ob->tiley-1
return 0;
}
}
if ((ob->angle < 256)&&(ob->angle >= 256-SMALLANGLE)) {
if ((tilemap[ob->tilex][ob->tiley-1])!=0){//ob->tiley-1
return 0;
}
}

//use max down angle
dTopYZANGLELIMIT = (90*FINEANGLES/360);
return 1;
}
// bna added function end
//----------------------------------------------------------------------




/*
===================
=
Expand Down
7 changes: 3 additions & 4 deletions rott/winrott.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ int iGLOBAL_AMMO_Y;
int iGLOBAL_FOCALWIDTH;
double dGLOBAL_FPFOCALWIDTH;

double dTopYZANGLELIMIT;

int iG_X_center;
int iG_Y_center;

Expand All @@ -31,6 +29,7 @@ extern int viewwidth;

//----------------------------------------------------------------------
#define FINEANGLES 2048
extern int YZANGLELIMIT;
void SetRottScreenRes (int Width, int Height)
{

Expand All @@ -49,7 +48,7 @@ void SetRottScreenRes (int Width, int Height)
iGLOBAL_AMMO_X = 300;
iGLOBAL_AMMO_Y = 184;

dTopYZANGLELIMIT = (44*FINEANGLES/360);;
YZANGLELIMIT = (30*FINEANGLES/360);
}
if (iGLOBAL_SCREENWIDTH == 640) {
iGLOBAL_FOCALWIDTH = 180;
Expand All @@ -59,7 +58,7 @@ void SetRottScreenRes (int Width, int Height)
iGLOBAL_AMMO_X = 600;//300*2;
iGLOBAL_AMMO_Y = 464;//480-16;

dTopYZANGLELIMIT = (42*FINEANGLES/360);;
YZANGLELIMIT = (60*FINEANGLES/360);
}
}

Expand Down
Loading