Selaa lähdekoodia

fixed sleep error on windows and ubuntu

Luis 9 vuotta sitten
vanhempi
commit
235d3a06ad
1 muutettua tiedostoa jossa 18 lisäystä ja 3 poistoa
  1. 18
    3
      functions.cpp

+ 18
- 3
functions.cpp Näytä tiedosto

@@ -7,6 +7,7 @@
7 7
 
8 8
 #include <QMessageBox>
9 9
 #include <QMap>
10
+#include <windows.h>
10 11
 #include "functions.h"
11 12
 #ifdef _WIN32
12 13
 #include <windows.h>
@@ -115,7 +116,12 @@ void MainWindow::diceAlpha(){
115 116
     //This loop is used to simulate the dice rolling by
116 117
     //changing the images at a slowing down speed
117 118
     for (int i = 0; i<=150000 ; i=i+5000){
119
+
120
+#ifdef _WIN32
118 121
         Sleep(i);
122
+#else
123
+        usleep(i);
124
+#endif
119 125
 
120 126
         //First dice image. Since we want random pictures
121 127
         //on each iteration, we get a random number, converted
@@ -173,8 +179,11 @@ void MainWindow::diceBeta(){
173 179
     QString a, b;
174 180
 
175 181
     for (int i = 0; i<=150000 ; i=i+5000){
182
+#ifdef _WIN32
176 183
         Sleep(i);
177
-
184
+#else
185
+        usleep(i);
186
+#endif
178 187
         a = ":/images/resources/d";
179 188
         a.append(QString::number(rand()%6 + 1));
180 189
         a.append(".png");
@@ -205,8 +214,11 @@ void MainWindow::diceGamma(){
205 214
     QString a, b;
206 215
 
207 216
     for (int i = 0; i<=150000 ; i=i+5000){
217
+#ifdef _WIN32
208 218
         Sleep(i);
209
-
219
+#else
220
+        usleep(i);
221
+#endif
210 222
         a = ":/images/resources/d";
211 223
         a.append(QString::number(rand()%6 + 1));
212 224
         a.append(".png");
@@ -239,8 +251,11 @@ void MainWindow::diceDelta(){
239 251
     QString a, b;
240 252
 
241 253
     for (int i = 0; i<=150000 ; i=i+5000){
254
+#ifdef _WIN32
242 255
         Sleep(i);
243
-
256
+#else
257
+        usleep(i);
258
+#endif
244 259
         a = ":/images/resources/d";
245 260
         a.append(QString::number(rand()%6 + 1));
246 261
         a.append(".png");