I am a kind of big noob in coding! I actually has 3 thing in it to ask! I had watched some tutorials on making a game using python and from that i have made a game type thing! In which i have draw bullets to which i want to change to image and it fires all at a click i also wnat to fire 1 bullet a time abd also i want my character to do a double jump.Thanks for visit!Please help me out!
import pygame
pygame.init()
class projectile(object):
def __init__(self,x,y,radius,color,facing):
self.x = x
self.y = y
self.radius = radius
self.color = color
self.facing = facing
self.vel = 8 * facing
def draw(self,win):
pygame.draw.circle(win, self.color, (self.x,self.y), self.radius)
def redrawGameWindow():
win.blit(bg, (0,0))
man.draw(win)
for bullet in bullets:
bullet.draw(win)
pygame.display.update()
#mainloop
man = player(200, 410, 64,64)
bullets = []
run = True
while run:
clock.tick(27)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
for bullet in bullets:
if bullet.x < 500 and bullet.x > 0:
bullet.x += bullet.vel
else:
bullets.pop(bullets.index(bullet))
keys = pygame.key.get_pressed()
if keys[pygame.K_c]:
if man.left:
facing = -1
else:
facing = 1
if len(bullets) < 3:
bullets.append(projectile(round(man.x + man.width //2), round(man.y + man.height//2), 6, (0,0,0), facing))
if keys[pygame.K_a] and man.x > man.vel:
man.x -= man.vel
man.left = True
man.right = False
man.standing = False
elif keys[pygame.K_d] and man.x < 500 - man.width - man.vel:
man.x += man.vel
man.right = True
man.left = False
man.standing = False
else:
man.standing = True
man.walkCount = 0
if not(man.isJump):
if keys[pygame.K_SPACE]:
man.isJump = True
if man.left:
facing = -1
else:
facing = 1
man.walkCount = 0
else:
if man.jumpCount >= -8:
neg = 1
if man.jumpCount < 0:
neg = -1
man.y -= (man.jumpCount ** 2) * 0.5 * neg
man.jumpCount -= 1
else:
man.isJump = False
man.jumpCount = 8
redrawGameWindow()
pygame.quit()