C
C#13mo ago
Tomy

❔ Console RPG Game

Hello. Im currently in middle school, and our project is to make an RPG game using console. Sadly we cant use Unity or anything like that to make a graphical game. Is there any way to print things faster? Im planning to make a 2D top view game, but rendering the map takes too much time, and its like a CRT monitor, watching the map appear line by line every sec.
21 Replies
Jimmacle
Jimmacle13mo ago
it would help to see your current code to get an idea of what might be slow some things off the top of my head would be minimizing the actual Console calls like building up your screen in a buffer beforehand, or dropping down to lower level APIs to manipulate the console buffer directly
Angius
Angius13mo ago
Or using a package that makes it easier, should using 3rd party packages be allowed
Tomy
TomyOP13mo ago
I dont have a code yet, I'm just planning in my head, but its smt like map = "##################" "#AATAAARAAAAATAAAA# "#AAATAARAAAAATAAAA# .... A=Air T=Tree R=Road And its getting scaled to screen size So # = "███" "███" "███" And my graphic processor would be like if map[i] == "#": print(...) Im kinda new to c#
Jimmacle
Jimmacle13mo ago
if you don't have anything yet i'd start with building up one large string that you print to the console with one write call then if that's too slow go from there to find a more optimized solution
Tomy
TomyOP13mo ago
So print line by line, not process block by block?
Jimmacle
Jimmacle13mo ago
print an entire screen with one Console.Write
Tomy
TomyOP13mo ago
ooo, so whole map is 1 print?
Jimmacle
Jimmacle13mo ago
right
Tomy
TomyOP13mo ago
Geeeez, gonna be fun to build it But thats a good idea
Angius
Angius13mo ago
The console isn't slow even with really large strings
Tomy
TomyOP13mo ago
Thank you soo much
Jimmacle
Jimmacle13mo ago
yeah, it's usually best to know something is slow before trying to optimize it otherwise you might spend time optimizing something that wasn't slow anyway
Tomy
TomyOP13mo ago
I had a project and while printing the Fox&Rabbit simulation grid I could see the things appear line by line when the simulation map size was too big
Tomy
TomyOP13mo ago
Is there any idea how to process the scaling? Because when Map = "###" I cant print ███ ███ ███ then go back lines and print more characters after it ███ ███ ███ ███ ███ ███ Also if I want to color the wall gray, and trees green+brown, how can I do it in 1 print?
Jimmacle
Jimmacle13mo ago
you can using ANSI escape codes to modify the text style assuming the terminal you're using supports them, windows terminal should by default but cmd.exe doesn't
Tomy
TomyOP13mo ago
yoo Thats gonna be wild 🔥 Can u give me an example? K = character, # = wall
public static string map1 =
@"
##################
# #
# #
# K #
# #
# #
##################
";
public static string map1 =
@"
##################
# #
# #
# K #
# #
# #
##################
";
I cant get it working :/
class Palya
{
public static string palya1 =
@"
\x1b[31m################\x1b[0m
# #
# #
# \u001B[1m\u001B[33mK\u001B[39m\u001B[22m #
# #
# #
##################";

public static string palya2 =
@"\x1b[36m################\x1b[0m
# #
# #
# #
# #
# #
##################";

public static void PalyaBetoltes()
{
Console.WriteLine("\x1b[36mSzoveg\x1b[0m");
Console.Write(palya1);
}
}
class Palya
{
public static string palya1 =
@"
\x1b[31m################\x1b[0m
# #
# #
# \u001B[1m\u001B[33mK\u001B[39m\u001B[22m #
# #
# #
##################";

public static string palya2 =
@"\x1b[36m################\x1b[0m
# #
# #
# #
# #
# #
##################";

public static void PalyaBetoltes()
{
Console.WriteLine("\x1b[36mSzoveg\x1b[0m");
Console.Write(palya1);
}
}
I might have to look into stringbuilder idk what it is, but it seems like I cant do it with string+writeline
Omnissiah
Omnissiah13mo ago
oh boy, you know the casey muratori/molly rocket case, right?
BlyZe
BlyZe13mo ago
If you want to use an engine like package you could use this: https://www.nuget.org/packages/ConsoleNexusEngine
ConsoleNexusEngine 2.4.0
A powerful and easy to use engine to create console games
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Tomy
TomyOP13mo ago
._.
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server