caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Building a game loop (sort of)
@ 2010-03-21 21:12 C. Fr
  2010-03-21 21:26 ` [Caml-list] " Stas Miasnikou
  0 siblings, 1 reply; 3+ messages in thread
From: C. Fr @ 2010-03-21 21:12 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 923 bytes --]

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.

 

 

 

 


[-- Attachment #2: Type: text/html, Size: 6454 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Building a game loop (sort of)
  2010-03-21 21:12 Building a game loop (sort of) C. Fr
@ 2010-03-21 21:26 ` Stas Miasnikou
  2010-03-22  0:04   ` Yang Ye
  0 siblings, 1 reply; 3+ messages in thread
From: Stas Miasnikou @ 2010-03-21 21:26 UTC (permalink / raw)
  To: C. Fr; +Cc: caml-list

On 3/21/10, C. Fr <newsgroups.fr@gmail.com> wrote:
> 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?

What are size_x and size_y, what you got, and what you are supposed to get?

> 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?

Stas


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Building a game loop (sort of)
  2010-03-21 21:26 ` [Caml-list] " Stas Miasnikou
@ 2010-03-22  0:04   ` Yang Ye
  0 siblings, 0 replies; 3+ messages in thread
From: Yang Ye @ 2010-03-22  0:04 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1589 bytes --]

For 2nd question, skipping the outer if? Because read_key is waiting and
queuing they keypresses already.

On Mon, Mar 22, 2010 at 5:26 AM, Stas Miasnikou <stas.miasnikou@gmail.com>wrote:

> On 3/21/10, C. Fr <newsgroups.fr@gmail.com> wrote:
> > 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?
>
> What are size_x and size_y, what you got, and what you are supposed to get?
>
> > 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?
>
> Stas
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



-- 
Regards,
Yang Ye

[-- Attachment #2: Type: text/html, Size: 2523 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-22  0:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-21 21:12 Building a game loop (sort of) C. Fr
2010-03-21 21:26 ` [Caml-list] " Stas Miasnikou
2010-03-22  0:04   ` Yang Ye

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).