5 blue_rect.pl - draw a blue rectangle using the SDL library and NQP
9 To run this file, execute the following command from the Parrot
12 $ ./parrot compilers/nqp/nqp.pbc examples/sdl/blue_rect.pl
16 # load the SDL class libraries
17 PIR q
< load_bytecode
'SDL/App.pir' >;
18 PIR q
< load_bytecode
'SDL/Rect.pir' >;
19 PIR q
< load_bytecode
'SDL/Color.pir' >;
21 # make sure NQP has class protoobjects for the SDL classes
22 Protomaker
.new_proto
('SDL::App');
23 Protomaker
.new_proto
('SDL::Rect');
24 Protomaker
.new_proto
('SDL::Color');
26 # create an SDL::App object
27 my $app := SDL
::App
.new
();
28 $app.init
( :height
(480), :width
(640), :bpp
(0), :flags
(1) );
30 # fetch the SDL::Surface representing the main window
31 my $main_screen := $app.surface
();
33 # create an SDL::Rect object
34 my $rect := SDL
::Rect
.new
();
35 $rect.init
( :height
(100), :width
(100), :x
(270), :y
(190) );
37 # create an SDL::Color object
38 my $color := SDL
::Color
.new
();
39 $color.init
( :r
(0), :g
(0), :b
(255) );
41 # draw the rectangle to the surface and update it
42 $main_screen.fill_rect
( $rect, $color );
43 $main_screen.update_rect
( $rect );
45 # pause for people to see it
54 blue_rect.pl created by Patrick R. Michaud (pmichaud@pobox.com)
55 based on blue_rect.pir by chromatic (chromatic at wgz dot org).
59 Copyright (C) 2004-2007, Parrot Foundation.
65 # cperl-indent-level: 4
68 # vim: expandtab shiftwidth=4: