-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewController.m
More file actions
158 lines (116 loc) · 3.08 KB
/
Copy pathViewController.m
File metadata and controls
158 lines (116 loc) · 3.08 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
//
// ViewController.m
// App
//
// Created by Brian Bigdelle on 8/18/14.
// Copyright (c) 2014 Brian Bigdelle. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//label.text = [NSString stringWithFormat:@"Score is %i" ,score];
score = 0;
[self instructions];
}
-(IBAction)restartButton:(id)sender
{
score=0;
[self instructions];
label.text= [NSString stringWithFormat:@"Score:0"];
/*ISSU: TRYING TO PRINT
*/
//instructions.text=[NSString stringWithFormat:@"You lose"];
self.view.backgroundColor= [UIColor whiteColor];
}
-(IBAction)leftClickedButton:(id)sender
{
[self randColorgen];
if(on==true)
{
[self didScore];
label.text = [NSString stringWithFormat:@"Score: %i", score];
}
else if(on==false)
{
//label.text= [NSString stringWithFormat:@"YOU LOSE!!!"];
[self reset];
}
[self instructions];
}
-(IBAction)rightClickedButton:(id)sender
{
[self randColorgen];
if(on==false)
{
[self didScore];
label.text= [NSString stringWithFormat:@"Score: %i", score];
}
else if(on==true)
{
//label.text= [NSString stringWithFormat:@"YOU LOSE!!!"];
[self reset];
}
[self instructions];
}
-(void) reset
{
score=0;
label.text= [NSString stringWithFormat:@"Thanks for playing, click restart to try again"];
}
-(void)instructions
{
x=arc4random() % 10;
//if x is less than 5, the left button should be clicked
if(x<5)
{
instructions.text= [NSString stringWithFormat:@"Click Left"];
on=true;
}
else
{
instructions.text= [NSString stringWithFormat:@"Click Right"];
on=false;
}
}
-(void)didScore
{
score += 10;
label.text = [NSString stringWithFormat:@"Score: %i", score];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)randColorgen
{
int color= arc4random() %10;
if(color==0)
self.view.backgroundColor=[UIColor redColor];
else if(color==1)
self.view.backgroundColor= [UIColor blueColor];
else if(color==2)
self.view.backgroundColor= [UIColor greenColor];
else if (color==3)
self.view.backgroundColor= [UIColor yellowColor];
else if(color==4)
self.view.backgroundColor= [UIColor grayColor];
else if(color==5)
self.view.backgroundColor=[UIColor purpleColor];
else if(color==6)
self.view.backgroundColor=[UIColor orangeColor];
else if(color==7)
self.view.backgroundColor=[UIColor magentaColor];
else if(color==8)
self.view.backgroundColor=[UIColor brownColor];
else if(color==9)
self.view.backgroundColor=[UIColor lightGrayColor];
else if(color==10)
self.view.backgroundColor=[UIColor orangeColor];
}
@end