
Sticky Man Adventure: Reach the Crashed Ship Episode 1
"Embark on an immersive sticky man adventure using the TKINTER Python module! Help Mr. Sticky Man reach the crew at the crashed ship by mastering jumps and platform challenges. Utilize arrow keys and spacebar for a thrilling experience."
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Escape A sticky man adventure using TKINTER python module By: Channing Burgess
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!
1. self.tk = Toplevel() 2. self.tk.title("Mr.Sticky Man -----Episode 1-----Mission: Reach the crew at the crashed ship!----") 3. self.tk.resizable(0, 0) Modify game window size and canvas layout 4. self.tk.wm_attributes("-topmost", 1) 5. self.canvas = Canvas(self.tk, width=900, height=600, highlightthickness=0) 6. self.canvas.pack() 7. self.tk.update() 8. self.canvas_height = 600 9. self.canvas_width = 900 10. self.bg = PhotoImage(file="background.gif") 11. self.bh = PhotoImage(file="background1.gif") 1. 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 12. w = self.bg.width() 13. h = self.bg.height() 2. 3. 14. for x in range(0, 9): 15. self.canvas.create_image(x * w, 0 * h, image=self.bh, anchor='nw') 16. for x in range(0, 9): 17. self.canvas.create_image(x * w, 1 * h, image=self.bg, anchor='nw') 4. 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 18. for x in range(0, 9): 19. self.canvas.create_image(x * w, 2 * h, image=self.bh, anchor='nw') 20. for x in range(0, 9): 21. self.canvas.create_image(x * w, 3 * h, image=self.bg, anchor='nw') 22. for x in range(0, 9): 23. self.canvas.create_image(x * w, 4 * h, image=self.bh, anchor='nw') 24. for x in range(0, 9): 25. self.canvas.create_image(x * w, 5 * h, image=self.bg, anchor='nw')
Change sprite jump size 1. def jump(self, evt): 1. Very simply, just made the sprite jump height a little lower to make the game seem bigger 2. if self.y == 0: 3. self.y = -3 4. self.jump_count = 0
Add platform layout 1. I deleted the old layout from sitckyman and added 43 platforms by hard coding.
1. def update_timeText(): 2. if (state): 3. #Always true gate 4. global timer 5. #centiseconds plus one Added a Timer 6. timer[2] += 1 7. if (timer[2] >= 100): 8. #seconds plus one 9. timer[2] = 0 10. timer[1] += 1 11. if (timer[1] >= 60): 1. 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. 2. The call of this function is in the same place as updating the sprites movement. 12. #minutes plus one 13. timer[0] += 1 14. timer[1] = 0 15. #tkinter function 16. timeString = pattern.format(timer[0], timer[1], timer[2]) 17. timeText.configure(text=timeString) 18. root.after(100000, update_timeText) 19. state = True 20. root = tk.Tk() 21. timer = [0, 0, 0] 22. pattern = '{0:02d}:{1:02d}:{2:02d}' 23. #Makes the window 24. timeText = tk.Label(root, text="00:00:00", font=("Helvetica", 50)) 25. #packs it in the window 26. timeText.pack()
1. 2. 3. 4. 5. self.bar_imagefile1 = PhotoImage(file="background.gif") self.bar_x = 100 self.bar_y = 0 Animation Configuration self.bar_speed = +2 self.bar_image1 = game.canvas.create_image(self.bar_x, self.bar_y, image=self.bar_imagefile1, anchor='nw ) 1. 2. 3. 4. 5. 6. def animateblocks(self): 1. Lines 1-5 is one of the 6 animation images that seen here, show how I configured them bloc 2. Lines 1-11 are the function I made to keep the configured blocks in the canvas window self.bar_x = self.bar_x + self.bar_speed if self.bar_x < 0: self.bar_speed = +2 elif self.bar_x > 900: self.bar_speed= -2 7. 8. 9. 10. 11. 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
1. self.animateblocks() 2. 3. Animation #Image 1 move 4. #image #x #y 5. self.game.canvas.move(self.bar_image, self.bar_speed, 0) 6. #Image 2 move 7. self.game.canvas.move(self.bar_image2, self.bar_speed2, 0) 1. Underneath the class that animates the sprite I call my animate blocks function. 2. Lines 5-15 move my images using TKINTER method canvas.move taking in the image and x,y movement speed. 8. #Image 3 move 9. self.game.canvas.move(self.bar_image3, self.bar_speed, 0) 10. #Image 4 move 11. self.game.canvas.move(self.bar_image4, self.bar_speed2, 0) 12. #Image 5 move 13. self.game.canvas.move(self.bar_image5, self.bar_speed, 0) 14. #Image 6 move 15. self.game.canvas.move(self.bar_image1, self.bar_speed2, 0)
Conclusion 1. 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! 2. 3.