Jack Ton

@JackTon (9)
JackTon
JackTon
shared a Post
8 months ago
2
Roguelike Demo I made
Share
Beat through the tutorial of a game I'm currently making.
Dungeon Delving(Demo)
cpp11
Read full post
DynamicSquid
DynamicSquid This is cool! Just something I noticed: Many of your classes don't need destructors. You only need one when your class has a pointer that is used to manage dynamic allocated memory.8 months ago
JackTon
JackTon
shared a Post
11 months ago
2
Dynamic_Cast
Ask
I'm currently using dynamic_cast to access fields accessible only in the child of a parent object to use to construct children with said fields explic
Dungeon Delving(Demo)
cpp11
xxpertHacker
xxpertHacker Dynamicially casting from child -> parent sounds incredibly unsafe, as the child may not be the parent at all, or it may have inherited differently. struct A { char a; }; struct B : A { unsigned int b; }; struct C : A { unsigned short c; }; int main() { { auto const var = A { .a = 'a' }; dynamic_cast(var).b; // OOB access, undefined behavior } { auto const parent = C { .a = 'a', .c = 0xFFFFu }; auto const child = dynamic_cast(parent)11 months ago
JackTon
JackTon
shared a Post
9 months ago
Database
Ask
I'm trying to develop a randomizer for chests and enemy drops, but I can't think of a way how to expand the size of the database without reducing its
Dungeon Delving(Demo)
cpp11
Highwayman
Highwayman ok now that I'm seeing what you are talking about.. it seems like when you where naming each thing you kind of forget that you're inside a namespace, cause moveSetList::playerMoveSet seems kinda redundant. Probably want to change that to moveSetList::player, instead. or even better, not separate the moves from the actual player, and have Player::MoveSetList or Goblin::MoveSetList type thing. Also, you should probably make some more classes, like a Slash class and a Potion class or something, cau9 months ago
Highwayman
Highwayman I can't see your code because of the strange replit loading thing rn, so this might be off topic, but I think you might want to use using statements maybe? using small_name = std::vector>; `9 months ago
Coder100
Coder100 try structures struct MyData { std::vector enemy; std::vector }; another way would be classes. Probably you want to use classes more, as you can use constructors.9 months ago
JackTon
JackTon
shared a Post
5 months ago
1
Adding text files to an array
Ask
I'm currently working on a project that has a level generator which is based on getting access to multiple arrays of strings created via text files. I
Not Helltaker
cpp11
Highwayman
Highwayman c++17 std::filesystem standard header..?5 months ago
JackTon
JackTon
shared a Post
1 year ago
How can I avoid long switch statements for a factory method?
Ask
I have this program which relies on a factories comprised of switch statements and ids(integers) to create objects. I don't want to deal with a potent
Dungeon Delving(Demo)
cpp11
PattanAhmed
PattanAhmed @JustinWu Hi, Can we know Which file are you talking about in your question? Hope this helps.1 year ago
DynamicSquid
DynamicSquid which file are you taking about?1 year ago
JackTon
JackTon
shared a Post
9 months ago
File Organization
Ask
Is there any way how I can organize my files in a non-alphabetical order?
ZarmDev
ZarmDev You can export it to VSCode or a code editor and organize it and then import it, but there shouldn't be much need to do that.9 months ago
Coder100
Coder100 Nope, all repls are organized like this: folders files If you want, you can use tabs which can go in any order, ctrl+click a file9 months ago
JackTon
JackTon
shared a Post
6 months ago
1
Movement
Ask
I'm currently trying to replicate the gameplay of Helltaker, and I've noticed that the only thing the methods responsible for changing the coordinates
Not Helltaker
cpp11
SixBeeps
SixBeeps Keep them there just in case you need them in a separate script later. Once you've finished the first iteration and go onto polishing, then you can move it. IMO better to keep things modular, especially if that's the way they already are.6 months ago
JackTon
JackTon
shared a Post
7 months ago
1
Adding certain parts of a text file into an array
Ask
I know one way how to do textfile insertions are while(infile >> character >> integer >> integer2), but what should I do if I wanted to create a chara
Text File Thing
C++
DynamicSquid
DynamicSquid The best you can do is this: char c; file >> c; int arr[10]; for (int i = 0; i > arr[i]; `7 months ago
JackTon
JackTon
shared a Post
9 months ago
Input Getters
Ask
I created this incredibly basic game which uses inputs to move the character around. Does c++ provide something which allows the console to automatica
Dungeon Delving(Demo)
cpp11
ANDREWVOSS
ANDREWVOSS #include #include char getch() { char buf = 0; struct termios old = {0}; if (tcgetattr(0, &old) < 0) perror("tcsetattr()"); old.c_lflag &= ~ICANON; old.c_lflag &= ~ECHO; old.c_cc[VMIN] = 1; old.c_cc[VTIME] = 0; if (tcsetattr(0, TCSANOW, &old) < 0) perror("tcsetattr ICANON"); if (read(0, &buf, 1) < 0) perror ("read()"); old.c_lflag |= ICANON; old.c_lflag |= ECHO; if (tcsetattr(0, TCSADRAIN, &old) < 0) perror ("tcsetattr ~ICANON"); return (buf); } Just us9 months ago
JackTon
JackTon
shared a Post
12 months ago
Classes with only functions
Ask
I have heard classes with only data and nothing else are a bad practice. Would it be just as bad to have a class only consist of functions? What if th
Dungeon Delving(Demo)
cpp11
Coder100
Coder100 It's not a bad idea, it's just you would normally not use classes that way. Why use classes when all you have are functions? Use namespaces namespace Thing { void something() {} } Classes with nothing but data is should be replaced with structs. Also, the last one is literally just what classes are for class Class { public: int field void method() { ... } }; `12 months ago
JackTon
JackTon
shared a Post
1 year ago
1
Dijkstra's Algorithm for a 6x6 matrix
Share
This is an algorithm made to calculate the shortest path from one point to the next. The matrix represents a graph with directions. Feedback and quest
Dijkstra's algorithm
cpp11
SixBeeps
SixBeeps Neat. I'm going to have to use Dijkstra's alg for a project I've got going on, might just use this for reference ^^1 year ago
ChezTacoz
ChezTacoz Cool! It would be even better if users could make custom things.1 year ago
JackTon
JackTon
shared a Post
1 year ago
Avoiding a type system in factory methods
Ask
When I'm talking about a "type system", I'm talking about an additional value which is for doing something like this: void do_thing(parent target){
Dungeon Delving(Demo)
cpp11
SixBeeps
SixBeeps There's a few ways to go about this. The most simple way is to incorporate a parameter in the constructor that carries the type value for that object (in the example you provided, target.type). You could also make two separate classes that stem off of a parent class if you know how class inheritance works.1 year ago
JackTon
JackTon
shared a Post
1 year ago
Is the address of an lvalue initialized before an initializer list?
Ask
My issue is in battleObjectData.cpp. I know that doing something like this: object(int xx, int yy, int zz):x(x), y(y), z(zz){} would cause x and y to
Dungeon Delving(Demo)
cpp11
DynamicSquid
DynamicSquid you mean this? Constructor(int x, int y) : x(x), y(y) {} `1 year ago
JackTon
JackTon
shared a Post
10 months ago
1
Folder Structure
Ask
So I've decided to try putting all of the files in this project into folders. They all fall into one of these categories (besides .cpp and .h files):
Dungeon Delving(Demo)
cpp11
Coder100
Coder100 Here's how i do it: factory/ .cpp .h wrapper/ .cpp .h main.cpp `10 months ago
MocaCDeveloper
MocaCDeveloper Depends on what each file does. usually the file name tells you what the content within that file will do. First off, you'd probably want to start with creating a 'src' folder to store all, and any, other file besides the main file. So, lets say, as you have stated, you create a folder 'Data'(within the src folder), you would then put the corresponding files in it. Such as, 'overworldObjectData.cpp'. But, lets say you had a folder 'server' and you put the file 'client.cpp' in it, that would ma10 months ago
JackTon
JackTon
shared a Post
1 year ago
Printing Paths on Dijkstra's Algorithm
Ask
I've made a dijkstra's algorithm which prints out the distance between a point and its destination. However, I don't have a clue how I can string toge
Dijkstra's Algorithm with Classes
cpp11
SixBeeps
SixBeeps Are each of the nodes equidistant from each other, or does each one have a distance value assigned to it?1 year ago
JackTon
JackTon
shared a Post
2 years ago
Library header files
Ask
Is it a good practice to dedicate a header file to just containing standard library headers (ex. #include )?
Coder100
Coder100 Yes, you should always do that. This is just like having a ` tag in html`.2 years ago
Bookie0
Bookie0 here i found this that might interest you: https://stackoverflow.com/questions/1804486/should-i-use-include-in-headers Hope this helps! =)2 years ago
JackTon
JackTon
shared a Post
2 years ago
1
Namespaces and object oriented programming
Ask
Does the use of namespaces to encapsulate global variables and methods violate the principles of object oriented programming?
DynamicSquid
DynamicSquid Namespaces are useful when creating DLLs (or any sort of library), or code that is used in other projects. But I wouldn't compare namespaces with OOP as they are very different. I guess a namespace is really just a class with static members...2 years ago
SixBeeps
SixBeeps I wouldn't see why it would, I do it all the time.2 years ago
JackTon
JackTon
shared a Post
8 months ago
Signal:Killed
Ask
I run this code and I get signal:killed. Is there a reason why I got this? I don't see any obvious errors which could cause it.
WorkSheet
cpp11
JackTon
JackTon Just found out the problem; I just accidentally created an infinite loop.8 months ago
JackTon
JackTon
shared a Post
6 months ago
1
Short Game I Made
Share
I made this in 1.5 years, it's a 2d roguelike. I would love some advise on improving its game design or on making more efficient code for the future!
Dungeon Delving
cpp11
JackTon
JackTon
shared a Post
2 years ago
Thing I made
Share
This is a thing I made as a prototype, which, though having most of its core components finished, is still W.I.P., to an idea of a game I plan on maki
Dungeon Delving(Demo)
cpp11