I want to make a simple platforming game where the player must reach the end, but at the moment I just have 2-way movement (right and left) is there any way I could simulate gravity?
Some notes: I am not using pygame.
Edit: here is the code I have,
Some notes: I am not using pygame.
Edit: here is the code I have,
import turtle
import time
pause = 0.1
#screen
Screen = turtle.Screen()
Screen.title("Block")
Screen.bgcolor("white")
Screen.setup(width=1280, height=720)
Screen.tracer(0)#turns off the screen updates
#game
Block = turtle.Turtle()
Block.speed(0)#no slow down with animation speed
Block.shape("square")#shape
Block.color("black")#color not colour
Block.penup()#stops drawing
Block.goto(0,0)#spawns in
Block.direction = "stop"#cant you read
#fucntions
def go_up():
Block.direction = "up"
def go_down():
Block.direction = "down"
def go_left():
Block.direction = "left"
def go_right():
Block.direction = "right"
def move():
if Block.direction == "up":
y = Block.ycor()
Block.sety(y + 20)
#time.sleep()
elif Block.direction == "down":
y = Block.ycor()
Block.sety(y - 20)
elif Block.direction == "left":
x = Block.xcor()
Block.setx(x - 20)
elif Block.direction == "right":
x = Block.xcor()
Block.setx(x + 20)
#keyboard
Screen.onkeypress(go_up, "w")
Screen.onkeypress(go_down, "`")
Screen.onkeypress(go_left, "a")
Screen.onkeypress(go_right, "d")
Screen.listen()
#gameloop
while True:
Screen.update()
move()
time.sleep(pause)
Screen.mainloop()
