Version française
Home     About     Download     Resources     Contact us    
Browse thread
Building a game loop (sort of)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: C. Fr <newsgroups.fr@g...>
Subject: Building a game loop (sort of)
Hello everyone,

 

I’m building a small fractal visualisation app in ocaml, but I encounter
many problems with the graphics package.

 

First, plot (size_x / 2) (size_y / 2) doesn’t actually plot in the middle of
the screen… Any idea why?

 

Then, using the following code

 

if key_pressed () then

        begin

            match read_key () with

            | 'q' -> raise Exit

            | 'o' -> scale := !scale *. 2.

            | 'i' -> scale := !scale /. 2.

            | 'l' -> mid_x := !mid_x + 100

            | 'r' -> mid_x := !mid_x - 100

            | 'u' -> mid_y := !mid_y + 100

            | 'd' -> mid_y := !mid_y - 100

            | _ -> ()

        end

    done;

in a while true loop behaves randomly, ignoring some key presses, and
repeating some… Is there something that I did wrong?

 

Thanks a lot,

Andrea.