redef type I: SDLImage
- # Initialize a surface with width and height
+ # Initialize a surface with width and height
new ( w, h: Int) is extern `{
SDL_Init(SDL_INIT_VIDEO);
return SDL_SetVideoMode( w, h, 24, SDL_HWSURFACE );
`}
- # Destroy the surface
+ # Destroy the surface
fun destroy is extern `{
if ( SDL_WasInit( SDL_INIT_VIDEO ) )
SDL_Quit();
# Set the position of the cursor to x,y
fun warp_mouse( x,y: Int ) `{ SDL_WarpMouse( x, y ); `}
- # Show or hide the cursor
+ # Show or hide the cursor
fun show_cursor( show: Bool ) `{ SDL_ShowCursor( show ); `}
end
return NULL;
`}
- # Copy of an existing SDLImage
+ # Copy of an existing SDLImage
new copy_of( image: SDLImage ) is extern `{
SDL_Surface *new_image = SDL_CreateRGBSurface( image->flags, image->w, image->h, 24,
0, 0, 0, 0 );
# Save the image into the specified file
fun save_to_file( path: String ) is extern import String::to_cstring `{ `}
- # Destroy the image and free the memory
+ # Destroy the image and free the memory
redef fun destroy is extern `{ SDL_FreeSurface( recv ); `}
redef fun width: Int is extern `{ return recv->w; `}
# A simple rectangle
extern SDLRectangle in "C" `{SDL_Rect*`}
- # Constructor with x,y positions width and height of the rectangle
+ # Constructor with x,y positions width and height of the rectangle
new ( x: Int, y: Int, w: Int, h: Int ) is extern `{
SDL_Rect *rect = malloc( sizeof( SDL_Rect ) );
rect->x = (Sint16)x;
end
end
- # Return true if the key is down, false otherwise
+ # Return true if the key is down, false otherwise
redef fun is_down do return down
- # Return true if the key is the up arrow
+ # Return true if the key is the up arrow
redef fun is_arrow_up do return key_name == "up"
# Return true if the key is the left arrow
redef fun is_arrow_left do return key_name == "left"
return TTF_FontLineSkip( recv );
`}
- # Return true is the font used fixed width for each char
+ # Return true is the font used fixed width for each char
fun is_fixed_width: Bool is extern `{
return TTF_FontFaceIsFixedWidth( recv );
`}