-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathadditiongame.php
More file actions
73 lines (67 loc) · 2.09 KB
/
additiongame.php
File metadata and controls
73 lines (67 loc) · 2.09 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
66
67
68
69
70
71
72
73
<?php
define("FILENAME","additionDB.txt");
define("POINTS_TO_WIN",10);
$burger_images = array();
$burger_images[]="goodburger00.png";
$burger_images[]="goodburger01.png";
$burger_images[]="goodburger02.png";
$burger_images[]="goodburger03.png";
$burger_images[]="goodburger04.png";
$burger_images[]="goodburger05.png";
$burger_images[]="goodburger06.png";
$burger_images[]="goodburger07.png";
$burger_images[]="goodburger08.png";
$burger_images[]="goodburger09.png";
$burger_images[]="goodburger10.png";
$burger_height = array();
$burger_width = array();
$burger_width[]=307;
$burger_height[] = 70;
$burger_width[]=310;
$burger_height[] = 100;
$burger_width[]=348;
$burger_height[] = 150;
$burger_width[]=348;
$burger_height[] = 160;
$burger_width[]=340;
$burger_height[] = 190;
$burger_width[]=342;
$burger_height[] = 220;
$burger_width[]=343;
$burger_height[] = 269;
$burger_width[]=344;
$burger_height[] = 283;
$burger_width[]=345;
$burger_height[] = 301;
$burger_width[]=346;
$burger_height[] = 315;
$burger_width[]=348;
$burger_height[] = 348;
global $num_probs;
global $current_answer;
//get problems from file and store in array
function get_problems(){
global $num_probs;
$num_probs=0;
$file = fopen(FILENAME,"r") or die ("Unable to open file");
while(!feof($file)){
$line = fgets($file);
$info = explode(" ",$line);
$problems[]=$info;
$num_probs++;
}
fclose($file);
return $problems;
}
//pick a problem and print it
function pick_problem(){
global $num_probs;
$problems = get_problems();
$prob_num = rand(1,$num_probs)-1;
$number1 = $problems[$prob_num][0];
$number2 = $problems[$prob_num][1];
global $current_answer;
$current_answer = $problems[$prob_num][2];
return $number1." + ".$number2." = ";
}
?>