From 97793fb26b8efb96e2d45dd6d2b8d14f44b2ec93 Mon Sep 17 00:00:00 2001 From: John McCardle Date: Sun, 12 Mar 2023 00:32:27 -0500 Subject: [PATCH] Clean up console output for 7DRL submission --- src/GameEngine.cpp | 8 +++---- src/Grid.cpp | 6 ++--- src/McRFPy_API.cpp | 10 ++++---- src/MenuScene.cpp | 8 ++++--- src/scripts/TestScene.py | 49 ++++++++++++++++++++++++---------------- 5 files changed, 46 insertions(+), 35 deletions(-) diff --git a/src/GameEngine.cpp b/src/GameEngine.cpp index 74d4b55..1ce9297 100644 --- a/src/GameEngine.cpp +++ b/src/GameEngine.cpp @@ -8,10 +8,10 @@ GameEngine::GameEngine() { font.loadFromFile("./assets/JetbrainsMono.ttf"); - window.create(sf::VideoMode(1024, 768), "McRogueFace Engine by John McCardle"); + window.create(sf::VideoMode(1024, 768), "McRogueFace - 7DRL Submission by John McCardle"); visible = window.getDefaultView(); window.setFramerateLimit(30); - scene = "py"; + scene = "menu"; //std::cout << "Constructing MenuScene" << std::endl; scenes["menu"] = new MenuScene(this); //std::cout << "Constructed MenuScene" <setProperties(x, y, p.transparent, p.walkable); } } - std::cout << "Map refreshed: " << total << " squares, " << walkable << "walkable, " << transparent << " transparent" << std::endl; + //std::cout << "Map refreshed: " << total << " squares, " << walkable << "walkable, " << transparent << " transparent" << std::endl; } void Grid::refreshTCODsight(int x, int y) { tcodmap->computeFov(x,y, 0, true, FOV_PERMISSIVE_8); diff --git a/src/McRFPy_API.cpp b/src/McRFPy_API.cpp index 3f841f5..5e02163 100644 --- a/src/McRFPy_API.cpp +++ b/src/McRFPy_API.cpp @@ -1015,7 +1015,7 @@ void McRFPy_API::player_input(int dx, int dy) { //std::cout << "Grid pointed to: " << (long)player_entity->cGrid->grid << std::endl; if (McRFPy_API::input_mode.compare("playerturn") != 0) { // no input accepted while computer moving - std::cout << "Can't move while it's not player's turn." << std::endl; + //std::cout << "Can't move while it's not player's turn." << std::endl; return; } // TODO: selection cursor via keyboard @@ -1027,19 +1027,19 @@ void McRFPy_API::player_input(int dx, int dy) { player_entity->cGrid->y + dy < 0 || player_entity->cGrid->x + dx > grid->grid_x - 1 || player_entity->cGrid->y + dy > grid->grid_y - 1) { - std::cout << "(" << player_entity->cGrid->x << ", " << player_entity->cGrid->y << - ") + (" << dx << ", " << dy << ") is OOB." << std::endl; + //std::cout << "(" << player_entity->cGrid->x << ", " << player_entity->cGrid->y << + // ") + (" << dx << ", " << dy << ") is OOB." << std::endl; return; } //std::cout << PyUnicode_AsUTF8(PyObject_Repr(player_entity->cBehavior->object)) << std::endl; PyObject* move_fn = PyObject_GetAttrString(player_entity->cBehavior->object, "move"); //std::cout << PyUnicode_AsUTF8(PyObject_Repr(move_fn)) << std::endl; if (move_fn) { - std::cout << "Calling `move`" << std::endl; + //std::cout << "Calling `move`" << std::endl; PyObject* move_args = Py_BuildValue("(ii)", dx, dy); PyObject_CallObject((PyObject*) move_fn, move_args); } else { - std::cout << "player_input called on entity with no `move` method" << std::endl; + //std::cout << "player_input called on entity with no `move` method" << std::endl; } } diff --git a/src/MenuScene.cpp b/src/MenuScene.cpp index c1af2a8..7eabc98 100644 --- a/src/MenuScene.cpp +++ b/src/MenuScene.cpp @@ -4,13 +4,13 @@ MenuScene::MenuScene(GameEngine* g) : Scene(g) { text.setFont(game->getFont()); - text.setString("McRogueFace Engine - Testing & Early Access"); + text.setString("McRogueFace Engine - 7DRL 2023 Submission (Incomplete)"); text.setCharacterSize(24); //std::cout << "MenuScene Initialized. " << game << std::endl; //std::cout << "Font: " << game->getFont().getInfo().family << std::endl; text2.setFont(game->getFont()); - text2.setString("Press 'Spacebar' to begin; 'Up' and 'Down' switch Resolution"); + text2.setString("Press 'Spacebar' to run demo"); text2.setCharacterSize(16); text2.setPosition(0.0f, 50.0f); @@ -29,11 +29,13 @@ void MenuScene::doAction(std::string name, std::string type) //std::cout << "MenuScene doAction: " << name << ", " << type << std::endl; //if (name.compare("start_game") == 0 and type.compare("start") == 0) if(ACTION("start_game", "start")) - game->changeScene("play"); + game->changeScene("py"); + /* else if(ACTIONONCE("up")) game->getWindow().setSize(sf::Vector2u(1280, 800)); else if(ACTIONONCE("down")) game->getWindow().setSize(sf::Vector2u(1024, 768)); + */ } void MenuScene::sRender() diff --git a/src/scripts/TestScene.py b/src/scripts/TestScene.py index eb7b26c..fc5c24d 100644 --- a/src/scripts/TestScene.py +++ b/src/scripts/TestScene.py @@ -3,7 +3,7 @@ import Grid import mcrfpy from random import randint, choice from pprint import pprint -print("TestScene imported") +#print("TestScene imported") BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED, GREEN, BLUE = (255, 0, 0), (0, 255, 0), (0, 0, 255) @@ -50,7 +50,7 @@ class TestEntity: for g in scene.grids: if g.title == self.grid: if g.at(self.x + dx, self.y + dy) is None or not g.at(self.x + dx, self.y + dy).walkable: - print("Blocked at target location.") + #print("Blocked at target location.") return if self.label == "player": mcrfpy.lockPlayerInput() @@ -169,27 +169,32 @@ class TestScene: mcrfpy.createMenu( "hintsmenu", 0, 505, 0, 0) mcrfpy.createCaption("hintsmenu", "", 16, WHITE) + # menu names must be created in alphabetical order (?!) - thanks, C++ hash map mcrfpy.createMenu( "i", 600, 20, 0, 0) #mcrfpy.createMenu( "camstatemenu", 600, 20, 0, 0) mcrfpy.createCaption("i", "", 16, WHITE) - mcrfpy.createButton( "i", 0, 0, 40, 40, DARKBLUE, WHITE, "Recenter", "activatecamfollow") + + mcrfpy.createMenu( "j", 600, 500, 0, 0) + mcrfpy.createButton( "j", 0, 0, 80, 40, DARKBLUE, WHITE, "Recenter", "activatecamfollow") #print("Make UIs visible") self.menus = mcrfpy.listMenus() self.menus[0].visible = True self.menus[1].w = 170 self.menus[1].visible = True - self.menus[2].visible = True + #self.menus[2].visible = True self.menus[2].bgcolor = BLACK self.menus[3].visible = True self.menus[3].bgcolor = BLACK self.menus[4].visible = True self.menus[4].bgcolor = BLACK + self.menus[5].visible = True mcrfpy.modMenu(self.menus[0]) mcrfpy.modMenu(self.menus[1]) mcrfpy.modMenu(self.menus[2]) mcrfpy.modMenu(self.menus[3]) mcrfpy.modMenu(self.menus[4]) + mcrfpy.modMenu(self.menus[5]) #pprint(mcrfpy.listMenus()) #print(f"UI 1 gave back this sprite: {self.menus[0].sprites}") @@ -205,17 +210,17 @@ class TestScene: #print("Create fancy entity") self.tes = [ - #TestEntity("demogrid", "classtest", 1, 1538, 5, 7, 64, walk_frames=5, attack_frames=6), - #TestEntity("demogrid", "classtest", 1, 1545, 7, 9, 64, walk_frames=5, attack_frames=6), - #TestEntity("demogrid", "classtest", 1, 1552, 9, 11, 64, walk_frames=5, attack_frames=6), - #TestEntity("demogrid", "classtest", 1, 1566, 11, 13, 64, walk_frames=4, attack_frames=6), - #TestEntity("demogrid", "classtest", 1, 1573, 13, 15, 64, walk_frames=4, attack_frames=6), - #TestEntity("demogrid", "classtest", 1, 1583, 15, 17, 64, walk_frames=4, attack_frames=6), - #TestEntity("demogrid", "classtest", 1, 130, 9, 7, 64, walk_frames=5, attack_frames=6), - #TestEntity("demogrid", "classtest", 1, 136, 11, 9, 64, walk_frames=5, attack_frames=6), - #TestEntity("demogrid", "classtest", 1, 143, 13, 11, 64, walk_frames=5, attack_frames=6), - #TestEntity("demogrid", "classtest", 1, 158, 15, 13, 64, walk_frames=5, attack_frames=6), - #TestEntity("demogrid", "classtest", 1, 165, 17, 15, 64, walk_frames=5, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 1538, 5, 7, 64, walk_frames=5, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 1545, 7, 9, 64, walk_frames=5, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 1552, 9, 11, 64, walk_frames=5, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 1566, 11, 13, 64, walk_frames=4, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 1573, 13, 15, 64, walk_frames=4, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 1583, 15, 17, 64, walk_frames=4, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 130, 9, 7, 64, walk_frames=5, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 136, 11, 9, 64, walk_frames=5, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 143, 13, 11, 64, walk_frames=5, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 158, 15, 13, 64, walk_frames=5, attack_frames=6), + TestEntity("demogrid", "classtest", 1, 165, 17, 15, 64, walk_frames=5, attack_frames=6), TestEntity("demogrid", "player", 3, 20, 17, 3, 5, walk_frames=4, attack_frames=5, do_fov=True) ] self.grids = mcrfpy.listGrids() @@ -242,7 +247,9 @@ class TestScene: mcrfpy.registerPyAction("skipsp", lambda: self.changesprite(16)) mcrfpy.unlockPlayerInput() mcrfpy.setActiveGrid("demogrid") + self.gridgen() self.updatehints() + mcrfpy.camFollow(True) def animate_entity(self, direction, attacking=False): if direction is None: @@ -303,10 +310,8 @@ class TestScene: def updatehints(self): self.menus[2].captions[0].text=mcrfpy.activeGrid() - #print(mcrfpy.camFollow) - #print(mcrfpy.camFollow()) - mcrfpy.modMenu(self.menus[2]) + self.menus[3].captions[0].text=mcrfpy.inputMode() mcrfpy.modMenu(self.menus[3]) #self.menus[4].captions[0].text=f"follow: {mcrfpy.camFollow()}" @@ -314,10 +319,13 @@ class TestScene: self.menus[4].captions[0].text="following" if mcrfpy.camFollow() else "free" mcrfpy.modMenu(self.menus[4]) + self.menus[5].visible = not mcrfpy.camFollow() + mcrfpy.modMenu(self.menus[5]) + def gridgen(self): - print(f"[Python] modifying {len(self.grids[0].points)} grid points") + #print(f"[Python] modifying {len(self.grids[0].points)} grid points") for p in self.grids[0].points: #p.color = (randint(0, 255), randint(64, 192), 0) p.color = (0,0,0) @@ -368,6 +376,7 @@ class TestScene: self.grids[0].at(10, 10).walkable = False self.grids[0].visible = True mcrfpy.modGrid(self.grids[0]) + #self.grids = mcrfpy.listGrids() #print(f"Sent grid: {repr(self.grids[0])}") #print(f"Received grid: {repr(mcrfpy.listGrids()[0])}") @@ -409,6 +418,6 @@ class TestScene: def start(): global scene - print("TestScene.start called") + #print("TestScene.start called") scene = TestScene()