首页 上一页 1 2 3 4 5 6 7 下一页 尾页

西门子1200贪吃蛇程序带触摸屏可仿真 点击:7035 | 回复:122



zeyao00

    
  • 精华:1帖
  • 求助:0帖
  • 帖子:10帖 | 115回
  • 年度积分:644
  • 历史总积分:8789
  • 注册:2018年4月13日
发表于:2019-11-19 14:57:43
楼主

西门子1200贪吃蛇 程序带触摸屏 可仿真 SCL 博图V14

正在下载,请等待……
下载附件需3积分!



楼主最近还看过



Lonely_99

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 2548回
  • 年度积分:0
  • 历史总积分:84
  • 注册:2014年10月29日
发表于:2019-11-19 15:05:15
1楼

谢谢楼主分享,已果断下载

回复本条

    

郭远林

  • [版主]
  • 精华:3帖
  • 求助:10帖
  • 帖子:114帖 | 2277回
  • 年度积分:87
  • 历史总积分:45769
  • 注册:2011年10月21日
发表于:2019-11-19 15:19:16
2楼

这个不错,我晚上测试一下,刚刚的,我看看能不能教我侠门玩玩

回复本条

    

AC米兰

  • 精华:0帖
  • 求助:0帖
  • 帖子:135帖 | 1088回
  • 年度积分:21
  • 历史总积分:5978
  • 注册:2016年4月23日
发表于:2019-11-21 10:18:29
3楼

回复内容:

对: 郭远林 这个不错,我晚上测试一下,刚刚的,我看看能不能教我侠门玩玩 内容的回复!

-------------------------


回复本条

    

AC米兰

  • 精华:0帖
  • 求助:0帖
  • 帖子:135帖 | 1088回
  • 年度积分:21
  • 历史总积分:5978
  • 注册:2016年4月23日
发表于:2019-11-21 10:19:42
4楼

下载下来看看

回复本条

    

ju691031

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 2258回
  • 年度积分:0
  • 历史总积分:106
  • 注册:2010年7月16日
发表于:2019-11-21 20:22:10
5楼

下载下来看看

回复本条

    

IE5338

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 123回
  • 年度积分:0
  • 历史总积分:0
  • 注册:1900年1月01日
发表于:2019-11-22 12:06:37
6楼


估计现在这程序都没人自己重新编程,都是复制粘贴过来的



macro_command main()
bool Line_one[16],Line_two[16],Line_three[16],Line_four[16],Line_five[16],Line_six[16]
bool Line_seven[16],Line_eight[16],Line_nine[16],Line_ten[16],Line_eleven[16],Line_twelve[16]
bool Line_thirteen[16],Line_fourteen[16],Line_fifteen[16],Line_sixteen[16],Line_seventeen[16]
bool Line_eighteen[16],Line_nineteen[16],Line_twenty[16]
bool Line_matrix[320],display_matrix[320],snake_matrix[320]
bool new_game,start_flag,pause_flag,new_game_button,run_game
bool true_bool = true,false_bool = false
bool up_control,down_control,left_control,right_control
bool up_flag,down_flag,left_flag,right_flag
bool game_over=false,eat_flag
short start_rand,start_pos,next_rand,next_point,snake_point[320],snake_length,index,snake_last_point[320]
short speed,score,best_score,flash_index,search_snake
short snake_end,pre_direction
float start_point,start_float
short snake_first,snake_last
GetData(new_game, "Local HMI", LB, 2, 1)
GetData(start_flag, "Local HMI", LB, 0, 1)
GetData(pause_flag, "Local HMI", LB, 1, 1)
GetData(up_control, "Local HMI", LB, 3, 1)
GetData(right_control, "Local HMI", LB, 4, 1)
GetData(down_control, "Local HMI", LB, 5, 1)
GetData(left_control, "Local HMI", LB, 6, 1)
GetData(speed, "Local HMI", RW, 28, 1)
GetData(best_score, "Local HMI", RW, 21, 1)
//GetData(Line_one[0], "Local HMI", RW_Bit, 0.0, 16)
//GetData(Line_two[0], "Local HMI", RW_Bit, 1.0, 16)
//GetData(Line_three[0], "Local HMI", RW_Bit, 2.0, 16)
//GetData(Line_four[0], "Local HMI", RW_Bit, 3.0, 16)
//GetData(Line_five[0], "Local HMI", RW_Bit, 4.0, 16)
//GetData(Line_six[0], "Local HMI", RW_Bit, 5.0, 16)
//GetData(Line_seven[0], "Local HMI", RW_Bit, 6.0, 16)
//GetData(Line_eight[0], "Local HMI", RW_Bit, 7.0, 16)
//GetData(Line_nine[0], "Local HMI", RW_Bit, 8.0, 16)
//GetData(Line_ten[0], "Local HMI", RW_Bit, 9.0, 16)
//GetData(Line_eleven[0], "Local HMI", RW_Bit, 10.0, 16)
//GetData(Line_twelve[0], "Local HMI", RW_Bit, 11.0, 16)
//GetData(Line_thirteen[0], "Local HMI", RW_Bit, 12.0, 16)
//GetData(Line_fourteen[0], "Local HMI", RW_Bit, 13.0, 16)
//GetData(Line_fifteen[0], "Local HMI", RW_Bit, 14.0, 16)
//GetData(Line_sixteen[0], "Local HMI", RW_Bit, 15.0, 16)
//GetData(Line_seventeen[0], "Local HMI", RW_Bit, 16.0, 16)
//GetData(Line_eighteen[0], "Local HMI", RW_Bit, 17.0, 16)
//GetData(Line_nineteen[0], "Local HMI", RW_Bit, 18.0, 16)
//GetData(Line_twenty[0], "Local HMI", RW_Bit, 19.0, 16)
GetData(Line_matrix[0], "Local HMI", RW_Bit, 0.0, 320)
if new_game and not game_over then
 game_over = false
 score = 0
 snake_length = 1
 eat_flag = false
 SetData(false_bool, "Local HMI", LB, 100, 1)
 FILL(Line_matrix[0], 0, 320)
 FILL(display_matrix[0], 0, 320)
 FILL(snake_matrix[0],0,320)
 FILL(snake_last_point[0],0,320)
 FILL(snake_point[0],0,320)
 SetData(Line_matrix[0], "Local HMI", RW_Bit, 0.0, 320) 
 SetData(display_matrix[0], "Local HMI", RW_Bit, 30.0, 320) 
 new_game_button = true
 run_game = true
 new_game = false
 down_flag = true
 pre_direction = 2 
 
end if
if new_game_button and not new_game then  
 RAND(start_rand)
 start_pos = start_rand/100 
 if start_pos>=320 then
  start_pos = 319
 end if
 snake_first = start_pos
 RAND(next_rand)
 next_point = next_rand/100
 if next_point>=320 then
  next_point = 319
 end if
 snake_point[start_pos] = 1
 Line_matrix[start_pos] = true
 display_matrix[start_pos] = true
 display_matrix[next_point] = true
 SetData(Line_matrix[0], "Local HMI", RW_Bit, 0.0, 320) 
 SetData(display_matrix[0], "Local HMI", RW_Bit, 30.0, 320) 
 new_game_button = false
 DELAY(50)
end if
if start_flag then
 run_game = true
end if
if pause_flag then
 run_game = false
end if
if up_control and pre_direction<>2 then
 up_flag = up_control
 down_flag = false
 left_flag = false
 right_flag = false
 pre_direction = 1
 TRACE("pre_direction=%d",pre_direction)
else if down_control and pre_direction<>1 then
 down_flag = down_control
 up_flag = false
 left_flag = false
 right_flag = false
 pre_direction = 2
 TRACE("pre_direction=%d",pre_direction)
else if left_control and pre_direction<>4 then
 left_flag = left_control
 up_flag = false
 down_flag = false
 right_flag = false
 pre_direction = 3
 TRACE("pre_direction=%d",pre_direction)
else if right_control and pre_direction<>3 then
 right_flag = right_control
 up_flag = false
 down_flag = false
 left_flag = false
 pre_direction = 4
 TRACE("pre_direction=%d",pre_direction)
end if
if run_game then 
 if up_flag then
  Line_matrix[start_pos] = false
  display_matrix[start_pos] = false
  if start_pos>15 then
   if not eat_flag then
    snake_end = start_pos
    if snake_length>=2 then
     for flash_index = 0 to 319 step 1
      snake_point[flash_index] = snake_last_point[flash_index]
     next flash_index
    end if
    start_pos = start_pos - 16
    snake_point[start_pos] = 1
    snake_point[snake_end] = 0
    TRACE("snake_length=%d",snake_length)
   else if eat_flag and snake_length == 1 then
    snake_end = start_pos
    eat_flag = false
    snake_last_point[snake_end] = 1
    start_pos = start_pos - 16
    snake_first = start_pos
    snake_point[snake_end] = snake_last_point[snake_end]
    snake_point[start_pos] = 1
    snake_last = snake_end
    snake_length = snake_length + 1 
    TRACE("snake_end=%d",snake_end)
    TRACE("start_pos=%d",start_pos)
    TRACE("snake_length=%d",snake_length)
   else if eat_flag and snake_length <> 1 then
    for flash_index = 0 to 319 step 1
     snake_point[flash_index] = snake_last_point[flash_index]
    next flash_index
    start_pos = start_pos - 16
    snake_first = start_pos 
    snake_point[start_pos] = 1
    eat_flag = false
    snake_length = snake_length + 1
    TRACE("snake_end=%d",snake_end)
    TRACE("start_pos=%d",start_pos)
    TRACE("snake_length=%d",snake_length)    
   end if      
  else if start_pos<=15 then
   game_over = true 
  end if
  for search_snake = 0 to 319 step 1
   if snake_point[search_snake] == 1 then
    Line_matrix[search_snake] = true
    display_matrix[search_snake] = true 
    TRACE("snake_point[search_snake]=%d",snake_point[search_snake])
    TRACE("search_snake=%d",search_snake)
   end if
  next search_snake
  
  //for flash_index = 0 to 319 step 1
  // snake_last_point[flash_index] = snake_point[flash_index]
  //next flash_index
 else if down_flag then
  Line_matrix[start_pos] = false
  display_matrix[start_pos] = false
  if start_pos<=303 then
   start_pos = start_pos + 16
  else if start_pos>303 then
   game_over = true
  end if
  Line_matrix[start_pos] = true
  display_matrix[start_pos] = true
  //for flash_index = 0 to 319 step 1
  // snake_last_point[flash_index] = snake_point[flash_index]
  //next flash_index
 else if left_flag then
  Line_matrix[start_pos] = false
  display_matrix[start_pos] = false
  if start_pos<>0 and start_pos<>16 and start_pos<>32 and start_pos<>48 and start_pos<>64 and start_pos<>80 and start_pos<>96 and start_pos<>112 and start_pos<>128 and start_pos<>144 and start_pos<>160 and start_pos<>176 and start_pos<>192 and start_pos<>208 and start_pos<>224 and start_pos<>240 and start_pos<>256 and start_pos<>272 and start_pos<>288 and start_pos<>304 then
   start_pos = start_pos - 1
  else if start_pos==0 or start_pos==16 or start_pos==32 or start_pos==48 or start_pos==64 or start_pos==80 or start_pos==96 or start_pos==112 or start_pos==128 or start_pos==144 or start_pos==160 or start_pos==176 or start_pos==192 or start_pos==208 or start_pos==224 or start_pos==240 or start_pos==256 or start_pos==272 or start_pos==288 or start_pos==304 then
   game_over = true  
  end if
  Line_matrix[start_pos] = true
  display_matrix[start_pos] = true
  //for flash_index = 0 to 319 step 1
  // snake_last_point[flash_index] = snake_point[flash_index]
  //next flash_index
 else if right_flag then
  Line_matrix[start_pos] = false
  display_matrix[start_pos] = false
  if start_pos<>15 and start_pos<>31 and start_pos<>47 and start_pos<>63 and start_pos<>79 and start_pos<>95 and start_pos<>111 and start_pos<>127 and start_pos<>143 and start_pos<>159 and start_pos<>175 and start_pos<>191 and start_pos<>207 and start_pos<>223 and start_pos<>239 and start_pos<>255 and start_pos<>271 and start_pos<>287 and start_pos<>303 and start_pos<>319 then
   start_pos = start_pos + 1
  else if start_pos==15 or start_pos==31 or start_pos==47 or start_pos==63 or start_pos==79 or start_pos==95 or start_pos==111 or start_pos==127 or start_pos==143 or start_pos==159 or start_pos==175 or start_pos==191 or start_pos==207 or start_pos==223 or start_pos==239 or start_pos==255 or start_pos==271 or start_pos==287 or start_pos==303 or start_pos==319 then
   game_over = true
  end if
  Line_matrix[start_pos] = true
  display_matrix[start_pos] = true
  //for flash_index = 0 to 319 step 1
  // snake_last_point[flash_index] = snake_point[flash_index]
  //next flash_index
 end if
 if next_point == start_pos then
  RAND(next_rand)
  next_point = next_rand/100
  if next_point>=320 then
   next_point = 318
  end if
  display_matrix[next_point] = true
  SetData(display_matrix[0], "Local HMI", RW_Bit, 30.0, 320)
  score = score + 1
  SetData(score, "Local HMI", RW, 20, 1)
  eat_flag = true
 end if
 if score>best_score then
  best_score = score
  SetData(score, "Local HMI", RW, 21, 1)
 end if
 SetData(Line_matrix[0], "Local HMI", RW_Bit, 0.0, 320) 
 SetData(display_matrix[0], "Local HMI", RW_Bit, 30.0, 320) 
 //DELAY(speed)
end if
if game_over then
 run_game = false
 SetData(true_bool, "Local HMI", LB, 100, 1)
end if
end macro_command


回复本条

    

IE5338

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 123回
  • 年度积分:0
  • 历史总积分:0
  • 注册:1900年1月01日
发表于:2019-11-22 12:07:10
7楼

sub short RAND_num(short para)
RAND(para)
return para
end sub
macro_command main()
bool button_flag[3],game_run,game_over,game_pause,game_init,eat_flag,bool_true = true,bool_false = false
bool display_snake[320],display_init[320]
short direction,pro_direction,get_dir,init_dir = 1
short snake_head_p,snake_cell_p,snake_body_p[318]
short snake_martix[320],snake_pre_martix[320]
short score,best_score,snake_length,speed
short start_rand,next_rand,next_point
short init_index,display_index,count_index,length_index
short temp_body,temp_next_body,temp_last_body
GetData(get_dir, "Local HMI", LW, 0, 1)
GetData(button_flag[0], "Local HMI", LB, 0, 3)
GetData(speed, "Local HMI", RW, 28, 1)
if get_dir==1 and pro_direction<>2 then
 direction = 1
 pro_direction = 1
else if get_dir==2 and pro_direction<>1 then
 direction = 2
 pro_direction = 2
else if get_dir==3 and pro_direction<>4 then
 direction = 3
 pro_direction = 3
else if get_dir==4 and pro_direction<>3 then
 direction = 4
 pro_direction = 4
end if
if button_flag[2] then
 score = 0
 SetData(score, "Local HMI", RW, 20, 1)
 snake_length = 3
 SetData(bool_false, "Local HMI", LB, 100, 1)
 FILL(display_snake[0],0,320)
 FILL(display_init[0],0,320)
 FILL(snake_martix[0],0,320)
 FILL(snake_pre_martix[0],0,320)
 eat_flag = false
 game_over = false
 game_pause = false  
 game_init = true
end if
if game_init and not button_flag[2] then
 RAND(start_rand)
 if start_rand >= 32000 then
  RAND(start_rand)
 end if
 snake_head_p = start_rand/100
 if snake_head_p%16 > 2 then
  snake_body_p[0] = snake_head_p - 1
  snake_cell_p = snake_head_p - 2
  init_dir = 4
  SetData(init_dir, "Local HMI", LW, 0, 1)
  direction = 4
  pro_direction = 4
 else if snake_head_p%16 <= 2 then
  snake_body_p[0] = snake_head_p + 1
  snake_cell_p = snake_head_p + 2
  init_dir = 3
  SetData(init_dir, "Local HMI", LW, 0, 1)
  direction = 3
  pro_direction = 3
 end if
 RAND(next_rand)
 next_point = next_rand/100
 if next_point >= 320 or next_point == snake_head_p or next_point == snake_body_p[0] or next_point == snake_cell_p then
  RAND(next_rand)
 end if
 next_point = next_rand/100
 display_init[next_point] = true
 for init_index = 0 to 319 step 1
  if init_index == snake_head_p or init_index == snake_body_p[0] or init_index == snake_cell_p then
   snake_martix[init_index] = 1
   display_snake[init_index] = true
   display_init[init_index] = true
   SetData(display_snake[0], "Local HMI", RW_Bit, 0.0, 320)
   SetData(display_init[0], "Local HMI", RW_Bit, 30.0, 320)
  end if
  snake_pre_martix[init_index] = snake_martix[init_index]
 next init_index
 game_run = true
 game_init = false
 DELAY(80) 
end if
if game_run then
 if direction == 1 then
  if snake_head_p > 15 then
   if not eat_flag then
    snake_pre_martix[snake_cell_p] = 0
    snake_cell_p = snake_body_p[0]
    if snake_length>3 then
     for length_index = 0 to snake_length-4 step 1
      //temp_last_body = length_index + 4
      temp_next_body = length_index + 1
      snake_body_p[length_index] = snake_body_p[temp_next_body]
      //if temp_next_body == 1 then
      // break
      //end if
     next length_index
    end if
    temp_body = snake_length-3
    snake_body_p[temp_body] = snake_head_p
    snake_head_p = snake_head_p - 16
   else if eat_flag then
    for length_index = 3 to 318 step 1
     if length_index == snake_length then
      temp_body = snake_length-3
      snake_body_p[temp_body] = snake_head_p
      snake_head_p = snake_head_p - 16
      eat_flag = false
      TRACE("length_index=%d",length_index)
      TRACE("snake_body_p[0]=%d",snake_body_p[temp_body])
      TRACE("snake_body_p[1]=%d",snake_body_p[temp_body])
      TRACE("snake_body_p[0]=%d",snake_body_p[0])
      break
     end if
    next length_index
    TRACE("snake_length=%d",snake_length)
   end if
   for count_index = 0 to 319 step 1
    snake_martix[count_index] = snake_pre_martix[count_index]
   next count_index
   snake_martix[snake_head_p] = 1
  else if snake_head_p <=15 then
   game_over = true
  end if
 else if direction == 2 then
  if snake_head_p <= 303 then
   if not eat_flag then
    snake_pre_martix[snake_cell_p] = 0
    snake_cell_p = snake_body_p[0]
    if snake_length>3 then
     for length_index = 0 to snake_length-4 step 1
      //temp_last_body = snake_length - 4
      temp_next_body = length_index + 1
      snake_body_p[length_index] = snake_body_p[temp_next_body]
     next length_index
    end if
    temp_body = snake_length-3
    snake_body_p[temp_body] = snake_head_p
    snake_head_p = snake_head_p + 16
    //snake_pre_martix[snake_cell_p] = 0
    //for length_index = snake_length down 3 step 1
    // temp_body = length_index-3
    // snake_cell_p = snake_body_p[temp_body]
    // snake_body_p[temp_body] = snake_head_p
    //next length_index
    //snake_head_p = snake_head_p + 16
   else if eat_flag then
    for length_index = 3 to 318 step 1
     if length_index == snake_length then
      temp_body = snake_length-3
      snake_body_p[temp_body] = snake_head_p
      snake_head_p = snake_head_p + 16
      eat_flag = false
      TRACE("length_index=%d",length_index)
      TRACE("snake_body_p[0]=%d",snake_body_p[temp_body])
      TRACE("snake_body_p[1]=%d",snake_body_p[temp_body])
      TRACE("snake_body_p[0]=%d",snake_body_p[0])
      break
     end if
    next length_index
   end if
   for count_index = 0 to 319 step 1
    snake_martix[count_index] = snake_pre_martix[count_index]
   next count_index
   snake_martix[snake_head_p] = 1
  else if snake_head_p > 303 then
   game_over = true
  end if
 else if direction == 3 then
  if snake_head_p<>0 and snake_head_p<>16 and snake_head_p<>32 and snake_head_p<>48 and snake_head_p<>64 and snake_head_p<>80 and snake_head_p<>96 and snake_head_p<>112 and snake_head_p<>128 and snake_head_p<>144 and snake_head_p<>160 and snake_head_p<>176 and snake_head_p<>192 and snake_head_p<>208 and snake_head_p<>224 and snake_head_p<>240 and snake_head_p<>256 and snake_head_p<>272 and snake_head_p<>288 and snake_head_p<>304 then 
   if not eat_flag then
    snake_pre_martix[snake_cell_p] = 0
    snake_cell_p = snake_body_p[0]
    if snake_length>3 then
     for length_index = 0 to snake_length-4 step 1
      //temp_last_body = snake_length - 4
      temp_next_body = length_index + 1
      snake_body_p[length_index] = snake_body_p[temp_next_body]
     next length_index
    end if
    temp_body = snake_length-3
    snake_body_p[temp_body] = snake_head_p
    snake_head_p = snake_head_p - 1
    
    //snake_pre_martix[snake_cell_p] = 0
    //for length_index = snake_length down 3 step 1
    // temp_body = length_index-3
    // snake_cell_p = snake_body_p[temp_body]
    // snake_body_p[temp_body] = snake_head_p
    //next length_index
    //snake_head_p = snake_head_p - 1
   else if eat_flag then
    for length_index = 3 to 318 step 1
     if length_index == snake_length then
      temp_body = snake_length-3
      snake_body_p[temp_body] = snake_head_p
      snake_head_p = snake_head_p - 1
      eat_flag = false
      TRACE("length_index=%d",length_index)
      TRACE("snake_body_p[0]=%d",snake_body_p[temp_body])
      TRACE("snake_body_p[1]=%d",snake_body_p[temp_body])
      TRACE("snake_body_p[0]=%d",snake_body_p[0])
      break
     end if
    next length_index
   end if      
   for count_index = 0 to 319 step 1
    snake_martix[count_index] = snake_pre_martix[count_index]
   next count_index
   snake_martix[snake_head_p] = 1
  else if snake_head_p==0 or snake_head_p==16 or snake_head_p==32 or snake_head_p==48 or snake_head_p==64 or snake_head_p==80 or snake_head_p==96 or snake_head_p==112 or snake_head_p==128 or snake_head_p==144 or snake_head_p==160 or snake_head_p==176 or snake_head_p==192 or snake_head_p==208 or snake_head_p==224 or snake_head_p==240 or snake_head_p==256 or snake_head_p==272 or snake_head_p==288 or snake_head_p==304 then
   game_over = true  
  end if
 else if direction == 4 then
  if snake_head_p<>15 and snake_head_p<>31 and snake_head_p<>47 and snake_head_p<>63 and snake_head_p<>79 and snake_head_p<>95 and snake_head_p<>111 and snake_head_p<>127 and snake_head_p<>143 and snake_head_p<>159 and snake_head_p<>175 and snake_head_p<>191 and snake_head_p<>207 and snake_head_p<>223 and snake_head_p<>239 and snake_head_p<>255 and snake_head_p<>271 and snake_head_p<>287 and snake_head_p<>303 and snake_head_p<>319 then
   if not eat_flag then
    snake_pre_martix[snake_cell_p] = 0
    snake_cell_p = snake_body_p[0]
    if snake_length>3 then
     for length_index = 0 to snake_length-4 step 1
      //temp_last_body = snake_length - 4
      temp_next_body = length_index + 1
      snake_body_p[length_index] = snake_body_p[temp_next_body]
     next length_index
    end if
    temp_body = snake_length-3
    snake_body_p[temp_body] = snake_head_p
    snake_head_p = snake_head_p + 1
    
    //snake_pre_martix[snake_cell_p] = 0
    //for length_index = snake_length down 3 step 1
    // temp_body = length_index-3
    // snake_cell_p = snake_body_p[temp_body]
    // snake_body_p[temp_body] = snake_head_p
    //next length_index
    //snake_head_p = snake_head_p + 1
   else if eat_flag then
    for length_index = 3 to 318 step 1
     if length_index == snake_length then
      temp_body = snake_length-3
      snake_body_p[temp_body] = snake_head_p
      snake_head_p = snake_head_p + 1
      eat_flag = false
      TRACE("length_index=%d",length_index)
      TRACE("snake_body_p[0]=%d",snake_body_p[temp_body])
      TRACE("snake_body_p[1]=%d",snake_body_p[temp_body])
      TRACE("snake_body_p[0]=%d",snake_body_p[0])
      break
     end if
    next length_index
   end if
   for count_index = 0 to 319 step 1
    snake_martix[count_index] = snake_pre_martix[count_index]
   next count_index
   snake_martix[snake_head_p] = 1

  else if snake_head_p==15 or snake_head_p==31 or snake_head_p==47 or snake_head_p==63 or snake_head_p==79 or snake_head_p==95 or snake_head_p==111 or snake_head_p==127 or snake_head_p==143 or snake_head_p==159 or snake_head_p==175 or snake_head_p==191 or snake_head_p==207 or snake_head_p==223 or snake_head_p==239 or snake_head_p==255 or snake_head_p==271 or snake_head_p==287 or snake_head_p==303 or snake_head_p==319 then
   game_over = true
  end if
 end if
 for display_index = 0 to 319 step 1
  //if display_index == snake_head_p or display_index == snake_body_p[0] or display_index == snake_cell_p then
  if snake_martix[display_index] == 1 then
   display_snake[display_index] = true
   display_init[display_index] = true
   //TRACE("snake_martix[display_index]=%d",snake_martix[display_index])
   //TRACE("display_index=%d",display_index)
  else if snake_martix[display_index] <> 1 then
   display_snake[display_index] = false
   display_init[display_index] = false 
  end if
  snake_pre_martix[display_index] = snake_martix[display_index]
 next display_index
 if next_point == snake_head_p then
  RAND(next_rand)
  next_point = next_rand/100
  if next_point >= 320 or next_point == snake_head_p or next_point == snake_body_p[0] or next_point == snake_cell_p then
   RAND(next_rand)
  end if
  next_point = next_rand/100
  snake_length = snake_length + 1
  eat_flag = true
  score = score + 1
  SetData(score, "Local HMI", RW, 20, 1)
 end if
 display_init[next_point] = true
 SetData(display_snake[0], "Local HMI", RW_Bit, 0.0, 320)
 SetData(display_init[0], "Local HMI", RW_Bit, 30.0, 320)
 if score>best_score then
  best_score = score
  SetData(score, "Local HMI", RW, 21, 1)
 end if
 DELAY(speed)
end if
if game_over then
 game_run = false
 SetData(bool_true, "Local HMI", LB, 100, 1)
 game_over = false
end if
if button_flag[0] then
 game_run = true
end if
if button_flag[1] then
 game_run = false
end if
end macro_command


回复本条

    

chxkdy001

  • 精华:0帖
  • 求助:0帖
  • 帖子:3帖 | 87回
  • 年度积分:8
  • 历史总积分:912
  • 注册:2013年1月17日
发表于:2019-11-22 21:02:56
8楼

谢谢分享了。

回复本条

    

都叫不好意思耽误了

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 40回
  • 年度积分:0
  • 历史总积分:102
  • 注册:2019年7月06日
发表于:2019-11-24 00:17:39
9楼

下载下来学习学习

回复本条

    

IE5338

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 123回
  • 年度积分:0
  • 历史总积分:0
  • 注册:1900年1月01日
发表于:2019-11-24 13:21:19
10楼

威纶HMI-贪吃蛇游戏-能不能申精??http://bbs.gongkong.com/D/201901/781402_1.shtml

分享一个应用宏指令制作的贪吃蛇游戏,http://bbs.gongkong.com/d/201512/651815_1.shtml 

回复本条

    

伟大古月

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 40回
  • 年度积分:0
  • 历史总积分:0
  • 注册:1900年1月01日
发表于:2019-11-24 21:37:25
11楼

感谢分享,下载看看

回复本条

    

snajdan111

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 21回
  • 年度积分:0
  • 历史总积分:997
  • 注册:2013年10月17日
发表于:2019-11-26 10:52:04
12楼

感谢分享,下载学习

回复本条

    

xingxuesnow

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 98回
  • 年度积分:0
  • 历史总积分:97
  • 注册:2011年12月04日
发表于:2019-11-27 16:15:34
13楼



.感谢楼主 ,楼主辛苦

回复本条

    

jkworld

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 23回
  • 年度积分:0
  • 历史总积分:51
  • 注册:2008年8月11日
发表于:2019-12-01 11:12:33
14楼

下载学习研究,很不错的程序

回复本条

    

行云168

  • 精华:0帖
  • 求助:0帖
  • 帖子:3帖 | 323回
  • 年度积分:0
  • 历史总积分:147
  • 注册:2008年9月03日
发表于:2019-12-02 08:17:03
15楼

下载学习研究,很不错的程序

回复本条

    

liangxingzhi

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 133回
  • 年度积分:0
  • 历史总积分:84
  • 注册:2016年8月17日
发表于:2019-12-02 15:02:22
16楼

谢谢楼主 啊

回复本条

    

leisurefly

  • 精华:0帖
  • 求助:1帖
  • 帖子:7帖 | 1257回
  • 年度积分:0
  • 历史总积分:8282
  • 注册:2012年5月22日
发表于:2019-12-02 17:12:30
17楼

感觉很复杂呢,这思路不是一般人能够做的!

回复本条

    

leisurefly

  • 精华:0帖
  • 求助:1帖
  • 帖子:7帖 | 1257回
  • 年度积分:0
  • 历史总积分:8282
  • 注册:2012年5月22日
发表于:2019-12-02 17:13:34
18楼

还有这贴得代码是在附件里面有的么,不是我说复制粘贴都要得一段时间

回复本条

    

chenrenfu

  • 精华:0帖
  • 求助:0帖
  • 帖子:2帖 | 666回
  • 年度积分:29
  • 历史总积分:133
  • 注册:2011年9月08日
发表于:2019-12-02 21:02:59
19楼

下载下来看看!

回复本条

    

y82223634

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 158回
  • 年度积分:0
  • 历史总积分:401
  • 注册:2014年6月29日
发表于:2019-12-03 19:18:13
20楼

谢谢楼主分享

回复本条

    

热门招聘
相关主题

官方公众号

智造工程师
    
    首页 上一页 1 2 3 4 5 6 7 下一页 尾页