-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
54 lines (47 loc) · 1.12 KB
/
sketch.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
var database;
var back_img;
var gameState =0;
var playerCount = 0;
var allPlayers;
var score =0;
var player, form,game;
var player1,player2;
var players;
var fruits;
var fruitGroup;
var fruit1_img, fruit2_img, fruit3_img, fruit4_img, fruit5_img;
var player_img;
var player1score =0;
var player2score =0;
var obstacleGroup,obstacle,obstacleImage;
function preload(){
back_img = loadImage("images/jungle.jpg");
player_img = loadImage("images/basket2.png");
fruit1_img = loadImage("images/apple2.png");
fruit2_img = loadImage("images/banana2.png");
fruit3_img = loadImage("images/melon2.png");
fruit4_img = loadImage("images/orange2.png");
fruit5_img = loadImage("images/pineapple2.png");
fruitGroup = new Group();
obstacleImage = loadImage("images/mushroom.png")
}
function setup() {
createCanvas(1000, 600);
database = firebase.database();
game = new Game();
game.getState();
game.start();
}
function draw() {
background(back_img);
if (playerCount === 2) {
game.update(1);
}
if (gameState === 1) {
clear();
game.play();
}
if (gameState === 2) {
game.end();
}
}