view title_scene.c @ 26:4447fd650f60

*** empty log message ***
author gongo
date Sun, 05 Nov 2006 02:25:30 +0000
parents 6910aeb52843
children 8edae89a3877
line wrap: on
line source

/*
 * $Id$
*/
#include "libps2.h"
#include "ps2util.h"
#include "title_scene.h"

typedef enum {
    TITLE_INIT,
    TITLE_MAIN,
    TITLE_FINISH
} TITLE_STATE;


static ps2utilSprite title_sprite;

static TEXTURE *title_img;

#define TITLE_IMG_FILE "img/title.png"


static void
title_init() 
{    
    /*    
	  load texture 
    */
    title_img = read_png_file( TITLE_IMG_FILE );
    ps2util_tex_Set( title_img );

    /*    
	  create sprite object
     */
    ps2util_sprite_Create( &title_sprite, title_img );
    ps2util_sprite_Set_basicAttribute( &title_sprite, 
	0, 0, 650, 500, 0, 0, 512, 256, SPRITE_PRIO_FOREGROUND );
    ps2util_sprite_Use_alpha( &title_sprite );
    ps2util_sprite_Request( &title_sprite );
}

void
title_init_call()
{
  title_init();
}

static void
title_finish()
{
    ps2util_sprite_Destroy( &title_sprite );
    ps2util_tex_Exclude( title_img );
    free_texture( title_img );
}

void
title_finish_call()
{
    title_finish();
}

int
title_scene() 
{
    static TITLE_STATE state = TITLE_INIT;
    int pad;

    switch (state) {
    case TITLE_INIT:
	title_init();
	state = TITLE_MAIN;
	break;

    case TITLE_MAIN:
	pad = sjoy_get_ps2_button( JOYPAD_1 );
	state = (pad & SJOY_PS2_START) ? TITLE_FINISH : TITLE_MAIN;
	break;

    case TITLE_FINISH:
      	title_finish();
	return -1;

    default:
	break;
    }
    return 0;
}