X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=move_square.cc;h=664b70f50d1320dab97f816cf0dc355723a1da1e;hb=HEAD;hp=1722be846ab2f9ea7658eef2a53375b26f407290;hpb=ba46b057f3e2613a86f2dea7fa8022990482c735;p=universe.git diff --git a/move_square.cc b/move_square.cc index 1722be8..664b70f 100644 --- a/move_square.cc +++ b/move_square.cc @@ -1,19 +1,6 @@ -//////////////////////////////////////////////////////////////////////////////// -// This program is free software; you can redistribute it and/or // -// modify it under the terms of the GNU General Public License // -// version 2 as published by the Free Software Foundation. // -// // -// This program is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// General Public License for more details. // -// // -// Written and (C) by François Fleuret // -// Contact for comments & bug reports // -//////////////////////////////////////////////////////////////////////////////// - -// $Id: move_square.cc,v 1.16 2006-07-21 08:44:16 fleuret Exp $ +// Written and (C) by Francois Fleuret +// Contact for comments & bug reports #include "task.h" #include "universe.h" @@ -29,7 +16,7 @@ class MoveSquare : public Task { public: - virtual char *name() { return "MOVE_SQUARE"; } + virtual const char *name() { return "MOVE_SQUARE"; } virtual int nb_degrees() { return 5; } @@ -42,13 +29,24 @@ public: else if(degree == 1) _square_size = 150; else if(degree == 2) _square_size = 100; else _square_size = 50; - scalar_t x[] = { -_square_size/2, _square_size/2, _square_size/2, -_square_size/2 }; - scalar_t y[] = { -_square_size/2, -_square_size/2, _square_size/2, _square_size/2 }; + + scalar_t x[] = { + -_square_size / 2.0, _square_size / 2.0, + _square_size / 2.0, -_square_size / 2.0 + }; + + scalar_t y[] = { + -_square_size / 2.0, -_square_size / 2.0, + _square_size / 2.0, _square_size / 2.0 + }; + _target = new Polygon(0.5, 1.0, 1.0, 0.0, x, y, 4); _target->set_position(_square_size/2, _square_size/2 + (world_height - _square_size) * drand48(), 0); _target->set_speed(0, 0, 0); - universe->initialize(_target); + + universe->initialize_polygon(_target); universe->add_polygon(_target); + if(degree == 4) { Polygon *obstacle; scalar_t x[] = { ( 9 * world_width)/20, (11 * world_width)/20, @@ -59,7 +57,7 @@ public: obstacle->set_position(world_width/2, world_height/2, 0); obstacle->set_speed(0, 0, 0); obstacle->_nailed = true; - universe->initialize(obstacle); + universe->initialize_polygon(obstacle); universe->add_polygon(obstacle); } } @@ -72,7 +70,9 @@ public: _target->set_speed(0, 0, 0); manipulator->force_release(); return 1.0; - } else return 0.0; + } else { + return 0.0; + } } virtual void draw(SimpleWindow *window) {