Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import simplegui
- import math
- width = 900
- height = 900
- # player to obstacles variables
- orbit_time = 5
- fx = 0
- fy = 0
- dx = 0
- dy = 0
- force_scalar = 0
- distance = 0
- collision = 0
- player_mass = 5
- key_binding = "up"
- hover_pos_spacecraft = 0
- met_planet_list = []
- obstacle_check_color = 'White'
- # game global variables
- timespent = 0
- lives = 3
- score = 4000
- t = 1000
- time_score = 10
- game_end = 0
- # hint boxes variables
- time_hint = 100
- time_hint_duration = 0
- hit_by_this_ticker = 100
- hit_by_this_duration = 0
- hint_message = ""
- deviator_warning_message = ""
- hit_by_this_lives2_message = ""
- hit_by_this_lives1_message = ""
- # Time functions
- def tick():
- global timespent
- timespent = timespent + 1
- def tick_score():
- global score
- score -= 1
- class spacecraft:
- def __init__(self,centre, lwidth,lcolour, fillcolour, vel, boost_acceleration, hitbox_radius):
- self.centre = centre
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.vel = vel
- self.boost_acceleration = boost_acceleration
- self.player_mass = player_mass
- self.hitbox_radius = hitbox_radius
- def move(self, obstacle):
- global width, height, lives, score, met_planet_list, obstacle_check_color
- self.centre[0] = self.centre[0] + self.vel[0]
- self.centre[1] = self.centre[1] + self.vel[1]
- # Code to ensure spacecraft doesn’t go beyond the edges of the canvas
- if self.centre[0] <= self.hitbox_radius:
- lives -= 1
- score -= 10
- self.centre = [50, 850]
- self.vel = [0, 0]
- victory_call.game_victory = 0
- met_planet_list = []
- o1.lcolour = 'White'
- o2.lcolour = 'White'
- o3.lcolour = 'White'
- o4.lcolour = 'White'
- o5.lcolour = 'White'
- o6.lcolour = 'White'
- o7.lcolour = 'White'
- o8.lcolour = 'White'
- o9.lcolour = 'White'
- o10.lcolour = 'White'
- elif self.centre[0] >= width-self.hitbox_radius:
- lives -= 1
- score -= 10
- self.centre = [50, 850]
- self.vel = [0, 0]
- victory_call.game_victory = 0
- met_planet_list = []
- o1.lcolour = 'White'
- o2.lcolour = 'White'
- o3.lcolour = 'White'
- o4.lcolour = 'White'
- o5.lcolour = 'White'
- o6.lcolour = 'White'
- o7.lcolour = 'White'
- o8.lcolour = 'White'
- o9.lcolour = 'White'
- o10.lcolour = 'White'
- elif self.centre[1] <= self.hitbox_radius:
- lives -= 1
- score -= 10
- self.centre = [50, 850]
- self.vel = [0, 0]
- victory_call.game_victory = 0
- met_planet_list = []
- o1.lcolour = 'White'
- o2.lcolour = 'White'
- o3.lcolour = 'White'
- o4.lcolour = 'White'
- o5.lcolour = 'White'
- o6.lcolour = 'White'
- o7.lcolour = 'White'
- o8.lcolour = 'White'
- o9.lcolour = 'White'
- o10.lcolour = 'White'
- elif self.centre[1] >= height-self.hitbox_radius:
- lives -= 1
- score -= 10
- self.centre = [50, 850]
- self.vel = [0, 0]
- victory_call.game_victory = 0
- met_planet_list = []
- o1.lcolour = 'White'
- o2.lcolour = 'White'
- o3.lcolour = 'White'
- o4.lcolour = 'White'
- o5.lcolour = 'White'
- o6.lcolour = 'White'
- o7.lcolour = 'White'
- o8.lcolour = 'White'
- o9.lcolour = 'White'
- o10.lcolour = 'White'
- def drawSpacecraft(self, canvas):
- canvas.draw_polygon([(self.centre[0] + 10, self.centre[1]), (self.centre[0] - 10, self.centre[1] -10), (self.centre[0] -10, self.centre[1] +10)], self.lwidth, self.lcolour, self.fillcolour)
- def gravity(self, obstacle):
- global dx, dy, distance, force_scalar, fx, fy, theta, ax, ay, orbit_time, collision, lives, score, player_mass, Call_hit_by_this_message, hit_by_this_lives2_message, hit_by_this_lives1_message, ticker_hint, met_planet_list, obstacle_check_color
- dx = (obstacle.centre[0]- self.centre[0])
- dy = (obstacle.centre[1] - self.centre[1])
- # Calculate the distance between the spacecraft and the obstacle - d
- distance = math.sqrt(dx**2 + dy**2)
- # Calculate the gravitational force - F
- force_scalar = player_mass * obstacle.mass/(distance**2)
- # Compute the direction of the force
- theta = math.atan2(dy, dx)
- # Calculate x and y components of the force
- fx = math.cos(theta) * force_scalar
- fy = math.cos(theta) * force_scalar
- # Axis changing
- if self.centre[0] > obstacle.centre[0]:
- theta = -theta
- elif self.centre[0] < obstacle.centre[0]:
- theta = math.fabs(theta)
- elif self.centre[1] > obstacle.centre[1]:
- theta = math.fabs(theta)
- elif self.centre[1] < obstacle.centre[1]:
- theta = -theta
- # Calculate acceleration in x and y directions
- ax = fx/player_mass
- ay = fy/player_mass
- # updating velocity components using acceleration
- self.vel[0] = self.vel[0]+ ax * orbit_time
- self.vel[1]= self.vel[1] + ay * orbit_time
- # Collision detection -
- if distance <= (10 + obstacle.radius):
- lives -= 1
- score -= 100
- self.centre = [50, 850]
- self.vel = [0, 0]
- Call_hit_by_this_message.planet_hit_location2 = obstacle.centre
- Call_hit_by_this_message.planet_hit_location1 = obstacle.centre
- Call_hit_by_this_message.planet_hit_lives2 = obstacle.SNo
- Call_hit_by_this_message.planet_hit_lives1 = obstacle.SNo
- victory_call.game_victory = 0
- met_planet_list = []
- obstacle.lcolour = 'White'
- o1.lcolour = 'White'
- o2.lcolour = 'White'
- o3.lcolour = 'White'
- o4.lcolour = 'White'
- o5.lcolour = 'White'
- o6.lcolour = 'White'
- o7.lcolour = 'White'
- o8.lcolour = 'White'
- o9.lcolour = 'White'
- o10.lcolour = 'White'
- if lives <= 2 and lives >= 1:
- hit_by_this_lives2_message = "You've been hit by planet" + " " + str(Call_hit_by_this_message.planet_hit_lives2)
- if lives <= 1:
- hit_by_this_lives1_message = "You've been hit by planet" + " " + str(Call_hit_by_this_message.planet_hit_lives1)
- def met_planet(self, obstacle_hitboxes, obstacle):
- global dx, dy, distance, met_planet_list, obstacle_check_color
- # met planet checker
- if distance <= (80 + obstacle_hitboxes.radius):
- met_planet_list.append(str(obstacle_hitboxes.SNo))
- obstacle.lcolour = 'Green'
- # Key Bindings
- def keydown(self, key):
- # Code for booster
- global key_binding, hover_pos_spacecraft, game_end, timespent, score, lives, hit_by_this_lives2_message, hit_by_this_lives1_message, met_planet_list, obstacle_check_color
- if key == simplegui.KEY_MAP[key_binding]:
- self.vel[1] -= self.boost_acceleration
- elif key == simplegui.KEY_MAP["space"]:
- hover_pos_spacecraft = 10
- if key == simplegui.KEY_MAP["r"] and game_end == 1:
- lives = 3
- timespent = 0
- score = 4000
- hit_by_this_lives2_message = ""
- hit_by_this_lives1_message = ""
- hover_pos_spacecraft = 0
- Call_hit_by_this_message.hit_by_this_spacer = 0
- victory_call.game_victory = 0
- def keyup(self, key):
- #Code for booster key
- global key_binding, game_end
- if key == simplegui.KEY_MAP[key_binding]:
- self.vel[1] = 0
- if key == simplegui.KEY_MAP["r"]:
- game_end = 0
- # Obstacles classes
- class obstacle1:
- def __init__(self, centre,radius, lwidth, lcolour,fillcolour, SNo, mass):
- self.centre = centre
- self.radius = radius
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.SNo = SNo
- self.mass = mass
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-5, self.centre[1]+5], 20, "White")
- class obstacle2:
- def __init__(self, centre,radius, lwidth, lcolour,fillcolour, SNo, mass):
- self.centre = centre
- self.radius = radius
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.SNo = SNo
- self.mass = mass
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-5, self.centre[1]+5], 20, "White")
- class obstacle3:
- def __init__(self, centre,radius, lwidth, lcolour,fillcolour, SNo, mass):
- self.centre = centre
- self.radius = radius
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.SNo = SNo
- self.mass = mass
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-5, self.centre[1]+5], 20, "White")
- class obstacle4:
- def __init__(self, centre,radius, lwidth, lcolour,fillcolour, SNo, mass):
- self.centre = centre
- self.radius = radius
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.SNo = SNo
- self.mass = mass
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-5, self.centre[1]+5], 20, "White")
- class obstacle5:
- def __init__(self, centre,radius, lwidth, lcolour,fillcolour, SNo, mass):
- self.centre = centre
- self.radius = radius
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.SNo = SNo
- self.mass = mass
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-5, self.centre[1]+5], 20, "White")
- class obstacle6:
- def __init__(self, centre,radius, lwidth, lcolour,fillcolour, SNo, mass):
- self.centre = centre
- self.radius = radius
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.SNo = SNo
- self.mass = mass
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-5, self.centre[1]+5], 20, "White")
- class obstacle7:
- def __init__(self, centre,radius, lwidth, lcolour,fillcolour, SNo, mass):
- self.centre = centre
- self.radius = radius
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.SNo = SNo
- self.mass = mass
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-5, self.centre[1]+5], 20, "White")
- class obstacle8:
- def __init__(self, centre,radius, lwidth, lcolour,fillcolour, SNo, mass):
- self.centre = centre
- self.radius = radius
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.SNo = SNo
- self.mass = mass
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-5, self.centre[1]+5], 20, "White")
- class obstacle9:
- def __init__(self, centre,radius, lwidth, lcolour,fillcolour, SNo, mass):
- self.centre = centre
- self.radius = radius
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.SNo = SNo
- self.mass = mass
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-5, self.centre[1]+5], 20, "White")
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-5, self.centre[1]+5], 20, "White")
- class obstacle10:
- def __init__(self, centre,radius, lwidth, lcolour,fillcolour, SNo, mass):
- self.centre = centre
- self.radius = radius
- self.lwidth = lwidth
- self.lcolour = lcolour
- self.fillcolour = fillcolour
- self.SNo = SNo
- self.mass = mass
- def drawobstacle(self, canvas):
- canvas.draw_circle([self.centre[0], self.centre[1]], self.radius,self.lwidth,self.lcolour,self.fillcolour)
- canvas.draw_text(str(self.SNo), [self.centre[0]-11, self.centre[1]+5], 20, "White")
- # obstacle hitboxes to utilize
- class obstacle_hitboxes1:
- def __init__(self, centre,radius, SNo):
- self.centre = centre
- self.radius = radius
- self.SNo = SNo
- class obstacle_hitboxes2:
- def __init__(self, centre,radius, SNo):
- self.centre = centre
- self.radius = radius
- self.SNo = SNo
- class obstacle_hitboxes3:
- def __init__(self, centre,radius, SNo):
- self.centre = centre
- self.radius = radius
- self.SNo = SNo
- class obstacle_hitboxes4:
- def __init__(self, centre,radius, SNo):
- self.centre = centre
- self.radius = radius
- self.SNo = SNo
- class obstacle_hitboxes5:
- def __init__(self, centre,radius, SNo):
- self.centre = centre
- self.radius = radius
- self.SNo = SNo
- class obstacle_hitboxes6:
- def __init__(self, centre,radius, SNo):
- self.centre = centre
- self.radius = radius
- self.SNo = SNo
- class obstacle_hitboxes7:
- def __init__(self, centre,radius, SNo):
- self.centre = centre
- self.radius = radius
- self.SNo = SNo
- class obstacle_hitboxes8:
- def __init__(self, centre,radius, SNo):
- self.centre = centre
- self.radius = radius
- self.SNo = SNo
- class obstacle_hitboxes9:
- def __init__(self, centre,radius, SNo):
- self.centre = centre
- self.radius = radius
- self.SNo = SNo
- class obstacle_hitboxes10:
- def __init__(self, centre,radius, SNo):
- self.centre = centre
- self.radius = radius
- self.SNo = SNo
- # Hint message
- class hint_message_fun:
- def hint_trigger():
- global ticker_hint, key_binding, hint_message, lives, time_hint_duration
- if lives == 2:
- ticker_hint.start()
- hint_message = "Hint: Carefully rapid tap the" + " \"" + str(key_binding) + "\" " + "key to boost."
- if time_hint_duration > 30:
- hint_message = ""
- ticker_hint.stop()
- def tick_hint():
- global time_hint_duration
- time_hint_duration += 1
- class hit_by_this_message:
- def __init__(self, planet_hit_lives2, planet_hit_lives1, planet_hit_location2, planet_hit_location1, time_hint_restart, hit_by_this_spacer):
- self.planet_hit_lives2 = planet_hit_lives2
- self.planet_hit_lives1 = planet_hit_lives1
- self.planet_hit_location2 = planet_hit_location2
- self.planet_hit_location1 = planet_hit_location1
- self.time_hint_restart = time_hint_restart
- self.hit_by_this_spacer = hit_by_this_spacer
- def hit_by_this_lives2(self):
- global lives, hit_by_this_lives2_message, time_hint_duration
- if time_hint_duration > 30:
- hit_by_this_lives2_message = ""
- if self.planet_hit_location2[0] < 750:
- self.hit_by_this_spacer = 0
- def time_hit_by_this_restarter(self):
- global time_hint_duration, ticker_hint
- if self.time_hint_restart == 1:
- time_hint_duration = 0
- self.time_hint_restart = 0
- def hit_by_this_lives1(self):
- global lives, hit_by_this_lives1_message, time_hint_duration
- if lives <= 1:
- if time_hint_duration > 30:
- hit_by_this_lives1_message = ""
- if self.planet_hit_location2[0] < 750:
- self.hit_by_this_spacer = 0
- def draw_hitbythis_text(self, canvas):
- global hit_by_this_lives2_message, hit_by_this_lives1_message
- canvas.draw_text (hit_by_this_lives2_message, [self.planet_hit_location2[0] - (70 + self.hit_by_this_spacer), self.planet_hit_location2[1] - 25], 10, "White","monospace")
- canvas.draw_text (hit_by_this_lives1_message, [self.planet_hit_location1[0] - (70 + self.hit_by_this_spacer), self.planet_hit_location1[1] - 25], 10, "White","monospace")
- def text_spacer(self):
- global s1
- if s1.centre[0] > 780:
- self.hit_by_this_spacer = 30
- # Calling spacecraft
- s1 = spacecraft([50, 850] , 2,'black','Red', [0,0], 3.5, 10)
- #11 Obstacles
- obslist = []
- o1 = obstacle1 ([136, 803], 40, 5, 'White', 'Teal', 1, 10)
- obslist.append(o1)
- o2 = obstacle2 ([52, 700], 30, 5, 'White', 'Cyan', 2, 10)
- obslist.append(o2)
- o3 = obstacle3 ([205, 631], 55, 5, 'White', 'Brown', 3, 50)
- obslist.append(o3)
- o4 = obstacle4 ([351, 536], 40, 5, 'White', 'Red', 4, 40)
- obslist.append(o4)
- o5 = obstacle5 ([496, 689], 65, 5, 'White', 'Blue', 5, 50)
- obslist.append(o5)
- o6 = obstacle6 ([758, 558], 125, 5, 'White', 'Orange', 6, 50)
- obslist.append(o6)
- o7 = obstacle7 ([747, 304], 52, 5, 'White', 'Orange', 8, 30)
- obslist.append(o7)
- o8 = obstacle8 ([496, 223], 125, 5, 'White', 'Silver', 7, 40)
- obslist.append(o8)
- o9 = obstacle9 ([658, 141], 41, 5, 'White', 'Maroon', 9, 20)
- obslist.append(o9)
- o10 = obstacle10 ([859, 135], 30, 5, 'White', 'Orange', 10, 70)
- obslist.append(o10)
- # Obstacle hitboxes list
- obhitlist = []
- oh1 = obstacle_hitboxes1 ([136, 803], 70, 1)
- obhitlist.append(oh1)
- oh2 = obstacle_hitboxes2 ([52, 700], 60, 2)
- obhitlist.append(oh2)
- oh3 = obstacle_hitboxes3 ([205, 631], 85, 3)
- obhitlist.append(oh3)
- oh4 = obstacle_hitboxes4 ([351, 536], 70, 4)
- obhitlist.append(oh4)
- oh5 = obstacle_hitboxes5 ([496, 689], 95, 5)
- obhitlist.append(oh5)
- oh6 = obstacle_hitboxes6 ([758, 558], 105, 6)
- obhitlist.append(oh6)
- oh7 = obstacle_hitboxes7 ([747, 304], 82, 7)
- obhitlist.append(oh7)
- oh8 = obstacle_hitboxes8 ([476, 193], 115, 8)
- obhitlist.append(oh8)
- oh9 = obstacle_hitboxes9 ([658, 141], 71, 9)
- obhitlist.append(oh9)
- oh10 = obstacle_hitboxes10 ([859, 135], 60, 10)
- obhitlist.append(oh10)
- # Calling message functions
- Call_hint_message = hint_message_fun
- Call_hit_by_this_message = hit_by_this_message(0, 0, [0, 0], [0, 0], 0, 0)
- class planet_checker_for_victory:
- def __init__(self, game_victory):
- self.game_victory = game_victory
- def victory_checker(self, obstacle):
- if obstacle.lcolour == 'White':
- self.game_victory = 0
- elif o1.lcolour == 'White':
- self.game_victory = 0
- elif o2.lcolour == 'White':
- self.game_victory = 0
- elif o3.lcolour == 'White':
- self.game_victory = 0
- elif o4.lcolour == 'White':
- self.game_victory = 0
- elif o5.lcolour == 'White':
- self.game_victory = 0
- elif o6.lcolour == 'White':
- self.game_victory = 0
- elif o7.lcolour == 'White':
- self.game_victory = 0
- elif o8.lcolour == 'White':
- self.game_victory = 0
- elif o9.lcolour == 'White':
- self.game_victory = 0
- elif o10.lcolour == 'White':
- self.game_victory = 0
- else:
- self.game_victory = 1
- victory_call = planet_checker_for_victory(0)
- # Calling functions and drawing on canvas
- def draw(canvas):
- global s1, obslist, timespent, score, game_end, hit_by_this_lives2_message, Call_hit_by_this_message, hint_message, met_planet_list, obhitlist, victory_call, deviator_warning_message
- #Game Over Screen
- if lives == 0 or score < 0:
- canvas.draw_text("Game Over!", [330,450], 50, "Red")
- game_end = 1
- canvas.draw_text("Press R to restart", [360,500], 25, "White")
- elif s1.centre[0] > 740 and s1.centre[1] < 100 and victory_call.game_victory == 1:
- #Code to check if the spacecraft has reached the finish point and display
- #message on the canvas accordingly
- canvas.draw_text("You're Winner!", [330,440], 50, "Yellow")
- time_score.stop()
- t.stop()
- canvas.draw_text("You're score:" + " " + str(score), [372,485], 25, "White")
- canvas.draw_text("You've completed in:" + " " + str(timespent) + " seconds.", [370,520], 15, "White")
- else:
- # Draw main objects
- s1.drawSpacecraft(canvas)
- for item in obslist:
- item.drawobstacle(canvas)
- s1.gravity(item)
- s1.met_planet(item, item)
- victory_call.victory_checker(item)
- s1.move(item)
- # Deviator warning boundries
- if (s1.centre[0] < 490 and s1.centre[1] < 514) or (s1.centre[0] > 450 and s1.centre[1] > 645) or (s1.centre[0] > 806 and (s1.centre[1] < 465 and s1.centre[1] > 175)):
- deviator_warning_message = "You are going out of planet order and won't be able to complete the level."
- else:
- deviator_warning_message = ""
- # Code to display time elapsed
- canvas.draw_text ("Time Elapsed since the start:" + str(timespent), [200, 30], 20, "White","monospace")
- # Code to display lives on the canvas
- canvas.draw_text ("Lives left:" + str(lives), [570, 30], 20, "Yellow","monospace")
- # Code to display score on the canvas
- canvas.draw_text ("Score:" + str(score), [380, 70], 30, "Cyan","monospace")
- # Draw finish box
- canvas.draw_polygon([(740, 0), (740, 70), (900, 70), (900, 0)], 5, "Green", "Black")
- canvas.draw_text ("Finish Line", [790, 37], 10, "White","monospace")
- canvas.draw_text (deviator_warning_message, [100,400], 18, "White","monospace")
- # Draw hint text
- Call_hit_by_this_message.draw_hitbythis_text(canvas)
- canvas.draw_text (hint_message, [180,450], 20, "White","monospace")
- # Call hint trigger
- Call_hint_message.hint_trigger()
- Call_hit_by_this_message.hit_by_this_lives2()
- Call_hit_by_this_message.hit_by_this_lives1()
- Call_hit_by_this_message.time_hit_by_this_restarter()
- Call_hit_by_this_message.text_spacer()
- # Dev information text
- canvas.draw_text (str(s1.centre), [s1.centre[0] - 70, s1.centre[1] - 25], hover_pos_spacecraft, "White","monospace")
- canvas.draw_text (str(victory_call.game_victory), [290, 800], hover_pos_spacecraft/1.5, "White","monospace")
- #Frame Handlers
- f = simplegui.create_frame("Spacecraft Slingshot", width, height)
- t = simplegui.create_timer(t, tick)
- time_score = simplegui.create_timer(time_score, tick_score)
- ticker_hint = simplegui.create_timer(time_hint, Call_hint_message.tick_hint)
- f.set_keydown_handler(s1.keydown)
- f.set_keyup_handler(s1.keyup)
- f.set_draw_handler(draw)
- f.start()
- t.start()
- time_score.start()
- ticker_hint.stop()
Advertisement
Add Comment
Please, Sign In to add comment