Create the following script, scroller.py:
- Begin by importing the required libraries and parameters:
#!/usr/bin/python3 # scroller.py import tkinter as TK import time import math from random import randint STEP=7 xVAL,yVAL=0,1 MAX_WIDTH,MAX_HEIGHT=640,480 SPACE_WIDTH=MAX_WIDTH*2 SPACE_HEIGHT=MAX_HEIGHT*2 LEFT,UP,RIGHT,DOWN=0,1,2,3 SPACE_LIMITS=[0,0,SPACE_WIDTH-MAX_WIDTH, SPACE_HEIGHT-MAX_HEIGHT] DIS_LIMITS=[STEP,STEP,MAX_WIDTH-STEP,MAX_HEIGHT-STEP] BGN_IMG="bg.gif" PLAYER_IMG=["playerL.gif","playerU.gif", "playerR.gif","playerD.gif"] WALL_IMG=["wallH.gif","wallV.gif"] GOLD_IMG="gold.gif" MARK_IMG="mark.gif" newGame=False checks=list()
- Provide functions to handle the movements of the player:
def move_right(event): movePlayer(RIGHT,STEP) ...