Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alien game code from book
#4
Sorry, my bad. It was just lines 8-12. line 7 was OK. Note also there is misspelled variable name on line 2

alien_0 = {'x_position': 0, 'y_poaition': 25, 'speed': 'medium'}
print('original x-position: ' + str(alien_0['x_position']))
 
#Move the alien to the right.
#Determine how far to move the alien based on its current speed.
if alien_0['speed'] =='slow':
    x_increment = 1
elif alien_0['speed'] == 'medium':
    x_increment = 2
else:
    # This must be a fast alien
    x_increment = 3
  
  
# The new position is the old position plus the increment.
alien_0['x_position'] = alien_0['x_position'] + x_increment
 
print('new x_position: ' +str(alien_0['x_position']))
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Alien game code from book - by TheMusicMan - Aug-26-2018, 04:06 PM
RE: Alien game code from book - by buran - Aug-26-2018, 04:12 PM
RE: Alien game code from book - by TheMusicMan - Aug-26-2018, 05:14 PM
RE: Alien game code from book - by buran - Aug-26-2018, 05:28 PM
RE: Alien game code from book - by TheMusicMan - Aug-26-2018, 06:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  needing some help to write some code for a game calculator rymdaksel 1 462 Jan-02-2024, 09:56 AM
Last Post: deanhystad
  Problem with my pong game code Than999 8 3,894 May-15-2022, 06:40 AM
Last Post: deanhystad
  Music Selection Game Code WyattH 3 2,466 Jul-20-2020, 11:16 AM
Last Post: ndc85430
  Beginner Code, how to print something after a number of turns (guessing game) QTPi 4 2,818 Jun-18-2020, 04:59 PM
Last Post: QTPi
  Restart Error when using code from lesson book Kathleen57 2 2,322 Mar-13-2020, 09:18 PM
Last Post: Kathleen57
  Help for guessing game code Kronos 5 3,336 Mar-09-2020, 04:53 PM
Last Post: snippsat
  Need help - 22000 lines of code / alien writings! gfetng 1 1,945 Feb-22-2019, 03:25 PM
Last Post: ichabod801
  Individuallien attack in alien invasion game runnerpaul 1 2,414 Jul-31-2018, 07:10 AM
Last Post: ThiefOfTime
  pyython code copied 1to1 from book not working. BlackReptile 2 2,917 Feb-21-2018, 02:46 AM
Last Post: abhin
  I am trying to make a Colour Wars game, "Winning code" missing Ondrejoda 0 2,293 Feb-18-2018, 11:06 AM
Last Post: Ondrejoda

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020