1 / 9

Escape

Escape. A sticky man adventure using TKINTER python module By: Channing Burgess. How to use the game!.

alaura
Download Presentation

Escape

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Escape A sticky man adventure using TKINTER python module By: Channing Burgess

  2. How to use the game! • To use the game. Use the LEFT and RIGHT arrow keys to move. PRESS SPACE to jump. Try using all the space on each platform to gain momentum and time your jumps just right to be successful in getting to the ship!

  3. self.tk = Toplevel() • self.tk.title("Mr.Sticky Man -----Episode 1-----Mission: Reach the crew at the crashed ship!----") • self.tk.resizable(0, 0) • self.tk.wm_attributes("-topmost", 1) • self.canvas = Canvas(self.tk, width=900, height=600, highlightthickness=0) • self.canvas.pack() • self.tk.update() • self.canvas_height = 600 • self.canvas_width = 900 • self.bg = PhotoImage(file="background.gif") • self.bh = PhotoImage(file="background1.gif") • w = self.bg.width() • h = self.bg.height() • for x in range(0, 9): • self.canvas.create_image(x * w,0 * h, image=self.bh, anchor='nw') • for x in range(0, 9): • self.canvas.create_image(x * w,1 * h, image=self.bg, anchor='nw') • for x in range(0, 9): • self.canvas.create_image(x * w, 2 * h, image=self.bh, anchor='nw') • for x in range(0, 9): • self.canvas.create_image(x * w, 3 * h, image=self.bg, anchor='nw') • for x in range(0, 9): • self.canvas.create_image(x * w, 4 * h, image=self.bh, anchor='nw') • for x in range(0, 9): • self.canvas.create_image(x * w, 5 * h, image=self.bg, anchor='nw') Modify game window size and canvas layout Change TK() tkinter call to toplevel to run over top of the clock Change the title Lines 5,8,9 changes the size of the canvas and window size Lines 15,25. Originally it the canvas was made by two nested for loops. I took it out of the nested loop to have six different fill options the highlighted numbers are the order of each fill method form top to bottom

  4. def jump(self, evt): • if self.y == 0: • self.y = -3 • self.jump_count = 0 Change sprite jump size Very simply, just made the sprite jump height a little lower to make the game seem bigger

  5. Add platform layout I deleted the old layout from sitckyman and added 43 platforms by hard coding.

  6. def update_timeText(): • if (state): • #Always true gate • global timer • #centiseconds plus one • timer[2] += 1 • if (timer[2] >= 100): • #seconds plus one • timer[2] = 0 • timer[1] += 1 • if (timer[1] >= 60): • #minutes plus one • timer[0] += 1 • timer[1] = 0 • #tkinter function • timeString = pattern.format(timer[0], timer[1], timer[2]) • timeText.configure(text=timeString) • root.after(100000, update_timeText) • state = True • root = tk.Tk() • timer = [0, 0, 0] • pattern = '{0:02d}:{1:02d}:{2:02d}' • #Makes the window • timeText = tk.Label(root, text="00:00:00", font=("Helvetica", 50)) • #packs it in the window • timeText.pack() Added a Timer Implemented a function with simple if else statement with centiseconds, seconds, and minutes. Then using tkinter method of tk.Tk() it packs it into its own window using pattern.format to keep the pattern the same. A lot of help from online forums. The call of this function is in the same place as updating the sprites movement.

  7. self.bar_imagefile1 = PhotoImage(file="background.gif") • self.bar_x = 100 • self.bar_y = 0 • self.bar_speed = +2 • self.bar_image1 = game.canvas.create_image(self.bar_x, self.bar_y, image=self.bar_imagefile1, anchor='nw‘) • def animateblocks(self): • self.bar_x = self.bar_x + self.bar_speed • if self.bar_x < 0: • self.bar_speed = +2 • elifself.bar_x > 900: • self.bar_speed= -2 • self.bar_x2 = self.bar_x2 + self.bar_speed2 • if self.bar_x2 < 0: • self.bar_speed2 = +2 • elif self.bar_x2 > 900: • self.bar_speed2 = -2 Animation Configuration Lines 1-5 is one of the 6 animation images that seen here, show how I configured them bloc Lines 1-11 are the function I made to keep the configured blocks in the canvas window

  8. self.animateblocks() • #Image 1 move • #image #x #y • self.game.canvas.move(self.bar_image, self.bar_speed, 0) • #Image 2 move • self.game.canvas.move(self.bar_image2, self.bar_speed2, 0) • #Image 3 move • self.game.canvas.move(self.bar_image3, self.bar_speed, 0) • #Image 4 move • self.game.canvas.move(self.bar_image4, self.bar_speed2, 0) • #Image 5 move • self.game.canvas.move(self.bar_image5, self.bar_speed, 0) • #Image 6 move • self.game.canvas.move(self.bar_image1, self.bar_speed2, 0) Animation Underneath the class that animates the sprite I call my animate blocks function. Lines 5-15 move my images using TKINTER method canvas.move taking in the image and x,y movement speed.

  9. Conclusion I learned a lot by using tkinter. I wish I had used pygame instead because of it’s limited abilities and simple class structure. I feel as though I would be better at class stuctures that way. However, I did gain a lot by learning individual problem solving having to look up and study each tkinter built in method. In the future I would like to set the clock and the canvas in a frame and add a high score keeper in the frame as well. Thank you Dr. Hua for all of your help!

More Related