-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPong.cpp
More file actions
65 lines (63 loc) · 1.53 KB
/
Pong.cpp
File metadata and controls
65 lines (63 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#define s_width 80
#define s_height 80
#include "include\Fazen.hpp"
#include "PongIncludes\Ball.hpp"
#include "PongIncludes\Paddel.hpp"
void showScores(Fazen2d game,Paddel p1,Paddel p2)
{
game.drawTextFromInt(10,10,L"PLAYER 1 SCORE : ",p1.score);
game.drawTextFromInt(s_width-30,10,L"PLAYER 2 SCORE : ",p2.score);
}
int main()
{
Fazen2d game;
game.make2DConsole(8,8,"Pong");
TIMEVARS
Ball b;
Paddel p1(10);
Paddel p2(s_width-10);
while(1)
{
TIMER
game.background();
game.drawRectangle(p1.x,p1.y,p1.w,p1.h,0,redF);
game.drawRectangle(p2.x,p2.y,p2.w,p2.h,0,blueF);
game.drawRectangle(b.x,b.y,2,2,0,greenF);
b.update(felapsedTime);
b.edges(p1.score,p2.score);
b.checkCollide(p1,p2);
p1.clipY();
p2.clipY();
if(GetAsyncKeyState(VK_UP))
{
p2.y-=70*felapsedTime;
}
if(GetAsyncKeyState(VK_DOWN))
{
p2.y+=70*felapsedTime;
}
if(GetAsyncKeyState(0x57))
{
p1.y-=70*felapsedTime;
}
if(GetAsyncKeyState(0x53))
{
p1.y+=70*felapsedTime;
}
if(GetAsyncKeyState(VK_ESCAPE))
{
if(p1.score>p2.score)
{
game.Text(30,30,L"Player 1 Wins");
}
else
{
game.Text(30,30,L"Player 2 Wins");
}
game.display();
break;
}
showScores(game,p1,p2);
game.display();
}
}