本帖最后由 mskimizd 于 2012-5-2 19:18 编辑
("snake", 0, mesh_load_window, [
(ti_on_presentation_load,
[
(presentation_set_duration, 999999),
(set_fixed_point_multiplier, 1000),
(assign,"$coordinate_x",500),
(assign,"$coordinate_y",500),
(assign,"$div_old",0),
(assign,"$direction",2),
(assign,"$food_is_empty",1),
(create_mesh_overlay, "$g_presentation_obj_23", "mesh_white_plane"),
(overlay_set_color, "$g_presentation_obj_23", 0),
(position_set_x, pos1, 50000),
(position_set_y, pos1, 40000),
(overlay_set_size, "$g_presentation_obj_23", pos1),
(create_mesh_overlay,"$g_presentation_credits_obj_1","mesh_white_plane"),
(create_mesh_overlay,"$g_presentation_credits_obj_2","mesh_white_plane"),
(create_mesh_overlay,"$g_presentation_credits_obj_3","mesh_white_plane"),
(create_mesh_overlay,"$g_presentation_credits_obj_4","mesh_white_plane"),
(position_set_x,pos1,0),
(position_set_y,pos1,0),
(overlay_set_position,"$g_presentation_credits_obj_1",pos1),
(position_set_x,pos1,1000),
(position_set_y,pos1,40000),
(overlay_set_size,"$g_presentation_credits_obj_1",pos1),
(position_set_x,pos1,0),
(position_set_y,pos1,725),
(overlay_set_position,"$g_presentation_credits_obj_2",pos1),
(position_set_x,pos1,40000),
(position_set_y,pos1,1300),
(overlay_set_size,"$g_presentation_credits_obj_2",pos1),
(position_set_x,pos1,0),
(position_set_y,pos1,0),
(overlay_set_position,"$g_presentation_credits_obj_3",pos1),
(position_set_x,pos1,40000),
(position_set_y,pos1,1000),
(overlay_set_size,"$g_presentation_credits_obj_3",pos1),
(position_set_x,pos1,800),
(position_set_y,pos1,0),
(overlay_set_position,"$g_presentation_credits_obj_4",pos1),
(position_set_x,pos1,1000),
(position_set_y,pos1,40000),
(overlay_set_size,"$g_presentation_credits_obj_4",pos1),
(create_text_overlay,"$g_presentation_obj_3","@SCORE: 0",tf_center_justify|tf_with_outline),
(overlay_set_color, "$g_presentation_obj_3", 0xFFFFFFFF),
(position_set_x, pos1, 900),
(position_set_y, pos1, 400),
(overlay_set_position, "$g_presentation_obj_3", pos1),
(create_slider_overlay, "$g_presentation_credits_obj_6", 1,5),
(store_div,reg10,500,"$speed"),
(overlay_set_val, "$g_presentation_credits_obj_6",reg10),
(position_set_x, pos1, 950),
(position_set_y, pos1, 310),
(overlay_set_position, "$g_presentation_credits_obj_6", pos1),
(position_set_x, pos1, 500),
(position_set_y, pos1, 500),
(overlay_set_size, "$g_presentation_credits_obj_6", pos1),
(create_text_overlay,"$g_presentation_credits_obj_8","@SPEED:{reg10}",tf_center_justify|tf_with_outline),
(overlay_set_color, "$g_presentation_credits_obj_8", 0xFFFFFFFF),
(position_set_x, pos1, 900),
(position_set_y, pos1, 350),
(overlay_set_position, "$g_presentation_credits_obj_8", pos1),
(create_slider_overlay, "$g_presentation_credits_obj_7", 5,10),
(assign,reg11,"$node"),
(overlay_set_val, "$g_presentation_credits_obj_7",reg11),
(position_set_x, pos1, 950),
(position_set_y, pos1, 210),
(overlay_set_position, "$g_presentation_credits_obj_7", pos1),
(position_set_x, pos1, 500),
(position_set_y, pos1, 500),
(overlay_set_size, "$g_presentation_credits_obj_7", pos1),
(create_text_overlay,"$g_presentation_credits_obj_9","@NODE:{reg11}",tf_center_justify|tf_with_outline),
(overlay_set_color, "$g_presentation_credits_obj_9", 0xFFFFFFFF),
(position_set_x, pos1, 900),
(position_set_y, pos1, 250),
(overlay_set_position, "$g_presentation_credits_obj_9", pos1),
(create_game_button_overlay, "$g_presentation_credits_obj_10", "@START", 0),
(position_set_x, pos1, 900),
(position_set_y, pos1, 150),
(overlay_set_position, "$g_presentation_credits_obj_10", pos1),
(create_game_button_overlay, "$g_presentation_credits_obj_11", "@PAUSE", 0),
(position_set_x, pos1, 900),
(position_set_y, pos1, 90),
(overlay_set_position, "$g_presentation_credits_obj_11", pos1),
(create_game_button_overlay, "$g_presentation_credits_obj_12", "@CONTINUE", 0),
(position_set_x, pos1, 900),
(position_set_y, pos1, 30),
(overlay_set_position, "$g_presentation_credits_obj_12", pos1),
(try_begin),
(eq,"$start",1),
(try_for_range,":slot_no",0,"$node"),
(create_mesh_overlay, "$g_presentation_obj_1", "mesh_white_plane"),
(overlay_set_color, "$g_presentation_obj_1", 0x00ff00),
(position_set_x, pos1, "$coordinate_x"),
(position_set_y, pos1, "$coordinate_y"),
(overlay_set_position, "$g_presentation_obj_1", pos1),
(val_add,"$coordinate_x",23),
#(overlay_set_size, "$g_presentation_obj_1", pos1),## 1000 1390
(troop_set_slot,"trp_player",":slot_no","$g_presentation_obj_1"),
(try_end),
(try_end),
#(call_script, "script_presentation_load"),
]),
(ti_on_presentation_event_state_change,
[
(store_trigger_param_1, ":object"),
(store_trigger_param_2, ":value"),
(try_begin),
(eq,":object", "$g_presentation_credits_obj_6"),
(store_div,"$speed",500,":value"),
(start_presentation, "prsnt_snake"),
(else_try),
(eq,":object", "$g_presentation_credits_obj_7"),
(assign,"$node",":value"),
(start_presentation, "prsnt_snake"),
(else_try),
(eq,":object", "$g_presentation_credits_obj_10"),
(assign,"$start",1),
(assign,"$snake_score",0),
(start_presentation, "prsnt_snake"),
(else_try),
(eq,":object", "$g_presentation_credits_obj_11"),
(neq,"$pause",2),
(assign,"$pause",1),
(else_try),
(eq,":object", "$g_presentation_credits_obj_12"),
(eq,"$pause",1),
(assign,"$pause",0),
(try_end),
]),
(ti_on_presentation_run,
[
(set_fixed_point_multiplier, 1000),
#(call_script, "script_presentation_run"),
(store_trigger_param_1, ":cur_time"),
(assign,reg39, ":cur_time"),
(store_div,":div",":cur_time","$speed"),#250
(try_begin),
(eq,"$start",1),
(gt,":div",0),
(store_sub,":sub",":div","$div_old"),
(eq,":sub",1),
(assign,"$div_old",":div"),
(eq,"$pause",0),
(try_for_range_backwards,":slot_no",0,"$node"),
(store_sub,":next_obj",":slot_no",1),
(ge,":next_obj",0),
(troop_get_slot,"$g_presentation_obj_1","trp_player",":next_obj"),
(overlay_get_position, pos1, "$g_presentation_obj_1"),
(troop_get_slot,"$g_presentation_obj_2","trp_player",":slot_no"),
(overlay_set_position,"$g_presentation_obj_2", pos1),
(troop_set_slot,"trp_player",":slot_no","$g_presentation_obj_2"),
(try_end),
(troop_get_slot,"$g_presentation_obj_1","trp_player",0),
(overlay_get_position, pos1, "$g_presentation_obj_1"),
(position_get_x, ":x", pos1),
(position_get_y, ":y", pos1),
(try_begin),
(eq,"$direction",1),
(val_add,":y",25),
(else_try),
(eq,"$direction",-1),
(val_add,":y",-25),
(else_try),
(eq,"$direction",2),
(val_add,":x",-25),
(else_try),
(eq,"$direction",-2),
(val_add,":x",25),
(try_end),
(position_set_x, pos1, ":x"),
(position_set_y, pos1, ":y"),
(overlay_set_position,"$g_presentation_obj_1", pos1),
(try_end),
(try_begin),
(eq,"$start",1),
(try_begin),
(key_clicked, key_up),
(neq,"$direction",-1),
(assign,"$direction",1),
(else_try),
(key_clicked, key_down),
(neq,"$direction",1),
(assign,"$direction",-1),
(else_try),
(key_clicked, key_left),
(neq,"$direction",-2),
(assign,"$direction",2),
(else_try),
(key_clicked, key_right),
(neq,"$direction",2),
(assign,"$direction",-2),
(try_end),
(try_end),
(try_begin),
(eq,"$start",1),
(eq,"$food_is_empty",1),
(store_random_in_range,":food_x",1,32),
(val_mul,":food_x",25),
(store_random_in_range,":food_y",1,29),
(val_mul,":food_y",25),
(create_mesh_overlay,"$g_presentation_credits_obj_5","mesh_white_plane"),
(overlay_set_color, "$g_presentation_credits_obj_5", 0xFFFF00),
(position_set_x,pos1,":food_x"),
(position_set_y,pos1,":food_y"),
(overlay_set_position,"$g_presentation_credits_obj_5",pos1),
(assign,"$food_is_empty",0),
(try_end),
(try_begin),
(eq,"$start",1),
(eq,"$food_is_empty",0),
(troop_get_slot,"$g_presentation_obj_1","trp_player",0),
(overlay_get_position, pos1, "$g_presentation_obj_1"),
(position_get_x, ":x", pos1),
(position_get_y, ":y", pos1),
(overlay_get_position, pos1, "$g_presentation_credits_obj_5"),
(position_get_x, ":food_x", pos1),
(position_get_y, ":food_y", pos1),
(eq,":x",":food_x"),
(eq,":y",":food_y"),
(create_mesh_overlay, "$g_presentation_obj_1", "mesh_white_plane"),
(overlay_set_color, "$g_presentation_obj_1", 0x00ff00),
#(troop_get_slot,"$g_presentation_obj_2","trp_player","$node"),
#(overlay_get_position, pos1, "$g_presentation_obj_2"),
#(overlay_set_position,"$g_presentation_obj_1", pos1),
(troop_set_slot,"trp_player","$node","$g_presentation_obj_1"),
(val_add,"$node",1),
(overlay_set_display,"$g_presentation_credits_obj_5",0),
(assign,"$food_is_empty",1),
(overlay_set_display,"$g_presentation_obj_3",0),
(val_add,"$snake_score",10),
(assign,reg15,"$snake_score"),
(create_text_overlay,"$g_presentation_obj_3","@SCORE:{reg15}",tf_center_justify|tf_with_outline),
(overlay_set_color, "$g_presentation_obj_3", 0xFFFFFFFF),
(position_set_x, pos1, 900),
(position_set_y, pos1, 400),
(overlay_set_position, "$g_presentation_obj_3", pos1),
(try_end),
(try_begin),
(eq,"$start",1),
(troop_get_slot,"$g_presentation_obj_1","trp_player",0),
(overlay_get_position, pos1, "$g_presentation_obj_1"),
(position_get_x, ":x_h", pos1),
(position_get_y, ":y_h", pos1),
(try_for_range,":slot_no",1,"$node"),
(troop_get_slot,"$g_presentation_obj_1","trp_player",":slot_no"),
(overlay_get_position, pos1, "$g_presentation_obj_1"),
(position_get_x, ":x_o", pos1),
(position_get_y, ":y_o", pos1),
(try_begin),
(eq,":x_h",":x_o"),
(eq,":y_h",":y_o"),
(display_message,"@OOPS!Snake is dead."),
(assign,"$start",0),
#(assign,"$pause",2),
(assign,"$node",5),
(start_presentation, "prsnt_snake"),
(try_end),
(try_end),
(try_begin),
(this_or_next|lt,":x_h",25),
(this_or_next|gt,":x_h",775),
(this_or_next|lt,":y_h",25),
(gt,":y_h",700),
(display_message,"@OOPS!Snake is dead."),
(assign,"$start",0),
#(assign,"$pause",2), # means the snake is dead, the move stop need the start again.
(assign,"$node",5),
(start_presentation, "prsnt_snake"),
(try_end),
(try_end),
(try_begin),
(this_or_next|key_clicked, key_escape),
(key_clicked, key_right_mouse_button),
(assign,"$start",0),
(presentation_set_duration, 0),
(jump_to_menu, "mnu_start_game_0"),
(else_try),
(key_clicked, key_p),
(try_begin),
(eq,"$pause",0),
(assign,"$pause",1),
(else_try),
(eq,"$pause",1),
(assign,"$pause",0),
(try_end),
(try_end),
]),
]),
还有一些初始化的代码,放在需要开始的菜单里
(assign,"$start",0),
(assign,"$pause",0),
(assign,"$node",5),
(assign,"$speed",500),
(assign,"$snake_score",0),
(start_presentation,"prsnt_snake"), |