Changeset b07eeac in network-game for common


Ignore:
Timestamp:
May 25, 2013, 1:45:54 AM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
2df63d6
Parents:
b81cea1
Message:

Players pick up flags when they get close to the flag objects, not the structres. When a flag is picked up, a REMOVE_OBJECT message is sent

Location:
common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • common/Common.cpp

    rb81cea1 rb07eeac  
    22
    33#include <iostream>
    4 using namespace std;
     4#include <cmath>
    55
    66#if defined WINDOWS
     
    99   #include <time.h>
    1010#endif
     11
     12using namespace std;
     13
     14/*
     15FLOAT_POSITION POSITION::toFloat() {
     16   FLOAT_POSITION floatPosition;
     17   floatPosition.x = x;
     18   floatPosition.y = y;
     19
     20   return floatPosition;
     21}
     22*/
    1123
    1224void set_nonblock(int sock)
     
    3850   return numMilliseconds;
    3951}
     52
     53float posDistance(FLOAT_POSITION pos1, FLOAT_POSITION pos2) {
     54   float xDiff = pos2.x - pos1.x;
     55   float yDiff = pos2.y - pos1.y;
     56
     57   return sqrt( pow(xDiff,2) + pow(yDiff,2) );   
     58}
  • common/Common.h

    rb81cea1 rb07eeac  
    1212#endif
    1313
    14 void set_nonblock(int sock);
    15 unsigned long long getCurrentMillis();
    16 
    17 typedef struct
    18 {
    19    int x;
    20    int y;
    21 } POSITION;
    22 
    2314typedef struct
    2415{
     
    2718} FLOAT_POSITION;
    2819
     20typedef struct
     21{
     22   int x;
     23   int y;
     24   //FLOAT_POSITION toFloat();
     25   FLOAT_POSITION toFloat() {
     26      FLOAT_POSITION floatPosition;
     27      floatPosition.x = x;
     28      floatPosition.y = y;
     29
     30      return floatPosition;
     31   }
     32} POSITION;
     33
     34void set_nonblock(int sock);
     35unsigned long long getCurrentMillis();
     36float posDistance(FLOAT_POSITION pos1, FLOAT_POSITION pos2);
     37
    2938#endif
  • common/Message.cpp

    rb81cea1 rb07eeac  
    1919   int ret =  sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in));
    2020
     21   cout << "Send a message of type " << msg->type << endl;
     22
    2123   return ret;
    2224}
Note: See TracChangeset for help on using the changeset viewer.