- 31st Jul 2024
- 17:49 pm
In this assignment our experts can guide you in incorporating essential game features such as image integration, scoring mechanisms, and leaderboards. We offer support in adding customizable controls, collision detection, and special features like save/load and boss keys to enhance your game’s functionality and player experience. The game should attempt to include the following features:
- The use of images.
- The use of shapes.
- The use of text.
- A scoring mechanism.
- A leader board which is presented at appropriate places in the game (i.e. from a menu before the game begins and/or at the end of the game) a. The leader board must retain player names (or initials if you adopt a retro style), with their score and their position in the leader board. b. When the game is quit and reloaded, the leader board will reflect the history of the leaders of the game.
- To avoid having to scale images for different screen resolutions you can use any of the following resolutions. 1920x1080, 1366x768, 1536x864, 1440x900, 1280x720 or 1600x900. Indicate the screen resolution at the top of the python source code as a comment just in case the marker needs to alter their screen resolution to best view your game.
- The movement of objects.
- The ability for the user to move an object.
- Some form of collision detection.
- The ability for the player to pause and unpause the game (so that they can make a cup of tea).
- The ability to customise the experience for the user, for example, if the game has an object that can be moved the player should be able to define the keys that control that object.
- Special cheat codes (i.e. if your game was a snake game, you might incorporate ‘a shrink cheat’ that decreases the length of the snake’s body each time the code was entered).
- Save/Load game feature so that the player can resume playing where they left off tomorrow.
- A ‘boss key’, we shouldn’t play games at work. Some games introduced a boss key which allowed the game to flip to an image that gave the impression that the player was doing something work related quickly.
Free Assignment Solution - Essential Features For A Comprehensive Game Design
# Resolution set on line 81 using root.geometry('604x604')604x604
# We use the keys A and S(part of AWSD keys because they allow the gamer to access more of the keys around them, which means more keys may be assigned to other tasks in the game.
from tkinter import *
from random import randrange
from PIL import ImageTk,Image
def viewTheCommands():
import tkinter as tk
master = tk.Tk()
whatever_you_do = "A(<--LEFT) is the ONLY key used in place of the LEFT(<--) arrow key to play the game .we shouldn’t play games at work. Press the Boss Key b to display appropriate image)"
msg = tk.Message(master, text = whatever_you_do)
msg.config(bg='lightgreen', font=('times', 24, 'italic'))
msg.pack()
def donothing():
filewin = Toplevel(root)
button = Button(filewin, text="view Commands")
button.pack()
# Enter player name and store in player_name then in pname variable
def set_player_name():
ws = Tk()
#The game should attempt to include the following features:
#3. The use of text.
ws.title("Snake Game Player Name Entry ")
ws.geometry('400x300')
ws['bg'] = '#ffbf00'
def printValue():
pname = player_name.get()
f = open("leaderboard.txt", "a")
f.write(pname + "\n")
Label(ws, text=f'{pname}, Registered!', pady=20, bg='#ffbf00').pack()
c.create_text(400, 400, font ='Terminal 25', text=pname, fill='green')
player_name = Entry(ws)
player_name.pack(pady=30)
Button(
ws,
text="Register Player",
padx=10,
pady=5,
command=printValue
).pack()
# Button for closing
exit_button = Button(ws, text="Exit", command=ws.destroy)
exit_button.pack(pady=20)
def menu_screen():
width=100
height=10
# 2 Illustrate the use of text
global text1, text2,text3
text1 = Canvas.create_text(width/2,height/2 - 200,font="Arial 20 bold", text="H E L L O K I T T Y")
text2 = Canvas.create_text(width/2,height/2 + 50,font="Arial 12 bold", text="Press p to Begin the Game")
text3 = Canvas.create_text(width/2,height/2 + 80,font="Arial 12 bold", text="Press c to View the Commands")
#delete_menu()
root = Tk()
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Enter Player Name, Default is GUEST ", command=set_player_name)
filemenu.add_command(label="Press P to Begin the game and to pause and unpause use A(<--LEFT)during game to move the snake and eat apple", command=menu_screen)
filemenu.add_command(label="Press here to View the Commands", command=viewTheCommands)
filemenu.add_command(label="Exit", command=donothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="Instructions", menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Undo", command=donothing)
editmenu.add_separator()
root.config(menu=menubar)
#root = Tk()
root.geometry('604x604')
root.title('Welcome to Snake Game')
width=604
height=604
pname=" "
c = Canvas(root,bg='yellow', width=604, height=604, highlightthickness=0)
c.pack()
c.create_text(302, 250, font='Terminal 17 bold', text="Press p to start and Pause the game", fill='blue')
c.create_text(400, 400, font='Terminal 12 bold', text=pname, fill='white',)
#The game should attempt to include the following features:
#1. The use of images.
myimg = PhotoImage(file='snake.png')
c.create_image(200, 10, image=myimg, anchor='nw')
s = []
directions = [[-30,0],[0,-30],[30,0],[0,30]]
which_direction = randrange(0,4)
ap = []
run = True
score = 0
speed = 50
score_board = ''
pause_text = ''
sp = ''
#The game should attempt to include the following features:
#2. The use of shapes.
def create_the_square(x, y):
square = c.create_rectangle(x, y, x+30, y+30, fill='', outline='green')
s.insert(0,square)
#Here we create a square shape 300 BY 300
def create_s():
for x in range(3):
create_the_square(x=300,y=300)
def s_move():
iswall()
if run:
for part in range(len(s)-1):
c.coords(s[part],c.coords(s[part+1]))
c.move(s[len(s)-1],directions[which_direction][0],directions[which_direction][1])
the_snake()
if run:
aple()
c.after(speed*3+70,s_move)
def the_snake():
for part in range(len(s)-1):
if c.coords(s[part]) == c.coords(s[len(s)-1]):
game_over()
def iswall():
if (c.coords(s[len(s)-1])[0]+directions[which_direction][0]>=600 or \
c.coords(s[len(s)-1])[1]+directions[which_direction][1]>=600 or \
c.coords(s[len(s)-1])[0]+directions[which_direction][0]<=-30 or \
c.coords(s[len(s)-1])[1]+directions[which_direction][1]<=-30) and run:
game_over()
def aple():
global score
x, y = randrange(0,600,30), randrange(0,600,30)
if not ap:
apple = c.create_rectangle(x+7,y+7,x+23,y+23, fill='green', outline='green')
ap.append(apple)
ap_co = [c.coords(ap[0])[0]-7,c.coords(ap[0])[1]-7]
if c.coords(s[len(s)-1])[:2] == ap_co:
create_the_square(c.coords(s[0])[0],c.coords(s[0])[1])
c.delete(ap[0])
del ap[0]
score += 1
score_counter()
def score_counter():
global score_board
c.delete(score_board)
score_board = c.create_text(5, 25, font='Terminal 50 bold', text=str(score), fill='blue', anchor=W)
def game_over():
global run
if score > 0:
f = open("leaderboard.txt", "a")
f.write(pname + " :" + str(score) + "\n")
run = False
c.create_text(302, 200, font='Terminal 50 bold', text='GAME OVER', fill='red')
c.create_text(302, 260, font ='Terminal 25', text=pname + " :" + str(score), fill='white')
root.bind('
', restart)
def restart(_):
global s, ap, run, which_direction, score
root.bind('
', pause)
c.delete(ALL)
score = 0
score_counter()
show_speed()
s = []
ap = []
which_direction = randrange(0,4)
create_s()
run = True
s_move()
def pause(_):
global run, pause_text
if run == False:
run = True
c.delete(pause_text)
c.after(speed*3+70,s_move)
else:
run = False
pause_text = c.create_text(302, 250, font='Terminal 30 bold', text="Press p to resume", fill='white')
def rotate_left(_):
global which_direction
if run: which_direction += 1
if which_direction == 4: which_direction = 0
def rotate_right(_):
global which_direction
if run: which_direction -= 1
if which_direction == -1: which_direction = 3
def show_speed():
global sp
c.delete(sp)
sp = c.create_text(10, 585, font='TimesNewRoman 10', text=f'speed: {100-speed}', fill='blue', anchor=W)
def increase_speed(_):
global speed
if speed > 0:
speed -= 1
show_speed()
def decrease_speed(_):
global speed
if speed < 100:
speed += 1
show_speed()
def display_boss_image(_):
from PIL import ImageTk,Image
root = Tk()
canvas = Canvas(root, width = 1500, height = 1500)
canvas.pack()
img = ImageTk.PhotoImage(Image.open("boss.png"))
canvas.create_image(10, 10, anchor=NW, image=img)
def start(_):
# leaderboard = []
f = open('Leaderboard.txt', 'r')
leaderboard = [line.replace('\n','') for line in f.readlines()]
for i in leaderboard:
print(i)
global score_board
root.bind('', display_boss_image)
root.bind('
', pause)
root.bind('k',increase_speed)
root.bind('l',decrease_speed)
c.delete(ALL)
score_counter()
show_speed()
root.bind('a',rotate_right)
root.bind('d',rotate_left)
create_s()
s_move()
root.bind('
',start)
root.mainloop()
Get the best Essential Features For A Comprehensive Game Design assignment help and tutoring services from our experts now!
Our team of Python experts has successfully finished this sample Python assignment. The provided solutions are intended solely for research and reference. If you find the reports and code useful, our Python tutors would be happy to help.
- For a complete solution package that includes code, reports, and screenshots, please check out our Python Assignment Sample Solution page.
- For personalized online tutoring sessions to address any questions you have about this assignment, reach out to our Python experts.
- For additional insights, explore the partial solution available in the blog above.
About The Author - Jane Doe
Jane Doe is a game design expert with extensive experience in developing engaging and interactive games. She specializes in integrating visual elements, scoring systems, leaderboards, and customizable features. Jane's passion lies in creating dynamic gaming experiences with innovative functionalities like save/load features and boss keys.