Game Development Reference
In-Depth Information
#import <GameKit/GameKit.h>
◦ Add two more NetworkPacketCode for players to move and a packet
code for when game finishes, for example, a packet for losing a game:
typedef enum {
KNetworkPacketCodePlayerAllotment,
KNetworkPacketCodePlayerMove,
KNetworkPacketCodePlayerLost,
} NetworkPacketCode;
◦ Declare a structure called TankInfo , which will be used as a data struc-
ture for sending the information on tanks; the same structure will be used
to sync at the remote player's receiving end.
typedef struct {
CGPoint tankPreviousPosition;
CGPoint tankPosition;
CGPoint tankDestination;
CGFloat tankRotation;
CGFloat tankDirection;
} TankInfo;
◦ For the movement of Tanks, add Speed and TurnSpeed constants
const float kTankSpeed = 1.0f;
const float kTankTurnSpeed = 0.1f;
◦ Change the text of the first and the second player's labels to blue and red
respectively
// Blue is the First and Red is the Second Player
#define kFirstPlayerLabelText @"You're Blue"
#define kSecondPlayerLabelText @"You're Red"
◦ Add text hash defines for when someone wins or loses.
#define kGameWonText @"You Won"
#define kGameLostText @"You Lost"
3. Add some properties to the private interface of GameScene , like a local data
structure of the tank to be maintained and updated, so that it can be sent to the re-
Search WWH ::




Custom Search