def playGameKeyPressed(event, data): # Control the drop direction with wasd # When the water drop is moving, you can't control the direction anymore if event.keysym == 'd': if data.drop.direction == None: data.drop.direction = 'Right' recordPlayback(data) if event.keysym == 'a': if data.drop.direction == None: data.drop.direction = 'Left' recordPlayback(data) if event.keysym == 'w': if data.drop.direction == None: data.drop.direction = 'Up' recordPlayback(data) if event.keysym == 's': if data.drop.direction == None: data.drop.direction = 'Down' recordPlayback(data) # Realize some additional function # Press R to restart if event.keysym == 'r': data.currentScore = 0 data.drop = copy.deepcopy(data.dropMapDict[data.level]) data.currentTargetMap = copy.deepcopy(data.targetMapDict[data.level]) data.currentTrigeredMap = [] updatePlaybackThings(data) updateAllSpikeRealatedMaps(data) # Press P to pause if event.keysym == 'p': data.mode = 'pause'
def clearanceMousePressed(event, data): if 160 < event.x < 440 and 290 < event.y < 350: data.mode = 'playback' data.currentScore = 0 # this time, playTime record the replaying time # so that the game displays correctly data.playTime = 0 updateAllCurrentGeneralMaps(data) updateAllSpikeRealatedMaps(data) elif 160 < event.x < 440 and 370 < event.y < 430: data.mode = 'menu'
def buildMyMazeKeyPressed(event, data): if event.keysym == 'c': data.currentItem = None data.occupiedMap = [(-1, -1, 'drop')] data.occupiedCoordinatesMap = [(-1, -1)] data.dropMapDict[-1] = Drop(-1, -1) data.drop = copy.deepcopy(data.dropMapDict[-1]) updateAllMapDicts(data) updateAllCurrentGeneralMaps(data) data.EBM[-1] = [] data.WBM[-1] = [] data.NBM[-1] = [] data.SBM[-1] = [] data.ESM[-1] = [] data.WSM[-1] = [] data.NSM[-1] = [] data.SSM[-1] = [] updateAllSpikeRealatedMaps(data)
def CMVictoryMousePressed(event, data): # Click the START JOURNEY button and play!!! if 160 < event.x < 440 and 200 < event.y < 300: data.mode = 'playGame' data.level = 1 updatePlaybackThings(data) updateAllCurrentGeneralMaps(data) updateAllSpikeRealatedMaps(data) # Click the PLAYBACK button and review your tour if 160 < event.x < 440 and 300 < event.y < 400: data.mode = 'playback' data.currentScore = 0 # this time, playTime record the replaying time # so that the game displays correctly data.playTime = 0 updateAllCurrentGeneralMaps(data) updateAllSpikeRealatedMaps(data) # Click the BUILD ANOTHER MAZE button to customize a map elif 160 < event.x < 440 and 400 < event.y < 500: data.mode = 'buildMyMaze' data.level = -1 updatePlaybackThings(data) updateAllCurrentGeneralMaps(data) updateAllSpikeRealatedMaps(data) # Click the MENU button to go to menu page elif 160 < event.x < 440 and 500 < event.y < 600: data.mode = 'menu' updatePlaybackThings(data)
def intervalMousePressed(event, data): # Click the PLAYBACK button and review your tour if 160 < event.x < 440 and 280 < event.y < 360: data.mode = 'playback' data.currentScore = 0 # this time, playTime record the replaying time # so that the game displays correctly data.playTime = 0 updateAllCurrentGeneralMaps(data) updateAllSpikeRealatedMaps(data) # Click the CONTINUE button to go to next level if 160 < event.x < 440 and 360 < event.y < 440: data.level += 1 data.mode = 'playGame' data.currentScore = 0 updatePlaybackThings(data) updateAllCurrentGeneralMaps(data) updateAllSpikeRealatedMaps(data) # Click the MENU button to go to menu page elif 160 < event.x < 440 and 440 < event.y < 520: data.mode = 'menu'
def menuMousePressed(event,data): # Click the START JOURNEY button and play!!! if 160 < event.x < 440 and 190 < event.y < 250: data.mode = 'playGame' # modify here to test! data.level = 1 updateAllCurrentGeneralMaps(data) updateAllSpikeRealatedMaps(data) # Click the HELP button and learn how to play elif 160 < event.x < 440 and 290 < event.y < 350: data.mode = 'helpPage1' # Click the BUILD MY MAZE button to customize a map elif 160 < event.x < 440 and 390 < event.y < 450: data.mode = 'buildMyMaze' data.level = -1 updateAllCurrentGeneralMaps(data) updateAllSpikeRealatedMaps(data) # Click the ABOUT ME button and learn about this game elif 160 < event.x < 440 and 490 < event.y < 550: data.mode = 'aboutMe'
def init(data): data.mode = 'menu' # This is the menu mode data.level = -1 # make the level be -1 to be used for BUILD MY MAZE mode! data.totalLevels = 9 # this is 1 larger than the actual levels, for convenient usage. data.currentScore = 0 data.accumulatedScore = 0 data.currentIndex = -1 # record playback index data.playbackMap = [[], [], []] # record your last solution data.playTime = 0 # record yout tour-time data.step = 0 # record your tour step index data.MINSteps = { -1: "?", 1: "5", 2: "7", 3: "3", 4: "7", 5: "6", 6: "7", 7: "3", 8: "3" } # initialize the time of background animation data.snowflakeTime = 0 data.fallingLeavesTime = 0 data.dogTime = 0 # record the occupied positions with the item name # used in deleting items # the first element is set to be (-1,-1), and it is reserved for record drop # since drop is different from others, only one drop can exist, this makes finding # and checking drop position easy data.occupiedMap = [(-1, -1, 'drop')] # record the occupied positions only, no more items can be placed overlap # used in placing items. The (-1,-1) is the same as data.occupiedMap data.occupiedCoordinatesMap = [(-1, -1)] data.currentItem = None # describe the current selected item in BUILD MY MAZE mode # This image is cited from https://play.blocksworld.com/play?world_id=26183522 data.dropImage = PhotoImage(file='pictures/drop.gif') # The following 3 images are cited from https://gamejolt.com/games/erayu/109632 data.menuBGImage = PhotoImage(file='pictures/menuBG.png') data.playBGImage = PhotoImage(file='pictures/playBG.png') data.helpBGImage = PhotoImage(file='pictures/helpBG.png') data.aboutmeBGImage = PhotoImage(file='pictures/aboutmeBG.png') # This image is cited from https://www.roblox.com/library/170321226/sanic-ring-1 data.scrollImage = PhotoImage(file='pictures/scrollImage.gif') # This image is cited from http://img.neoseeker.com/v_concept_art.php?caid=36373 data.brickImage = PhotoImage(file='pictures/brick.png') # This image is cited from # https://www.brik.co/blogs/pixel-art/super-mario-galaxy-luma-star-pixel-art data.targetImage = PhotoImage(file='pictures/target.gif') # The following four images are modified from # https://www.brik.co/blogs/pixel-art/candy-corn-pixel-art data.spikeNorthImage = PhotoImage(file='pictures/spikeNorth.gif') data.spikeSouthImage = PhotoImage(file='pictures/spikeSouth.gif') data.spikeEastImage = PhotoImage(file='pictures/spikeEast.gif') data.spikeWestImage = PhotoImage(file='pictures/spikeWest.gif') # This image is cited from http://piq.codeus.net/picture/327376/med_pack data.crossImage = PhotoImage(file='pictures/cross.png') # This image is cited from http://piq.codeus.net/picture/8582/bomb data.bombImage = PhotoImage(file='pictures/bomb.png') # This image is cited from https://www.thinglink.com/scene/657786259783024642 data.wormholeAImage = PhotoImage(file='pictures/wormholeA.png') # This image is edited from https://www.thinglink.com/scene/657786259783024642 data.wormholeBImage = PhotoImage(file='pictures/wormholeB.png') # This image is cited from https://lowpolypix.deviantart. # com/art/Super-Dragonsin-Saga-Items-Free-Use-345202858 data.trap1Image = PhotoImage(file='pictures/trap1.png') # This image is cited from https://lowpolypix.deviantart. # com/art/Super-Dragonsin-Saga-Items-Free-Use-345202858 data.trap2Image = PhotoImage(file='pictures/trap2.png') # This image is cited from https://www.redbubble.com/fr/people/thesaurusrex/works # /21656630-wasd-keys-black?p=womens-relaxed-fit data.wasdImage = PhotoImage(file='pictures/wasd.png') # This image is cited from http://photobucket.com/gifs/pink%20arrow%20pixel data.arrowImage = PhotoImage(file='pictures/arrow.png') # This image is cited from https://opengameart.org/content/home-button-pixel data.menuButtonImage = PhotoImage(file='pictures/menuButton.png') # The following 2 images are cited from # https://opengameart.org/content/restart-button-pixel data.nextButtonImage = PhotoImage(file='pictures/nextButton.png') data.prevButtonImage = PhotoImage(file='pictures/prevButton.png') # This image is cited from # https://free.clipartof.com/details/12-Free-Vector-Illustration-Of-A-Question-Mark-Icon data.helpButtonImage = PhotoImage(file='pictures/helpButton.png') # This image is cited from http://pixelartmaker.com/art/2fec8acf327f433 data.playbackButtonImage = PhotoImage(file='pictures/playback.png') # The following 4 images are cited from # http://www.dickbaldwin.com/XNA/XNA0122/XNA0122.htm data.dog1Image = PhotoImage(file='pictures/dog1.png') data.dog2Image = PhotoImage(file='pictures/dog2.png') data.dog3Image = PhotoImage(file='pictures/dog3.png') data.dog4Image = PhotoImage(file='pictures/dog4.png') # The next 4 images are cited from # https://mrbubblewand.wordpress.com/2010/01/18/animation-magic_004/ data.snowflake1Image = PhotoImage(file='pictures/snow1.png') data.snowflake2Image = PhotoImage(file='pictures/snow2.png') data.snowflake3Image = PhotoImage(file='pictures/snow3.png') data.snowflake4Image = PhotoImage(file='pictures/snow4.png') # The next 4 images are cited and eidted from # https://www.pinterest.com/pin/375839531394461912/ data.leaf1Image = PhotoImage(file='pictures/leaf1.png') data.leaf2Image = PhotoImage(file='pictures/leaf2.png') data.leaf3Image = PhotoImage(file='pictures/leaf3.png') data.leaf4Image = PhotoImage(file='pictures/leaf4.png') data.dropMapDict = dropMapDict data.brick = Brick() data.scroll = Scroll() data.target = Target() data.spike = Spike() data.bomb = Bomb() data.wormholeA = WormholeA() data.wormholeB = WormholeB() data.trap = Trap() # update all the maps! updateAllMapDicts(data) updateAllCurrentGeneralMaps(data) ### The following 2 blocks will not affected by adding new classes ### # data.ESM/WSM/NSM/SSM are short for data.East/West/North/SouthSpikeMap # get spike maps which are seperated by 4 directions! data.ESM = makeSpikeMaps(data.spikeMapDict, 'east', data.totalLevels) data.WSM = makeSpikeMaps(data.spikeMapDict, 'west', data.totalLevels) data.NSM = makeSpikeMaps(data.spikeMapDict, 'north', data.totalLevels) data.SSM = makeSpikeMaps(data.spikeMapDict, 'south', data.totalLevels) # data.EBM/WBM/NBM/SBM are short for data.East/West/North/SouthBrickMap data.EBM = makeBarrierMaps(data.brickMapDict, data.spikeMapDict, 'east', data.totalLevels) data.WBM = makeBarrierMaps(data.brickMapDict, data.spikeMapDict, 'west', data.totalLevels) data.NBM = makeBarrierMaps(data.brickMapDict, data.spikeMapDict, 'north', data.totalLevels) data.SBM = makeBarrierMaps(data.brickMapDict, data.spikeMapDict, 'south', data.totalLevels) # update spike related maps! updateAllSpikeRealatedMaps(data) pass