qq240559043
干就完了
級別: 略有小成
|
圖片:
圖片:
圖片:
//**********************************************************開始游戲 if start == true and snake_len == 0 then snake_pos_x[0] = 9 snake_pos_y[0] = 9 snake_len = 1 //繪制小蛇 for index = 0 to snake_len - 1 snake_index = snake_pos_y[index] * 20 + snake_pos_x[index] SetData(ON, "Local HMI", LB, snake_index, 1) next SetData(ON, "Local HMI", LB, 2000, 1) end if //**********************************************************暫停游戲 if stop then SetData(OFF, "Local HMI", LB, 1001, 1) SetData(OFF, "Local HMI", LB, 1002, 1) start = false end if if snake_len > 0 and start == true then ////********************************************************** ////**********************************************小蛇向上移動 ////********************************************************** if snake_UP == true and snake_DOWN == false then //清除小蛇 for index = 0 to snake_len-1 snake_index = snake_pos_y[index] * 20 + snake_pos_x[index] SetData(OFF, "Local HMI", LB, snake_index, 1) next //蛇頭撞墻 if snake_pos_y[0] == 0 then game_over = true SetData(ON, "Local HMI", LB, 2010, 1) else snake_len1 = snake_len-1 snake_tail_pos_x = snake_pos_x[snake_len1] snake_tail_pos_y = snake_pos_y[snake_len1] snake_head_pos_x = snake_pos_x[0] snake_head_pos_y = snake_pos_y[0] - 1 |
---|---|
|