def on_tick(self): bacon.draw_image(title, 0, 0) bacon.push_color() bacon.set_color(0, 0, 0, 1 - round( (abs(bacon.mouse.y - 270.0) / 540.0), 2)) bacon.draw_string(titlefont, 'ELEMENT', 70, 100) bacon.draw_string(titlefont, 'RUNNER', 250, 140) bacon.draw_string(byline, "Game Over", 150, 180) bacon.draw_string(planet, "Final Score: %d" % myplayer.money_in_bank, 150, 210) bacon.draw_string(planet, "[ press 'space' to start a new game ]", 150, 235) bacon.draw_string(planet, "[ High Scores ]", 150, 280) if myplayer.turn > 10: high_score.append([ int(myplayer.money_in_bank + myplayer.money_in_pocket), myplayer.name ]) high_score.sort(key=None, reverse=True) myplayer.turn = 10 for i, item in enumerate(high_score): bacon.draw_string(planet, "%s " % high_score[i][1], 150, (315 + line_height * i)) bacon.draw_string(planet, " ........ ", 150 + len(high_score[i][1]), (315 + line_height * i)) bacon.draw_string(planet, "%d" % high_score[i][0], 300, (315 + line_height * i)) bacon.pop_color() if bacon.Keys.space in bacon.keys: myplayer.character_cleaner() myship.ship_cleaner() bacon.run(Enter_name())
def on_key(self, key, pressed): if key == bacon.Keys.escape: print "back to menu" bacon.run(menu) if key == bacon.Keys.f and pressed == False: bacon.window.fullscreen = not bacon.window.fullscreen self.generate_star_field()
def on_tick(self): bacon.draw_image(title, 0, 0) bacon.draw_string(planet, "[ Type your Name ]", 100, 430) bacon.draw_string(planet, "[ press 'Enter' when done ]", 100, 450) n = 0 for item in myplayer.name: bacon.draw_string(robot_speak, "%s" % myplayer.name[n], (240 + (10 * n)), 475) n += 1 if bacon.Keys.enter in bacon.keys: myplayer.name = "".join(myplayer.name) bacon.run(Character_Builder())
def on_tick(self): bacon.draw_image(title, 0, 0) bacon.push_color() bacon.set_color(0, 0, 0, 1 - round((abs(bacon.mouse.y-270.0)/540.0), 2)) bacon.draw_string(titlefont, 'ELEMENT', 70, 100) bacon.draw_string(titlefont, 'RUNNER', 250, 140) bacon.draw_string(byline, "a game by ben kulp", 150, 180) bacon.draw_string(planet, "[ press space to begin ]", 130, bacon.window.height/2) bacon.draw_string(planet, "[ hold 'h' for tutorial ]", 130, (bacon.window.height/2 - 30)) bacon.pop_color() if bacon.Keys.space in bacon.keys: bacon.run(Enter_name()) if bacon.Keys.h in bacon.keys: bacon.draw_image(tutorial, 0, 0)
def on_tick(self): bacon.draw_image(title, 0, 0) bacon.push_color() bacon.set_color(0, 0, 0, 1 - round( (abs(bacon.mouse.y - 270.0) / 540.0), 2)) bacon.draw_string(titlefont, 'ELEMENT', 70, 100) bacon.draw_string(titlefont, 'RUNNER', 250, 140) bacon.draw_string(byline, "a game by ben kulp", 150, 180) bacon.draw_string(planet, "[ press space to begin ]", 130, bacon.window.height / 2) bacon.draw_string(planet, "[ hold 'h' for tutorial ]", 130, (bacon.window.height / 2 - 30)) bacon.pop_color() if bacon.Keys.space in bacon.keys: bacon.run(Enter_name()) if bacon.Keys.h in bacon.keys: bacon.draw_image(tutorial, 0, 0)
def on_tick(self): bacon.draw_image(title, 0, 0) bacon.push_color() bacon.set_color(0, 0, 0, 1 - round((abs(bacon.mouse.y-270.0)/540.0), 2)) bacon.draw_string(titlefont, 'ELEMENT', 70, 100) bacon.draw_string(titlefont, 'RUNNER', 250, 140) bacon.draw_string(byline, "Game Over", 150, 180) bacon.draw_string(planet, "Final Score: %d" % myplayer.money_in_bank, 150, 210) bacon.draw_string(planet, "[ press 'space' to start a new game ]", 150, 235) bacon.draw_string(planet, "[ High Scores ]", 150, 280) if myplayer.turn > 10: high_score.append([int(myplayer.money_in_bank + myplayer.money_in_pocket), myplayer.name]) high_score.sort(key=None, reverse=True) myplayer.turn = 10 for i, item in enumerate(high_score): bacon.draw_string(planet, "%s " % high_score[i][1], 150, (315 + line_height * i)) bacon.draw_string(planet, " ........ ", 150 + len(high_score[i][1]), (315 + line_height * i)) bacon.draw_string(planet, "%d" % high_score[i][0], 300, (315 + line_height * i)) bacon.pop_color() if bacon.Keys.space in bacon.keys: myplayer.character_cleaner() myship.ship_cleaner() bacon.run(Enter_name())
def on_tick(self): x, y = bacon.mouse.x, bacon.mouse.y oberon = [5000, 75, 40, 5] # set ship attributes intrepid = [6000, 225, 80, 2] excelsior = [4000, 100, 60, 2] firefly = [7000, 125, 80, 3] bacon.draw_image(title, 0, 0) bacon.draw_string(planet, "Select your starship", 240, 450) if x in range( (bacon.window.width * 0/4 + 20), (bacon.window.width * 0/4 + 20 + ship1.width)) and y in range( 300, (300 + ship1.height)): bacon.draw_image(triangle, (bacon.window.width * 0/4 + 42), 265) bacon.fill_rect(0, 125, 200, 265) bacon.push_color() bacon.set_color(0,0,0,1) #black bacon.draw_string(planet, "Class: Oberon", 10, 153) bacon.draw_string(planet, "Price: %d credits" % oberon[0], 10, 153 + line_height * 4) bacon.draw_string(planet, "Cargo Space: %d" % oberon[1], 10, 153 + line_height) bacon.draw_string(planet, "Weight: %d tons" % oberon[2], 10, 153 + line_height * 2) bacon.draw_string(planet, "Max Velocity: %d" % oberon[3], 10, 153 + line_height * 3) bacon.pop_color() if bacon.mouse.left: myplayer.ship = "Oberon" myplayer.money_in_pocket -= oberon[0] myship.cost_to_buy = oberon[0] myship.hauling_capacity = oberon[1] myship.weight = oberon[2] myship.velocity = oberon[3] bacon.run(Game()) bacon.draw_image(ship1, (bacon.window.width * 0/4 + 40), 300) if x in range( (bacon.window.width * 1/4 + 20), (bacon.window.width * 1/4 + 20 + ship1.width)) and y in range( 300, (300 + ship1.height)): bacon.draw_image(triangle, (bacon.window.width * 1/4 + 45), 265) bacon.fill_rect(135, 125, 335, 265) bacon.push_color() bacon.set_color(0,0,0,1) #black bacon.draw_string(planet, "Class: Intrepid", 145, 153) bacon.draw_string(planet, "Price: %d credits" % intrepid[0], 145, 153 + line_height * 4) bacon.draw_string(planet, "Cargo Space: %d" % intrepid[1], 145, 153 + line_height) bacon.draw_string(planet, "Weight: %d tons" % intrepid[2], 145, 153 + line_height * 2) bacon.draw_string(planet, "Max Velocity: %d" % intrepid[3], 145, 153 + line_height * 3) bacon.pop_color() if bacon.mouse.left: myplayer.ship = "Intrepid" myplayer.money_in_pocket -= intrepid[0] myship.cost_to_buy = intrepid[0] myship.hauling_capacity = intrepid[1] myship.weight = intrepid[2] myship.velocity = intrepid[3] bacon.run(Game()) bacon.draw_image(ship2, (bacon.window.width * 1/4 + 40), 300) if x in range( (bacon.window.width * 2/4 + 20), (bacon.window.width * 2/4 + 20 + ship1.width)) and y in range( 300, (300 + ship1.height)): bacon.draw_image(triangle, (bacon.window.width * 2/4 + 29), 265) bacon.fill_rect(290, 125, 490, 265) bacon.push_color() bacon.set_color(0,0,0,1) #black bacon.draw_string(planet, "Class: Excelsior", 300, 153) bacon.draw_string(planet, "Price: %d credits" % excelsior[0], 300, 153 + line_height * 4) bacon.draw_string(planet, "Cargo Space: %d" % excelsior[1], 300, 153 + line_height) bacon.draw_string(planet, "Weight: %d tons" % excelsior[2], 300, 153 + line_height * 2) bacon.draw_string(planet, "Max Velocity: %d" % excelsior[3], 300, 153 + line_height * 3) bacon.pop_color() if bacon.mouse.left: myplayer.ship = "Excelsior" myplayer.money_in_pocket -= excelsior[0] myship.cost_to_buy = excelsior[0] myship.hauling_capacity = excelsior[1] myship.weight = excelsior[2] myship.velocity = excelsior[3] bacon.run(Game()) bacon.draw_image(ship3, (bacon.window.width * 2/4 + 30), 300) if x in range( (bacon.window.width * 3/4 + 20), (bacon.window.width * 3/4 + 20 + ship1.width)) and y in range( 300, (300 + ship1.height)): bacon.draw_image(triangle, (bacon.window.width * 3/4 + 22), 265) bacon.fill_rect(440, 125, 640, 265) bacon.push_color() bacon.set_color(0,0,0,1) #black bacon.draw_string(planet, "Class: Firefly", 450, 153) bacon.draw_string(planet, "Price: %d credits" % firefly[0], 450, 153 + line_height * 4) bacon.draw_string(planet, "Cargo Space: %d" % firefly[1], 450, 153 + line_height) bacon.draw_string(planet, "Weight: %d tons" % firefly[2], 450, 153 + line_height * 2) bacon.draw_string(planet, "Max Velocity: %d" % firefly[3], 450, 153 + line_height * 3) bacon.pop_color() if bacon.mouse.left: myplayer.ship = "Firefly" myplayer.money_in_pocket -= firefly[0] myship.cost_to_buy = firefly[0] myship.hauling_capacity = firefly[1] myship.weight = firefly[2] myship.velocity = firefly[3] bacon.run(Game()) bacon.draw_image(ship4, (bacon.window.width * 3/4 + 20), 300)
bacon.draw_string(titlefont, 'RUNNER', 250, 140) bacon.draw_string(byline, "Game Over", 150, 180) bacon.draw_string(planet, "Final Score: %d" % myplayer.money_in_bank, 150, 210) bacon.draw_string(planet, "[ press 'space' to start a new game ]", 150, 235) bacon.draw_string(planet, "[ High Scores ]", 150, 280) if myplayer.turn > 10: high_score.append([int(myplayer.money_in_bank + myplayer.money_in_pocket), myplayer.name]) high_score.sort(key=None, reverse=True) myplayer.turn = 10 for i, item in enumerate(high_score): bacon.draw_string(planet, "%s " % high_score[i][1], 150, (315 + line_height * i)) bacon.draw_string(planet, " ........ ", 150 + len(high_score[i][1]), (315 + line_height * i)) bacon.draw_string(planet, "%d" % high_score[i][0], 300, (315 + line_height * i)) bacon.pop_color() if bacon.Keys.space in bacon.keys: myplayer.character_cleaner() myship.ship_cleaner() bacon.run(Enter_name()) bacon.run(Menu())
import bacon kitten = bacon.Image('res/kitten.png') class Game(bacon.Game): def on_tick(self): bacon.clear(0, 0, 0, 1) x, y = bacon.mouse.x, bacon.mouse.y bacon.draw_image_region(kitten, x - 50, y - 50, x + 50, y + 50, x - 50, y - 50, x + 50, y + 50) bacon.run(Game())
bacon.draw_string(byline, "Game Over", 150, 180) bacon.draw_string(planet, "Final Score: %d" % myplayer.money_in_bank, 150, 210) bacon.draw_string(planet, "[ press 'space' to start a new game ]", 150, 235) bacon.draw_string(planet, "[ High Scores ]", 150, 280) if myplayer.turn > 10: high_score.append([ int(myplayer.money_in_bank + myplayer.money_in_pocket), myplayer.name ]) high_score.sort(key=None, reverse=True) myplayer.turn = 10 for i, item in enumerate(high_score): bacon.draw_string(planet, "%s " % high_score[i][1], 150, (315 + line_height * i)) bacon.draw_string(planet, " ........ ", 150 + len(high_score[i][1]), (315 + line_height * i)) bacon.draw_string(planet, "%d" % high_score[i][0], 300, (315 + line_height * i)) bacon.pop_color() if bacon.Keys.space in bacon.keys: myplayer.character_cleaner() myship.ship_cleaner() bacon.run(Enter_name()) bacon.run(Menu())
# current alpha = current alpha + (0.5 * bacon.timestep) # or # current alpha = current alpha + (-0.5 * bacon.timestep) pirate.alpha += (self.alpha_value * bacon.timestep) # draw the scallywag pirate.draw() # called by bacon when the window is resized def on_resize(self, w, h): # when the window is resized, center our sprites kitten.center_image() pirate.center_image() # called when the mouse wheel is scrolled def on_mouse_scroll(self, dx, dy): pirate.scale_x += dy pirate.scale_y += dy # called when a key is down/up def on_key(self, key, pressed): # if the F key was pressed and then released # Note: (pressed == False) happens once when a key is pressed and released if key == bacon.Keys.f and pressed == False: # toggle fullscreen value bacon.window.fullscreen = not bacon.window.fullscreen # run the bacon scene bacon.run(myGame())
def on_mouse_button(self, button, pressed): if pressed: bacon.run(menu)
bacon.draw_string(font, 'This is the menu; click to start game', bacon.window.width / 2, bacon.window.height / 2, align=bacon.Alignment.center, vertical_align=bacon.VerticalAlignment.center) def on_mouse_button(self, button, pressed): if pressed: bacon.run(game) class Game(bacon.Game): def on_tick(self): bacon.clear(0.2, 0, 0, 1) bacon.draw_string(font, 'This is the game; click to return to menu', bacon.window.width / 2, bacon.window.height / 2, align=bacon.Alignment.center, vertical_align=bacon.VerticalAlignment.center) def on_mouse_button(self, button, pressed): if pressed: bacon.run(menu) game = Game() menu = Menu() bacon.run(menu)
def on_mouse_button(self, button, pressed): x, y = bacon.mouse.x, bacon.mouse.y if window.bank: #money goest into/out of bank in 1000 increments for speed/simplicity if x in range(515, 617) and y in range(412, 442) and myplayer.money_in_bank > 1000: myplayer.money_in_bank -= 1000 myplayer.money_in_pocket += 1000 elif x in range(515, 617) and y in range(378, 406) and myplayer.money_in_pocket > 1000: myplayer.money_in_bank += 1000 myplayer.money_in_pocket -= 1000 if window.destination: for item in planet_list: # on mouse hover over planet if x in range(item[1], item[1] + 12) and y in range(item[2], item[2] + 12): distance_and_fuel(myplayer.location_x, myplayer.location_y, item[1], item[2]) bacon.push_color() # place pin bacon.set_color(.74, .07, .07, 1) # red bacon.draw_image(target, item[1] - 7, item[2] - 20) bacon.pop_color() bacon.push_color() # set fuel usage in red on gauge gauge_level = (179 * (myplayer.fuel_used/100.0)) if gauge_level == 0: gauge_level = 14 bacon.set_color(.74, .07, .07, 1) # red bacon.fill_rect(14, 496, (gauge_level), 530) bacon.pop_color() bacon.push_color() bacon.set_color(0, 0, 0, 1) if myplayer.fuel_used > myship.fuel: bacon.draw_string(planet, "need more fuel", 16, 522) else: bacon.draw_string(planet, "fuel used: %r " % myplayer.fuel_used, 16, 522) bacon.pop_color() myplayer.destination = copy.copy(item[0]) myplayer.destination_x = copy.copy(item[1]) myplayer.destination_y = copy.copy(item[2]) bacon.draw_image(depart, 561, 485) if myplayer.destination: # set up next turn properties if myplayer.destination_x == myplayer.location_x and myplayer.destination_y == myplayer.location_y: return False elif x in range( depart_range['x1'], depart_range['x2']) and y in range( depart_range['y1'], depart_range['y2']): myplayer.location_x = copy.copy(myplayer.destination_x) # move player to destination myplayer.location_y = copy.copy(myplayer.destination_y) myplayer.turn += 1 # advance turn myship.fuel -= myplayer.fuel_used # remove fuel from flight myplayer.destination_x = None # return destination variables to none myplayer.destination_y = None myplayer.destination = None if myplayer.money_in_bank < 0: myplayer.money_in_bank += (myplayer.money_in_bank * .15) # calc bank loan interest else: myplayer.money_in_bank += (myplayer.money_in_bank * .05) # calc bank interest price_refresh()# recalculate price index and quantities if myplayer.turn > 10: bacon.run(Game_Over()) if window.refuel: if x in range(230, 260) and y in range(408, 444): # no refill window.refuel = False if x in range(102, 140) and y in range(408, 444): # yes refill refill_tank() window.refuel = False
def on_tick(self): x, y = bacon.mouse.x, bacon.mouse.y oberon = [5000, 75, 40, 5] # set ship attributes intrepid = [6000, 225, 80, 2] excelsior = [4000, 100, 60, 2] firefly = [7000, 125, 80, 3] bacon.draw_image(title, 0, 0) bacon.draw_string(planet, "Select your starship", 240, 450) if x in range( (bacon.window.width * 0 / 4 + 20), (bacon.window.width * 0 / 4 + 20 + ship1.width)) and y in range( 300, (300 + ship1.height)): bacon.draw_image(triangle, (bacon.window.width * 0 / 4 + 42), 265) bacon.fill_rect(0, 125, 200, 265) bacon.push_color() bacon.set_color(0, 0, 0, 1) #black bacon.draw_string(planet, "Class: Oberon", 10, 153) bacon.draw_string(planet, "Price: %d credits" % oberon[0], 10, 153 + line_height * 4) bacon.draw_string(planet, "Cargo Space: %d" % oberon[1], 10, 153 + line_height) bacon.draw_string(planet, "Weight: %d tons" % oberon[2], 10, 153 + line_height * 2) bacon.draw_string(planet, "Max Velocity: %d" % oberon[3], 10, 153 + line_height * 3) bacon.pop_color() if bacon.mouse.left: myplayer.ship = "Oberon" myplayer.money_in_pocket -= oberon[0] myship.cost_to_buy = oberon[0] myship.hauling_capacity = oberon[1] myship.weight = oberon[2] myship.velocity = oberon[3] bacon.run(Game()) bacon.draw_image(ship1, (bacon.window.width * 0 / 4 + 40), 300) if x in range( (bacon.window.width * 1 / 4 + 20), (bacon.window.width * 1 / 4 + 20 + ship1.width)) and y in range( 300, (300 + ship1.height)): bacon.draw_image(triangle, (bacon.window.width * 1 / 4 + 45), 265) bacon.fill_rect(135, 125, 335, 265) bacon.push_color() bacon.set_color(0, 0, 0, 1) #black bacon.draw_string(planet, "Class: Intrepid", 145, 153) bacon.draw_string(planet, "Price: %d credits" % intrepid[0], 145, 153 + line_height * 4) bacon.draw_string(planet, "Cargo Space: %d" % intrepid[1], 145, 153 + line_height) bacon.draw_string(planet, "Weight: %d tons" % intrepid[2], 145, 153 + line_height * 2) bacon.draw_string(planet, "Max Velocity: %d" % intrepid[3], 145, 153 + line_height * 3) bacon.pop_color() if bacon.mouse.left: myplayer.ship = "Intrepid" myplayer.money_in_pocket -= intrepid[0] myship.cost_to_buy = intrepid[0] myship.hauling_capacity = intrepid[1] myship.weight = intrepid[2] myship.velocity = intrepid[3] bacon.run(Game()) bacon.draw_image(ship2, (bacon.window.width * 1 / 4 + 40), 300) if x in range( (bacon.window.width * 2 / 4 + 20), (bacon.window.width * 2 / 4 + 20 + ship1.width)) and y in range( 300, (300 + ship1.height)): bacon.draw_image(triangle, (bacon.window.width * 2 / 4 + 29), 265) bacon.fill_rect(290, 125, 490, 265) bacon.push_color() bacon.set_color(0, 0, 0, 1) #black bacon.draw_string(planet, "Class: Excelsior", 300, 153) bacon.draw_string(planet, "Price: %d credits" % excelsior[0], 300, 153 + line_height * 4) bacon.draw_string(planet, "Cargo Space: %d" % excelsior[1], 300, 153 + line_height) bacon.draw_string(planet, "Weight: %d tons" % excelsior[2], 300, 153 + line_height * 2) bacon.draw_string(planet, "Max Velocity: %d" % excelsior[3], 300, 153 + line_height * 3) bacon.pop_color() if bacon.mouse.left: myplayer.ship = "Excelsior" myplayer.money_in_pocket -= excelsior[0] myship.cost_to_buy = excelsior[0] myship.hauling_capacity = excelsior[1] myship.weight = excelsior[2] myship.velocity = excelsior[3] bacon.run(Game()) bacon.draw_image(ship3, (bacon.window.width * 2 / 4 + 30), 300) if x in range( (bacon.window.width * 3 / 4 + 20), (bacon.window.width * 3 / 4 + 20 + ship1.width)) and y in range( 300, (300 + ship1.height)): bacon.draw_image(triangle, (bacon.window.width * 3 / 4 + 22), 265) bacon.fill_rect(440, 125, 640, 265) bacon.push_color() bacon.set_color(0, 0, 0, 1) #black bacon.draw_string(planet, "Class: Firefly", 450, 153) bacon.draw_string(planet, "Price: %d credits" % firefly[0], 450, 153 + line_height * 4) bacon.draw_string(planet, "Cargo Space: %d" % firefly[1], 450, 153 + line_height) bacon.draw_string(planet, "Weight: %d tons" % firefly[2], 450, 153 + line_height * 2) bacon.draw_string(planet, "Max Velocity: %d" % firefly[3], 450, 153 + line_height * 3) bacon.pop_color() if bacon.mouse.left: myplayer.ship = "Firefly" myplayer.money_in_pocket -= firefly[0] myship.cost_to_buy = firefly[0] myship.hauling_capacity = firefly[1] myship.weight = firefly[2] myship.velocity = firefly[3] bacon.run(Game()) bacon.draw_image(ship4, (bacon.window.width * 3 / 4 + 20), 300)
def on_mouse_button(self, button, pressed): x, y = bacon.mouse.x, bacon.mouse.y if window.bank: #money goest into/out of bank in 1000 increments for speed/simplicity if x in range(515, 617) and y in range( 412, 442) and myplayer.money_in_bank > 1000: myplayer.money_in_bank -= 1000 myplayer.money_in_pocket += 1000 elif x in range(515, 617) and y in range( 378, 406) and myplayer.money_in_pocket > 1000: myplayer.money_in_bank += 1000 myplayer.money_in_pocket -= 1000 if window.destination: for item in planet_list: # on mouse hover over planet if x in range(item[1], item[1] + 12) and y in range( item[2], item[2] + 12): distance_and_fuel(myplayer.location_x, myplayer.location_y, item[1], item[2]) bacon.push_color() # place pin bacon.set_color(.74, .07, .07, 1) # red bacon.draw_image(target, item[1] - 7, item[2] - 20) bacon.pop_color() bacon.push_color() # set fuel usage in red on gauge gauge_level = (179 * (myplayer.fuel_used / 100.0)) if gauge_level == 0: gauge_level = 14 bacon.set_color(.74, .07, .07, 1) # red bacon.fill_rect(14, 496, (gauge_level), 530) bacon.pop_color() bacon.push_color() bacon.set_color(0, 0, 0, 1) if myplayer.fuel_used > myship.fuel: bacon.draw_string(planet, "need more fuel", 16, 522) else: bacon.draw_string( planet, "fuel used: %r " % myplayer.fuel_used, 16, 522) bacon.pop_color() myplayer.destination = copy.copy(item[0]) myplayer.destination_x = copy.copy(item[1]) myplayer.destination_y = copy.copy(item[2]) bacon.draw_image(depart, 561, 485) if myplayer.destination: # set up next turn properties if myplayer.destination_x == myplayer.location_x and myplayer.destination_y == myplayer.location_y: return False elif x in range(depart_range['x1'], depart_range['x2']) and y in range( depart_range['y1'], depart_range['y2']): myplayer.location_x = copy.copy( myplayer.destination_x) # move player to destination myplayer.location_y = copy.copy(myplayer.destination_y) myplayer.turn += 1 # advance turn myship.fuel -= myplayer.fuel_used # remove fuel from flight myplayer.destination_x = None # return destination variables to none myplayer.destination_y = None myplayer.destination = None if myplayer.money_in_bank < 0: myplayer.money_in_bank += (myplayer.money_in_bank * .15 ) # calc bank loan interest else: myplayer.money_in_bank += (myplayer.money_in_bank * .05 ) # calc bank interest price_refresh() # recalculate price index and quantities if myplayer.turn > 10: bacon.run(Game_Over()) if window.refuel: if x in range(230, 260) and y in range(408, 444): # no refill window.refuel = False if x in range(102, 140) and y in range(408, 444): # yes refill refill_tank() window.refuel = False
import bacon kitten = bacon.Image('res/kitten.png') class Game(bacon.Game): def on_tick(self): bacon.clear(0, 0, 0, 1) bacon.set_color(1, 0, 0, 1) bacon.draw_image(kitten, 0, 0) bacon.run(Game())
def on_mouse_button(self, button, pressed): if pressed: print "onwards to game!" bacon.run(game)