branch | new_graphics |
changeset 412 | 721c60072091 |
parent 408 | e6cfc44266af |
child 417 | c503e0c6a740 |
411:106aaf6eadfe | 412:721c60072091 |
---|---|
1 #include "Player.hh" |
1 #include "Player.hh" |
2 #include "Rope.hh" |
2 #include "Rope.hh" |
3 #include "Engine.hh" |
3 #include "Engine.hh" |
4 #include "Graphics.hh" |
4 |
5 #include <math.h> |
5 #include <math.h> |
6 #include <stdexcept> |
6 #include <stdexcept> |
7 |
7 |
8 Rope::Rope(Player &player) : |
8 Rope::Rope(Player &player) : |
9 PhysicsObject(player.state.world, ROPE_MASS, Vector(0,0), Vector(0,0), ROPE, 0.00, false), |
9 PhysicsObject(player.state.world, ROPE_MASS, Vector(0,0), Vector(0,0), ROPE, 0.00, false), |
148 void Rope::updateLength (float length) { |
148 void Rope::updateLength (float length) { |
149 // update length |
149 // update length |
150 this->length = length; |
150 this->length = length; |
151 } |
151 } |
152 |
152 |
153 void Rope::draw (Graphics *g, PixelCoordinate camera) { |
153 void Rope::draw (graphics::Display &display, PixelCoordinate camera) { |
154 PixelCoordinate player_pos = player.getCoordinate() - camera; |
154 PixelCoordinate player_pos = player.getCoordinate() - camera; |
155 PixelCoordinate target_pos; |
155 PixelCoordinate target_pos; |
156 |
156 |
157 // figure out what target is |
157 // figure out what target is |
158 if (state == ROPE_FOLDED) { |
158 if (state == ROPE_FOLDED) { |
173 |
173 |
174 // align with camera |
174 // align with camera |
175 target_pos -= camera; |
175 target_pos -= camera; |
176 |
176 |
177 // draw a line from the player to the target chosen above |
177 // draw a line from the player to the target chosen above |
178 g->get_gc()->draw_line( |
178 display.get_gc()->draw_line( |
179 player_pos.x, player_pos.y, |
179 player_pos.x, player_pos.y, |
180 target_pos.x, target_pos.y, |
180 target_pos.x, target_pos.y, |
181 ROPE_COLOR_DARK |
181 ROPE_COLOR_DARK |
182 ); |
182 ); |
183 } |
183 } |