2
namespace invadersGame{
9
private const int SCREEN_HEIGHT = 640;
10
private const int SCREEN_WIDTH = 480;
11
private const int SCREEN_FPS = 60;
12
private const int SCREEN_BPP = 32;
14
private uint32 fpsTimer;
16
private unowned SDL.Screen screen;
17
private GLib.Rand rand;
19
private bool eventBool[322];
23
stdout.printf("Running contructor...\n");
25
this.rand = new GLib.Rand();
26
for(int i = 0; i < 322; i++) { // init them all to false
31
public void mainLoop(){
34
fpsTimer = SDL.Timer.get_ticks();
37
if(SDL.Timer.get_ticks() - fpsTimer < 1000/SCREEN_FPS){
38
SDL.Timer.delay(1000/SCREEN_FPS - (SDL.Timer.get_ticks() - fpsTimer));
42
public void initScreen(){
43
uint32 VideoFlags = SurfaceFlag.DOUBLEBUF
45
| SurfaceFlag.HWSURFACE;
46
this.screen = Screen.set_video_mode (SCREEN_WIDTH, SCREEN_HEIGHT,
47
SCREEN_BPP, VideoFlags);
48
if(this.screen == null){
49
stderr.printf("Could not initize video \n");
51
SDL.WindowManager.set_caption("Invaders_vala","");
59
private void process_events(){
60
Event event = Event();
61
while(Event.poll(event) != 0){
64
stdout.printf("quiting...\n");
67
case EventType.KEYDOWN:
68
stdout.printf("keydown\n");
69
this.eventBool[event.key.keysym.sym] = true;
72
stdout.printf("keyup\n");
73
this.eventBool[event.key.keysym.sym] = false;