Changeset e5697b1 in network-game for client/Client/GameRender.cpp


Ignore:
Timestamp:
Jan 19, 2014, 8:02:22 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
1f6233e
Parents:
d05c484
Message:

Projectile drawing code moved to the GameRender class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/GameRender.cpp

    rd05c484 re5697b1  
    22
    33#include <allegro5/allegro_primitives.h>
     4
     5#include "../../common/Common.h"
    46
    57void GameRender::drawMap(WorldMap* gameMap)
     
    113115   }
    114116}
     117
     118void GameRender::drawProjectiles(map<unsigned int, Projectile>& mapProjectiles, map<unsigned int, Player*>& mapPlayers)
     119{
     120   map<unsigned int, Projectile>::iterator it;
     121   for (it = mapProjectiles.begin(); it != mapProjectiles.end(); it++)
     122   {
     123      Projectile proj = it->second;
     124
     125      FLOAT_POSITION target = mapPlayers[proj.target]->pos;
     126      float angle =  atan2(target.y-proj.pos.toFloat().y, target.x-proj.pos.toFloat().x);
     127
     128      POSITION start, end;
     129      start.x = cos(angle)*15+proj.pos.x;
     130      start.y = sin(angle)*15+proj.pos.y;
     131      end.x = proj.pos.x;
     132      end.y = proj.pos.y;
     133
     134      start = mapToScreen(start);
     135      end = mapToScreen(end);
     136
     137      al_draw_line(start.x, start.y, end.x, end.y, al_map_rgb(0, 0, 0), 4);
     138   }
     139}
Note: See TracChangeset for help on using the changeset viewer.