change the dictionary
This commit is contained in:
parent
0dd825059c
commit
e8e31470d0
2
main.py
2
main.py
@ -2,5 +2,7 @@ import pygame as pg
|
|||||||
from source.main import main
|
from source.main import main
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
|
# do everything in this main function
|
||||||
main()
|
main()
|
||||||
|
# don't forget quit for release all resource
|
||||||
pg.quit()
|
pg.quit()
|
||||||
@ -1,5 +1,3 @@
|
|||||||
__author__ = 'marble_xu'
|
|
||||||
|
|
||||||
import random
|
import random
|
||||||
import pygame as pg
|
import pygame as pg
|
||||||
from .. import tool
|
from .. import tool
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
__author__ = 'marble_xu'
|
|
||||||
|
|
||||||
START_LEVEL_NUM = 1
|
START_LEVEL_NUM = 1
|
||||||
|
|
||||||
ORIGINAL_CAPTION = 'Plant VS Zombies Game'
|
ORIGINAL_CAPTION = 'Plant VS Zombies Game'
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
__author__ = 'marble_xu'
|
__author__ = 'wcb'
|
||||||
|
|
||||||
from . import tool
|
from . import tool
|
||||||
from . import constants as c
|
from . import constants as c
|
||||||
from .state import mainmenu, screen, level
|
from .state import mainmenu, screen, level
|
||||||
|
|
||||||
|
# create a standard game
|
||||||
def main():
|
def main():
|
||||||
game = tool.Control()
|
game = tool.Control()
|
||||||
state_dict = {c.MAIN_MENU: mainmenu.Menu(),
|
state_dict = {c.MAIN_MENU: mainmenu.Menu(),
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class Level(tool.State):
|
|||||||
|
|
||||||
def loadMap(self):
|
def loadMap(self):
|
||||||
map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json'
|
map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json'
|
||||||
file_path = os.path.join('source', 'data', 'map', map_file)
|
file_path = os.path.join('resources', 'data', 'map', map_file)
|
||||||
f = open(file_path)
|
f = open(file_path)
|
||||||
self.map_data = json.load(f)
|
self.map_data = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
__author__ = 'marble_xu'
|
|
||||||
|
|
||||||
import pygame as pg
|
import pygame as pg
|
||||||
from .. import tool
|
from .. import tool
|
||||||
from .. import constants as c
|
from .. import constants as c
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
__author__ = 'marble_xu'
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
@ -100,7 +98,7 @@ def load_image_frames(directory, image_name, colorkey, accept):
|
|||||||
tmp = {}
|
tmp = {}
|
||||||
# image_name is "Peashooter", pic name is 'Peashooter_1', get the index 1
|
# image_name is "Peashooter", pic name is 'Peashooter_1', get the index 1
|
||||||
index_start = len(image_name) + 1
|
index_start = len(image_name) + 1
|
||||||
frame_num = 0;
|
frame_num = 0
|
||||||
for pic in os.listdir(directory):
|
for pic in os.listdir(directory):
|
||||||
name, ext = os.path.splitext(pic)
|
name, ext = os.path.splitext(pic)
|
||||||
if ext.lower() in accept:
|
if ext.lower() in accept:
|
||||||
@ -154,14 +152,14 @@ def load_all_gfx(directory, colorkey=c.WHITE, accept=('.png', '.jpg', '.bmp', '.
|
|||||||
return graphics
|
return graphics
|
||||||
|
|
||||||
def loadZombieImageRect():
|
def loadZombieImageRect():
|
||||||
file_path = os.path.join('source', 'data', 'entity', 'zombie.json')
|
file_path = os.path.join('resources', 'data', 'entity', 'zombie.json')
|
||||||
f = open(file_path)
|
f = open(file_path)
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
return data[c.ZOMBIE_IMAGE_RECT]
|
return data[c.ZOMBIE_IMAGE_RECT]
|
||||||
|
|
||||||
def loadPlantImageRect():
|
def loadPlantImageRect():
|
||||||
file_path = os.path.join('source', 'data', 'entity', 'plant.json')
|
file_path = os.path.join('resources', 'data', 'entity', 'plant.json')
|
||||||
f = open(file_path)
|
f = open(file_path)
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user