-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJoystickView.m
52 lines (38 loc) · 909 Bytes
/
JoystickView.m
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
//
// JoystickView.m
// SumoDebugger
//
// Created by Tymon Tobolski on 10-02-19.
// Copyright 2010 Politechnika Wrocławska. All rights reserved.
//
#import "JoystickView.h"
@implementation JoystickView
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect {
float width = dirtyRect.size.width;
float height = dirtyRect.size.height;
int a = (xValue + 100) * width / 200;
int b = (yValue + 100) * height / 200;
[[NSColor blueColor] set];
NSBezierPath* thePath = [NSBezierPath bezierPath];
[thePath appendBezierPathWithOvalInRect:NSMakeRect(a-5, b-5, 10, 10)];
[thePath stroke];
[thePath fill];
}
- (void)setX:(int)x
{
xValue = x;
[self setNeedsDisplay:YES];
}
- (void)setY:(int)y
{
yValue = y;
[self setNeedsDisplay:YES];
}
@end