Skip to content

Commit bdf823d

Browse files
committed
Add sleep for modern computers
Add sleep to allow gameplay on modern computers
1 parent 476f99d commit bdf823d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Source/Castle.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <time.h>
44
#include <stdio.h>
55
#include <string.h>
6+
#include <stdlib.h>
67
#include "data.h"
78

89
#define for if(false) {} else for
@@ -16,6 +17,8 @@
1617
#define MAX_ITEM_CARRY 6
1718
#define TILESIZE 32
1819

20+
#define SLEEPTIME 50
21+
1922
#define UP 0
2023
#define DOWN 1
2124
#define LEFT 2
@@ -98,6 +101,9 @@
98101
#define FAIRY1 512
99102
#define FAIRY2 1024
100103

104+
DWORD LastSystemTime = 0;
105+
DWORD CurrentDelay = 0;
106+
101107
typedef struct ITEM
102108
{
103109
char name[20];
@@ -2307,6 +2313,8 @@ int main()
23072313
{
23082314
drawAll();
23092315

2316+
LastSystemTime = GetTickCount();
2317+
23102318
if (key[KEY_LEFT])
23112319
{
23122320
if (player.x<=0 && room[player.rm-1].exits[3]!=0)
@@ -2400,6 +2408,9 @@ int main()
24002408
}
24012409

24022410
if (gameover) done=true;
2411+
2412+
CurrentDelay = GetTickCount() - LastSystemTime;
2413+
if (CurrentDelay < SLEEPTIME) Sleep(SLEEPTIME - CurrentDelay);
24032414
}
24042415

24052416
if (gameover)

0 commit comments

Comments
 (0)