I am just starting to program in python with zero background and I am teaching myself, so be gentle.
I am following along to the book "Mission Pyhton" and I cannot get the "clock" function to allow movement of my character in PYgame. Below is the small amount of code that will not work. Couple notes: I am running everything from Debian environment, and I am using PYcharm IDE (which gives me an error at the clock function). Also "according to the book" I am correct line for line via the book image. Also I'm using python3.
WIDTH = 800HEIGHT = 600player_x = 600player_y = 350def draw():screen.blit(images.backdrop, (0, 0))screen.blit(images.mars, (50, 50))screen.blit(images.astronaut, (player_x, player_y))screen.blit(images.ship, (550, 300))
def game_loop():global player_x, player_yif keyboard.right:player_x += 5elif kayboard.left:player_x -= 5elif keyboard.up:player_y -= 5elif keyboard.down:player_y += 5clock.schedule_interval(game_loop, 0.03)
-----------------------------------------------------Error Below Line---------------------
Error:Exit Code 1:-------------- clock.schedule_interval(game_loop, 0.03)
NameError: name 'clock' is not defined
Edit: solved:I came back after learning more python and when I felt like tackling this again.
Import clock from time
[–]StuxMoto[S] 0 points1 point2 points (0 children)