Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 3 [4]

Author Topic: DagronQwest - my first attempt at coding in [s]VB.[/s] C++ :/  (Read 7583 times)

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: DagronQwest - my first attempt at coding in [s]VB.[/s] C++ :/
« Reply #45 on: April 27, 2011, 12:57:38 am »

enumeration will work, but only for hardcoded creatures (modding will only be able to be done by you ;))
ya, .csv is prob the way to go. you'll be able to read the output in excel, as well.

also, you might want to add a header with all your #includes, and just #include that file itself (you will get all access then :))
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: DagronQwest - my first attempt at coding in [s]VB.[/s] C++ :/
« Reply #46 on: April 27, 2011, 06:07:32 pm »

also, you might want to add a header with all your #includes, and just #include that file itself (you will get all access then :))

Though this is a way to do it, I strongly recommend you use separate #includes (such as #include <iostream>) in every file/header as required instead of inserting a header with them.

This way, you know the dependencies for each separate file, and don't have to go niggle around to look for them. Remember that modular code, each piece readable and usable in its own right, is what you're aiming for (aka ravioli code). Things like that are an easy way to get spaghetti code if done wrong.

You might want to ask a proper programmer, seeing as none of us here have any real authority. We'll do more harm than good, so go seek up a programming forum or talk to a professor.
Logged

bowdown2q

  • Bay Watcher
    • View Profile
Re: DagronQwest - my first attempt at coding in [s]VB.[/s] C++ :/
« Reply #47 on: April 27, 2011, 08:51:08 pm »

Status report:
4.27.2011.2200: MyGodItsFullOfStats -complete- //I now have an array holding my critterstats.csv file. SWEET.

4.27.2011.2237: Bison Reduplication Error Repaired

NEXT: make the array dynamic so adding more creatures doesn't suck
THEN: add code to search the Bestiary array for [creature name]
THEN: add code to the critter object constructor so it can parse the array into critter stats
THEN: creating a For loop to make a template creature for everything in the bestiary.

WEEKEND: ...text-based combat?

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: DagronQwest - my first attempt at coding in [s]VB.[/s] C++ :/
« Reply #48 on: April 27, 2011, 11:16:55 pm »

You might want to ask a proper programmer, seeing as none of us here have any real authority. We'll do more harm than good, so go seek up a programming forum or talk to a professor.
probably the best advice so far  :P

well, in my news, a "friend" gave me the source code for a colored console game (snake) so I'll be trying to mod that for Hacker Wars.
I'll try to be helpful then too ^^
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: DagronQwest - my first attempt at coding in [s]VB.[/s] C++ :/
« Reply #49 on: April 27, 2011, 11:58:08 pm »

You might want to ask a proper programmer, seeing as none of us here have any real authority. We'll do more harm than good, so go seek up a programming forum or talk to a professor.

I am a real programmer, just that my c++ is really rusty and vb is something that i would rather forget. I don't feel comfortable enough in the language to provide more than general architectural advice, especially since I never used visual c++ with garbage collection/managed code as it looks like you are from that code snippet.

Status report:
4.27.2011.2200: MyGodItsFullOfStats -complete- //I now have an array holding my critterstats.csv file. SWEET.

4.27.2011.2237: Bison Reduplication Error Repaired

NEXT: make the array dynamic so adding more creatures doesn't suck
THEN: add code to search the Bestiary array for [creature name]
THEN: add code to the critter object constructor so it can parse the array into critter stats
THEN: creating a For loop to make a template creature for everything in the bestiary.

WEEKEND: ...text-based combat?
I would have advice for how to do this, but you may not have strong enough fundamentals to be ready for it.
I would create a struct or class for for your bestiary entry, then use a stl list or map instead of an array to store them.
Then I would have a different struct or class that represents your creature and have a method that creates a creature from a bestiary entry.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

bowdown2q

  • Bay Watcher
    • View Profile
Re: DagronQwest - my first attempt at coding in [s]VB.[/s] C++ :/
« Reply #50 on: April 28, 2011, 06:18:58 pm »

Well, today was... interesting.

I began by trying to fully parse my CSV into a 2d array. Several hours later, I reverted the code to last night's version, and drank a Coke.
>_>

HOWEVER. since then, I have managed to create a function witch will search my bestiary array and return a matching index. ATM that input is user-typed in all caps ("DRAGON" or "GOAT"), but it does return that entry's stats correctly. I'm using
Code: [Select]
strQue = a_sBestiary[xx].substr(0,(a_sBestiary[xx].find(",")));to grab the first CSV field from the unformatted array, then using
Code: [Select]
if (QUEREY.compare(strQue) == 0 )to check if it's the line i'm looking for, and looping that from 0 to [bestiarylength] until I find it (or come up with "DERP, it aint here", exit(2);)

^hoping that's a decent way to do it, and wont make a user's comp explode or something.

Tonight I'm going to write up an RNG file, to hold anything where I need a random number, both for dice rolls and generators.

Now... does anybody have any advice on how to organize a master list so I can use the RNG to pick random creatures? I was thinking I could use an enumerated list, but that would preclude modding.
I could pull another array from this one, just to yank the names out (via substring again), and use the RNG/whatever on that index. This is the way I know I can do it, but if there's a simpler way...? I was mucking around with lists, but I'm not sure that's what I want?

I'm still very much confused by dynamic memory, though I'm planning on reading through those sections on learncpp.com again later.

I think... the next things before monday are
[a] a RNG
use the stat array to feed the critter constructor. I was having some issues with getline, so I switched over to just using "file >> strLine" (which is fine, as my CSV is correctly formatted). As for extracting information from the array - which would return me a line such as
Code: [Select]
GOAT,5,1,1,1,1,1,1,5,0,10,5,1what's the best (read:simplest) way to parse that into separate strings and then into the creature's properties? I'm thinking... can I loop through functions? I'm going to have a bunch of
void Set[Property](input) {[parse 1st field of data]}
can I set up a For loop, or will I have to manually increment everything?
Also, if I use [string].find(','), can I make sure it discards the data so I dont end up putting the same field in every stat? and is it safe to cast those string fragments as integers with
Code: [Select]
int (str[parsed int value])?

Once I have those, I can get to work on the player object, and then I can hop into combat code O_o (any pointers there would be nice too.)

Fayrik

  • Bay Watcher
    • View Profile
Re: DagronQwest - my first attempt at coding in [s]VB.[/s] C++ :/
« Reply #51 on: April 29, 2011, 12:55:37 pm »

Code: [Select]
GOAT,5,1,1,1,1,1,1,5,0,10,5,1what's the best (read:simplest) way to parse that into separate strings and then into the creature's properties?
I'd use the String.Split(','); function (assuming you're using the .NET libraries).
The resulting array can then be cast into the creature's relevant fields.
Logged
So THIS is how migrations start.
"Hey, dude, there's this crazy bastard digging in the ground for stuff. Let's go watch."

Gantolandon

  • Bay Watcher
  • He has a fertile imagination.
    • View Profile
Re: DagronQwest - my first attempt at coding in [s]VB.[/s] C++ :/
« Reply #52 on: April 29, 2011, 05:16:00 pm »

Quote
what's the best (read:simplest) way to parse that into separate strings and then into the creature's properties? I'm thinking... can I loop through functions? I'm going to have a bunch of
void Set[Property](input) {[parse 1st field of data]}
can I set up a For loop, or will I have to manually increment everything?

I'm not sure if I understood what you meant. If you mean a bunch of functions like "SetProperty1", "SetProperty2", etc., you can't use for to call them. The names you are giving them are only for you and the compiler, they are lost after source code is converted to binary form.
Logged
Pages: 1 2 3 [4]