{"id":212441,"student_id":3760,"content":"from game import *\n\nsky = create_sprite('sky.png') #天空背景圖\nground = create_sprite('ground.png') #跑道\nend = create_sprite('end.png') #終點線\nplayer = create_sprite('p1_0.png', 'p1_1.png') #運動員\narrow = create_sprite('arrow.png') #標槍\nboard = create_sprite('dashboard.png') #計分板\n\n#角色圖片不隨 direction 屬性旋轉\nsky.rotation_style = 'fixed'\nground.rotation_style = 'fixed'\nplayer.rotation_style = 'fixed'\nend.rotation_style = 'fixed'\n\nboard.move_to(150, 100)\nplayer.move_to(600, 600)\narrow.move_to(600, 600)\n\nspeed = 0\nstatus = 0\nend.x += 2000\n\nrounds = 0\nscores = [0, 0, 0]\n\ngame.create_sound('bgm.mp3')\n\ndef reset(): \n global i, status, speed, rounds\n status = 0\n speed = 0\n player.move_to(600, 600)\n arrow.move_to(600, 600)\n end.move_to(600 + 2000, 450)\n arrow.direction = 90\n rounds += 1\n\n\ndef loop():\n global status, speed\n \n if sky.x \u003c 0: sky.x += 1200\n if sky.y \u003c 0: sky.y += 900\n if sky.y \u003e 900: sky.y -= 900\n if ground.x \u003c 0: ground.x += 1200\n \n if status == 0 or status == 2:\n sky.direction = arrow.direction + 180\n sky.step_forward(speed)\n ground.direction = arrow.direction + 180\n ground.step_forward(speed)\n end.direction = arrow.direction + 180\n end.step_forward(speed)\n \n if key.up and status != 2:\n status = 1\n arrow.direction -= 1\n speed -= 0.2\n \n if status == 1 and key.up == False:\n status = 2\n \n if status == 2:\n player.direction = arrow.direction + 180\n player.step_forward(speed)\n arrow.direction += 0.2\n \n if player.x \u003e end.x or player.y \u003c 600: status = 3\n \n draw_text('回合1: ' + str(scores[0]) + 'm', 30, 40, 'white', 30)\n draw_text('回合2: ' + str(scores[1]) + 'm', 30, 90, 'white', 30)\n draw_text('回合3: ' + str(scores[2]) + 'm', 30, 140, 'white', 30)\n\n if arrow.x \u003e end.x:\n scores[rounds] = int(arrow.x - end.x) / 100\n \n if status == 3 and key.r: reset()\n \n player.costume_id = int(scores[rounds]) % 2\n\ndef speedup():\n global speed\n speed += 1\n\non('keyup', 'right', speedup)\nforever(loop)\n\n","created_at":"2020-12-15T22:16:30.003+08:00","updated_at":"2020-12-16T04:43:38.488+08:00","name":"運動會系列 - 標槍競賽 範例","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/212441/27c4ae13aade524d55ff2d9c64365a72.jpg"},"parent_id":199148,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":33,"hashid":"ej9s22nm5","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3720632,"file_name":"bgm.mp3","project_id":212441,"asset_id":293311,"created_at":"2020-12-15T22:16:30.009+08:00","updated_at":"2020-12-15T22:16:30.009+08:00"},{"id":3720633,"file_name":"ground.png","project_id":212441,"asset_id":293310,"created_at":"2020-12-15T22:16:30.010+08:00","updated_at":"2020-12-15T22:16:30.010+08:00"},{"id":3720634,"file_name":"end.png","project_id":212441,"asset_id":293309,"created_at":"2020-12-15T22:16:30.011+08:00","updated_at":"2020-12-15T22:16:30.011+08:00"},{"id":3720635,"file_name":"dashboard.png","project_id":212441,"asset_id":291652,"created_at":"2020-12-15T22:16:30.012+08:00","updated_at":"2020-12-15T22:16:30.012+08:00"},{"id":3720636,"file_name":"arrow.png","project_id":212441,"asset_id":291420,"created_at":"2020-12-15T22:16:30.013+08:00","updated_at":"2020-12-15T22:16:30.013+08:00"},{"id":3720637,"file_name":"p1_0.png","project_id":212441,"asset_id":291417,"created_at":"2020-12-15T22:16:30.014+08:00","updated_at":"2020-12-15T22:16:30.014+08:00"},{"id":3720638,"file_name":"p1_1.png","project_id":212441,"asset_id":291416,"created_at":"2020-12-15T22:16:30.015+08:00","updated_at":"2020-12-15T22:16:30.015+08:00"},{"id":3720639,"file_name":"sky.png","project_id":212441,"asset_id":291415,"created_at":"2020-12-15T22:16:30.016+08:00","updated_at":"2020-12-15T22:16:30.016+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦