{"id":857580,"student_id":2589,"content":"from game import *\nfrom random import *\n\nnums = [str(i) + '.png' for i in range(10)] #建立 0-9 數字圖片名稱\nbg = create_sprite('bg.png') #背景\ncow = create_sprite('cow_2.png', 'cow_1.png', 'cow_0.png') #公牛\nboy = create_sprite('boy.png') #牛仔\nn1 = create_sprite(nums) #百位數\nn2 = create_sprite(nums) #十位數\nn3 = create_sprite(nums) #個位數\nsec = create_sprite('sec.png') #秒數單位\nrules = create_sprite('rule.png') #遊戲說明\nspace = create_sprite('space.png') #空白鍵\nn1.move_to(100, 100)\nn2.move_to(150, 100)\nn3.move_to(200, 100)\nsec.move_to(280, 110)\ncreate_sound('bgm.mp3', True)\n\nclock = 0\n\ndef reset():\n global clock\n clock = 0 #重置時間\n boy.y = 450 #重置牛仔垂直位置\n boy.direction = 90 #重置牛仔角度\n space.hidden = True #隱藏空白鍵\n rules.hidden = True #隱藏說明圖\n\ndef loop():\n global clock\n clock += 1\n \n if space.hidden:\n update_clock() #更新時間\n update_scene() #更新場景\n \n fq = 30 - clock // 60\n \n # 隨機改變公牛和牛仔的角度\n if space.hidden and clock % fq == 0:\n if cow.direction == 90:\n if random() \u003e 0.5:\n cow.direction += 30\n boy.direction += 30\n else:\n cow.direction -= 30\n boy.direction -= 30\n else:\n cow.direction = 90\n\n if boy.direction == 0 or boy.direction == 180:\n space.hidden = False\n cow.direction = 90\n cow.costume_id = 0\n \n if not space.hidden and boy.y \u003c 700:\n boy.y += 5\n\ndef update_clock():\n sec = clock // 60\n n1.costume_id = (sec // 100) % 10 #更新百位數\n n2.costume_id = (sec // 10) % 10 #更新十位數\n n3.costume_id = (sec // 1) % 10 #更新個位數\n\n# 背景捲動和牛的造型\ndef update_scene():\n bg.x += 1\n if bg.x \u003e= 1200: bg.x -= 1200\n cow.costume_id = (clock // 15) % 3\n\n# 按下右鍵牛仔向右旋轉 30 度\ndef key_right():\n if space.hidden: boy.direction += 30\n\n# 按下左鍵牛仔向右旋轉 30 度\ndef key_left():\n if space.hidden: boy.direction -= 30\n \non('keydown', 'right', key_right)\non('keydown', 'left', key_left)\non('keydown', 'space', reset)\nforever(loop)\n","created_at":"2024-10-07T12:10:01.200+08:00","updated_at":"2024-10-07T12:10:29.900+08:00","name":"5_騎公牛大賽_完整版","language":"python","screenshot":{"url":null},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":3,"hashid":"p93s3wy5r","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18806417,"file_name":"boy.png","project_id":857580,"asset_id":781732,"created_at":"2024-10-07T12:10:29.642+08:00","updated_at":"2024-10-07T12:10:29.642+08:00"},{"id":18806418,"file_name":"cow_0.png","project_id":857580,"asset_id":781733,"created_at":"2024-10-07T12:10:29.650+08:00","updated_at":"2024-10-07T12:10:29.650+08:00"},{"id":18806419,"file_name":"0.png","project_id":857580,"asset_id":781734,"created_at":"2024-10-07T12:10:29.657+08:00","updated_at":"2024-10-07T12:10:29.657+08:00"},{"id":18806420,"file_name":"1.png","project_id":857580,"asset_id":781735,"created_at":"2024-10-07T12:10:29.662+08:00","updated_at":"2024-10-07T12:10:29.662+08:00"},{"id":18806421,"file_name":"6.png","project_id":857580,"asset_id":781736,"created_at":"2024-10-07T12:10:29.667+08:00","updated_at":"2024-10-07T12:10:29.667+08:00"},{"id":18806422,"file_name":"7.png","project_id":857580,"asset_id":781737,"created_at":"2024-10-07T12:10:29.672+08:00","updated_at":"2024-10-07T12:10:29.672+08:00"},{"id":18806423,"file_name":"space.png","project_id":857580,"asset_id":781738,"created_at":"2024-10-07T12:10:29.678+08:00","updated_at":"2024-10-07T12:10:29.678+08:00"},{"id":18806424,"file_name":"rule.png","project_id":857580,"asset_id":781739,"created_at":"2024-10-07T12:10:29.685+08:00","updated_at":"2024-10-07T12:10:29.685+08:00"},{"id":18806425,"file_name":"8.png","project_id":857580,"asset_id":781740,"created_at":"2024-10-07T12:10:29.691+08:00","updated_at":"2024-10-07T12:10:29.691+08:00"},{"id":18806426,"file_name":"9.png","project_id":857580,"asset_id":781741,"created_at":"2024-10-07T12:10:29.696+08:00","updated_at":"2024-10-07T12:10:29.696+08:00"},{"id":18806427,"file_name":"dot.png","project_id":857580,"asset_id":781742,"created_at":"2024-10-07T12:10:29.701+08:00","updated_at":"2024-10-07T12:10:29.701+08:00"},{"id":18806428,"file_name":"sec.png","project_id":857580,"asset_id":781743,"created_at":"2024-10-07T12:10:29.705+08:00","updated_at":"2024-10-07T12:10:29.705+08:00"},{"id":18806429,"file_name":"cow_1.png","project_id":857580,"asset_id":781744,"created_at":"2024-10-07T12:10:29.711+08:00","updated_at":"2024-10-07T12:10:29.711+08:00"},{"id":18806430,"file_name":"cow_2.png","project_id":857580,"asset_id":781745,"created_at":"2024-10-07T12:10:29.717+08:00","updated_at":"2024-10-07T12:10:29.717+08:00"},{"id":18806431,"file_name":"4.png","project_id":857580,"asset_id":781746,"created_at":"2024-10-07T12:10:29.722+08:00","updated_at":"2024-10-07T12:10:29.722+08:00"},{"id":18806432,"file_name":"5.png","project_id":857580,"asset_id":781747,"created_at":"2024-10-07T12:10:29.728+08:00","updated_at":"2024-10-07T12:10:29.728+08:00"},{"id":18806433,"file_name":"bg.png","project_id":857580,"asset_id":781748,"created_at":"2024-10-07T12:10:29.735+08:00","updated_at":"2024-10-07T12:10:29.735+08:00"},{"id":18806434,"file_name":"2.png","project_id":857580,"asset_id":781749,"created_at":"2024-10-07T12:10:29.743+08:00","updated_at":"2024-10-07T12:10:29.743+08:00"},{"id":18806435,"file_name":"3.png","project_id":857580,"asset_id":781750,"created_at":"2024-10-07T12:10:29.748+08:00","updated_at":"2024-10-07T12:10:29.748+08:00"},{"id":18806436,"file_name":"bgm.mp3","project_id":857580,"asset_id":781751,"created_at":"2024-10-07T12:10:29.898+08:00","updated_at":"2024-10-07T12:10:29.898+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦