-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctf.js
67 lines (56 loc) · 1.44 KB
/
ctf.js
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
66
67
const game = new Game();
const gameWidth = 800;
const gameHeight = 400;
const prisonSize = 40;
const playerRadius = 20;
const flagRadius = 40;
const timeLimit = 120;
const speed = 3;
function setup() {
createCanvas(gameWidth, gameHeight);
game.start();
game.setupGame();
}
function draw() {
stroke('black');
//draw the board
fill('lightblue');
rect(0,0,width/2,height);
fill('lightpink');
rect(width/2,0, width/2, height);
//jail
fill('white');
rect(0,0,prisonSize,prisonSize);
rect(width-prisonSize, height-prisonSize, prisonSize, prisonSize);
//draw players
for (let i=0; i<10; i++){
let player = game.getPlayerData(i);
if (player.team===0) {
fill('blue');
} else {
fill('red');
}
circle(player.x, player.y, playerRadius);
}
//draw flags
for (let i=0; i<2; i++){
let flag = game.getFlagData(i);
if (flag.team===0) {
fill('blue');
} else {
fill('red');
}
circle(flag.x, flag.y, flagRadius);
}
//process the game playerRadius
if (game.checkIsGameOver()===false){
game.processMoves();
game.checkForPlayerCaptures();
game.checkForJailBreaks();
game.checkForFlagPickup();
game.checkForPoints();
game.displayPoints();
game.checkTimeVictory();
game.checkFlagVictory();
}
}