Bug 66048 - "Crash!" when the crashing player is near screen's edge
Summary: "Crash!" when the crashing player is near screen's edge
Status: RESOLVED FIXED
Alias: None
Product: ktron
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Matthias Kiefer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-15 03:11 UTC by Mathieu
Modified: 2003-11-15 11:28 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mathieu 2003-10-15 03:11:36 UTC
Version:           1.0 (KDE 3.1.4) (using KDE KDE 3.1.4)
Installed from:    Gentoo Packages

When dying, there is a text label that appears on screen. (In english, it says "Crash!").

This label is misplaced when the player died at the edge of the screen.

At the left of the screen, only "sh!" will be displayed
At the right, only "Cra" will be displayed
At the top, you can't see the text at all.
Bottom is ok.
Comment 1 Albert Astals Cid 2003-11-15 11:28:36 UTC
Subject: kdegames/ktron

CVS commit by aacid: 

Make sure the crash text is always inside the screen. Will backport to KDE 3.1.x in a moment.
CCMAIL:66048-done@bugs.kde.org
CCMAIL:ben+ktron@meyerhome.net


  M +7 -23     tron.cpp   1.31


--- kdegames/ktron/tron.cpp  #1.30:1.31
@@ -602,31 +602,15 @@ void Tron::paintEvent(QPaintEvent *e)
       QPainter p(this);
       int w=p.fontMetrics().width(message);
+      int h=p.fontMetrics().height();
       for(int i=0;i<2;i++)
       {
          if(!players[i].alive)
          {
-            int x=players[i].xCoordinate*rectSize+(width()%rectSize)/2-w/2;
-            int y=players[i].yCoordinate*rectSize+(height()%rectSize)/2;
-            if(players[i].dir==::Right)
-            {
-               x+=rectSize;
-               y+=rectSize/2;
-            }
-            if(players[i].dir==::Left)
-            {
-               y+=rectSize/2;
-            }
-            if(players[i].dir==::Down)
-            {
-               y+=rectSize;
-               x+=rectSize/2;
-            }
-            if(players[i].dir==::Up)
-            {
-               x+=rectSize/2;
-               y+=rectSize/3;
-            }
-
-
+            int x=players[i].xCoordinate*rectSize;
+            int y=players[i].yCoordinate*rectSize;
+            while(x<0) x+=rectSize;
+            while(x+w>width()) x-=rectSize;
+            while(y-h<0) y+=rectSize;
+            while(y>height()) y-=rectSize;
             p.drawText(x,y,message);
          }