{"id":162865,"student_id":2589,"content":"import game\nimport random\nimport time\n\nbackground = game.create_sprite(\"background.png\")\nplayer = game.create_sprite(\"koding.png\", \"koding2.png\")\nbad_guy = game.create_sprite(\"bad_guy.png\")\n\nbad_guy.hidden = True\n\ncounter = 0\ndirection = 0\nspeed = 0\nt_s = time.time()\n\ndef loop():\n global counter, direction, speed, t_s\n t = 20-(time.time()-t_s)\n if t \u003c= 0:\n game.draw_text(\"WIN\", 900, 20, \"black\", 90)\n game.stop()\n else:\n game.draw_text(t, 900, 20, \"black\", 90)\n \n # 叩叮走路動畫\n if counter \u003e 15:\n player.costumeId = 1\n counter +=1\n if counter == 30:\n counter = 0\n else:\n player.costumeId = 0\n counter +=1\n \n # 叩叮移動\n if key.w and player.y \u003e 170:\n player.y -= 10\n if key.a and player.x \u003e 320:\n player.x -= 10\n if key.s and player.y \u003c 730:\n player.y += 10\n if key.d and player.x \u003c 880:\n player.x += 10\n \n # 怪物出現\n if bad_guy.hidden == True:\n speed = random.randint(10, 25)\n direction = random.randrange(4)\n path = random.randint(-2, 2)\n if direction == 0:\n bad_guy.x = 600+path*140\n bad_guy.y = 0\n if direction == 1:\n bad_guy.x = 600+path*140\n bad_guy.y = 900\n if direction == 2:\n bad_guy.x = 0\n bad_guy.y = 450+path*140\n if direction == 3:\n bad_guy.x = 1200\n bad_guy.y = 450+path*140\n bad_guy.hidden = False\n \n # 怪物移動\n if direction == 0 and bad_guy.hidden == False:\n bad_guy.y += speed\n if direction == 1 and bad_guy.hidden == False:\n bad_guy.y -= speed\n if direction == 2 and bad_guy.hidden == False:\n bad_guy.x += speed\n if direction == 3 and bad_guy.hidden == False:\n bad_guy.x -= speed\n \n # 怪物消失\n if bad_guy.x \u003e 1210 or bad_guy.x \u003c -10 or bad_guy.y \u003e 910 or bad_guy.y \u003c -10:\n bad_guy.hidden = True\n \n # 遊戲結束\n if bad_guy.touched(player):\n game.stop()\n \ngame.forever(loop)","created_at":"2020-07-06T02:11:53.422+08:00","updated_at":"2020-07-12T17:48:36.097+08:00","name":"閃喔_T ","language":"python","screenshot":{"url":null},"parent_id":160776,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":177,"hashid":"qmdsqpge","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2832772,"file_name":"bad_guy.png","project_id":162865,"asset_id":233830,"created_at":"2020-07-06T02:11:53.428+08:00","updated_at":"2020-07-06T02:11:53.428+08:00"},{"id":2832773,"file_name":"koding2.png","project_id":162865,"asset_id":233829,"created_at":"2020-07-06T02:11:53.430+08:00","updated_at":"2020-07-06T02:11:53.430+08:00"},{"id":2832774,"file_name":"koding.png","project_id":162865,"asset_id":233828,"created_at":"2020-07-06T02:11:53.431+08:00","updated_at":"2020-07-06T02:11:53.431+08:00"},{"id":2832775,"file_name":"background.png","project_id":162865,"asset_id":233824,"created_at":"2020-07-06T02:11:53.432+08:00","updated_at":"2020-07-06T02:11:53.432+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦