Changeset fbcfc35 in network-game


Ignore:
Timestamp:
Jun 9, 2013, 5:59:48 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
8795a38
Parents:
b978503
Message:

Add the Projectile class to the client project and add a list of projectiles to the client

Location:
client/Client
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • client/Client/Client.vcxproj

    rb978503 rfbcfc35  
    6565  <ItemGroup>
    6666    <ClCompile Include="..\..\common\Common.cpp" />
     67    <ClCompile Include="..\..\common\Projectile.cpp" />
    6768    <ClCompile Include="..\..\common\WorldMap.cpp" />
    6869    <ClCompile Include="..\..\common\Message.cpp" />
     
    7879    <ClInclude Include="..\..\common\Common.h" />
    7980    <ClInclude Include="..\..\common\Compiler.h" />
     81    <ClInclude Include="..\..\common\Projectile.h" />
    8082    <ClInclude Include="..\..\common\WorldMap.h" />
    8183    <ClInclude Include="..\..\common\Message.h" />
  • client/Client/Client.vcxproj.filters

    rb978503 rfbcfc35  
    5858      <Filter>Source Files\common</Filter>
    5959    </ClCompile>
     60    <ClCompile Include="..\..\common\Projectile.cpp">
     61      <Filter>Source Files\common</Filter>
     62    </ClCompile>
    6063  </ItemGroup>
    6164  <ItemGroup>
     
    9093      <Filter>Header Files\common</Filter>
    9194    </ClInclude>
     95    <ClInclude Include="..\..\common\Projectile.h">
     96      <Filter>Header Files\common</Filter>
     97    </ClInclude>
    9298  </ItemGroup>
    9399  <ItemGroup>
  • client/Client/main.cpp

    rb978503 rfbcfc35  
    3333#include "../../common/WorldMap.h"
    3434#include "../../common/Player.h"
     35#include "../../common/Projectile.h"
    3536
    3637#include "Window.h"
     
    4748void initWinSock();
    4849void shutdownWinSock();
    49 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed);
     50void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed);
    5051void drawMap(WorldMap* gameMap);
    5152void drawPlayers(map<unsigned int, Player>& mapPlayers, ALLEGRO_FONT* font, unsigned int curPlayerId);
     
    99100   doexit = false;
    100101   map<unsigned int, Player> mapPlayers;
     102   map<unsigned int, Projectile> mapProjectiles;
    101103   unsigned int curPlayerId = -1;
    102104   int scoreBlue, scoreRed;
     
    299301                  map<unsigned int, Player>::iterator it;
    300302
     303                  cout << "Detected a right-click" << endl;
     304
    301305                  Player* curPlayer;
    302306                  for(it = mapPlayers.begin(); it != mapPlayers.end(); it++)
     
    309313                  for(it = mapPlayers.begin(); it != mapPlayers.end(); it++)
    310314                  {
     315                     // need to check if the right-click was actually on this player
    311316                     target = &it->second;
    312317                     if (target->id != curPlayerId && target->team != curPlayer->team) {
     
    323328
    324329      if (receiveMessage(&msgFrom, sock, &from) >= 0)
    325          processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, curPlayerId, scoreBlue, scoreRed);
     330         processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, mapProjectiles, curPlayerId, scoreBlue, scoreRed);
    326331
    327332      if (redraw)
     
    447452}
    448453
    449 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed)
     454void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed)
    450455{
    451456   string response = string(msg.buffer);
     
    623628            case MSG_TYPE_PROJECTILE:
    624629            {
     630               cout << "Received a prjectile message" << endl;
     631
     632               int id, x, y, targetId;
     633
     634               memcpy(&id, msg.buffer, 4);
     635               memcpy(&x, msg.buffer+4, 4);
     636               memcpy(&y, msg.buffer+8, 4);
     637               memcpy(&targetId, msg.buffer+12, 4);
     638
     639               cout << "id" << id << endl;
     640               cout << "x" << x << endl;
     641               cout << "y" << y << endl;
     642               cout << "Target" << targetId << endl;
     643
    625644               break;
    626645            }
Note: See TracChangeset for help on using the changeset viewer.