change it with DAMOOON512 def setstage(): """ Sets up the stage and introduces the game…
- User
change it with DAMOOON_512 def set_stage(): """ Sets up the stage and introduces the game """ stage.set_background("planet") sprite = codesters.Sprite("astronaut1") sprite.set_say_color("white") sprite.say("Only click on the aliens and UFOs!") stage.wait(2) sprite.say("Don't click on the astronauts!") stage.wait(2) sprite.hide()
def add_click_event(sprite, my_display, my_dictionary): """ Attaches a click event to a sprite """ def click(sprite): stage.remove_sprite(sprite) image = sprite.get_image_name() my_value = my_dictionary.get(image) print(my_value) global score score += my_value my_display.update(score) # add other actions…
codesprite.event_click(click)def play_game(my_display, my_dictionary): """ Creates an interval event to start the game """ image_list = list(my_dictionary.keys()) print(image_list) def interval(): x = random.randint(-200, 200) y = random.randint(-200, 200) image = random.choice(image_list) sprite = codesters.Sprite(image, x, y) add_click_event(sprite, my_display, my_dictionary) stage.wait(1) stage.remove_sprite(sprite) # add any other actions…
codestage.event_interval(interval, 1)def main(): """ Sets up the program and calls other functions """ set_stage() global score score = 0 my_display = codesters.Display(score, 0, 175) my_dictionary = {"alien1": 10, "alien2": 20, "ufo": 5, "alien3": 15} my_dictionary["astronaut1"] = -100 print(my_dictionary) my_dictionary["astronaut2"] = -200 print(my_dictionary) play_game(my_display, my_dictionary)
main()
- Assistant
def set_stage(): """ Sets up the stage and introduces the game """ stage.set_background("planet") sprite = codesters.Sprite("astronaut1") sprite.set_say_color("white") sprite.say("Only click on the aliens and UFOs!") stage.wait(2) sprite.say("Don't click on the astronauts!") stage.wait(2) sprite.hide()
def add_click_event(sprite, my_display, my_dictionary): """ Attaches a click event to a sprite """ def click(sprite): stage.remove_sprite(sprite) image = sprite.get_image_name() my_value = my_dictionary.get(image) print(my_value) global score score += my_value my_display.update(score) # add other actions…
codesprite.event_click(click)def play_game(my_display, my_dictionary): """ Creates an interval event to start the game """ image_list = list(my_dictionary.keys()) print(image_list) def interval(): x = random.randint(-200, 200) y = random.randint(-200, 200) image = random.choice(image_list) sprite = codesters.Sprite(image, x, y) add_click_event(sprite, my_display, my_dictionary) stage.wait(1) stage.remove_sprite(sprite) # add any other actions…
- User
bad input on line: 2
- Assistant
Apologies for that mistake. Here's the corrected code with DAMOOON_512 instead:
python - User
planet and replace it with the one called damoon
- Assistant
To change the background from "planet" to "damoon", you can modify the
set_backgroundfunction call in the code. Here is the updated code with the background changed to "damoon":python