-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorld.cpp
More file actions
54 lines (37 loc) · 1.14 KB
/
World.cpp
File metadata and controls
54 lines (37 loc) · 1.14 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
/*
* World.cpp: Main program file for Project 3, CS 559
*
* (c) 2001-2002: Stephen Chenney
*/
#include <Fl/Fl.h>
#include "WorldWindow.h"
#include <stdio.h>
#include <cstring>
// The time per frame, in seconds (enforced only by timeouts.)
static const float FRAME_TIME = 0.025f;
static WorldWindow *world_window; // The window with world view in it
// This callback is called every 40th of a second if the system is fast
// enough. You should change the variable FRAME_TIME defined above if you
// want to change the frame rate.
static void
Timeout_Callback(void *data)
{
// Update the motion in the world. This both moves the view and
// animates the train.
world_window->Update(FRAME_TIME);
world_window->redraw();
// Do the timeout again for the next frame.
Fl::repeat_timeout(FRAME_TIME, Timeout_Callback);
}
int
main(int argc, char *argv[])
{
Fl::visual(FL_RGB);
const char * s = "world";
char * t = new char[6];
std::strncpy(t, s, 6);
world_window = new WorldWindow(100, 100, 800, 600, t);
world_window->show(argc, argv);
Fl::add_timeout(0.0, Timeout_Callback, NULL);
return Fl::run();
}