diff --git a/data/tools.py b/data/tools.py index 5f26b5b..101cf97 100644 --- a/data/tools.py +++ b/data/tools.py @@ -4,17 +4,19 @@ import pygame as pg keybinding = { - 'action':pg.K_s, - 'jump':pg.K_a, - 'left':pg.K_LEFT, - 'right':pg.K_RIGHT, - 'down':pg.K_DOWN + 'action': pg.K_j, + 'jump': pg.K_k, + 'left': pg.K_a, + 'right': pg.K_d, + 'down': pg.K_s } + class Control(object): """Control class for entire project. Contains the game loop, and contains the event_loop which passes events to States as needed. Logic for flipping states is also found here.""" + def __init__(self, caption): self.screen = pg.display.get_surface() self.done = False @@ -48,7 +50,6 @@ def flip_state(self): self.state.startup(self.current_time, persist) self.state.previous = previous - def event_loop(self): for event in pg.event.get(): if event.type == pg.QUIT: @@ -60,14 +61,12 @@ def event_loop(self): self.keys = pg.key.get_pressed() self.state.get_event(event) - def toggle_show_fps(self, key): if key == pg.K_F5: self.show_fps = not self.show_fps if not self.show_fps: pg.display.set_caption(self.caption) - def main(self): """Main loop for entire program""" while not self.done: @@ -106,8 +105,7 @@ def update(self, surface, keys, current_time): pass - -def load_all_gfx(directory, colorkey=(255,0,255), accept=('.png', 'jpg', 'bmp')): +def load_all_gfx(directory, colorkey=(255, 0, 255), accept=('.png', 'jpg', 'bmp')): graphics = {} for pic in os.listdir(directory): name, ext = os.path.splitext(pic) @@ -118,14 +116,14 @@ def load_all_gfx(directory, colorkey=(255,0,255), accept=('.png', 'jpg', 'bmp')) else: img = img.convert() img.set_colorkey(colorkey) - graphics[name]=img + graphics[name] = img return graphics def load_all_music(directory, accept=('.wav', '.mp3', '.ogg', '.mdi')): songs = {} for song in os.listdir(directory): - name,ext = os.path.splitext(song) + name, ext = os.path.splitext(song) if ext.lower() in accept: songs[name] = os.path.join(directory, song) return songs @@ -135,21 +133,10 @@ def load_all_fonts(directory, accept=('.ttf')): return load_all_music(directory, accept) -def load_all_sfx(directory, accept=('.wav','.mpe','.ogg','.mdi')): +def load_all_sfx(directory, accept=('.wav', '.mpe', '.ogg', '.mdi')): effects = {} for fx in os.listdir(directory): name, ext = os.path.splitext(fx) if ext.lower() in accept: effects[name] = pg.mixer.Sound(os.path.join(directory, fx)) return effects - - - - - - - - - - - diff --git "a/\346\234\252\345\221\275\345\220\215\347\273\230\345\233\276.drawio" "b/\346\234\252\345\221\275\345\220\215\347\273\230\345\233\276.drawio" new file mode 100644 index 0000000..092002b --- /dev/null +++ "b/\346\234\252\345\221\275\345\220\215\347\273\230\345\233\276.drawio" @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +