Initial
16
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Current File",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "~/Documents/Projects/PyGameTuts/better_tutorial/game.py",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Images/L1.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
Images/L10E.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
Images/L11E.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
Images/L1E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/L2.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Images/L2E.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Images/L3.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Images/L3E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/L4.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Images/L4E.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
Images/L5.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
Images/L5E.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
Images/L6.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
Images/L6E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/L7.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
Images/L7E.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
Images/L8.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Images/L8E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/L9.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
Images/L9E.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Images/R1.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
Images/R10E.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Images/R11E.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
Images/R1E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/R2.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
Images/R2E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/R3.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
Images/R3E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/R4.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
Images/R4E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/R5.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
Images/R5E.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Images/R6.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
Images/R6E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/R7.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
Images/R7E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/R8.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Images/R8E.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Images/R9.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
Images/R9E.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
Images/bg.jpg
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
Images/standing.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Music/music.mp3
Normal file
59
game.py
Normal file
@ -0,0 +1,59 @@
|
||||
import pygame
|
||||
pygame.init()
|
||||
|
||||
win = pygame.display.set_mode((500, 500))
|
||||
pygame.display.set_caption("First Game")
|
||||
|
||||
# Shit vars
|
||||
x, y = 50, 50
|
||||
width, height = 40, 60
|
||||
vel = 5
|
||||
isJump = False
|
||||
jumpCount = 10
|
||||
|
||||
# Animation Vars
|
||||
left = False
|
||||
Right = False
|
||||
walkCount = 0
|
||||
|
||||
# https://www.techwithtim.net/tutorials/game-development-with-python/pygame-tutorial/pygame-animation
|
||||
|
||||
walkRight = [pygame.image.load]
|
||||
|
||||
run = True
|
||||
|
||||
while run:
|
||||
pygame.time.delay(100)
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
run = False
|
||||
|
||||
keys = pygame.key.get_pressed()
|
||||
|
||||
if keys[pygame.K_LEFT] and x > vel:
|
||||
x -= vel
|
||||
if keys[pygame.K_RIGHT] and x < 500 - vel - width:
|
||||
x += vel
|
||||
|
||||
if isJump is False:
|
||||
if keys[pygame.K_UP] and y > vel:
|
||||
y -= vel
|
||||
if keys[pygame.K_DOWN] and y < 500 - height - vel:
|
||||
y += vel
|
||||
if keys[pygame.K_SPACE]:
|
||||
isJump = True
|
||||
else:
|
||||
if jumpCount >= -10:
|
||||
y -= (jumpCount * abs(jumpCount)) * 0.5
|
||||
jumpCount -= 1
|
||||
else:
|
||||
jumpCount = 10
|
||||
isJump = False
|
||||
|
||||
win.fill((0, 0, 0))
|
||||
pygame.draw.rect(win, (255,0,0), (x, y, width, height))
|
||||
pygame.display.update()
|
||||
|
||||
|
||||
|
||||
pygame.quit()
|
||||