Clean up console output for 7DRL submission

This commit is contained in:
John McCardle 2023-03-12 00:32:27 -05:00
parent b3134f0890
commit 97793fb26b
5 changed files with 46 additions and 35 deletions

View File

@ -8,10 +8,10 @@
GameEngine::GameEngine() GameEngine::GameEngine()
{ {
font.loadFromFile("./assets/JetbrainsMono.ttf"); 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(); visible = window.getDefaultView();
window.setFramerateLimit(30); window.setFramerateLimit(30);
scene = "py"; scene = "menu";
//std::cout << "Constructing MenuScene" << std::endl; //std::cout << "Constructing MenuScene" << std::endl;
scenes["menu"] = new MenuScene(this); scenes["menu"] = new MenuScene(this);
//std::cout << "Constructed MenuScene" <<std::endl; //std::cout << "Constructed MenuScene" <<std::endl;
@ -67,7 +67,7 @@ void GameEngine::sUserInput()
sf::FloatRect area(0.f, 0.f, event.size.width, event.size.height); sf::FloatRect area(0.f, 0.f, event.size.width, event.size.height);
visible = sf::View(area); visible = sf::View(area);
window.setView(visible); window.setView(visible);
std::cout << "Visible area set to (0, 0, " << event.size.width << ", " << event.size.height <<")"<<std::endl; //std::cout << "Visible area set to (0, 0, " << event.size.width << ", " << event.size.height <<")"<<std::endl;
actionType = "resize"; actionType = "resize";
} }
@ -107,7 +107,7 @@ void GameEngine::sUserInput()
} }
else else
{ {
std::cout << "[GameEngine] Action not registered for input: " << actionCode << ": " << actionType << std::endl; //std::cout << "[GameEngine] Action not registered for input: " << actionCode << ": " << actionType << std::endl;
} }
} }
} }

View File

@ -47,15 +47,15 @@ Grid::Grid(int gx, int gy, int gs, int _x, int _y, int _w, int _h):
} }
void Grid::refreshTCODmap() { void Grid::refreshTCODmap() {
int total = 0, walkable = 0, transparent = 0; //int total = 0, walkable = 0, transparent = 0;
for (int x = 0; x < grid_x; x++) { for (int x = 0; x < grid_x; x++) {
for (int y = 0; y < grid_y; y++) { for (int y = 0; y < grid_y; y++) {
auto p = at(x, y); auto p = at(x, y);
total++; if (p.walkable) walkable++; if (p.transparent) transparent++; //total++; if (p.walkable) walkable++; if (p.transparent) transparent++;
tcodmap->setProperties(x, y, p.transparent, p.walkable); tcodmap->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) { void Grid::refreshTCODsight(int x, int y) {
tcodmap->computeFov(x,y, 0, true, FOV_PERMISSIVE_8); tcodmap->computeFov(x,y, 0, true, FOV_PERMISSIVE_8);

View File

@ -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; //std::cout << "Grid pointed to: " << (long)player_entity->cGrid->grid << std::endl;
if (McRFPy_API::input_mode.compare("playerturn") != 0) { if (McRFPy_API::input_mode.compare("playerturn") != 0) {
// no input accepted while computer moving // 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; return;
} }
// TODO: selection cursor via keyboard // 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->y + dy < 0 ||
player_entity->cGrid->x + dx > grid->grid_x - 1 || player_entity->cGrid->x + dx > grid->grid_x - 1 ||
player_entity->cGrid->y + dy > grid->grid_y - 1) { player_entity->cGrid->y + dy > grid->grid_y - 1) {
std::cout << "(" << player_entity->cGrid->x << ", " << player_entity->cGrid->y << //std::cout << "(" << player_entity->cGrid->x << ", " << player_entity->cGrid->y <<
") + (" << dx << ", " << dy << ") is OOB." << std::endl; // ") + (" << dx << ", " << dy << ") is OOB." << std::endl;
return; return;
} }
//std::cout << PyUnicode_AsUTF8(PyObject_Repr(player_entity->cBehavior->object)) << std::endl; //std::cout << PyUnicode_AsUTF8(PyObject_Repr(player_entity->cBehavior->object)) << std::endl;
PyObject* move_fn = PyObject_GetAttrString(player_entity->cBehavior->object, "move"); PyObject* move_fn = PyObject_GetAttrString(player_entity->cBehavior->object, "move");
//std::cout << PyUnicode_AsUTF8(PyObject_Repr(move_fn)) << std::endl; //std::cout << PyUnicode_AsUTF8(PyObject_Repr(move_fn)) << std::endl;
if (move_fn) { if (move_fn) {
std::cout << "Calling `move`" << std::endl; //std::cout << "Calling `move`" << std::endl;
PyObject* move_args = Py_BuildValue("(ii)", dx, dy); PyObject* move_args = Py_BuildValue("(ii)", dx, dy);
PyObject_CallObject((PyObject*) move_fn, move_args); PyObject_CallObject((PyObject*) move_fn, move_args);
} else { } 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;
} }
} }

View File

@ -4,13 +4,13 @@
MenuScene::MenuScene(GameEngine* g) : Scene(g) MenuScene::MenuScene(GameEngine* g) : Scene(g)
{ {
text.setFont(game->getFont()); text.setFont(game->getFont());
text.setString("McRogueFace Engine - Testing & Early Access"); text.setString("McRogueFace Engine - 7DRL 2023 Submission (Incomplete)");
text.setCharacterSize(24); text.setCharacterSize(24);
//std::cout << "MenuScene Initialized. " << game << std::endl; //std::cout << "MenuScene Initialized. " << game << std::endl;
//std::cout << "Font: " << game->getFont().getInfo().family << std::endl; //std::cout << "Font: " << game->getFont().getInfo().family << std::endl;
text2.setFont(game->getFont()); 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.setCharacterSize(16);
text2.setPosition(0.0f, 50.0f); 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; //std::cout << "MenuScene doAction: " << name << ", " << type << std::endl;
//if (name.compare("start_game") == 0 and type.compare("start") == 0) //if (name.compare("start_game") == 0 and type.compare("start") == 0)
if(ACTION("start_game", "start")) if(ACTION("start_game", "start"))
game->changeScene("play"); game->changeScene("py");
/*
else if(ACTIONONCE("up")) else if(ACTIONONCE("up"))
game->getWindow().setSize(sf::Vector2u(1280, 800)); game->getWindow().setSize(sf::Vector2u(1280, 800));
else if(ACTIONONCE("down")) else if(ACTIONONCE("down"))
game->getWindow().setSize(sf::Vector2u(1024, 768)); game->getWindow().setSize(sf::Vector2u(1024, 768));
*/
} }
void MenuScene::sRender() void MenuScene::sRender()

View File

@ -3,7 +3,7 @@ import Grid
import mcrfpy import mcrfpy
from random import randint, choice from random import randint, choice
from pprint import pprint from pprint import pprint
print("TestScene imported") #print("TestScene imported")
BLACK = (0, 0, 0) BLACK = (0, 0, 0)
WHITE = (255, 255, 255) WHITE = (255, 255, 255)
RED, GREEN, BLUE = (255, 0, 0), (0, 255, 0), (0, 0, 255) RED, GREEN, BLUE = (255, 0, 0), (0, 255, 0), (0, 0, 255)
@ -50,7 +50,7 @@ class TestEntity:
for g in scene.grids: for g in scene.grids:
if g.title == self.grid: 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: 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 return
if self.label == "player": if self.label == "player":
mcrfpy.lockPlayerInput() mcrfpy.lockPlayerInput()
@ -169,27 +169,32 @@ class TestScene:
mcrfpy.createMenu( "hintsmenu", 0, 505, 0, 0) mcrfpy.createMenu( "hintsmenu", 0, 505, 0, 0)
mcrfpy.createCaption("hintsmenu", "<hintline>", 16, WHITE) mcrfpy.createCaption("hintsmenu", "<hintline>", 16, WHITE)
# menu names must be created in alphabetical order (?!) - thanks, C++ hash map
mcrfpy.createMenu( "i", 600, 20, 0, 0) mcrfpy.createMenu( "i", 600, 20, 0, 0)
#mcrfpy.createMenu( "camstatemenu", 600, 20, 0, 0) #mcrfpy.createMenu( "camstatemenu", 600, 20, 0, 0)
mcrfpy.createCaption("i", "<camstate>", 16, WHITE) mcrfpy.createCaption("i", "<camstate>", 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") #print("Make UIs visible")
self.menus = mcrfpy.listMenus() self.menus = mcrfpy.listMenus()
self.menus[0].visible = True self.menus[0].visible = True
self.menus[1].w = 170 self.menus[1].w = 170
self.menus[1].visible = True self.menus[1].visible = True
self.menus[2].visible = True #self.menus[2].visible = True
self.menus[2].bgcolor = BLACK self.menus[2].bgcolor = BLACK
self.menus[3].visible = True self.menus[3].visible = True
self.menus[3].bgcolor = BLACK self.menus[3].bgcolor = BLACK
self.menus[4].visible = True self.menus[4].visible = True
self.menus[4].bgcolor = BLACK self.menus[4].bgcolor = BLACK
self.menus[5].visible = True
mcrfpy.modMenu(self.menus[0]) mcrfpy.modMenu(self.menus[0])
mcrfpy.modMenu(self.menus[1]) mcrfpy.modMenu(self.menus[1])
mcrfpy.modMenu(self.menus[2]) mcrfpy.modMenu(self.menus[2])
mcrfpy.modMenu(self.menus[3]) mcrfpy.modMenu(self.menus[3])
mcrfpy.modMenu(self.menus[4]) mcrfpy.modMenu(self.menus[4])
mcrfpy.modMenu(self.menus[5])
#pprint(mcrfpy.listMenus()) #pprint(mcrfpy.listMenus())
#print(f"UI 1 gave back this sprite: {self.menus[0].sprites}") #print(f"UI 1 gave back this sprite: {self.menus[0].sprites}")
@ -205,17 +210,17 @@ class TestScene:
#print("Create fancy entity") #print("Create fancy entity")
self.tes = [ self.tes = [
#TestEntity("demogrid", "classtest", 1, 1538, 5, 7, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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) TestEntity("demogrid", "player", 3, 20, 17, 3, 5, walk_frames=4, attack_frames=5, do_fov=True)
] ]
self.grids = mcrfpy.listGrids() self.grids = mcrfpy.listGrids()
@ -242,7 +247,9 @@ class TestScene:
mcrfpy.registerPyAction("skipsp", lambda: self.changesprite(16)) mcrfpy.registerPyAction("skipsp", lambda: self.changesprite(16))
mcrfpy.unlockPlayerInput() mcrfpy.unlockPlayerInput()
mcrfpy.setActiveGrid("demogrid") mcrfpy.setActiveGrid("demogrid")
self.gridgen()
self.updatehints() self.updatehints()
mcrfpy.camFollow(True)
def animate_entity(self, direction, attacking=False): def animate_entity(self, direction, attacking=False):
if direction is None: if direction is None:
@ -303,10 +310,8 @@ class TestScene:
def updatehints(self): def updatehints(self):
self.menus[2].captions[0].text=mcrfpy.activeGrid() self.menus[2].captions[0].text=mcrfpy.activeGrid()
#print(mcrfpy.camFollow)
#print(mcrfpy.camFollow())
mcrfpy.modMenu(self.menus[2]) mcrfpy.modMenu(self.menus[2])
self.menus[3].captions[0].text=mcrfpy.inputMode() self.menus[3].captions[0].text=mcrfpy.inputMode()
mcrfpy.modMenu(self.menus[3]) mcrfpy.modMenu(self.menus[3])
#self.menus[4].captions[0].text=f"follow: {mcrfpy.camFollow()}" #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" self.menus[4].captions[0].text="following" if mcrfpy.camFollow() else "free"
mcrfpy.modMenu(self.menus[4]) mcrfpy.modMenu(self.menus[4])
self.menus[5].visible = not mcrfpy.camFollow()
mcrfpy.modMenu(self.menus[5])
def gridgen(self): 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: for p in self.grids[0].points:
#p.color = (randint(0, 255), randint(64, 192), 0) #p.color = (randint(0, 255), randint(64, 192), 0)
p.color = (0,0,0) p.color = (0,0,0)
@ -368,6 +376,7 @@ class TestScene:
self.grids[0].at(10, 10).walkable = False self.grids[0].at(10, 10).walkable = False
self.grids[0].visible = True self.grids[0].visible = True
mcrfpy.modGrid(self.grids[0]) mcrfpy.modGrid(self.grids[0])
#self.grids = mcrfpy.listGrids()
#print(f"Sent grid: {repr(self.grids[0])}") #print(f"Sent grid: {repr(self.grids[0])}")
#print(f"Received grid: {repr(mcrfpy.listGrids()[0])}") #print(f"Received grid: {repr(mcrfpy.listGrids()[0])}")
@ -409,6 +418,6 @@ class TestScene:
def start(): def start():
global scene global scene
print("TestScene.start called") #print("TestScene.start called")
scene = TestScene() scene = TestScene()