- Timestamp:
- Feb 18, 2013, 7:41:52 PM (12 years ago)
- Branches:
- master
- Children:
- 66906aa
- Parents:
- 093c141
- Location:
- common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Player.cpp
r093c141 rf401cac 103 103 cout << "elapsed nsecs: " << diffTS.tv_nsec << endl; 104 104 105 // here we move 100 pixels per second 106 float pixels = 100 * (diffTS.tv_sec+diffTS.tv_nsec/1000000000.0); 107 cout << "We need to move " << pixels << "pixels" << endl; 105 // if we're at our target, don't move 106 if (pos.x == target.x || pos.y == target.y) 107 cout << "We're already at our target" << endl; 108 else { 109 float pixels = speed * (diffTS.tv_sec+diffTS.tv_nsec/1000000000.0); 110 cout << "We need to move " << pixels << " pixels" << endl; 108 111 109 double angle = atan2(target.y-pos.y, target.x-pos.x);112 double angle = atan2(target.y-pos.y, target.x-pos.x); 110 113 111 // we just need to check that we don't overjump the target 112 pos.x += cos(angle)*pixels; 113 pos.y += sin(angle)*pixels; 114 // we just need to check that we don't overjump the target 115 pos.x += cos(angle)*pixels; 116 pos.y += sin(angle)*pixels; 117 } 114 118 115 119 timeLastUpdated.tv_sec = curTS.tv_sec; -
common/WorldMap.cpp
r093c141 rf401cac 5 5 #include <fstream> 6 6 #include <sstream> 7 #include <cstdlib> 7 8 8 9 using namespace std; … … 67 68 WorldMap* m = new WorldMap(12l, 12); 68 69 69 ifstream file(filename );70 ifstream file(filename.c_str()); 70 71 71 72 if (file.is_open()) -
common/WorldMap.h
r093c141 rf401cac 1 1 #ifndef _WORLDMAP_H 2 2 #define _WORLDMAP_H 3 4 #include <string> 3 5 4 6 #include <vector>
Note:
See TracChangeset
for help on using the changeset viewer.