CodeBase - Two-Way Network Transmission (TNT)

Return to the CodeBase listing

Category: Multiplayer

Version: 1.1

0
0

Information

Uploaded: 6th Apr 2005 21:21

Modified: 7th Apr 2005 09:41

Author:  Trek

Summary

How to transmit a variable telling another computer what arrowkeys your pressing and input a variable to see what arrowkeys their pressing.

Full Description

This is a code snippet I wrote for the most basic transmission needed for most 3D games. In almost any game, the programmer needs to somehow let the computer know what the gamer wants to do. This is usually done by checking the status of the upkey(), downkey(), rightkey(), and leftkey() variables. However, when you want to play two player you only have one set of arrow keys. An easy way to solve this is to make a network game where someone else can play from another computer. <br /> <br /> In this program, I demonstrate how two variables can be used to tell the corresponding computer what arrow keys are being pressed on the given system. If the variable is set to 0 nothing is being pressed. If the variable has a 1 in the tens place the upkey is being pressed and if it has a 2 in the tens place the downkey is being pressed. If a 1 is in the ones place a left arrow key is being pressed and if a 2 is in the ones place the right arrow key is being pressed. These can be combined to make various combinations such as the following:<br /> <br /> 12 = Up Arrow and Right Arrow keys are pressed<br /> <br /> 20 = Down arrow is being pressed<br /> <br /> 1 = Left arrow key is being pressed<br /> <br /> I am using this concept right now in a fully 3D networked game called Ice Hockey II which is due to be released later this summer. To see a sneak peak and screenshot of it, check out my software website at http://roborangers.home.comcast.net/Trek.html and head over to the blog section.

Comments

No comments yet.