⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cl_input.java

📁 Jake2是一个Java 3D游戏引擎.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		if ((in_strafe.state & 1) != 0) {			cmd.sidemove += Globals.cl_sidespeed.value * KeyState(in_right);			cmd.sidemove -= Globals.cl_sidespeed.value * KeyState(in_left);		}		cmd.sidemove += Globals.cl_sidespeed.value * KeyState(in_moveright);		cmd.sidemove -= Globals.cl_sidespeed.value * KeyState(in_moveleft);		cmd.upmove += Globals.cl_upspeed.value * KeyState(in_up);		cmd.upmove -= Globals.cl_upspeed.value * KeyState(in_down);		if ((in_klook.state & 1) == 0) {			cmd.forwardmove += Globals.cl_forwardspeed.value * KeyState(in_forward);			cmd.forwardmove -= Globals.cl_forwardspeed.value * KeyState(in_back);		}		//		//	   adjust for speed key / running		//		if (((in_speed.state & 1) ^ (int) (Globals.cl_run.value)) != 0) {			cmd.forwardmove *= 2;			cmd.sidemove *= 2;			cmd.upmove *= 2;		}	}	static void ClampPitch() {		float pitch;		pitch = Math3D.SHORT2ANGLE(Globals.cl.frame.playerstate.pmove.delta_angles[Defines.PITCH]);		if (pitch > 180)			pitch -= 360;		if (Globals.cl.viewangles[Defines.PITCH] + pitch < -360)			Globals.cl.viewangles[Defines.PITCH] += 360; // wrapped		if (Globals.cl.viewangles[Defines.PITCH] + pitch > 360)			Globals.cl.viewangles[Defines.PITCH] -= 360; // wrapped		if (Globals.cl.viewangles[Defines.PITCH] + pitch > 89)			Globals.cl.viewangles[Defines.PITCH] = 89 - pitch;		if (Globals.cl.viewangles[Defines.PITCH] + pitch < -89)			Globals.cl.viewangles[Defines.PITCH] = -89 - pitch;	}	/*	 * ============== CL_FinishMove ==============	 */	static void FinishMove(usercmd_t cmd) {		int ms;		int i;		//		//	   figure button bits		//			if ((in_attack.state & 3) != 0)			cmd.buttons |= Defines.BUTTON_ATTACK;		in_attack.state &= ~2;		if ((in_use.state & 3) != 0)			cmd.buttons |= Defines.BUTTON_USE;		in_use.state &= ~2;		if (Key.anykeydown != 0 && Globals.cls.key_dest == Defines.key_game)			cmd.buttons |= Defines.BUTTON_ANY;		// send milliseconds of time to apply the move		ms = (int) (Globals.cls.frametime * 1000);		if (ms > 250)			ms = 100; // time was unreasonable		cmd.msec = (byte) ms;		ClampPitch();		for (i = 0; i < 3; i++)			cmd.angles[i] = (short) Math3D.ANGLE2SHORT(Globals.cl.viewangles[i]);		cmd.impulse = (byte) in_impulse;		in_impulse = 0;		// send the ambient light level at the player's current position		cmd.lightlevel = (byte) Globals.cl_lightlevel.value;	}	/*	 * ================= CL_CreateCmd =================	 */	static void CreateCmd(usercmd_t cmd) {		//usercmd_t cmd = new usercmd_t();		frame_msec = Globals.sys_frame_time - old_sys_frame_time;		if (frame_msec < 1)			frame_msec = 1;		if (frame_msec > 200)			frame_msec = 200;		// get basic movement from keyboard		BaseMove(cmd);		// allow mice or other external controllers to add to the move		IN.Move(cmd);		FinishMove(cmd);		old_sys_frame_time = Globals.sys_frame_time;		//return cmd;	}	/*	 * ============ CL_InitInput ============	 */	static void InitInput() {		Cmd.AddCommand("centerview", new xcommand_t() {			public void execute() {				IN.CenterView();			}		});		Cmd.AddCommand("+moveup", new xcommand_t() {			public void execute() {				IN_UpDown();			}		});		Cmd.AddCommand("-moveup", new xcommand_t() {			public void execute() {				IN_UpUp();			}		});		Cmd.AddCommand("+movedown", new xcommand_t() {			public void execute() {				IN_DownDown();			}		});		Cmd.AddCommand("-movedown", new xcommand_t() {			public void execute() {				IN_DownUp();			}		});		Cmd.AddCommand("+left", new xcommand_t() {			public void execute() {				IN_LeftDown();			}		});		Cmd.AddCommand("-left", new xcommand_t() {			public void execute() {				IN_LeftUp();			}		});		Cmd.AddCommand("+right", new xcommand_t() {			public void execute() {				IN_RightDown();			}		});		Cmd.AddCommand("-right", new xcommand_t() {			public void execute() {				IN_RightUp();			}		});		Cmd.AddCommand("+forward", new xcommand_t() {			public void execute() {				IN_ForwardDown();			}		});		Cmd.AddCommand("-forward", new xcommand_t() {			public void execute() {				IN_ForwardUp();			}		});		Cmd.AddCommand("+back", new xcommand_t() {			public void execute() {				IN_BackDown();			}		});		Cmd.AddCommand("-back", new xcommand_t() {			public void execute() {				IN_BackUp();			}		});		Cmd.AddCommand("+lookup", new xcommand_t() {			public void execute() {				IN_LookupDown();			}		});		Cmd.AddCommand("-lookup", new xcommand_t() {			public void execute() {				IN_LookupUp();			}		});		Cmd.AddCommand("+lookdown", new xcommand_t() {			public void execute() {				IN_LookdownDown();			}		});		Cmd.AddCommand("-lookdown", new xcommand_t() {			public void execute() {				IN_LookdownUp();			}		});		Cmd.AddCommand("+strafe", new xcommand_t() {			public void execute() {				IN_StrafeDown();			}		});		Cmd.AddCommand("-strafe", new xcommand_t() {			public void execute() {				IN_StrafeUp();			}		});		Cmd.AddCommand("+moveleft", new xcommand_t() {			public void execute() {				IN_MoveleftDown();			}		});		Cmd.AddCommand("-moveleft", new xcommand_t() {			public void execute() {				IN_MoveleftUp();			}		});		Cmd.AddCommand("+moveright", new xcommand_t() {			public void execute() {				IN_MoverightDown();			}		});		Cmd.AddCommand("-moveright", new xcommand_t() {			public void execute() {				IN_MoverightUp();			}		});		Cmd.AddCommand("+speed", new xcommand_t() {			public void execute() {				IN_SpeedDown();			}		});		Cmd.AddCommand("-speed", new xcommand_t() {			public void execute() {				IN_SpeedUp();			}		});		Cmd.AddCommand("+attack", new xcommand_t() {			public void execute() {				IN_AttackDown();			}		});		Cmd.AddCommand("-attack", new xcommand_t() {			public void execute() {				IN_AttackUp();			}		});		Cmd.AddCommand("+use", new xcommand_t() {			public void execute() {				IN_UseDown();			}		});		Cmd.AddCommand("-use", new xcommand_t() {			public void execute() {				IN_UseUp();			}		});		Cmd.AddCommand("impulse", new xcommand_t() {			public void execute() {				IN_Impulse();			}		});		Cmd.AddCommand("+klook", new xcommand_t() {			public void execute() {				IN_KLookDown();			}		});		Cmd.AddCommand("-klook", new xcommand_t() {			public void execute() {				IN_KLookUp();			}		});		cl_nodelta = Cvar.Get("cl_nodelta", "0", 0);	}	private static final sizebuf_t buf = new sizebuf_t();	private static final byte[] data = new byte[128];	private static final usercmd_t nullcmd = new usercmd_t();	/*	 * ================= CL_SendCmd =================	 */	static void SendCmd() {		int i;		usercmd_t cmd, oldcmd;		int checksumIndex;		// build a command even if not connected		// save this command off for prediction		i = Globals.cls.netchan.outgoing_sequence & (Defines.CMD_BACKUP - 1);		cmd = Globals.cl.cmds[i];		Globals.cl.cmd_time[i] = (int) Globals.cls.realtime; // for netgraph															 // ping calculation		// fill the cmd		CreateCmd(cmd);		Globals.cl.cmd.set(cmd);		if (Globals.cls.state == Defines.ca_disconnected || Globals.cls.state == Defines.ca_connecting)			return;		if (Globals.cls.state == Defines.ca_connected) {			if (Globals.cls.netchan.message.cursize != 0 || Globals.curtime - Globals.cls.netchan.last_sent > 1000)				Netchan.Transmit(Globals.cls.netchan, 0, new byte[0]);			return;		}		// send a userinfo update if needed		if (Globals.userinfo_modified) {			CL.FixUpGender();			Globals.userinfo_modified = false;			MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_userinfo);			MSG.WriteString(Globals.cls.netchan.message, Cvar.Userinfo());		}		SZ.Init(buf, data, data.length);		if (cmd.buttons != 0 && Globals.cl.cinematictime > 0 && !Globals.cl.attractloop				&& Globals.cls.realtime - Globals.cl.cinematictime > 1000) { // skip																			 // the																			 // rest																			 // of																			 // the																			 // cinematic			SCR.FinishCinematic();		}		// begin a client move command		MSG.WriteByte(buf, Defines.clc_move);		// save the position for a checksum byte		checksumIndex = buf.cursize;		MSG.WriteByte(buf, 0);		// let the server know what the last frame we		// got was, so the next message can be delta compressed		if (cl_nodelta.value != 0.0f || !Globals.cl.frame.valid || Globals.cls.demowaiting)			MSG.WriteLong(buf, -1); // no compression		else			MSG.WriteLong(buf, Globals.cl.frame.serverframe);		// send this and the previous cmds in the message, so		// if the last packet was dropped, it can be recovered		i = (Globals.cls.netchan.outgoing_sequence - 2) & (Defines.CMD_BACKUP - 1);		cmd = Globals.cl.cmds[i];		//memset (nullcmd, 0, sizeof(nullcmd));		nullcmd.clear();		MSG.WriteDeltaUsercmd(buf, nullcmd, cmd);		oldcmd = cmd;		i = (Globals.cls.netchan.outgoing_sequence - 1) & (Defines.CMD_BACKUP - 1);		cmd = Globals.cl.cmds[i];		MSG.WriteDeltaUsercmd(buf, oldcmd, cmd);		oldcmd = cmd;		i = (Globals.cls.netchan.outgoing_sequence) & (Defines.CMD_BACKUP - 1);		cmd = Globals.cl.cmds[i];		MSG.WriteDeltaUsercmd(buf, oldcmd, cmd);		// calculate a checksum over the move commands		buf.data[checksumIndex] = Com.BlockSequenceCRCByte(buf.data, checksumIndex + 1, buf.cursize - checksumIndex - 1,				Globals.cls.netchan.outgoing_sequence);		//		// deliver the message		//		Netchan.Transmit(Globals.cls.netchan, buf.cursize, buf.data);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -