Changeset e5697b1 in network-game
- Timestamp:
- Jan 19, 2014, 8:02:22 PM (11 years ago)
- Branches:
- master
- Children:
- 1f6233e
- Parents:
- d05c484
- Location:
- client/Client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/GameRender.cpp
rd05c484 re5697b1 2 2 3 3 #include <allegro5/allegro_primitives.h> 4 5 #include "../../common/Common.h" 4 6 5 7 void GameRender::drawMap(WorldMap* gameMap) … … 113 115 } 114 116 } 117 118 void 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 } -
client/Client/GameRender.h
rd05c484 re5697b1 18 18 19 19 #include "../../common/Player.h" 20 #include "../../common/Projectile.h" 20 21 #include "../../common/WorldMap.h" 21 22 … … 25 26 static void drawMap(WorldMap* gameMap); 26 27 static void drawPlayers(map<unsigned int, Player*>& mapPlayers, ALLEGRO_FONT* font, unsigned int curPlayerId); 28 static void drawProjectiles(map<unsigned int, Projectile>& mapProjectiles, map<unsigned int, Player*>& mapPLayers); 27 29 }; 28 30 -
client/Client/main.cpp
rd05c484 re5697b1 520 520 GameRender::drawMap(game->getMap()); 521 521 GameRender::drawPlayers(game->getPlayers(), font, curPlayerId); 522 523 // draw projectiles 524 for (it2 = game->getProjectiles().begin(); it2 != game->getProjectiles().end(); it2++) 525 { 526 Projectile proj = it2->second; 527 528 FLOAT_POSITION target = game->getPlayers()[proj.target]->pos; 529 float angle = atan2(target.y-proj.pos.toFloat().y, target.x-proj.pos.toFloat().x); 530 531 POSITION start, end; 532 start.x = cos(angle)*15+proj.pos.x; 533 start.y = sin(angle)*15+proj.pos.y; 534 end.x = proj.pos.x; 535 end.y = proj.pos.y; 536 537 start = mapToScreen(start); 538 end = mapToScreen(end); 539 540 al_draw_line(start.x, start.y, end.x, end.y, al_map_rgb(0, 0, 0), 4); 541 } 522 GameRender::drawProjectiles(game->getProjectiles(), game->getPlayers()); 542 523 } 543 524 else if (wndCurrent == wndGameSummary)
Note:
See TracChangeset
for help on using the changeset viewer.