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
|
#import "OGKEventQueue.h"
#import "OGKBitmap.h"
#import "TestMain.h"
OF_APPLICATION_DELEGATE(TestMain)
@implementation TestMain
- (void)displayWasClosed: (OGKCloseEvent*)event
{
running = NO;
}
- (void)keyWasPressed: (OGKKeyPressEvent*)event
{
of_log(@"Pressed: %d", event.keycode);
}
- (void)keyWasReleased: (OGKKeyReleaseEvent*)event
{
of_log(@"Released: %d", event.keycode);
}
- (void)mouseWasMoved: (OGKMouseMovedEvent*)event
{
of_log(@"Mouse moved: X=%.f(%.f) Y=%.f(%.f) WX=%.f(%.f) WY=%.f(%.f)",
event.cursor.x, event.deltaCursor.x,
event.cursor.y, event.deltaCursor.y,
event.wheel.x, event.deltaWheel.x,
event.wheel.y, event.deltaWheel.y);
}
- (void)mouseButtonWasPressed: (OGKMouseButtonPressedEvent*)event
{
of_log(@"Mouse button was pressed: %d (X=%.f Y=%.f WX=%.f WY=%.f)",
event.button, event.cursor.x, event.cursor.y,
event.wheel.x, event.wheel.y);
}
- (void)mouseButtonWasReleased: (OGKMouseButtonPressedEvent*)event
{
of_log(@"Mouse button was released: %d (X=%.f Y=%.f WX=%.f WY=%.f)",
event.button, event.cursor.x, event.cursor.y,
event.wheel.x, event.wheel.y);
}
- (void)handleEvents
{
[eventQueue handleNextEvent];
}
- (void)draw
{
[OGKBitmap clearToColor: OGK_COLOR_BLACK];
[bitmap drawAtPosition: of_point(160, 120)];
[display update];
}
- (void)applicationDidFinishLaunching
{
display = [[OGKDisplay alloc] initWithSize: of_dimension(640, 480)
position: of_point(200, 200)
|
>
|
>
>
>
>
>
>
>
|
|
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
|
#import "OGKEventQueue.h"
#import "OGKBitmap.h"
#import "TestMain.h"
OF_APPLICATION_DELEGATE(TestMain)
@implementation TestMain
- (void)display: (OGKDisplay*)display
wasClosed: (OGKCloseEvent*)event
{
running = NO;
}
- (void)keyWasPressed: (OGKKeyPressEvent*)event
display: (OGKDisplay*)display
{
of_log(@"Pressed: %d", event.keycode);
}
- (void)keyWasReleased: (OGKKeyReleaseEvent*)event
display: (OGKDisplay*)display
{
of_log(@"Released: %d", event.keycode);
}
- (void)mouseWasMoved: (OGKMouseMovedEvent*)event
display: (OGKDisplay*)display
{
of_log(@"Mouse moved: X=%.f(%.f) Y=%.f(%.f) WX=%.f(%.f) WY=%.f(%.f)",
event.cursor.x, event.deltaCursor.x,
event.cursor.y, event.deltaCursor.y,
event.wheel.x, event.deltaWheel.x,
event.wheel.y, event.deltaWheel.y);
position = event.cursor;
}
- (void)mouseButtonWasPressed: (OGKMouseButtonPressedEvent*)event
display: (OGKDisplay*)display
{
of_log(@"Mouse button was pressed: %d (X=%.f Y=%.f WX=%.f WY=%.f)",
event.button, event.cursor.x, event.cursor.y,
event.wheel.x, event.wheel.y);
}
- (void)mouseButtonWasReleased: (OGKMouseButtonPressedEvent*)event
display: (OGKDisplay*)display
{
of_log(@"Mouse button was released: %d (X=%.f Y=%.f WX=%.f WY=%.f)",
event.button, event.cursor.x, event.cursor.y,
event.wheel.x, event.wheel.y);
}
- (void)handleEvents
{
[eventQueue handleNextEvent];
}
- (void)draw
{
[OGKBitmap clearToColor: OGK_COLOR_BLACK];
[bitmap drawAtPosition: position];
[display update];
}
- (void)applicationDidFinishLaunching
{
display = [[OGKDisplay alloc] initWithSize: of_dimension(640, 480)
position: of_point(200, 200)
|