Having a lot of trouble with my collision system. I had it working so that you could move one tile at a time however I wanted to get smoothness and make it so that you could move smoothly. While I got the movement to work, my collision system was destroyed. Can someone please help me get it up and working. I have no idea were to start.
if event.type == pygame.KEYDOWN:
if event.key==K_w:
if map1[chary/32-1][charx/32] <> 01:
#chary -= 32
WUP==True
else:
WUP==False
#WUP=False
if event.key==K_a:
ALEFT=True
if map1[chary/32][charx/32-1] <> 01:
#charx -= 32
ALEFT==True
else:
WUP==False
#charx -= 32
#ALEFT=False
if event.key==K_s:
#SDOWN=True
if map1[chary/32+1][charx/32] <> 01:
#chary += 32
SDOWN=True
else:
SDOWN==False
if event.key==K_d:
if map1[chary/32][charx/32+1] <> 01:
#charx += 32
DRIGHT==True
else:
DRIGHT==False
Due to the code being over 259 lines I can't really have all of it here. All of this is taking place in a 10x10 list. Full code: http://pastebin.com/bhyazsLz
So to expound on Bartlomiej's response I went through and changed every <>
operator because !=
is much more pythonic and responds accurately. This is because essentially you are just wanting to make sure that it is anything BUT 01
if event.type == pygame.KEYDOWN:
if event.key==K_w:
if map1[chary/32-1][charx/32] != 01:
#chary -= 32
WUP==True
else:
WUP==False
#WUP=False
if event.key==K_a:
ALEFT=True
if map1[chary/32][charx/32-1] != 01:
#charx -= 32
ALEFT==True
else:
WUP==False
#charx -= 32
#ALEFT=False
if event.key==K_s:
#SDOWN=True
if map1[chary/32+1][charx/32] != 01:
#chary += 32
SDOWN=True
else:
SDOWN==False
if event.key==K_d:
if map1[chary/32][charx/32+1] != 01:
#charx += 32
DRIGHT==True
else:
DRIGHT==False
Having a lot of trouble with my collision system. I had it working so that you could move one tile at a time however I wanted to get smoothness and make it so that you could move smoothly. While I got the movement to work, my collision system was destroyed. Can someone please help me get it up and working. I have no idea were to start.
if event.type == pygame.KEYDOWN:
if event.key==K_w:
if map1[chary/32-1][charx/32] <> 01:
#chary -= 32
WUP==True
else:
WUP==False
#WUP=False
if event.key==K_a:
ALEFT=True
if map1[chary/32][charx/32-1] <> 01:
#charx -= 32
ALEFT==True
else:
WUP==False
#charx -= 32
#ALEFT=False
if event.key==K_s:
#SDOWN=True
if map1[chary/32+1][charx/32] <> 01:
#chary += 32
SDOWN=True
else:
SDOWN==False
if event.key==K_d:
if map1[chary/32][charx/32+1] <> 01:
#charx += 32
DRIGHT==True
else:
DRIGHT==False
Due to the code being over 259 lines I can't really have all of it here. All of this is taking place in a 10x10 list. Full code: http://pastebin.com/bhyazsLz
So to expound on Bartlomiej's response I went through and changed every <>
operator because !=
is much more pythonic and responds accurately. This is because essentially you are just wanting to make sure that it is anything BUT 01
if event.type == pygame.KEYDOWN:
if event.key==K_w:
if map1[chary/32-1][charx/32] != 01:
#chary -= 32
WUP==True
else:
WUP==False
#WUP=False
if event.key==K_a:
ALEFT=True
if map1[chary/32][charx/32-1] != 01:
#charx -= 32
ALEFT==True
else:
WUP==False
#charx -= 32
#ALEFT=False
if event.key==K_s:
#SDOWN=True
if map1[chary/32+1][charx/32] != 01:
#chary += 32
SDOWN=True
else:
SDOWN==False
if event.key==K_d:
if map1[chary/32][charx/32+1] != 01:
#charx += 32
DRIGHT==True
else:
DRIGHT==False
0 commentaires:
Enregistrer un commentaire