Permalink
Browse files

Added comments and mainmenu sketch

  • Loading branch information...
1 parent 358432a commit 367ec1c432f19f733a36563c37611f34c042b2a1 @Mandarancio committed Mar 2, 2012
Showing with 26 additions and 4 deletions.
  1. BIN Artwork/mainmenu.png
  2. +26 −4 level.cpp
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -317,7 +317,20 @@ void Level::paintEvent(QPaintEvent *e){
for (int i=0;i<stickys.length();i++)
stickys[i]->paint(p);
}
+
+
p.restore();
+
+ p.save();
+ p.translate(center);
+
+ if (flag==DEBUG){
+ p.setPen(Qt::white);
+ p.drawLine(0,5,0,-5);
+ p.drawLine(5,0,-5,0);
+ }
+ p.restore();
+
paintTargetArrow(p);
paintWin(p);
paintScore(p);
@@ -534,18 +547,27 @@ void Level::paintTargetArrow(QPainter &p){
if (!darea.contains(center-tp)){
//Target is not displayed.
tp=translation+tp;
+ //Translate at the center of the area and rotate in the direction of the target
p.save();
- p.setPen(Qt::black);
p.setBrush(Qt::black);
p.translate(center);
- p.rotate(atan2(-tp.y(),-tp.x())*180.0/3.141628-180);
- p.translate(550,0);
+ if (flag==DEBUG){ //Debug line
+ p.setPen(QPen(Qt::green,1.0,Qt::DashLine));
+ p.drawLine(0,0,tp.x(),tp.y());
+ }
+ p.setPen(Qt::black);
+ //Calculate the angle of the vector between center and target
+ float angle=atan2(-tp.y(),-tp.x())*180.0/3.141628-180;
+ p.rotate(angle);
+ p.translate((width()<height()? width()*3/5-40 : height()*3/5-40),0);
+ //create the arrow polygon
QPolygon arrow(3);
arrow.insert(0,QPoint(0,15));
arrow.insert(1,QPoint(30,0));
arrow.insert(2,QPoint(0,-15));
+ //Draw it
p.drawPolygon(arrow);
-
+ //Restor evrything
p.restore();
}

0 comments on commit 367ec1c

Please sign in to comment.