REFACTOR: Split into modules (controller, models, and utils)
This commit is contained in:
0
controllers/__init__.py
Normal file
0
controllers/__init__.py
Normal file
@@ -1,4 +1,4 @@
|
|||||||
from utils import mapped_value
|
from utils.utils import mapped_value
|
||||||
import math
|
import math
|
||||||
|
|
||||||
class ImageCoordController:
|
class ImageCoordController:
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# Description: This file contains the CoordinateManager class which is responsible for converting coordinates to pixels and vice versa.
|
# Description: This file contains the CoordinateManager class which is responsible for converting coordinates to pixels and vice versa.
|
||||||
|
|
||||||
import math
|
import math
|
||||||
from utils import mapped_value
|
from utils.utils import mapped_value
|
||||||
|
|
||||||
class MapCoordController:
|
class MapCoordController:
|
||||||
def __init__(self, screen_width: int, screen_height: int, map_min_x: int, map_max_x, map_min_y, map_max_y):
|
def __init__(self, screen_width: int, screen_height: int, map_min_x: int, map_max_x, map_min_y, map_max_y):
|
||||||
25
main.py
Normal file
25
main.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
from models.game import Game
|
||||||
|
from models.match import Match
|
||||||
|
from models.player import Player
|
||||||
|
|
||||||
|
def main():
|
||||||
|
import demoparser2
|
||||||
|
|
||||||
|
demo_parser = demoparser2.DemoParser("demo.dem")
|
||||||
|
game_info = demo_parser.parse_ticks(["X", "Y", "Z", "pitch", "yaw", "is_alive", "team", "player_steamid", "team_rounds_total"])
|
||||||
|
header_info = demo_parser.parse_header()
|
||||||
|
map_name = header_info['map_name']
|
||||||
|
players = demo_parser.parse_player_info()
|
||||||
|
|
||||||
|
start_tick = int(input())
|
||||||
|
m = Match(map_name, game_info)
|
||||||
|
m.tick = start_tick
|
||||||
|
for index, row in players.iterrows():
|
||||||
|
m.add_player(Player(row["name"], row["steamid"]))
|
||||||
|
|
||||||
|
game = Game(m)
|
||||||
|
|
||||||
|
game.run()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
0
models/__init__.py
Normal file
0
models/__init__.py
Normal file
@@ -1,10 +1,10 @@
|
|||||||
import pygame
|
import pygame
|
||||||
from match import Match
|
from models.match import Match
|
||||||
from player import Player
|
from models.player import Player
|
||||||
from map_coord_controller import MapCoordController
|
from controllers.map_coord_controller import MapCoordController
|
||||||
from image_coord_controller import ImageCoordController
|
from controllers.image_coord_controller import ImageCoordController
|
||||||
from json_object import JSONObject
|
from utils.json_object import JSONObject
|
||||||
from utils import mapped_value
|
from utils.utils import mapped_value
|
||||||
|
|
||||||
WIDTH, HEIGHT = 700, 700
|
WIDTH, HEIGHT = 700, 700
|
||||||
MAP_WIDTH, MAP_HEIGHT = 1024,1024
|
MAP_WIDTH, MAP_HEIGHT = 1024,1024
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from player import Player
|
from models.player import Player
|
||||||
|
|
||||||
class Match:
|
class Match:
|
||||||
def __init__(self, map_name, game_info, tick_rate=64):
|
def __init__(self, map_name, game_info, tick_rate=64):
|
||||||
29
parser.py
29
parser.py
@@ -1,29 +0,0 @@
|
|||||||
import demoparser2
|
|
||||||
from match import Match
|
|
||||||
from player import Player
|
|
||||||
|
|
||||||
demo_parser = demoparser2.DemoParser("demo.dem")
|
|
||||||
demo_info = demo_parser.parse_ticks(["X", "Y", "Z"])
|
|
||||||
|
|
||||||
class Parser:
|
|
||||||
def __init__(self, demo_path):
|
|
||||||
self.demo_parser = demoparser2.DemoParser(demo_path)
|
|
||||||
self.demo_info = self.demo_parser.parse_ticks(["X", "Y", "Z", "pitch", "yaw", "is_alive", "team", "player_steamid"])
|
|
||||||
|
|
||||||
self.players = self.demo_parser.parse_player_info()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
parser = Parser("demo.dem")
|
|
||||||
match = Match("de_dust2", parser.demo_info)
|
|
||||||
|
|
||||||
for index, row in parser.players.iterrows():
|
|
||||||
match.add_player(Player(row["name"], row["steamid"]))
|
|
||||||
|
|
||||||
while match.tick < match.max_tick:
|
|
||||||
match.next_tick()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
0
utils/__init__.py
Normal file
0
utils/__init__.py
Normal file
Reference in New Issue
Block a user