0

I am making a minecraft game in Ursina Engine

in that I added a function that checks for a key to be pressed and give me the specific block. but my code doesn't seen to work for some reason. I don't know the reason. And I have used the keyboard module for key detection. Here is the code----

def Update():
   global current_texture
   if keyboard.is_pressed('1'):
       current_texture = grass_texture
   if keyboard.is_pressed('2'):
       current_texture = dirt_texture
   if keyboard.is_pressed('3'):
       current_texture = stone_texture
   if keyboard.is_pressed('4'):
       current_texture = wood_plank_texture
jack
  • 1

1 Answers1

0

You should do this:

def update():
    global current_texture
    if held_keys['1']:
        current_texture = grass_texture
    if held_keys['2']:
        current_texture = dirt_texture
    if held_keys['3']:
        current_texture = stone_texture
    if held_keys['4']:
        current_texture = wood_plank_texture
Tanay
  • 561
  • 1
  • 3
  • 16