├── Tutorial 5 - Battle Screen
├── configmonster.py
├── imgs
│ ├── menu.png
│ ├── road.png
│ ├── water.png
│ ├── grass1.png
│ ├── grass2.png
│ ├── player.png
│ └── monsters
│ │ ├── 001.png
│ │ ├── 002.png
│ │ ├── 003.png
│ │ ├── 004.png
│ │ └── 005.png
├── utilities.py
├── game_state.py
├── config.py
├── monster.py
├── monsterfactory.py
├── main.py
├── player.py
├── menu.py
├── game_view
│ ├── battle.py
│ └── map.py
├── maps
│ └── 01.txt
└── game.py
├── Tutorial 1 - Set Up
├── config.py
├── game_state.py
├── main.py
├── player.py
└── game.py
├── Tutorial 6 - Rooms and NPCs
├── imgs
│ ├── door.png
│ ├── menu.png
│ ├── prof.png
│ ├── road.png
│ ├── dialog.png
│ ├── grass1.png
│ ├── grass2.png
│ ├── player.png
│ ├── water.png
│ ├── floor_mat.png
│ ├── lab_tile.png
│ ├── lab_wall.png
│ ├── rooms
│ │ ├── 01.png
│ │ ├── 02.png
│ │ ├── 03.png
│ │ ├── 04.png
│ │ └── 05.png
│ ├── battle
│ │ ├── menu.png
│ │ ├── hp_bar.png
│ │ ├── name_card.png
│ │ └── monster_pad.png
│ ├── monsters
│ │ ├── 001.png
│ │ ├── 002.png
│ │ ├── 003.png
│ │ ├── 004.png
│ │ ├── 005.png
│ │ ├── 006.png
│ │ ├── 007.png
│ │ ├── 008.png
│ │ ├── 009.png
│ │ ├── cow.png
│ │ ├── owl.png
│ │ ├── pig.png
│ │ ├── Thumbs.db
│ │ ├── bear.png
│ │ ├── duck.png
│ │ ├── frog.png
│ │ ├── goat.png
│ │ ├── hippo.png
│ │ ├── horse.png
│ │ ├── moose.png
│ │ ├── panda.png
│ │ ├── sloth.png
│ │ ├── snake.png
│ │ ├── whale.png
│ │ ├── zebra.png
│ │ ├── buffalo.png
│ │ ├── giraffe.png
│ │ ├── gorilla.png
│ │ ├── monkey.png
│ │ ├── narwhal.png
│ │ ├── parrot.png
│ │ ├── penguin.png
│ │ └── walrus.png
│ ├── monster_cage_starter_1.png
│ ├── monster_cage_starter_2.png
│ └── monster_cage_starter_3.png
├── fonts
│ └── PokemonGb.ttf
├── game_state.py
├── utilities.py
├── maps
│ ├── 02.txt
│ └── 01.txt
├── monster.py
├── rooms
│ └── 01
│ │ ├── 01.txt
│ │ └── 02.txt
├── main.py
├── building.py
├── monsterfactory.py
├── events
│ ├── game_event_handler.py
│ ├── prof_pick_monster_event.py
│ └── pick_monster_event.py
├── menu.py
├── npc.py
├── player.py
├── configmonster.py
├── config.py
├── game_view
│ ├── battle.py
│ └── map.py
└── game.py
├── Tutorial 4 - Monster Detection
├── imgs
│ ├── road.png
│ ├── grass1.png
│ ├── grass2.png
│ ├── player.png
│ └── water.png
├── game_state.py
├── utilities.py
├── monster.py
├── config.py
├── monsterfactory.py
├── main.py
├── player.py
├── maps
│ └── 01.txt
└── game.py
├── Tutorial 2 - Sprites and Graphics
├── game_state.py
├── imgs
│ ├── grass1.png
│ ├── grass2.png
│ ├── player.png
│ └── water.png
├── config.py
├── main.py
├── maps
│ └── 01.txt
├── player.py
└── game.py
├── Tutorial 3 - Camera and Simple Collision Detection
├── game_state.py
├── config.py
├── imgs
│ ├── grass1.png
│ ├── grass2.png
│ ├── player.png
│ └── water.png
├── main.py
├── player.py
├── maps
│ └── 01.txt
└── game.py
└── .idea
├── vcs.xml
├── inspectionProfiles
└── profiles_settings.xml
└── workspace.xml
/Tutorial 5 - Battle Screen/configmonster.py:
--------------------------------------------------------------------------------
1 | GRASS_TYPE_START = 1
2 | GRASS_TYPE_END = 5
3 |
--------------------------------------------------------------------------------
/Tutorial 1 - Set Up/config.py:
--------------------------------------------------------------------------------
1 |
2 | # colours
3 | BLACK = (0, 0, 0)
4 | WHITE = (255, 255, 255)
5 |
6 | SCALE = 10
--------------------------------------------------------------------------------
/Tutorial 1 - Set Up/game_state.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 | class GameState(Enum):
4 | NONE = 0,
5 | RUNNING = 1,
6 | ENDED = 2
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/menu.png
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/road.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/road.png
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/water.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/water.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/door.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/door.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/menu.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/prof.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/prof.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/road.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/road.png
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/imgs/road.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 4 - Monster Detection/imgs/road.png
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/grass1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/grass1.png
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/grass2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/grass2.png
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/player.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/dialog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/dialog.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/grass1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/grass1.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/grass2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/grass2.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/player.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/water.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/water.png
--------------------------------------------------------------------------------
/Tutorial 2 - Sprites and Graphics/game_state.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 | class GameState(Enum):
4 | NONE = 0,
5 | RUNNING = 1,
6 | ENDED = 2
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/game_state.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 | class GameState(Enum):
4 | NONE = 0,
5 | RUNNING = 1,
6 | ENDED = 2
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/imgs/grass1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 4 - Monster Detection/imgs/grass1.png
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/imgs/grass2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 4 - Monster Detection/imgs/grass2.png
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/imgs/player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 4 - Monster Detection/imgs/player.png
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/imgs/water.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 4 - Monster Detection/imgs/water.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/floor_mat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/floor_mat.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/lab_tile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/lab_tile.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/lab_wall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/lab_wall.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/rooms/01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/rooms/01.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/rooms/02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/rooms/02.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/rooms/03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/rooms/03.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/rooms/04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/rooms/04.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/rooms/05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/rooms/05.png
--------------------------------------------------------------------------------
/Tutorial 2 - Sprites and Graphics/imgs/grass1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 2 - Sprites and Graphics/imgs/grass1.png
--------------------------------------------------------------------------------
/Tutorial 2 - Sprites and Graphics/imgs/grass2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 2 - Sprites and Graphics/imgs/grass2.png
--------------------------------------------------------------------------------
/Tutorial 2 - Sprites and Graphics/imgs/player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 2 - Sprites and Graphics/imgs/player.png
--------------------------------------------------------------------------------
/Tutorial 2 - Sprites and Graphics/imgs/water.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 2 - Sprites and Graphics/imgs/water.png
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/monsters/001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/monsters/001.png
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/monsters/002.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/monsters/002.png
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/monsters/003.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/monsters/003.png
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/monsters/004.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/monsters/004.png
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/imgs/monsters/005.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 5 - Battle Screen/imgs/monsters/005.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/fonts/PokemonGb.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/fonts/PokemonGb.ttf
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/battle/menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/battle/menu.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/001.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/002.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/002.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/003.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/003.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/004.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/004.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/005.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/005.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/006.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/006.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/007.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/007.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/008.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/008.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/009.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/009.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/cow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/cow.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/owl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/owl.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/pig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/pig.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/battle/hp_bar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/battle/hp_bar.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/Thumbs.db
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/bear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/bear.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/duck.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/duck.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/frog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/frog.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/goat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/goat.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/hippo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/hippo.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/horse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/horse.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/moose.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/moose.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/panda.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/panda.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/sloth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/sloth.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/snake.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/snake.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/whale.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/whale.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/zebra.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/zebra.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/battle/name_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/battle/name_card.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/buffalo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/buffalo.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/giraffe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/giraffe.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/gorilla.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/gorilla.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/monkey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/monkey.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/narwhal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/narwhal.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/parrot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/parrot.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/penguin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/penguin.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monsters/walrus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monsters/walrus.png
--------------------------------------------------------------------------------
/Tutorial 3 - Camera and Simple Collision Detection/game_state.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 | class GameState(Enum):
4 | NONE = 0,
5 | RUNNING = 1,
6 | ENDED = 2
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/battle/monster_pad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/battle/monster_pad.png
--------------------------------------------------------------------------------
/Tutorial 2 - Sprites and Graphics/config.py:
--------------------------------------------------------------------------------
1 |
2 | # colours
3 | BLACK = (0, 0, 0)
4 | WHITE = (255, 255, 255)
5 |
6 | SCALE = 32
7 |
8 | SCREEN_HEIGHT = 480
9 | SCREEN_WIDTH = 640
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monster_cage_starter_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monster_cage_starter_1.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monster_cage_starter_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monster_cage_starter_2.png
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/imgs/monster_cage_starter_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 6 - Rooms and NPCs/imgs/monster_cage_starter_3.png
--------------------------------------------------------------------------------
/Tutorial 3 - Camera and Simple Collision Detection/config.py:
--------------------------------------------------------------------------------
1 |
2 | # colours
3 | BLACK = (0, 0, 0)
4 | WHITE = (255, 255, 255)
5 |
6 | SCALE = 32
7 |
8 | SCREEN_HEIGHT = 480
9 | SCREEN_WIDTH = 640
--------------------------------------------------------------------------------
/Tutorial 3 - Camera and Simple Collision Detection/imgs/grass1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 3 - Camera and Simple Collision Detection/imgs/grass1.png
--------------------------------------------------------------------------------
/Tutorial 3 - Camera and Simple Collision Detection/imgs/grass2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 3 - Camera and Simple Collision Detection/imgs/grass2.png
--------------------------------------------------------------------------------
/Tutorial 3 - Camera and Simple Collision Detection/imgs/player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 3 - Camera and Simple Collision Detection/imgs/player.png
--------------------------------------------------------------------------------
/Tutorial 3 - Camera and Simple Collision Detection/imgs/water.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wadsworj/pokemon_clone_python/HEAD/Tutorial 3 - Camera and Simple Collision Detection/imgs/water.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/utilities.py:
--------------------------------------------------------------------------------
1 | from random import randint
2 | from random import seed
3 |
4 |
5 | def generate_random_number(range1, range2):
6 | seed()
7 | return randint(range1, range2)
8 |
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/utilities.py:
--------------------------------------------------------------------------------
1 | from random import randint
2 | from random import seed
3 |
4 |
5 | def generate_random_number(range1, range2):
6 | seed()
7 | return randint(range1, range2)
8 |
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/monster.py:
--------------------------------------------------------------------------------
1 |
2 | class Monster:
3 | def __init__(self, monster_type):
4 | print("player created")
5 | self.type = monster_type
6 | self.health = 10
7 | self.attack = 10
8 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/game_state.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 | class GameState(Enum):
4 | NONE = 0,
5 | RUNNING = 1,
6 | ENDED = 2
7 |
8 | class CurrentGameState(Enum):
9 | MAP = 0,
10 | BATTLE = 1
11 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/game_state.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 | class GameState(Enum):
4 | NONE = 0,
5 | RUNNING = 1,
6 | ENDED = 2
7 |
8 | class CurrentGameState(Enum):
9 | MAP = 0,
10 | BATTLE = 1
11 |
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/config.py:
--------------------------------------------------------------------------------
1 |
2 | # colours
3 | BLACK = (0, 0, 0)
4 | WHITE = (255, 255, 255)
5 |
6 | SCALE = 32
7 |
8 | SCREEN_HEIGHT = 480
9 | SCREEN_WIDTH = 640
10 |
11 | MAP_TILE_GRASS = "G"
12 | MAP_TILE_WATER = "W"
13 | MAP_TILE_ROAD = "R"
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/config.py:
--------------------------------------------------------------------------------
1 |
2 | # colours
3 | BLACK = (0, 0, 0)
4 | WHITE = (255, 255, 255)
5 |
6 | SCALE = 32
7 |
8 | SCREEN_HEIGHT = 480
9 | SCREEN_WIDTH = 640
10 |
11 | MAP_TILE_GRASS = "G"
12 | MAP_TILE_WATER = "W"
13 | MAP_TILE_ROAD = "R"
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/monsterfactory.py:
--------------------------------------------------------------------------------
1 | from monster import Monster
2 |
3 |
4 | class MonsterFactory:
5 | def __init__(self):
6 | self.count = 0
7 |
8 | def create_monster(self, monster_type):
9 | monster = Monster(monster_type)
10 | self.count = self.count + 1
11 | return monster
12 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/utilities.py:
--------------------------------------------------------------------------------
1 | from random import randint
2 | from random import seed
3 |
4 |
5 | def generate_random_number(range1, range2):
6 | seed()
7 | return randint(range1, range2)
8 |
9 | def test_if_int(map_tile):
10 | try:
11 | int(map_tile)
12 | return True
13 | except ValueError:
14 | return False
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/monster.py:
--------------------------------------------------------------------------------
1 | import pygame
2 |
3 | class Monster:
4 | def __init__(self, monster_type, id):
5 | print("player created")
6 | self.type = monster_type
7 | self.health = 10
8 | self.attack = 10
9 | self.id = id
10 | self.image = pygame.image.load("imgs/monsters/" + f"{self.id:03d}" + ".png")
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/maps/02.txt:
--------------------------------------------------------------------------------
1 | G G G R R R R R R R R R R G G G G G G G G G G G G G G G G G G G
2 | G G G R G G G G G G G G G G G G G G G G G G G G G G G G G G G G
3 | G G G R G G G G G G G G G G G G G G G G G G G G G G G G G G G G
4 | G R R R G G G G G G G G G G G G G G G G G G G G G G G G G G G G
5 | G R G G G G G G G G G G W W G G G G G G G G G G G G G G G G G G
6 | G R G G G G G G G G W W W W W G G G G G G G G G G G G G G G G G
7 |
--------------------------------------------------------------------------------
/Tutorial 1 - Set Up/main.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | from game_state import GameState
4 |
5 | from game import Game
6 |
7 | pygame.init()
8 |
9 | screen = pygame.display.set_mode((600, 400))
10 |
11 | pygame.display.set_caption("Pokemon Clone")
12 |
13 | clock = pygame.time.Clock()
14 |
15 | game = Game(screen)
16 | game.set_up()
17 |
18 | while game.game_state == GameState.RUNNING:
19 | clock.tick(50)
20 | game.update()
21 | pygame.display.flip()
--------------------------------------------------------------------------------
/Tutorial 2 - Sprites and Graphics/main.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | from game_state import GameState
4 |
5 | from game import Game
6 |
7 | pygame.init()
8 |
9 | screen = pygame.display.set_mode((config.SCREEN_WIDTH, config.SCREEN_HEIGHT))
10 |
11 | pygame.display.set_caption("Pokemon Clone")
12 |
13 | clock = pygame.time.Clock()
14 |
15 | game = Game(screen)
16 | game.set_up()
17 |
18 | while game.game_state == GameState.RUNNING:
19 | clock.tick(50)
20 | game.update()
21 | pygame.display.flip()
--------------------------------------------------------------------------------
/Tutorial 3 - Camera and Simple Collision Detection/main.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | from game_state import GameState
4 |
5 | from game import Game
6 |
7 | pygame.init()
8 |
9 | screen = pygame.display.set_mode((config.SCREEN_WIDTH, config.SCREEN_HEIGHT))
10 |
11 | pygame.display.set_caption("Pokemon Clone")
12 |
13 | clock = pygame.time.Clock()
14 |
15 | game = Game(screen)
16 | game.set_up()
17 |
18 | while game.game_state == GameState.RUNNING:
19 | clock.tick(50)
20 | game.update()
21 | pygame.display.flip()
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/main.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | from game_state import GameState
4 |
5 | from game import Game
6 |
7 | pygame.init()
8 |
9 | screen = pygame.display.set_mode((config.SCREEN_WIDTH, config.SCREEN_HEIGHT))
10 |
11 | pygame.display.set_caption("Pokemon Clone")
12 |
13 | clock = pygame.time.Clock()
14 |
15 | game = Game(screen)
16 | game.set_up()
17 |
18 | # todo - this should handle menus at some point
19 | while game.game_state == GameState.RUNNING:
20 | clock.tick(50)
21 | game.update()
22 | pygame.display.flip()
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/monsterfactory.py:
--------------------------------------------------------------------------------
1 | import utilities
2 | import configmonster
3 |
4 | from monster import Monster
5 |
6 | class MonsterFactory:
7 | def __init__(self):
8 | self.count = 0
9 |
10 | def create_monster(self, monster_type):
11 | random_number = -1
12 |
13 | if monster_type == "G":
14 | random_number = utilities.generate_random_number(configmonster.GRASS_TYPE_START, configmonster.GRASS_TYPE_END)
15 |
16 | monster = Monster(monster_type, random_number)
17 | self.count = self.count + 1
18 |
19 | return monster
20 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/monster.py:
--------------------------------------------------------------------------------
1 | import pygame
2 |
3 | import configmonster
4 |
5 |
6 | class Monster:
7 | def __init__(self, monster_type, id):
8 | print("player created")
9 | self.type = monster_type
10 | self.health = 10
11 | self.attack = 10
12 | self.id = id
13 | self.image = pygame.image.load("imgs/monsters/" + f"{self.id:03d}" + ".png")
14 | self.name = configmonster.MONSTERS[id]['name']
15 | self.level = configmonster.MONSTERS[id]['level_start']
16 | self.base_health = configmonster.MONSTERS[id]['base_health']
17 |
--------------------------------------------------------------------------------
/Tutorial 1 - Set Up/player.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 |
4 | class Player:
5 | def __init__(self, x_postition, y_position):
6 | print("player created")
7 | self.position = [x_postition, y_position]
8 |
9 | def update(self):
10 | print("player updated")
11 |
12 | def update_position(self, x_change, y_change):
13 | self.position[0] += x_change
14 | self.position[1] += y_change
15 |
16 | def render(self, screen):
17 | pygame.draw.rect(screen, config.WHITE, (self.position[0] * config.SCALE, self.position[1] * config.SCALE, config.SCALE, config.SCALE), 4)
--------------------------------------------------------------------------------
/Tutorial 2 - Sprites and Graphics/maps/01.txt:
--------------------------------------------------------------------------------
1 | G G G G G G G G G G G G G G G G G G G G
2 | G G G G G G G G G G G G G G G G G G G G
3 | G G G G G G G G G G G G G G G G G G G G
4 | G G G G G G G G G G G G G G G G G G G G
5 | G G G G G G G G G G G G G G G G G G G G
6 | G G G G G G G G G G G G G G G G G G G G
7 | G G G G G G G G G G G G G G G G G G G G
8 | G G G G G G G G G G G G G G G G G G G G
9 | G G G G G G G G G G G G G G G G G G G G
10 | G G G G G G G G G G G G G G G G G G G G
11 | G G G G G G G G G G G G G G G G G G G G
12 | G G G G G G G G G G G G W W G G G G G G
13 | G G G G G G G G G G W W W W W G G G G G
14 | G G G G G G G G G G G G W W G G G G G G
15 | G G G G G G G G G G G G G G G G G G G G
16 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/rooms/01/01.txt:
--------------------------------------------------------------------------------
1 | l l l l l l l l l l l l l l l l l l l l
2 | l L L L L L L L L L L L L L L L L L L l
3 | l L L L L L L L L L L L L L L L L L L l
4 | l L L L L L L L L L L L L L L L L L L l
5 | l L L L L L L L L L L L L L L L L L L l
6 | l L L L L L L L L L L L L L L L L L L l
7 | l L L L L L L L L L L L L L L L L L L l
8 | l L L L L L L L L L L L L L L L L L L l
9 | l L L L L L L L L L L L L L L L L L L l
10 | l L L L L L L L L L L L L L L L L L L l
11 | l L L L L L L L L L L L L L L L L L L l
12 | l L L L L L L L L L L L L L L L L L L l
13 | l L L L L L L L L L L L L L L L L L L l
14 | l L L L L L L L L L L L L L L L L L L l
15 | l l l l l l l l l X X l l l l l l l l l
16 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/rooms/01/02.txt:
--------------------------------------------------------------------------------
1 | l l l l l l l l l l l l l l l l l l l l
2 | l L L L L L L L L L L L L L L L L L L l
3 | l L L L L L L L L L L L L L L L L L L l
4 | l L L L L L L L L L L L L L L L L L L l
5 | l L L L L L L L L L L L L L L L L L L l
6 | l L L L L L L L L L L L L L L L L L L l
7 | l L L L L L L L L G L L L L L L L L L l
8 | l L L L L L L L L L L L L L L L L L L l
9 | l L L L L L L L L L L L L L L L L L L l
10 | l L L L L L L L L L L L L L L L L L L l
11 | l L L L L L L L L L L L L L L L L L L l
12 | l L L L L L L L L L L L L L L L L L L l
13 | l L L L L L L L L L L L L L L L L L L l
14 | l L L L L L L L L L L L L L L L L L L l
15 | l l l l l l l l l X X l l l l l l l l l
16 |
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/main.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | from game_state import GameState
4 |
5 | from game import Game
6 | from menu import Menu
7 |
8 | pygame.init()
9 |
10 | screen = pygame.display.set_mode((config.SCREEN_WIDTH, config.SCREEN_HEIGHT))
11 |
12 | pygame.display.set_caption("Pokemon Clone")
13 |
14 | clock = pygame.time.Clock()
15 |
16 | game = Game(screen)
17 |
18 | menu = Menu(screen, game)
19 | menu.set_up()
20 |
21 | while game.game_state != GameState.ENDED:
22 | clock.tick(50)
23 |
24 | if game.game_state == GameState.NONE:
25 | menu.update()
26 |
27 | if game.game_state == GameState.RUNNING:
28 | game.update()
29 |
30 | pygame.display.flip()
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/main.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | from game_state import GameState
4 |
5 | from game import Game
6 | from menu import Menu
7 |
8 | pygame.init()
9 |
10 | screen = pygame.display.set_mode((config.SCREEN_WIDTH, config.SCREEN_HEIGHT))
11 |
12 | pygame.display.set_caption("Pokemon Clone")
13 |
14 | clock = pygame.time.Clock()
15 |
16 | game = Game(screen)
17 |
18 | menu = Menu(screen, game)
19 | menu.set_up()
20 |
21 | while game.game_state != GameState.ENDED:
22 | clock.tick(50)
23 |
24 | if game.game_state == GameState.NONE:
25 | menu.update()
26 |
27 | if game.game_state == GameState.RUNNING:
28 | game.update()
29 |
30 | pygame.display.flip()
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/building.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 |
4 | class Building:
5 | def __init__(self, image_name, position, size):
6 | print("npc created")
7 | self.position = position[:]
8 | self.size = size[:]
9 | self.image = pygame.image.load("imgs/rooms/" + str(image_name) + ".png")
10 | self.image = pygame.transform.scale(self.image, (self.size[0] * config.SCALE, self.size[1] * config.SCALE))
11 |
12 | def update(self):
13 | pass
14 |
15 | def render(self, screen, camera):
16 | self.rect = pygame.Rect(self.position[0] * config.SCALE - (camera[0] * config.SCALE), self.position[1] * config.SCALE - (camera[1] * config.SCALE), config.SCALE, config.SCALE)
17 | screen.blit(self.image, self.rect)
18 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/monsterfactory.py:
--------------------------------------------------------------------------------
1 | import utilities
2 | import configmonster
3 |
4 | from monster import Monster
5 |
6 | class MonsterFactory:
7 | def __init__(self):
8 | self.count = 0
9 |
10 | def create_monster_index(self, index):
11 | monster = Monster(configmonster.MONSTERS[index]['monster_type'], index)
12 | self.count = self.count + 1
13 | return monster
14 |
15 | def create_monster(self, monster_type):
16 | random_number = -1
17 |
18 | if monster_type == "G":
19 | random_number = utilities.generate_random_number(configmonster.GRASS_TYPE_START, configmonster.GRASS_TYPE_END)
20 |
21 | monster = Monster(monster_type, random_number)
22 | self.count = self.count + 1
23 |
24 | return monster
25 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/events/game_event_handler.py:
--------------------------------------------------------------------------------
1 | from events.pick_monster_event import PickMonsterEvent
2 | from events.prof_pick_monster_event import ProfPickMonsterEvent
3 |
4 |
5 | def handle_prof_event(game, player, npc):
6 | if len(player.monsters) != 0:
7 | return
8 |
9 | event = ProfPickMonsterEvent(game.screen, game, player)
10 | game.event = event
11 |
12 | def handle_pick_monster_event(game, player, npc):
13 | if len(player.monsters) != 0:
14 | return
15 |
16 | event = PickMonsterEvent(game.screen, game, player, npc)
17 | game.event = event
18 |
19 | def handle(game, player, npc):
20 | player.position = player.last_position
21 |
22 | if npc.name == 'prof':
23 | handle_prof_event(game, player, npc)
24 |
25 | if npc.name.startswith("monster_cage_starter_"):
26 | handle_pick_monster_event(game, player, npc)
27 |
28 | pass
--------------------------------------------------------------------------------
/Tutorial 2 - Sprites and Graphics/player.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 |
4 | class Player:
5 | def __init__(self, x_postition, y_position):
6 | print("player created")
7 | self.position = [x_postition, y_position]
8 | self.image = pygame.image.load("imgs/player.png")
9 | self.image = pygame.transform.scale(self.image, (config.SCALE, config.SCALE))
10 | self.rect = pygame.Rect(self.position[0] * config.SCALE, self.position[1] * config.SCALE, config.SCALE, config.SCALE)
11 |
12 | def update(self):
13 | print("player updated")
14 |
15 | def update_position(self, x_change, y_change):
16 | self.position[0] += x_change
17 | self.position[1] += y_change
18 | self.rect = pygame.Rect(self.position[0] * config.SCALE, self.position[1] * config.SCALE, config.SCALE, config.SCALE)
19 |
20 |
21 | def render(self, screen):
22 | screen.blit(self.image, self.rect)
23 |
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/player.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 |
4 | class Player:
5 | def __init__(self, x_postition, y_position):
6 | print("player created")
7 | self.position = [x_postition, y_position]
8 | self.image = pygame.image.load("imgs/player.png")
9 | self.image = pygame.transform.scale(self.image, (config.SCALE, config.SCALE))
10 | self.rect = pygame.Rect(self.position[0] * config.SCALE, self.position[1] * config.SCALE, config.SCALE, config.SCALE)
11 |
12 | def update(self):
13 | print("player updated")
14 |
15 | def update_position(self, new_position):
16 | self.position[0] = new_position[0]
17 | self.position[1] = new_position[1]
18 |
19 |
20 | def render(self, screen, camera):
21 | self.rect = pygame.Rect(self.position[0] * config.SCALE, self.position[1] * config.SCALE - (camera[1] * config.SCALE), config.SCALE, config.SCALE)
22 | screen.blit(self.image, self.rect)
23 |
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/player.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 |
4 | class Player:
5 | def __init__(self, x_postition, y_position):
6 | print("player created")
7 | self.position = [x_postition, y_position]
8 | self.image = pygame.image.load("imgs/player.png")
9 | self.image = pygame.transform.scale(self.image, (config.SCALE, config.SCALE))
10 | self.rect = pygame.Rect(self.position[0] * config.SCALE, self.position[1] * config.SCALE, config.SCALE, config.SCALE)
11 |
12 | def update(self):
13 | print("player updated")
14 |
15 | def update_position(self, new_position):
16 | self.position[0] = new_position[0]
17 | self.position[1] = new_position[1]
18 |
19 |
20 | def render(self, screen, camera):
21 | self.rect = pygame.Rect(self.position[0] * config.SCALE, self.position[1] * config.SCALE - (camera[1] * config.SCALE), config.SCALE, config.SCALE)
22 | screen.blit(self.image, self.rect)
23 |
--------------------------------------------------------------------------------
/Tutorial 3 - Camera and Simple Collision Detection/player.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 |
4 | class Player:
5 | def __init__(self, x_postition, y_position):
6 | print("player created")
7 | self.position = [x_postition, y_position]
8 | self.image = pygame.image.load("imgs/player.png")
9 | self.image = pygame.transform.scale(self.image, (config.SCALE, config.SCALE))
10 | self.rect = pygame.Rect(self.position[0] * config.SCALE, self.position[1] * config.SCALE, config.SCALE, config.SCALE)
11 |
12 | def update(self):
13 | print("player updated")
14 |
15 | def update_position(self, new_position):
16 | self.position[0] = new_position[0]
17 | self.position[1] = new_position[1]
18 |
19 |
20 | def render(self, screen, camera):
21 | self.rect = pygame.Rect(self.position[0] * config.SCALE, self.position[1] * config.SCALE - (camera[1] * config.SCALE), config.SCALE, config.SCALE)
22 | screen.blit(self.image, self.rect)
23 |
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/menu.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 | import pygame
4 | import config
5 | import math
6 | import utilities
7 |
8 | from player import Player
9 | from game_state import GameState
10 |
11 | class Menu:
12 | def __init__(self, screen, game):
13 | self.screen = screen
14 | self.game = game
15 |
16 | def set_up(self):
17 | self.menu_image = pygame.image.load("imgs/menu.png")
18 |
19 | def update(self):
20 | self.screen.fill(config.BLACK)
21 | rect = pygame.Rect(1, 1, 2, 2)
22 | self.screen.blit(self.menu_image, rect)
23 |
24 | for event in pygame.event.get():
25 | if event.type == pygame.QUIT:
26 | self.game.game_state = GameState.ENDED
27 | # handle key events
28 | elif event.type == pygame.KEYDOWN:
29 | if event.key == pygame.K_ESCAPE:
30 | self.game.game_state = GameState.ENDED
31 | elif event.key == pygame.K_RETURN: # up
32 | self.game.set_up()
33 | self.game.game_state = GameState.RUNNING
34 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/menu.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 | import pygame
4 | import config
5 | import math
6 | import utilities
7 |
8 | from player import Player
9 | from game_state import GameState
10 |
11 | class Menu:
12 | def __init__(self, screen, game):
13 | self.screen = screen
14 | self.game = game
15 |
16 | def set_up(self):
17 | self.menu_image = pygame.image.load("imgs/menu.png")
18 |
19 | def update(self):
20 | self.screen.fill(config.BLACK)
21 | rect = pygame.Rect(1, 1, 2, 2)
22 | self.screen.blit(self.menu_image, rect)
23 |
24 | for event in pygame.event.get():
25 | if event.type == pygame.QUIT:
26 | self.game.game_state = GameState.ENDED
27 | # handle key events
28 | elif event.type == pygame.KEYDOWN:
29 | if event.key == pygame.K_ESCAPE:
30 | self.game.game_state = GameState.ENDED
31 | elif event.key == pygame.K_RETURN: # up
32 | self.game.set_up()
33 | self.game.game_state = GameState.RUNNING
34 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/npc.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 |
4 | class Npc:
5 | def __init__(self, name, image, x_postition, y_position):
6 | print("npc created")
7 | self.name = name
8 | self.position = [x_postition, y_position]
9 | self.image = pygame.image.load("imgs/" + str(image) + ".png")
10 | self.image = pygame.transform.scale(self.image, (config.SCALE, config.SCALE))
11 | self.rect = pygame.Rect(self.position[0] * config.SCALE, self.position[1] * config.SCALE, config.SCALE, config.SCALE)
12 | self.monster = None
13 | self.monsters = []
14 |
15 | def update(self):
16 | print("npc updated")
17 |
18 | def update_position(self, new_position):
19 | self.position[0] = new_position[0]
20 | self.position[1] = new_position[1]
21 |
22 |
23 | def render(self, screen, camera):
24 | self.rect = pygame.Rect(self.position[0] * config.SCALE - (camera[0] * config.SCALE), self.position[1] * config.SCALE - (camera[1] * config.SCALE), config.SCALE, config.SCALE)
25 | screen.blit(self.image, self.rect)
26 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/player.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 |
4 | class Player:
5 | def __init__(self, x_postition, y_position):
6 | print("player created")
7 | self.position = [x_postition, y_position]
8 | self.last_position = [x_postition, y_position]
9 | self.image = pygame.image.load("imgs/player.png")
10 | self.image = pygame.transform.scale(self.image, (config.SCALE, config.SCALE))
11 | self.rect = pygame.Rect(self.position[0] * config.SCALE, self.position[1] * config.SCALE, config.SCALE, config.SCALE)
12 | self.monster = None
13 | self.monsters = []
14 |
15 | def update(self):
16 | print("player updated")
17 |
18 | def update_position(self, new_position):
19 | self.last_position = self.position[:]
20 | self.position[0] = new_position[0]
21 | self.position[1] = new_position[1]
22 |
23 |
24 | def render(self, screen, camera):
25 | self.rect = pygame.Rect(self.position[0] * config.SCALE - (camera[0] * config.SCALE), self.position[1] * config.SCALE - (camera[1] * config.SCALE), config.SCALE, config.SCALE)
26 | screen.blit(self.image, self.rect)
27 |
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/game_view/battle.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | import math
4 | import utilities
5 |
6 | class Battle:
7 | def __init__(self, screen, monster, player):
8 | self.screen = screen
9 | self.monster = monster
10 | self.player = player
11 |
12 | def load(self):
13 | pass
14 |
15 | def render(self):
16 | self.screen.fill(config.WHITE)
17 |
18 | rect = pygame.Rect(1, 1, 2, 2)
19 | self.screen.blit(self.monster.image, rect)
20 |
21 | self.screen.blit(self.player.image, (320, 40))
22 |
23 | font = pygame.font.SysFont(None, 24)
24 | img = font.render("health: " + str(self.monster.health) + " Attack: " + str(self.monster.attack), True, config.BLACK)
25 | self.screen.blit(img, (20, 120))
26 |
27 | img = font.render("press enter to attack!", True, config.BLACK)
28 | self.screen.blit(img, (20, 220))
29 |
30 |
31 | pass
32 |
33 | def update(self):
34 | for event in pygame.event.get():
35 | if event.type == pygame.QUIT:
36 | self.game.game_state = GameState.ENDED
37 | # handle key events
38 | elif event.type == pygame.KEYDOWN:
39 | if event.key == pygame.K_ESCAPE:
40 | self.game.game_state = GameState.ENDED
41 | if event.key == pygame.K_RETURN:
42 | self.monster.health = self.monster.health - 1
43 |
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/maps/01.txt:
--------------------------------------------------------------------------------
1 | G G G R G G G G W G G G G G G G G G G G
2 | G G G R G G G G W G G G G G G G G G G G
3 | G G G R G G G G W G G G G G G G G G G G
4 | G G G R G G G G W G G G G G G G G G G G
5 | G G G R G G G G G G G G G G G G G G G G
6 | G G G R G G G G G G G G G G G G G G G G
7 | G G G R G G G G G G G G G G G G G G G G
8 | G G G R G G G G G G G G G G G G G G G G
9 | G G G G G G G G G G G G G G G G G G G G
10 | G G G G G G G G G G G G G G G G G G G G
11 | G G G G G G G G G G G G G G G G G G G G
12 | G G G G G G G G G G G G W W G G G G G G
13 | G G G G G G G G G G W W W W W G G G G G
14 | G G G G G G G G G G G G W W G G G G G G
15 | G G G G G G G G G G G G G G G G G G G G
16 | G G G G G G G G G G G G G G G G G G G G
17 | G G G G G G G G G G G G G G G G G G G G
18 | G G G G G G G G G G G G G G G G G G G G
19 | G G G G G G G G G G G G G G G G G G G G
20 | G G G G G G G G G G G G G G G G G G G G
21 | G G G G G G G G G G G G G G G G G G G G
22 | G G G G G G G G G G G G W G G G G G G G
23 | G G G G G G G G G G G G G G G G G G G G
24 | G G G G G G G G G G G G G G G G G G G G
25 | G G G G G G G G G G G G W G G G G G G G
26 | G G G G G G G G G G G G G G G G G G G G
27 | G G G G G G G G G G G G G G G G G G G G
28 | G G G G G G G G G G G G G G G G G G G G
29 | G G G G G G G G G G G G W G G G G G G G
30 | G G G G G G G G G G G G G G G G G G G G
31 | G G G G G G G G G G G G G G G G G G G G
32 | G G G G G G G G G G G G G G G G G G G G
33 | G G G G G G G G G G G G G G G G G G G G
34 | G G G G G G G G G G G G G G G G G G G G
35 |
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/maps/01.txt:
--------------------------------------------------------------------------------
1 | G G G R G G G G W G G G G G G G G G G G
2 | G G G R G G G G W G G G G G G G G G G G
3 | G G G R G G G G W G G G G G G G G G G G
4 | G G G R G G G G W G G G G G G G G G G G
5 | G G G R G G G G G G G G G G G G G G G G
6 | G G G R G G G G G G G G G G G G G G G G
7 | G G G R G G G G G G G G G G G G G G G G
8 | G G G R G G G G G G G G G G G G G G G G
9 | G G G G G G G G G G G G G G G G G G G G
10 | G G G G G G G G G G G G G G G G G G G G
11 | G G G G G G G G G G G G G G G G G G G G
12 | G G G G G G G G G G G G W W G G G G G G
13 | G G G G G G G G G G W W W W W G G G G G
14 | G G G G G G G G G G G G W W G G G G G G
15 | G G G G G G G G G G G G G G G G G G G G
16 | G G G G G G G G G G G G G G G G G G G G
17 | G G G G G G G G G G G G G G G G G G G G
18 | G G G G G G G G G G G G G G G G G G G G
19 | G G G G G G G G G G G G G G G G G G G G
20 | G G G G G G G G G G G G G G G G G G G G
21 | G G G G G G G G G G G G G G G G G G G G
22 | G G G G G G G G G G G G W G G G G G G G
23 | G G G G G G G G G G G G G G G G G G G G
24 | G G G G G G G G G G G G G G G G G G G G
25 | G G G G G G G G G G G G W G G G G G G G
26 | G G G G G G G G G G G G G G G G G G G G
27 | G G G G G G G G G G G G G G G G G G G G
28 | G G G G G G G G G G G G G G G G G G G G
29 | G G G G G G G G G G G G W G G G G G G G
30 | G G G G G G G G G G G G G G G G G G G G
31 | G G G G G G G G G G G G G G G G G G G G
32 | G G G G G G G G G G G G G G G G G G G G
33 | G G G G G G G G G G G G G G G G G G G G
34 | G G G G G G G G G G G G G G G G G G G G
35 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/maps/01.txt:
--------------------------------------------------------------------------------
1 | G G G R G G G G W G G G G G G G G G G G
2 | G G G R G G G G W G G G G G G G G G G G
3 | G G G R G G G G W G . . G G G G G G G G
4 | G G G R G G G G W G . . . . G G G G G G
5 | G G G R G G G G G G . . . . G G G G G G
6 | G G G R G G G G G G . . . . G G G G G G
7 | G G G R G G G G G G . . 1 . G G G G G G
8 | G G G R R R R R R R R R R G G G G G G G
9 | G G G R G G G G G G G G G G G G G G G G
10 | G G G R G G G G G G G G G G G G G G G G
11 | G R R R G G G G G G G G G G G G G G G G
12 | G R G G G G G G G G G G W W G G G G G G
13 | G R G G G G G G G G W W W W W G G G G G
14 | G R G G G G G G G G G G W W G G G G G G
15 | G R G G G G G G G G G G G G G G G G G G
16 | G R G G G G G G G G G G G G G G G G G G
17 | G R G G G G G G G G G G G G G G G G G G
18 | G R G G G G G G G G G G G G G G G G G G
19 | G R G G G G G G G G G G G G G G G G G G
20 | G R G G G G G G G G G G G G G G G G G G
21 | G R G G G G G G G G G G G G G G G G G G
22 | G R G G G G G G G G G G W G G G G G G G
23 | G R G G G G G G G G G G G G G G G G G G
24 | G R G G G G G G G G G G G G G G G G G G
25 | G R G G G G G G G G G G W G G G G G G G
26 | G R G G G G G G G G G G G G G G G G G G
27 | G R G G G G . . . . . G G G G G G G G G
28 | G R G G G G . . . . . G G G G G G G G G
29 | G R G G G G . . . 2 . G W G G G G G G G
30 | G R R G G G G G G R G G G G G G G G G G
31 | G G R R R R R R R R R R R R R R R R R R
32 | G G G G G G G G G G G G G G G G G G G G
33 | G G G G G G G G G G G G G G G G G G G G
34 | G G G G G G G G G G G G G G G G G G G G
35 |
--------------------------------------------------------------------------------
/Tutorial 3 - Camera and Simple Collision Detection/maps/01.txt:
--------------------------------------------------------------------------------
1 | G G G G G G G G W G G G G G G G G G G G
2 | G G G G G G G G W G G G G G G G G G G G
3 | G G G G G G G G W G G G G G G G G G G G
4 | G G G G G G G G W G G G G G G G G G G G
5 | G G G G G G G G G G G G G G G G G G G G
6 | G G G G G G G G G G G G G G G G G G G G
7 | G G G G G G G G G G G G G G G G G G G G
8 | G G G G G G G G G G G G G G G G G G G G
9 | G G G G G G G G G G G G G G G G G G G G
10 | G G G G G G G G G G G G G G G G G G G G
11 | G G G G G G G G G G G G G G G G G G G G
12 | G G G G G G G G G G G G W W G G G G G G
13 | G G G G G G G G G G W W W W W G G G G G
14 | G G G G G G G G G G G G W W G G G G G G
15 | G G G G G G G G G G G G G G G G G G G G
16 | G G G G G G G G G G G G G G G G G G G G
17 | G G G G G G G G G G G G G G G G G G G G
18 | G G G G G G G G G G G G G G G G G G G G
19 | G G G G G G G G G G G G G G G G G G G G
20 | G G G G G G G G G G G G G G G G G G G G
21 | G G G G G G G G G G G G G G G G G G G G
22 | G G G G G G G G G G G G W G G G G G G G
23 | G G G G G G G G G G G G G G G G G G G G
24 | G G G G G G G G G G G G G G G G G G G G
25 | G G G G G G G G G G G G W G G G G G G G
26 | G G G G G G G G G G G G G G G G G G G G
27 | G G G G G G G G G G G G G G G G G G G G
28 | G G G G G G G G G G G G G G G G G G G G
29 | G G G G G G G G G G G G W G G G G G G G
30 | G G G G G G G G G G G G G G G G G G G G
31 | G G G G G G G G G G G G G G G G G G G G
32 | G G G G G G G G G G G G G G G G G G G G
33 | G G G G G G G G G G G G G G G G G G G G
34 | G G G G G G G G G G G G G G G G G G G G
35 |
--------------------------------------------------------------------------------
/Tutorial 1 - Set Up/game.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | from player import Player
4 | from game_state import GameState
5 |
6 | class Game:
7 | def __init__(self, screen):
8 | self.screen = screen
9 | self.objects = []
10 | self.game_state = GameState.NONE
11 |
12 | def set_up(self):
13 | player = Player(1, 1)
14 | self.player = player
15 | self.objects.append(player)
16 | print("do set up")
17 | self.game_state = GameState.RUNNING
18 |
19 | def update(self):
20 | self.screen.fill(config.BLACK)
21 | print("update")
22 | self.handle_events()
23 |
24 | for object in self.objects:
25 | object.render(self.screen)
26 |
27 | def handle_events(self):
28 | for event in pygame.event.get():
29 | if event.type == pygame.QUIT:
30 | self.game_state = GameState.ENDED
31 | # handle key events
32 | elif event.type == pygame.KEYDOWN:
33 | if event.key == pygame.K_ESCAPE:
34 | self.game_state = GameState.ENDED
35 | elif event.key == pygame.K_w: # up
36 | self.player.update_position(0, -1)
37 | elif event.key == pygame.K_s: # down
38 | self.player.update_position(0, 1)
39 | elif event.key == pygame.K_a: # up
40 | self.player.update_position(-1, 0)
41 | elif event.key == pygame.K_d: # up
42 | self.player.update_position(1, 0)
43 |
44 |
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/game_view/map.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | import math
4 | import utilities
5 |
6 | class Map:
7 | def __init__(self, screen):
8 | self.screen = screen
9 | self.map_array = []
10 | self.camera = [0, 0]
11 |
12 | def load(self, file_name):
13 | with open('maps/' + file_name + ".txt") as map_file:
14 | for line in map_file:
15 | tiles = []
16 | for i in range(0, len(line) - 1, 2):
17 | tiles.append(line[i])
18 | self.map_array.append(tiles)
19 | print(self.map_array)
20 |
21 | def render(self, screen, player, objects):
22 | self.determine_camera(player)
23 |
24 | y_pos = 0
25 | for line in self.map_array:
26 | x_pos = 0
27 | for tile in line:
28 | image = map_tile_image[tile]
29 | rect = pygame.Rect(x_pos * config.SCALE, y_pos * config.SCALE - (self.camera[1] * config.SCALE), config.SCALE, config.SCALE)
30 | screen.blit(image, rect)
31 | x_pos = x_pos + 1
32 |
33 | y_pos = y_pos + 1
34 |
35 | # draw all objects on map
36 | for object in objects:
37 | object.render(self.screen, self.camera)
38 |
39 | def determine_camera(self, player):
40 | max_y_position = len(self.map_array) - config.SCREEN_HEIGHT / config.SCALE
41 | y_position = player.position[1] - math.ceil(round(config.SCREEN_HEIGHT/ config.SCALE / 2))
42 |
43 | if y_position <= max_y_position and y_position >= 0:
44 | self.camera[1] = y_position
45 | elif y_position < 0:
46 | self.camera[1] = 0
47 | else:
48 | self.camera[1] = max_y_position
49 |
50 | map_tile_image = {
51 | config.MAP_TILE_GRASS : pygame.transform.scale(pygame.image.load("imgs/grass1.png"), (config.SCALE, config.SCALE)),
52 | config.MAP_TILE_WATER: pygame.transform.scale(pygame.image.load("imgs/water.png"), (config.SCALE, config.SCALE)),
53 | config.MAP_TILE_ROAD: pygame.transform.scale(pygame.image.load("imgs/road.png"), (config.SCALE, config.SCALE)),
54 | }
55 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/events/prof_pick_monster_event.py:
--------------------------------------------------------------------------------
1 | import pygame
2 |
3 | import config
4 | from game_state import GameState
5 |
6 |
7 | class ProfPickMonsterEvent:
8 | def __init__(self, screen, game, player):
9 | self.screen = screen
10 | self.game = game
11 | self.prof_image = pygame.image.load("imgs/prof.png")
12 | self.dialog = pygame.image.load("imgs/dialog.png")
13 |
14 | self.cut = 0
15 | self.max_cut = 2
16 |
17 | def load(self):
18 | pass
19 |
20 | def render(self):
21 | if self.cut == 0:
22 | self.render_scene_0()
23 | elif self.cut == 1:
24 | self.render_scene_1()
25 | elif self.cut == 2:
26 | self.render_scene_2()
27 |
28 | def render_scene_0(self):
29 | self.screen.blit(self.dialog, (0, 300))
30 | font = pygame.font.Font('fonts/PokemonGb.ttf', 20)
31 | img = font.render("hello, I am the prof", True, config.BLACK)
32 | self.screen.blit(img, (40, 400))
33 | pass
34 |
35 | def render_scene_1(self):
36 | self.screen.blit(self.dialog, (0, 300))
37 | font = pygame.font.Font('fonts/PokemonGb.ttf', 20)
38 | img = font.render("pick your pokemon!", True, config.BLACK)
39 | self.screen.blit(img, (40, 400))
40 | pass
41 |
42 | def render_scene_2(self):
43 | self.screen.blit(self.dialog, (0, 300))
44 | font = pygame.font.Font('fonts/PokemonGb.ttf', 20)
45 | img = font.render("chose wisely...!", True, config.BLACK)
46 | self.screen.blit(img, (40, 400))
47 | pass
48 |
49 | def update(self):
50 | if self.cut > self.max_cut:
51 | self.game.event = None
52 |
53 | for event in pygame.event.get():
54 | if event.type == pygame.QUIT:
55 | self.game.game_state = GameState.ENDED
56 | # handle key events
57 | elif event.type == pygame.KEYDOWN:
58 | if event.key == pygame.K_ESCAPE:
59 | self.game.game_state = GameState.ENDED
60 | if event.key == pygame.K_RETURN:
61 | self.cut = self.cut + 1
62 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/configmonster.py:
--------------------------------------------------------------------------------
1 | GRASS_TYPE_START = 1
2 | GRASS_TYPE_END = 5
3 |
4 | MONSTERS = [
5 | {
6 | "name" : "unknown",
7 | "index" : 0,
8 | "level_start" : 1,
9 | "base_health" : 5,
10 | "base_attack" : 5,
11 | "monster_type" : "G",
12 | },
13 | {
14 | "name" : "chick",
15 | "index" : 1,
16 | "level_start" : 1,
17 | "base_health" : 5,
18 | "base_attack" : 5,
19 | "monster_type" : "G",
20 | "evolves_to" : 2,
21 | },
22 | {
23 | "name": "chicken",
24 | "index": 2,
25 | "level_start": 5,
26 | "base_health": 5,
27 | "base_attack": 5,
28 | "monster_type": "G",
29 | "evolves_to": 3,
30 | },
31 | {
32 | "name": "elephent",
33 | "index": 3,
34 | "level_start": 15,
35 | "base_health": 5,
36 | "base_attack": 5,
37 | "monster_type": "G",
38 | "evolves_to": None,
39 | },
40 | {
41 | "name": "frog",
42 | "index": 4,
43 | "level_start": 1,
44 | "base_health": 5,
45 | "base_attack": 5,
46 | "monster_type": "G",
47 | "evolves_to": 5,
48 | },
49 | {
50 | "name": "snake",
51 | "index": 5,
52 | "level_start": 5,
53 | "base_health": 5,
54 | "base_attack": 5,
55 | "monster_type": "G",
56 | "evolves_to": 6,
57 | },
58 | {
59 | "name": "crocodile",
60 | "index": 6,
61 | "level_start": 15,
62 | "base_health": 5,
63 | "base_attack": 5,
64 | "monster_type": "G",
65 | "evolves_to": None,
66 | },
67 | {
68 | "name": "rabbit",
69 | "index": 7,
70 | "level_start": 1,
71 | "base_health": 5,
72 | "base_attack": 5,
73 | "monster_type": "G",
74 | "evolves_to": 8,
75 | },
76 | {
77 | "name": "dog",
78 | "index": 8,
79 | "level_start": 5,
80 | "base_health": 5,
81 | "base_attack": 5,
82 | "monster_type": "G",
83 | "evolves_to": 9,
84 | },
85 | {
86 | "name": "rhino",
87 | "index": 9,
88 | "level_start": 15,
89 | "base_health": 5,
90 | "base_attack": 5,
91 | "monster_type": "G",
92 | "evolves_to": None,
93 | },
94 | ]
95 |
96 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/events/pick_monster_event.py:
--------------------------------------------------------------------------------
1 | import pygame
2 |
3 | import config
4 | from game_state import GameState
5 | from monsterfactory import MonsterFactory
6 |
7 |
8 | class PickMonsterEvent:
9 | def __init__(self, screen, game, player, monster):
10 | self.screen = screen
11 | self.game = game
12 | self.player = player
13 | self.dialog = pygame.image.load("imgs/dialog.png")
14 | self.monster_factory = MonsterFactory()
15 |
16 | if monster.name == "monster_cage_starter_01":
17 | self.monster = self.monster_factory.create_monster_index(1)
18 | elif monster.name == "monster_cage_starter_02":
19 | self.monster = self.monster_factory.create_monster_index(4)
20 | elif monster.name == "monster_cage_starter_03":
21 | self.monster = self.monster_factory.create_monster_index(7)
22 |
23 | self.cut = 0
24 | self.max_cut = 0
25 |
26 | def load(self):
27 | pass
28 |
29 | def render(self):
30 | if self.cut == 0:
31 | self.render_scene_0()
32 |
33 | def render_scene_0(self):
34 | self.screen.blit(self.dialog, (0, 300))
35 | self.screen.blit(self.monster.image, (100, 100))
36 | font = pygame.font.Font('fonts/PokemonGb.ttf', 20)
37 | img = font.render("you picked.... " + str(self.monster.name), True, config.BLACK)
38 | self.screen.blit(img, (40, 350))
39 | img = font.render("are you sure? (y/n)", True, config.BLACK)
40 | self.screen.blit(img, (40, 400))
41 | pass
42 |
43 | def update(self):
44 | if self.cut > self.max_cut:
45 | self.game.event = None
46 |
47 | for event in pygame.event.get():
48 | if event.type == pygame.QUIT:
49 | self.game.game_state = GameState.ENDED
50 | # handle key events
51 | elif event.type == pygame.KEYDOWN:
52 | if event.key == pygame.K_ESCAPE:
53 | self.game.game_state = GameState.ENDED
54 | elif event.key == pygame.K_y:
55 | self.player.monsters.append(self.monster)
56 | self.game.event = None
57 | elif event.key == pygame.K_n:
58 | self.game.event = None
59 |
60 | # if event.key == pygame.K_RETURN:
61 | # self.cut = self.cut + 1
62 |
--------------------------------------------------------------------------------
/Tutorial 2 - Sprites and Graphics/game.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | from player import Player
4 | from game_state import GameState
5 |
6 | class Game:
7 | def __init__(self, screen):
8 | self.screen = screen
9 | self.objects = []
10 | self.game_state = GameState.NONE
11 | self.map = []
12 |
13 | def set_up(self):
14 | player = Player(1, 1)
15 | self.player = player
16 | self.objects.append(player)
17 | print("do set up")
18 | self.game_state = GameState.RUNNING
19 |
20 | self.load_map("01")
21 |
22 | def update(self):
23 | self.screen.fill(config.BLACK)
24 | print("update")
25 | self.handle_events()
26 |
27 | self.render_map(self.screen)
28 |
29 | for object in self.objects:
30 | object.render(self.screen)
31 |
32 | def handle_events(self):
33 | for event in pygame.event.get():
34 | if event.type == pygame.QUIT:
35 | self.game_state = GameState.ENDED
36 | # handle key events
37 | elif event.type == pygame.KEYDOWN:
38 | if event.key == pygame.K_ESCAPE:
39 | self.game_state = GameState.ENDED
40 | elif event.key == pygame.K_w: # up
41 | self.player.update_position(0, -1)
42 | elif event.key == pygame.K_s: # down
43 | self.player.update_position(0, 1)
44 | elif event.key == pygame.K_a: # up
45 | self.player.update_position(-1, 0)
46 | elif event.key == pygame.K_d: # up
47 | self.player.update_position(1, 0)
48 |
49 | def load_map(self, file_name):
50 | with open('maps/' + file_name + ".txt") as map_file:
51 | for line in map_file:
52 | tiles = []
53 | for i in range(0, len(line) - 1, 2):
54 | tiles.append(line[i])
55 | self.map.append(tiles)
56 | print(self.map)
57 |
58 | def render_map(self, screen):
59 | y_pos = 0
60 | for line in self.map:
61 | x_pos = 0
62 | for tile in line:
63 | image = map_tile_image[tile]
64 | rect = pygame.Rect(x_pos * config.SCALE, y_pos * config.SCALE, config.SCALE, config.SCALE)
65 | screen.blit(image, rect)
66 | x_pos = x_pos + 1
67 |
68 | y_pos = y_pos + 1
69 |
70 | map_tile_image = {
71 | "G" : pygame.transform.scale(pygame.image.load("imgs/grass1.png"), (config.SCALE, config.SCALE)),
72 | "W": pygame.transform.scale(pygame.image.load("imgs/water.png"), (config.SCALE, config.SCALE))
73 | }
74 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/config.py:
--------------------------------------------------------------------------------
1 |
2 | # colours
3 | import config
4 |
5 | BLACK = (0, 0, 0)
6 | WHITE = (255, 255, 255)
7 | GREEN = (106, 229, 153)
8 | YELLOW = (237, 208, 33)
9 | RED = (251, 87, 60)
10 |
11 | SCALE = 32
12 |
13 | SCREEN_HEIGHT = 480
14 | SCREEN_WIDTH = 640
15 |
16 | BATTLE_HEALTH_BAR_WIDTH = 102
17 |
18 | MAP_TILE_GRASS = "G"
19 | MAP_TILE_WATER = "W"
20 | MAP_TILE_ROAD = "R"
21 | MAP_TILE_DOOR = "1"
22 | MAP_TILE_DOORS = ["1", "2", "3", "4", "5", "6", "7", "8"]
23 | MAP_TILE_LAB_FLOOR = "L"
24 | MAP_TILE_LAB_WALL = "l"
25 | MAP_TILE_ROOM_EXIT = "X"
26 | MAP_TILE_BUILDING = "."
27 |
28 | MONSTER_TYPES = ["G", "W", "S", "F"]
29 |
30 | IMPASSIBLE = [MAP_TILE_WATER, MAP_TILE_LAB_WALL, MAP_TILE_BUILDING]
31 |
32 | MAP_CONFIG = {
33 | "01" : {
34 | "start_position": [9, 29],
35 | "exits" : [
36 | {
37 | "map" : "02",
38 | "position" : [3, 0],
39 | "new_start_position": [1, 4],
40 | }],
41 | "buildings": [
42 | {
43 | "sprite": "04",
44 | "name": "Research Building",
45 | "position": [10, 2],
46 | "size" : [4, 5]
47 | },
48 | {
49 | "sprite": "05",
50 | "name": "Home",
51 | "position": [6, 26],
52 | "size" : [5, 3]
53 | }
54 | ],
55 | },
56 | "02" : {
57 | "start_position": [1, 4],
58 | "exits" : [{
59 | "map" : "01",
60 | "position" : [1, 5],
61 | "new_start_position" : [3, 1],
62 | }],
63 | "buildings": [
64 | ],
65 | }
66 | }
67 |
68 | ROOM_CONFIG = {
69 | "01" : {
70 | "01" : {
71 | "start_position" : [10,13],
72 | "exit_position" : [12,7],
73 | "npcs" : [
74 | {
75 | "name" : "prof",
76 | "image" : "prof",
77 | "start_position" : [8,8]
78 | },
79 | {
80 | "name" : "monster_cage_starter_01",
81 | "image" : "monster_cage_starter_1",
82 | "start_position": [10, 8]
83 | },
84 | {
85 | "name" : "monster_cage_starter_02",
86 | "image": "monster_cage_starter_2",
87 | "start_position": [11, 8]
88 | },
89 | {
90 | "name" : "monster_cage_starter_03",
91 | "image": "monster_cage_starter_3",
92 | "start_position": [12, 8]
93 | }
94 | ]
95 | },
96 | "02" : {
97 | "start_position" : [10,13],
98 | "exit_position" : [12,7],
99 | "npcs" : [],
100 | }
101 | }
102 | }
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/game_view/battle.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | import math
4 | import utilities
5 |
6 |
7 | class Battle:
8 | def __init__(self, screen, monster, player):
9 | self.screen = screen
10 | self.monster = monster
11 | self.player = player
12 |
13 | def load(self):
14 | pass
15 |
16 | def render(self):
17 | self.screen.fill(config.WHITE)
18 |
19 | #font = pygame.font.SysFont(None, 24)
20 | font = pygame.font.Font("fonts/PokemonGb.ttf", 16)
21 |
22 | self.screen.blit(battle_images["monster_pad"], (0, 300))
23 | self.screen.blit(battle_images["name_card"], (310, 300))
24 | self.screen.blit(battle_images["hp_bar"], (340, 335))
25 |
26 |
27 | self.screen.blit(self.player.monsters[0].image, (70, 250))
28 |
29 | self.screen.blit(battle_images["monster_pad"], (300, 100))
30 | self.screen.blit(battle_images["name_card"], (15, 100))
31 | self.screen.blit(battle_images["hp_bar"], (50, 135))
32 | self.screen.blit(battle_images["menu"], (0, 388))
33 |
34 | img = font.render("press enter to attack!", True, config.WHITE)
35 | self.screen.blit(img, (30, 430))
36 |
37 | self.screen.blit(self.monster.image, (370, 30))
38 |
39 | img = font.render(str(self.monster.name), True,
40 | config.BLACK)
41 | self.screen.blit(img, (25, 110))
42 |
43 | img = font.render("Lv" + str(self.monster.level), True,
44 | config.BLACK)
45 | self.screen.blit(img, (260, 110))
46 |
47 |
48 | # draw player's monster name
49 | img = font.render(str(self.player.monsters[0].name), True,
50 | config.BLACK)
51 | self.screen.blit(img, (323, 311))
52 |
53 | img = font.render("Lv" + str(self.player.monsters[0].level), True,
54 | config.BLACK)
55 | self.screen.blit(img, (555, 311))
56 |
57 | monster_percent = self.monster.health / self.monster.base_health
58 | monster_color = self.determine_health_color(monster_percent)
59 | pygame.draw.rect(self.screen, monster_color, pygame.Rect(91, 137, config.BATTLE_HEALTH_BAR_WIDTH * monster_percent, 16))
60 |
61 | player_monster_percent = self.player.monsters[0].health / self.player.monsters[0].base_health
62 | player_monster_color = self.determine_health_color(player_monster_percent)
63 | pygame.draw.rect(self.screen, player_monster_color, pygame.Rect(381, 337, config.BATTLE_HEALTH_BAR_WIDTH * player_monster_percent, 16))
64 |
65 | img = font.render("health: " + str(self.monster.health) + " Attack: " + str(self.monster.attack), True, config.BLACK)
66 | self.screen.blit(img, (25, 155))
67 |
68 | def update(self):
69 | for event in pygame.event.get():
70 | if event.type == pygame.QUIT:
71 | self.game.game_state = GameState.ENDED
72 | # handle key events
73 | elif event.type == pygame.KEYDOWN:
74 | if event.key == pygame.K_ESCAPE:
75 | self.game.game_state = GameState.ENDED
76 | if event.key == pygame.K_RETURN:
77 | self.monster.health = self.monster.health - 1
78 |
79 | def determine_health_color(self, monster_percent):
80 | if monster_percent < .25:
81 | return config.RED
82 | if monster_percent < .7:
83 | return config.YELLOW
84 | return config.GREEN
85 |
86 | battle_images = {
87 | "monster_pad": pygame.transform.scale(pygame.image.load("imgs/battle/monster_pad.png"), (300, 88)),
88 | "name_card": pygame.transform.scale(pygame.image.load("imgs/battle/name_card.png"), (300, 80)),
89 | "hp_bar": pygame.transform.scale(pygame.image.load("imgs/battle/hp_bar.png"), (250, 20)),
90 | "menu": pygame.image.load("imgs/battle/menu.png"),
91 | }
92 |
--------------------------------------------------------------------------------
/Tutorial 3 - Camera and Simple Collision Detection/game.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | import math
4 | from player import Player
5 | from game_state import GameState
6 |
7 | class Game:
8 | def __init__(self, screen):
9 | self.screen = screen
10 | self.objects = []
11 | self.game_state = GameState.NONE
12 | self.map = []
13 | self.camera = [0, 0]
14 |
15 | def set_up(self):
16 | player = Player(1, 1)
17 | self.player = player
18 | self.objects.append(player)
19 | print("do set up")
20 | self.game_state = GameState.RUNNING
21 |
22 | self.load_map("01")
23 |
24 | def update(self):
25 | self.screen.fill(config.BLACK)
26 | print("update")
27 | self.handle_events()
28 |
29 | self.render_map(self.screen)
30 |
31 | for object in self.objects:
32 | object.render(self.screen, self.camera)
33 |
34 | def handle_events(self):
35 | for event in pygame.event.get():
36 | if event.type == pygame.QUIT:
37 | self.game_state = GameState.ENDED
38 | # handle key events
39 | elif event.type == pygame.KEYDOWN:
40 | if event.key == pygame.K_ESCAPE:
41 | self.game_state = GameState.ENDED
42 | elif event.key == pygame.K_w: # up
43 | self.move_unit(self.player, [0, -1])
44 | elif event.key == pygame.K_s: # down
45 | self.move_unit(self.player, [0, 1])
46 | elif event.key == pygame.K_a: # up
47 | self.move_unit(self.player, [-1, 0])
48 | elif event.key == pygame.K_d: # up
49 | self.move_unit(self.player, [1, 0])
50 |
51 | def load_map(self, file_name):
52 | with open('maps/' + file_name + ".txt") as map_file:
53 | for line in map_file:
54 | tiles = []
55 | for i in range(0, len(line) - 1, 2):
56 | tiles.append(line[i])
57 | self.map.append(tiles)
58 | print(self.map)
59 |
60 | def render_map(self, screen):
61 | self.determine_camera()
62 |
63 | y_pos = 0
64 | for line in self.map:
65 | x_pos = 0
66 | for tile in line:
67 | image = map_tile_image[tile]
68 | rect = pygame.Rect(x_pos * config.SCALE, y_pos * config.SCALE - (self.camera[1] * config.SCALE), config.SCALE, config.SCALE)
69 | screen.blit(image, rect)
70 | x_pos = x_pos + 1
71 |
72 | y_pos = y_pos + 1
73 |
74 | def move_unit(self, unit, position_change):
75 | new_position = [unit.position[0] + position_change[0], unit.position[1] + position_change[1]]
76 |
77 | if new_position[0] < 0 or new_position[0] > (len(self.map[0]) - 1):
78 | return
79 |
80 | if new_position[1] < 0 or new_position[1] > (len(self.map) - 1):
81 | return
82 |
83 | if self.map[new_position[1]][new_position[0]] == "W":
84 | return
85 |
86 | unit.update_position(new_position)
87 |
88 | def determine_camera(self):
89 | max_y_position = len(self.map) - config.SCREEN_HEIGHT / config.SCALE
90 | y_position = self.player.position[1] - math.ceil(round(config.SCREEN_HEIGHT/ config.SCALE / 2))
91 |
92 | if y_position <= max_y_position and y_position >= 0:
93 | self.camera[1] = y_position
94 | elif y_position < 0:
95 | self.camera[1] = 0
96 | else:
97 | self.camera[1] = max_y_position
98 |
99 |
100 | map_tile_image = {
101 | "G" : pygame.transform.scale(pygame.image.load("imgs/grass1.png"), (config.SCALE, config.SCALE)),
102 | "W": pygame.transform.scale(pygame.image.load("imgs/water.png"), (config.SCALE, config.SCALE))
103 | }
104 |
--------------------------------------------------------------------------------
/Tutorial 5 - Battle Screen/game.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 | import pygame
4 | import config
5 | import math
6 | import utilities
7 |
8 | from player import Player
9 | from game_state import GameState, CurrentGameState
10 | from monsterfactory import MonsterFactory
11 | from game_view.map import Map
12 | from game_view.battle import Battle
13 |
14 | class Game:
15 | def __init__(self, screen):
16 | self.screen = screen
17 | self.objects = []
18 | self.game_state = GameState.NONE
19 | self.current_game_state = CurrentGameState.MAP
20 | self.player_has_moved = False
21 | self.monster_factory = MonsterFactory()
22 | self.map = Map(screen)
23 | self.battle = None
24 |
25 | def set_up(self):
26 | player = Player(1, 1)
27 | self.player = player
28 | self.objects.append(player)
29 | print("do set up")
30 | self.game_state = GameState.RUNNING
31 |
32 | self.map.load("01")
33 |
34 | def update(self):
35 | if self.current_game_state == CurrentGameState.MAP:
36 | self.player_has_moved = False
37 | self.screen.fill(config.BLACK)
38 | # print("update")
39 | self.handle_events()
40 |
41 | self.map.render(self.screen, self.player, self.objects)
42 |
43 | if self.player_has_moved:
44 | self.determine_game_events()
45 | elif self.current_game_state == CurrentGameState.BATTLE:
46 | self.battle.update()
47 | self.battle.render()
48 |
49 | if self.battle.monster.health <= 0:
50 | self.current_game_state = CurrentGameState.MAP
51 |
52 | def determine_game_events(self):
53 | map_tile = self.map.map_array[self.player.position[1]][self.player.position[0]]
54 | print(map_tile)
55 |
56 | if map_tile == config.MAP_TILE_ROAD:
57 | return
58 |
59 | self.determine_pokemon_found(map_tile)
60 |
61 | def determine_pokemon_found(self, map_tile):
62 | random_number = utilities.generate_random_number(1, 10)
63 |
64 | # 20 percent chance of hitting pokemon
65 | if random_number <= 2:
66 | found_monster = self.monster_factory.create_monster(map_tile)
67 | print("you found a monster!")
68 | print("Monster Type: " + found_monster.type)
69 | print("Attack: " + str(found_monster.attack))
70 | print("Health: " + str(found_monster.health))
71 |
72 | self.battle = Battle(self.screen, found_monster, self.player)
73 | self.current_game_state = CurrentGameState.BATTLE
74 |
75 | def handle_events(self):
76 | for event in pygame.event.get():
77 | if event.type == pygame.QUIT:
78 | self.game_state = GameState.ENDED
79 | # handle key events
80 | elif event.type == pygame.KEYDOWN:
81 | if event.key == pygame.K_ESCAPE:
82 | self.game_state = GameState.NONE
83 | elif event.key == pygame.K_w: # up
84 | self.move_unit(self.player, [0, -1])
85 | elif event.key == pygame.K_s: # down
86 | self.move_unit(self.player, [0, 1])
87 | elif event.key == pygame.K_a: # up
88 | self.move_unit(self.player, [-1, 0])
89 | elif event.key == pygame.K_d: # up
90 | self.move_unit(self.player, [1, 0])
91 |
92 | def move_unit(self, unit, position_change):
93 | new_position = [unit.position[0] + position_change[0], unit.position[1] + position_change[1]]
94 |
95 | # check if off map
96 | if new_position[0] < 0 or new_position[0] > (len(self.map.map_array[0]) - 1):
97 | return
98 |
99 | if new_position[1] < 0 or new_position[1] > (len(self.map.map_array) - 1):
100 | return
101 |
102 | # check for valid movement
103 | if self.map.map_array[new_position[1]][new_position[0]] == config.MAP_TILE_WATER:
104 | return
105 |
106 | self.player_has_moved = True
107 |
108 | unit.update_position(new_position)
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/game_view/map.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | import config
3 | import math
4 | import utilities
5 | from building import Building
6 | from npc import Npc
7 |
8 |
9 | class Map:
10 | def __init__(self, screen):
11 | self.screen = screen
12 | self.map_array = []
13 | self.camera = [0, 0]
14 | self.file_name = None
15 | self.player_exit_position = None
16 | self.objects = []
17 | self.exit_positions = []
18 |
19 | def load(self, file_name, player):
20 | self.file_name = file_name
21 |
22 | self.player = player
23 | self.objects = [player]
24 |
25 | with open('maps/' + file_name + ".txt") as map_file:
26 | for line in map_file:
27 | tiles = []
28 | for i in range(0, len(line) - 1, 2):
29 | tiles.append(line[i])
30 | self.map_array.append(tiles)
31 | print(self.map_array)
32 |
33 | map_config = config.MAP_CONFIG[file_name]
34 |
35 | player.position = map_config['start_position'][:]
36 |
37 | for building_data in map_config["buildings"]:
38 | building = Building(building_data['sprite'], building_data['position'], building_data['size'])
39 | self.objects.append(building)
40 |
41 | for exit_position in map_config['exits']:
42 | self.exit_positions.append(exit_position)
43 |
44 | def load_room(self, map_name, room_name, player):
45 | self.player = player
46 | self.objects = [player]
47 |
48 | room_config = config.ROOM_CONFIG[map_name][str(room_name).zfill(2)]
49 | self.player.position = room_config['start_position'][:]
50 | self.player.player_exit_position = room_config['exit_position'][:]
51 | self.player_exit_position = room_config['exit_position'][:]
52 |
53 | # create our npcs
54 | for npc_data in room_config['npcs']:
55 | npc = Npc(npc_data['name'], npc_data['image'], npc_data['start_position'][0], npc_data['start_position'][1])
56 | self.objects.append(npc)
57 |
58 | with open('rooms/' + map_name + '/' + str(room_name).zfill(2) + ".txt") as room_file:
59 | for line in room_file:
60 | tiles = []
61 | for i in range(0, len(line) - 1, 2):
62 | tiles.append(line[i])
63 | self.map_array.append(tiles)
64 | print(self.map_array)
65 |
66 | pass
67 |
68 | def render(self, screen, player):
69 | self.determine_camera(player)
70 |
71 | y_pos = 0
72 | for line in self.map_array:
73 | x_pos = 0
74 | for tile in line:
75 | if tile not in map_tile_image:
76 | x_pos = x_pos + 1
77 | continue
78 | image = map_tile_image[tile]
79 | rect = pygame.Rect(x_pos * config.SCALE - (self.camera[0] * config.SCALE), y_pos * config.SCALE - (self.camera[1] * config.SCALE), config.SCALE, config.SCALE)
80 | screen.blit(image, rect)
81 | x_pos = x_pos + 1
82 |
83 | y_pos = y_pos + 1
84 |
85 | # draw all objects on map
86 | for object in self.objects:
87 | object.render(self.screen, self.camera)
88 |
89 | def determine_camera(self, player):
90 | # y axis
91 | max_y_position = len(self.map_array) - config.SCREEN_HEIGHT / config.SCALE
92 | y_position = player.position[1] - math.ceil(round(config.SCREEN_HEIGHT/ config.SCALE / 2))
93 |
94 | if y_position <= max_y_position and y_position >= 0:
95 | self.camera[1] = y_position
96 | elif y_position < 0:
97 | self.camera[1] = 0
98 | else:
99 | self.camera[1] = max_y_position
100 |
101 | # x axis
102 | max_x_position = len(self.map_array[0]) - config.SCREEN_WIDTH / config.SCALE
103 | x_position = player.position[0] - math.ceil(round(config.SCREEN_WIDTH / config.SCALE / 2))
104 |
105 | if x_position <= max_x_position and x_position >= 0:
106 | self.camera[0] = x_position
107 | elif x_position < 0:
108 | self.camera[0] = 0
109 | else:
110 | self.camera[0] = max_x_position
111 |
112 | map_tile_image = {
113 | config.MAP_TILE_GRASS : pygame.transform.scale(pygame.image.load("imgs/grass1.png"), (config.SCALE, config.SCALE)),
114 | config.MAP_TILE_WATER: pygame.transform.scale(pygame.image.load("imgs/water.png"), (config.SCALE, config.SCALE)),
115 | config.MAP_TILE_ROAD: pygame.transform.scale(pygame.image.load("imgs/road.png"), (config.SCALE, config.SCALE)),
116 | config.MAP_TILE_LAB_FLOOR: pygame.transform.scale(pygame.image.load("imgs/lab_tile.png"), (config.SCALE, config.SCALE)),
117 | config.MAP_TILE_LAB_WALL: pygame.transform.scale(pygame.image.load("imgs/lab_wall.png"), (config.SCALE, config.SCALE)),
118 | config.MAP_TILE_ROOM_EXIT: pygame.transform.scale(pygame.image.load("imgs/floor_mat.png"), (config.SCALE, config.SCALE)),
119 | }
120 |
--------------------------------------------------------------------------------
/Tutorial 4 - Monster Detection/game.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 | import pygame
4 | import config
5 | import math
6 | import utilities
7 |
8 | from player import Player
9 | from game_state import GameState
10 | from monsterfactory import MonsterFactory
11 |
12 | class Game:
13 | def __init__(self, screen):
14 | self.screen = screen
15 | self.objects = []
16 | self.game_state = GameState.NONE
17 | self.map = []
18 | self.camera = [0, 0]
19 | self.player_has_moved = False
20 | self.monster_factory = MonsterFactory()
21 |
22 | def set_up(self):
23 | player = Player(1, 1)
24 | self.player = player
25 | self.objects.append(player)
26 | print("do set up")
27 | self.game_state = GameState.RUNNING
28 |
29 | self.load_map("01")
30 |
31 | def update(self):
32 | self.player_has_moved = False
33 | self.screen.fill(config.BLACK)
34 | # print("update")
35 | self.handle_events()
36 |
37 | self.render_map(self.screen)
38 |
39 | for object in self.objects:
40 | object.render(self.screen, self.camera)
41 |
42 | if self.player_has_moved:
43 | self.determine_game_events()
44 |
45 | def determine_game_events(self):
46 | map_tile = self.map[self.player.position[1]][self.player.position[0]]
47 | print(map_tile)
48 |
49 | if map_tile == config.MAP_TILE_ROAD:
50 | return
51 |
52 | self.determine_pokemon_found(map_tile)
53 |
54 | def determine_pokemon_found(self, map_tile):
55 | random_number = utilities.generate_random_number(1, 10)
56 |
57 | # 20 percent chance of hitting pokemon
58 | if random_number <= 2:
59 | found_monster = self.monster_factory.create_monster(map_tile)
60 | print("you found a monster!")
61 | print("Monster Type: " + found_monster.type)
62 | print("Attack: " + str(found_monster.attack))
63 | print("Health: " + str(found_monster.health))
64 |
65 | def handle_events(self):
66 | for event in pygame.event.get():
67 | if event.type == pygame.QUIT:
68 | self.game_state = GameState.ENDED
69 | # handle key events
70 | elif event.type == pygame.KEYDOWN:
71 | if event.key == pygame.K_ESCAPE:
72 | self.game_state = GameState.ENDED
73 | elif event.key == pygame.K_w: # up
74 | self.move_unit(self.player, [0, -1])
75 | elif event.key == pygame.K_s: # down
76 | self.move_unit(self.player, [0, 1])
77 | elif event.key == pygame.K_a: # up
78 | self.move_unit(self.player, [-1, 0])
79 | elif event.key == pygame.K_d: # up
80 | self.move_unit(self.player, [1, 0])
81 |
82 | def load_map(self, file_name):
83 | with open('maps/' + file_name + ".txt") as map_file:
84 | for line in map_file:
85 | tiles = []
86 | for i in range(0, len(line) - 1, 2):
87 | tiles.append(line[i])
88 | self.map.append(tiles)
89 | print(self.map)
90 |
91 | def render_map(self, screen):
92 | self.determine_camera()
93 |
94 | y_pos = 0
95 | for line in self.map:
96 | x_pos = 0
97 | for tile in line:
98 | image = map_tile_image[tile]
99 | rect = pygame.Rect(x_pos * config.SCALE, y_pos * config.SCALE - (self.camera[1] * config.SCALE), config.SCALE, config.SCALE)
100 | screen.blit(image, rect)
101 | x_pos = x_pos + 1
102 |
103 | y_pos = y_pos + 1
104 |
105 | def move_unit(self, unit, position_change):
106 | new_position = [unit.position[0] + position_change[0], unit.position[1] + position_change[1]]
107 |
108 | # check if off map
109 | if new_position[0] < 0 or new_position[0] > (len(self.map[0]) - 1):
110 | return
111 |
112 | if new_position[1] < 0 or new_position[1] > (len(self.map) - 1):
113 | return
114 |
115 | # check for valid movement
116 | if self.map[new_position[1]][new_position[0]] == config.MAP_TILE_WATER:
117 | return
118 |
119 | self.player_has_moved = True
120 |
121 | unit.update_position(new_position)
122 |
123 | def determine_camera(self):
124 | max_y_position = len(self.map) - config.SCREEN_HEIGHT / config.SCALE
125 | y_position = self.player.position[1] - math.ceil(round(config.SCREEN_HEIGHT/ config.SCALE / 2))
126 |
127 | if y_position <= max_y_position and y_position >= 0:
128 | self.camera[1] = y_position
129 | elif y_position < 0:
130 | self.camera[1] = 0
131 | else:
132 | self.camera[1] = max_y_position
133 |
134 |
135 | map_tile_image = {
136 | config.MAP_TILE_GRASS : pygame.transform.scale(pygame.image.load("imgs/grass1.png"), (config.SCALE, config.SCALE)),
137 | config.MAP_TILE_WATER: pygame.transform.scale(pygame.image.load("imgs/water.png"), (config.SCALE, config.SCALE)),
138 | config.MAP_TILE_ROAD: pygame.transform.scale(pygame.image.load("imgs/road.png"), (config.SCALE, config.SCALE)),
139 | }
140 |
--------------------------------------------------------------------------------
/Tutorial 6 - Rooms and NPCs/game.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 | import pygame
4 | import config
5 | import math
6 | import utilities
7 | from events import game_event_handler
8 |
9 | from player import Player
10 | from game_state import GameState, CurrentGameState
11 | from monsterfactory import MonsterFactory
12 | from game_view.map import Map
13 | from game_view.battle import Battle
14 |
15 | class Game:
16 | def __init__(self, screen):
17 | self.screen = screen
18 | self.game_state = GameState.NONE
19 | self.current_game_state = CurrentGameState.MAP
20 | self.player_has_moved = False
21 | self.monster_factory = MonsterFactory()
22 | self.map = Map(screen)
23 | self.maps = [self.map]
24 | self.battle = None
25 | self.player = None
26 | self.event = None
27 |
28 | def set_up(self):
29 | player = Player(1, 1)
30 | self.player = player
31 | print("do set up")
32 | self.game_state = GameState.RUNNING
33 |
34 | self.map.load("01", self.player)
35 |
36 | def update(self):
37 | if self.current_game_state == CurrentGameState.MAP:
38 | self.player_has_moved = False
39 | self.screen.fill(config.BLACK)
40 | # print("update")
41 | self.handle_events()
42 |
43 | if self.player_has_moved:
44 | self.determine_game_events()
45 |
46 | self.map.render(self.screen, self.player)
47 |
48 | elif self.current_game_state == CurrentGameState.BATTLE:
49 | self.battle.update()
50 | self.battle.render()
51 |
52 | if self.battle.monster.health <= 0:
53 | self.current_game_state = CurrentGameState.MAP
54 |
55 | if self.event is not None:
56 | self.event.render()
57 | self.event.update()
58 |
59 | def determine_game_events(self):
60 | map_tile = self.map.map_array[self.player.position[1]][self.player.position[0]]
61 | print(map_tile)
62 |
63 | if map_tile == config.MAP_TILE_ROOM_EXIT:
64 | self.player.position = self.map.player_exit_position[:]
65 | self.maps.pop()
66 | self.map = self.maps[-1]
67 | return
68 |
69 | # if the map tile is a door, we need a room
70 | if utilities.test_if_int(map_tile):
71 | room = Map(self.screen)
72 | room.load_room(self.map.file_name, map_tile, self.player)
73 | self.map = room
74 | self.maps.append(room)
75 | return
76 |
77 | for npc in self.map.objects:
78 | if npc == self.map.player:
79 | continue
80 |
81 | if npc.position[:] == self.map.player.position[:]:
82 | game_event_handler.handle(self, self.player, npc)
83 |
84 | for exit_position in self.map.exit_positions:
85 | if self.player.position[:] == exit_position['position'][:]:
86 | map_file = exit_position['map']
87 | map = Map(self.screen)
88 |
89 | config.MAP_CONFIG[map_file]['start_position'] = exit_position['new_start_position'][:]
90 |
91 | map.load(map_file, self.player)
92 | self.maps.pop()
93 | self.map = map
94 | self.maps.append(map)
95 |
96 | if self.player.monsters:
97 | self.determine_pokemon_found(map_tile)
98 |
99 | def determine_pokemon_found(self, map_tile):
100 | if map_tile not in config.MONSTER_TYPES:
101 | return
102 |
103 | random_number = utilities.generate_random_number(1, 10)
104 |
105 | # 20 percent chance of hitting pokemon
106 | if random_number <= 2:
107 | found_monster = self.monster_factory.create_monster(map_tile)
108 | print("you found a monster!")
109 | print("Monster Type: " + found_monster.type)
110 | print("Attack: " + str(found_monster.attack))
111 | print("Health: " + str(found_monster.health))
112 |
113 | self.battle = Battle(self.screen, found_monster, self.player)
114 | self.current_game_state = CurrentGameState.BATTLE
115 |
116 | def handle_events(self):
117 | if self.event is not None:
118 | return
119 |
120 | for event in pygame.event.get():
121 | if event.type == pygame.QUIT:
122 | self.game_state = GameState.ENDED
123 | # handle key events
124 | elif event.type == pygame.KEYDOWN:
125 | if event.key == pygame.K_ESCAPE:
126 | self.game_state = GameState.NONE
127 | elif event.key == pygame.K_w: # up
128 | self.move_unit(self.player, [0, -1])
129 | elif event.key == pygame.K_s: # down
130 | self.move_unit(self.player, [0, 1])
131 | elif event.key == pygame.K_a: # left
132 | self.move_unit(self.player, [-1, 0])
133 | elif event.key == pygame.K_d: # right
134 | self.move_unit(self.player, [1, 0])
135 | #these are for debug
136 | elif event.key == pygame.K_UP: # up
137 | self.move_unit(self.player, [0, -10])
138 | elif event.key == pygame.K_DOWN: # down
139 | self.move_unit(self.player, [0, 10])
140 | elif event.key == pygame.K_LEFT: # left
141 | self.move_unit(self.player, [-10, 0])
142 | elif event.key == pygame.K_RIGHT: # right
143 | self.move_unit(self.player, [10, 0])
144 |
145 | def move_unit(self, unit, position_change):
146 | new_position = [unit.position[0] + position_change[0], unit.position[1] + position_change[1]]
147 |
148 | # check if off map
149 | if new_position[0] < 0 or new_position[0] > (len(self.map.map_array[0]) - 1):
150 | return
151 |
152 | if new_position[1] < 0 or new_position[1] > (len(self.map.map_array) - 1):
153 | return
154 |
155 | # check for valid movement
156 | if self.map.map_array[new_position[1]][new_position[0]] in config.IMPASSIBLE:
157 | return
158 |
159 | self.player_has_moved = True
160 |
161 | unit.update_position(new_position)
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 | 1637436219356
198 |
199 |
200 | 1637436219356
201 |
202 |
203 |
204 |
205 |
214 |
215 |
216 |
--------------------------------------------------------------------------------