{"id":811899,"student_id":10,"content":"from game import *\nfrom random import *\n\nset_backdrop('black')\n\npos = [\n { \"x\": 200, \"y\": 200, \"d\": 0 }, #0\n { \"x\": 300, \"y\": 300, \"d\": 90 }, #1\n { \"x\": 300, \"y\": 500, \"d\": 90 }, #2\n { \"x\": 200, \"y\": 600, \"d\": 0 }, #3\n { \"x\": 100, \"y\": 500, \"d\": 90 }, #4\n { \"x\": 100, \"y\": 300, \"d\": 90 }, #5\n { \"x\": 200, \"y\": 400, \"d\": 0 }, #6\n]\n\ntable = [[8],[7],[],[9],[],[6],[8, 5],[1],[9, 0, 6],[3, 8]]\n\nshapes = [\n '1111110', '0110000', '1101101', '1111001', '0110011',\n '1011011', '1011111', '1110000', '1111111', '1111011',\n]\n\nnums = []\nfor i in range(3):\n for p in pos:\n s = create_sprite('p_0.png', 'p_1.png')\n s.x = p[\"x\"] + i * 400\n s.y = p[\"y\"] + 50\n s.direction = p[\"d\"]\n nums.append(s)\n \nlevel = 0\nclock = 0\nok = False\n \ndef next_level():\n global level\n level += 1\n \n a = randrange(10)\n b = randrange(10 - a)\n c = a + b\n\n if a != 2 and a != 4 and random() \u003c 0.33:\n a = choice(table[a])\n elif b != 2 and b != 4 and random() \u003c 0.5:\n b = choice(table[b])\n elif c != 2 and c != 4:\n c = choice(table[c])\n else: next_level()\n \n s = shapes[a] + shapes[b] + shapes[c]\n for i in range(21):\n if s[i] == '0': nums[i].costume_id = 0\n if s[i] == '1': nums[i].costume_id = 1\n \n \ndef loop():\n global clock, ok\n clock += 1\n draw_text('等級: ' + str(level), 50, 50, 'white', 30)\n draw_text('時間: ' + str(clock // 60), 50, 100, 'white', 30)\n \n for s in nums: \n if ok: s.scale -= 0.1\n elif s.scale \u003c 1: s.scale += 0.1\n if nums[0].scale \u003c= 0:\n next_level()\n ok = False\n \ndef onclick():\n global ok\n for s in nums:\n if s.touched(cursor):\n s.costume_id = 0 if s.costume_id == 1 else 1\n \n a = check(nums[0:7])\n b = check(nums[7:14])\n c = check(nums[14:21])\n if a == -1 or b == -1 or c == -1: return\n if a + b == c:\n ok = True\n\ndef check(arr):\n s = ''\n for a in arr:\n if a.costume_id == 0: s += '0'\n else: s += '1'\n for i in range(10): if shapes[i] == s: return i\n return -1\n\non('click', onclick)\nforever(loop)\nnext_level()\n","created_at":"2024-08-06T14:25:08.284+08:00","updated_at":"2024-08-06T17:57:44.226+08:00","name":"火柴益智","language":"python","screenshot":{"url":"/uploads/project/screenshot/811899/a4771b0e4ccdf8e4c189026d4893253a.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":329,"hashid":"meysv984d","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[]
Orange Apple Learning Platform
My Projects
View Project Page
Export
Remix
Import
Delete
Screenshot
繁中
简中
English
日本語
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer