Advertisement
diddlside

Untitled

Jun 1st, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.42 KB | None | 0 0
  1. class Titlescreen < Scene_Base
  2.   def initialize
  3.         super
  4.         @index = 0
  5.         create_nav_points
  6.         update_background
  7.         create_background
  8.   end
  9.      
  10.   def start
  11.     $data_system.title_bgm.play
  12.     RPG::BGS.stop
  13.     RPG::ME.stop
  14.   end
  15.      
  16.   def transition_speed
  17.     return 15
  18.   end
  19.  
  20.   def update
  21.       super
  22.       Graphics.frame_reset
  23.       create_nav_points
  24.       process_cursor_move
  25.       process_handling
  26.       update_background
  27.   end
  28.      
  29.   def create_nav_points
  30.     points = {
  31.       0 => {
  32.           "title" => "Neues Spiel",
  33.           "icon" => "main_menu_new",
  34.       },
  35.       1 => {
  36.           "title" => "Spiel laden",
  37.           "icon" => "main_menu_continue",
  38.       },
  39.       2 => {
  40.           "title" => "Beenden",
  41.           "icon" => "main_menu_exit",
  42.       }
  43.     }
  44.  
  45.     @box_list = [];
  46.     count = points.length
  47.     points.each { |key,value|
  48.       x = ((640/count) - 40) * key;
  49.       y = 240
  50.       @box_list[key] = create_point key,value,count,x,y
  51.     }
  52.   end
  53.  
  54.   def create_point(key,point,count,x,y)
  55.      
  56.       nav_point = {}
  57.       nav_point['bg'] = Sprite.new
  58.       nav_point['bg'].bitmap = Bitmap.new 640,480
  59.       nav_point['bg'].bitmap.gradient_fill_rect(
  60.                             x + 20, y, 160, 160,
  61.                             Color.new(54,54,54),
  62.                             Color.new(0,0,0),0)
  63.                            
  64.       nav_point['title'] = Sprite.new
  65.       nav_point['title'].bitmap = Bitmap.new 640,480
  66.       nav_point['title'].bitmap.draw_text(x + 20, y + 30, 160, 160,
  67.       point['title'],1)
  68.      
  69.       nav_point['icon'] = Sprite.new
  70.       nav_point['icon'].bitmap = Cache.picture point['icon']
  71.       nav_point['icon'].x = x + 70
  72.       nav_point['icon'].y = y + 30
  73.      
  74.       nav_point
  75.     end
  76.    
  77.   def create_background
  78.     @sprite = Sprite.new
  79.     whitescreen = Bitmap.new(640,480);
  80.     whitescreen.fill_rect(0,0,640,480,Color.new(255,255,255))
  81.     @sprite.bitmap = whitescreen
  82.    
  83.    
  84.     @sprite3 = Sprite.new
  85.     @sprite3.bitmap = Cache.title1("logo")
  86.   end
  87.      
  88.   def process_cursor_move
  89.     cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
  90.     cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
  91.   end
  92.  
  93.   def update_background
  94.     @box_list.each_with_index do |point,index|
  95.       x = ((640/@box_list.length) - 40) * index;
  96.       y = 240
  97.       @box_list[index]['bg'].bitmap.clear
  98.       @box_list[index]['bg'].bitmap.gradient_fill_rect(
  99.                             x + 20, y, 160, 160,
  100.                             Color.new(54,54,54),
  101.                             Color.new(0,0,0),0)
  102.       end
  103.                          
  104.       x = ((640/@box_list.length) - 40) * @index;
  105.       y = 240
  106.       @box_list[@index]['bg'].bitmap.clear
  107.       @box_list[@index]['bg'].bitmap.fill_rect(
  108.                             x + 20, y, 160, 160,
  109.                             Color.new(177,0,0))
  110.   end
  111.  
  112.   def cursor_right trigger
  113.     @index += 1
  114.     if @index >= @box_list.length
  115.       @index = 0
  116.     end
  117.     Sound.play_cursor
  118.   end
  119.  
  120.   def cursor_left trigger
  121.     @index -= 1
  122.     if @index < 0
  123.       @index  = (@box_list.length - 1)
  124.     end
  125.     Sound.play_cursor
  126.   end
  127.  
  128.   def process_handling
  129.     return process_ok if Input.trigger?(:C)
  130.   end
  131.  
  132.   def process_ok
  133.     if @index == 1
  134.    
  135.     end
  136.     if @index == 2
  137.    
  138.     end
  139.     if @index == 3
  140.    
  141.     end
  142.   end
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement