mirror of
https://github.com/d3vyce/Python-Game.git
synced 2025-07-04 19:08:20 +02:00
Compare commits
11 Commits
e46fe34ea0
...
beta_chess
Author | SHA1 | Date | |
---|---|---|---|
fecf047a5f | |||
6555ed56b8 | |||
4a8d02efd2 | |||
232bb211ee | |||
d1f6110b10 | |||
cd50022bef | |||
aa6c9e907f | |||
142a684fd6 | |||
9a681d7618 | |||
b98cff34e3 | |||
bd8d9fc2fb |
1
Chess/README.md
Normal file
1
Chess/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
0
Chess/main.py
Normal file
0
Chess/main.py
Normal file
2
Chess/requirements.txt
Normal file
2
Chess/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
pygame
|
||||||
|
numpy
|
4
Chess/src/board.py
Normal file
4
Chess/src/board.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import src.board, src.board
|
||||||
|
import pygame
|
||||||
|
from pygame.locals import *
|
||||||
|
|
0
Chess/src/pieces.py
Normal file
0
Chess/src/pieces.py
Normal file
14
README.md
14
README.md
@ -1,3 +1,13 @@
|
|||||||
Python Game
|
# Python Game
|
||||||
|
Here are the different games I've made so far in python.
|
||||||
|
|
||||||
- Snake [Current Project]
|
- Snake
|
||||||
|
<p>
|
||||||
|
<img src="Snake/img/Snake.png" width="500" title="hover text">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
- Chess [WIP]
|
||||||
|
|
||||||
|
- Sudoku [SOON]
|
||||||
|
|
||||||
|
- Pandemic [SOON]
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
Snake in Python using pygame
|
# Snake in Python using pygame
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
```
|
```
|
||||||
|
BIN
Snake/img/Snake.png
Normal file
BIN
Snake/img/Snake.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -18,14 +18,15 @@ def main():
|
|||||||
Running = True
|
Running = True
|
||||||
Direction = 'right'
|
Direction = 'right'
|
||||||
Direction_prev = 'right'
|
Direction_prev = 'right'
|
||||||
Move_loop = 30
|
Move_loop = 10
|
||||||
Score = 0
|
Score = 0
|
||||||
Difficulty = 10
|
Difficulty = 1
|
||||||
Fruit = False
|
Fruit = False
|
||||||
|
|
||||||
# Spawn snake head
|
# Spawn snake head
|
||||||
L_snake = snake.List((5, 5), None)
|
L_snake = snake.List((5, 5), None)
|
||||||
|
|
||||||
|
# Spawn first apple
|
||||||
level.spawn_apple(Matrix, HEIGH, WIDTH)
|
level.spawn_apple(Matrix, HEIGH, WIDTH)
|
||||||
|
|
||||||
while Running:
|
while Running:
|
||||||
@ -48,7 +49,7 @@ def main():
|
|||||||
Direction = Direction_prev
|
Direction = Direction_prev
|
||||||
|
|
||||||
try:
|
try:
|
||||||
L_snake, Matrix, Fruit = snake.Snake_move(Matrix, L_snake, Direction, HEIGH, WIDTH)
|
L_snake, Matrix, Fruit, Score = snake.Snake_move(Matrix, L_snake, Direction, Score, HEIGH, WIDTH)
|
||||||
except ValueError as Error:
|
except ValueError as Error:
|
||||||
if Error.args[0] == 1:
|
if Error.args[0] == 1:
|
||||||
print("You take a wall !")
|
print("You take a wall !")
|
||||||
@ -60,7 +61,9 @@ def main():
|
|||||||
level.spawn_apple(Matrix, HEIGH, WIDTH)
|
level.spawn_apple(Matrix, HEIGH, WIDTH)
|
||||||
|
|
||||||
Direction_prev = Direction
|
Direction_prev = Direction
|
||||||
Move_loop = 30 - Difficulty*2
|
if(Score > 1000):
|
||||||
|
Difficulty = int(Score/1000) + 1
|
||||||
|
Move_loop = 11 - Difficulty
|
||||||
|
|
||||||
Move_loop -= 1
|
Move_loop -= 1
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class List:
|
|||||||
|
|
||||||
return i
|
return i
|
||||||
|
|
||||||
def Snake_move(M, L, dir, heigh, width):
|
def Snake_move(M, L, dir, score, heigh, width):
|
||||||
Fruit = False
|
Fruit = False
|
||||||
List_save = L
|
List_save = L
|
||||||
Save_Value = L.val
|
Save_Value = L.val
|
||||||
@ -71,7 +71,8 @@ def Snake_move(M, L, dir, heigh, width):
|
|||||||
# If snake eat fruit -> spawn new segment at the end of the snake
|
# If snake eat fruit -> spawn new segment at the end of the snake
|
||||||
if Fruit:
|
if Fruit:
|
||||||
List_save = List.List_add(List_save, Save_Value)
|
List_save = List.List_add(List_save, Save_Value)
|
||||||
|
score += 50
|
||||||
else:
|
else:
|
||||||
M[Save_Value[0]][Save_Value[1]] = 0
|
M[Save_Value[0]][Save_Value[1]] = 0
|
||||||
|
|
||||||
return List_save, M, Fruit
|
return List_save, M, Fruit, score
|
Reference in New Issue
Block a user