Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global SplashScreen = {};
- function SplashScreen.create()
- {
- data =
- {
- timer = 0,
- crage_tex = create_texture( "ui/crage_logo.png" ),
- back_tex = create_texture( "ui/flare_bg.png", "hrepeat,vrepeat" ),
- };
- return class( data, SplashScreen );
- }
- function SplashScreen.on_event( e )
- {
- if( e.type == SDL_KEYDOWN || e.type == SDL_MOUSEBUTTONDOWN )
- {
- if( this.timer < 5 ) this.timer = 5;
- }
- // inhibit all events
- return false;
- }
- function SplashScreen.draw( delta )
- {
- this.timer += delta;
- draw_color_rect_wh( 0, 0, 9999, 9999, 0, 0, 0, 1 );
- vis_crage = smoothlerp_range( this.timer, 0, 1, 3, 5 );
- if( vis_crage )
- {
- draw_tex_color_rect_wh( 0, -this.timer * 10, 1024, 1024, this.back_tex, 1, 1, 1, vis_crage );
- draw_tex_color_box_wh( W / 2, H / 2.1, this.crage_tex.width, this.crage_tex.height, this.crage_tex, 1, 1, 1, vis_crage );
- }
- return this.timer > 5;
- }
- global EndLevelScreen = {};
- function EndLevelScreen.create( params )
- {
- data =
- {
- level = params.level,
- timer = 0,
- back_tex = create_texture( "ui/flare_bg.png", "hrepeat,vrepeat" ),
- };
- Game.OverlayScreenNeedsBgr = false; // hacky hacky
- return class( data, EndLevelScreen );
- }
- function EndLevelScreen.on_event( e )
- {
- // inhibit all events
- return false;
- }
- function EndLevelScreen.draw( delta )
- {
- this.timer += delta;
- vis_background = smoothlerp_range( this.timer, 0, 3, 7, 8 );
- if( vis_background )
- {
- draw_color_rect_wh( 0, 0, 9999, 9999, 0, 0, 0, vis_background );
- }
- vis_text = smoothlerp_range( this.timer, 0, 3, 5, 7 );
- if( vis_text )
- {
- draw_tex_color_rect_wh( 0, -this.timer * 10, 1024, 1024, this.back_tex, 1, 1, 1, vis_text );
- draw_text_rect( "LEVEL COMPLETE\n\n\nLOADING...", g_GameFont, [1,1,1,vis_text], DT_CENTER | DT_VCENTER, 128, W - 128, 128, H - 128 );
- }
- if( this.timer > 7 )
- {
- Game.OverlayScreenNeedsBgr = true;
- Game.Start( this.level );
- }
- return this.timer > 7;
- }
- global EndGameScreen = {};
- function EndGameScreen.create()
- {
- data =
- {
- timer = 0,
- back_tex = create_texture( "ui/flare_bg.png", "hrepeat,vrepeat" ),
- };
- Game.OverlayScreenNeedsBgr = false; // hacky hacky
- return class( data, EndGameScreen );
- }
- function EndGameScreen.on_event( e )
- {
- // inhibit all events
- return false;
- }
- function EndGameScreen.draw( delta )
- {
- this.timer += delta;
- vis_background = smoothlerp_range( this.timer, 0, 3, 7, 8 );
- if( vis_background )
- {
- draw_color_rect_wh( 0, 0, 9999, 9999, 0, 0, 0, vis_background );
- }
- vis_text = smoothlerp_range( this.timer, 0, 3, 5, 7 );
- if( vis_text )
- {
- draw_tex_color_rect_wh( 0, -this.timer * 10, 1024, 1024, this.back_tex, 1, 1, 1, vis_text );
- draw_text_rect( "MISSION COMPLETE\n\n\nTHANK YOU FOR PLAYING!\n\n\n\nTO BE CONTINUED...?", g_GameFont, [1,1,1,vis_text], DT_CENTER | DT_VCENTER, 128, W - 128, 128, H - 128 );
- }
- if( this.timer > 7 )
- {
- Game.OverlayScreenNeedsBgr = true;
- Game.End(); // hacky hacky
- }
- return this.timer > 7;
- }
- global ConfirmationScreen = {};
- function ConfirmationScreen.create( params )
- {
- callback = params.callback;
- data =
- {
- question = params.question,
- callback = callback,
- };
- data.menu = GameMenu.create
- ([
- { text = "Yes", action = function() use(data){ data.callback( true ); data.menu = null; } },
- { text = "No", action = function() use(data){ data.callback( false ); data.menu = null; } },
- ],
- { x = 384, width = 256, y = 384 });
- data.menu.mouseon = 1;
- return class( data, ConfirmationScreen );
- }
- function ConfirmationScreen.on_event( e )
- {
- if( this.menu )
- this.menu.on_event( e );
- // inhibit all events
- return false;
- }
- function ConfirmationScreen.draw( delta )
- {
- if( !this.menu )
- return true;
- draw_color_rect_wh( 0, 0, 9999, 9999, 0.2, 0.2, 0.2, 0.5 );
- draw_text_rect( this.question, g_GameFont, [1,1,1], DT_CENTER | DT_VCENTER, 128, W - 128, 128, H/2 );
- this.menu.draw( delta );
- }
- global NotificationScreen = {};
- function NotificationScreen.create( params )
- {
- data =
- {
- title = params.title,
- text = params.text,
- };
- data.menu = GameMenu.create
- ([
- { text = "OK", action = function() use(data){ data.menu = null; } },
- ],
- { x = 384, width = 256, y = 480 });
- data.menu.mouseon = 0;
- return class( data, NotificationScreen );
- }
- function NotificationScreen.on_event( e )
- {
- if( this.menu )
- this.menu.on_event( e );
- // inhibit all events
- return false;
- }
- function NotificationScreen.draw( delta )
- {
- if( !this.menu )
- return true;
- draw_color_rect_wh( 0, 0, 9999, 9999, 0.2, 0.2, 0.2, 0.5 );
- draw_text_rect( this.title, g_GameFont, [1,1,1], DT_CENTER | DT_VCENTER, 128, W - 128, 192, 256 );
- draw_text_rect( this.text, g_TextFont, [1,1,1], DT_LEFT | DT_TOP, 128, W - 128, 256, H*3/4 );
- this.menu.draw( delta );
- }
- global MenuScreen = {};
- function MenuScreen.create( params )
- {
- data =
- {
- title = params.title,
- };
- if( isset( params, "params" ) )
- prm = clone( params.params );
- else
- prm = {};
- prm.width = 256;
- prm.x = 384;
- prm.y = 520 - 32 * params.options.size;
- data.menu = GameMenu.create( params.options, prm );
- data.menu.mouseon = 0;
- if( isset( params, "default" ) )
- data.menu.mouseon = params.default;
- return class( data, MenuScreen );
- }
- function MenuScreen.on_event( e )
- {
- if( this.menu )
- this.menu.on_event( e );
- // inhibit all events
- return false;
- }
- function MenuScreen.draw( delta )
- {
- if( !this.menu )
- return true;
- draw_color_rect_wh( 0, 0, 9999, 9999, 0.2, 0.2, 0.2, 0.5 );
- draw_text_rect( this.title, g_GameFont, [1,1,1], DT_CENTER | DT_VCENTER, 128, W - 128, 128, H/2 );
- this.menu.draw( delta );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement