![]() move ( course ) else : options = plan = choice ( options ) course. y + 10 ) dot ( 20, 'yellow' ) for point, course in ghosts : if valid ( point + course ): point. move ( aim ) index = offset ( pacman ) if tiles = 1 : tiles = 2 state += 1 x = ( index % 20 ) * 20 - 200 y = 180 - ( index // 20 ) * 20 square ( x, y ) up () goto ( pacman. ![]() write ( state ) clear () if valid ( pacman + aim ): pacman. dot ( 2, 'white' ) def move (): """Move pacman and all ghosts.""" writer. color ( 'blue' ) for index in range ( len ( tiles )): tile = tiles if tile > 0 : x = ( index % 20 ) * 20 - 200 y = 180 - ( index // 20 ) * 20 square ( x, y ) if tile = 1 : path. y % 20 = 0 def world (): """Draw world using path.""" bgcolor ( 'black' ) path. y, 20 )) / 20 index = int ( x + y * 20 ) return index def valid ( point ): """Return True if point is valid in tiles.""" index = offset ( point ) if tiles = 0 : return False index = offset ( point + 19 ) if tiles = 0 : return False return point. end_fill () def offset ( point ): """Return offset of point in tiles.""" x = ( floor ( point. begin_fill () for count in range ( 4 ): path. ![]() """ from random import choice from turtle import * from freegames import floor, vector state = path = Turtle ( visible = False ) writer = Turtle ( visible = False ) aim = vector ( 5, 0 ) pacman = vector ( - 40, - 80 ) ghosts =, ,, , ] # fmt: off tiles = # fmt: on def square ( x, y ): """Draw square using path at (x, y).""" path.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |