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 7601 times)

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #30 on: April 12, 2011, 06:36:29 pm »

This site was very approachable when I first started learning, and is one of the best C++ tutorial sites I've seen so far.

I'm still reading up in the C++ Programming Language by Stroustrup. It's a thick book, and to be honest I don't have that much time to read any more.
Logged

bowdown2q

  • Bay Watcher
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #31 on: April 12, 2011, 06:45:04 pm »

I've been reading up on http://www.learncpp.com/ all day.

I figure 2 things so far: 1. I should break the code down into separate files as much as possible, and (2) making a GUI is going to SUCK.

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #32 on: April 12, 2011, 06:48:40 pm »

I've been reading up on http://www.learncpp.com/ all day.

I figure 2 things so far: 1. I should break the code down into separate files as much as possible, and (2) making a GUI is going to SUCK.

1: Yes, but only as much as you feel is necessary. It'll get harder to keep track of with hundreds of files for example, especially when you're just starting out. Learn to love headers.

2: Enter Qt, libtcod, and SDL. It'll still require effort on your part, but so does programming in general.

Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: DagronQwest - my first attempt at coding in VB.
« Reply #33 on: April 12, 2011, 06:53:03 pm »

I've been reading up on http://www.learncpp.com/ all day.

I figure 2 things so far: 1. I should break the code down into separate files as much as possible, and (2) making a GUI is going to SUCK.

That is one reason I suggested c# if you were to change languages, gui creation will be very familiar to you comeing from vb.
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 VB.
« Reply #34 on: April 12, 2011, 06:57:20 pm »

1: Yes, but only as much as you feel is necessary. It'll get harder to keep track of with hundreds of files for example, especially when you're just starting out. Learn to love headers.

2: Enter Qt, libtcod, and SDL. It'll still require effort on your part, but so does programming in general.

Hm. I notice that Microsoft Visual Studio's "add a file" feature lets me add a windows form. It then tells me it has to translate it into..."Common Language Runtime" support.
>oh GOD the code it generates for the form is BIZZARE
Spoiler (click to show/hide)

NO IDEA what to do with that. I'm going to not worry about a GUI for a while tho. I think most of that isn't really important to me anyway; its all automatically generated and the code it comes up with for controls is fairly familiar to me via VB.

tl;dr, gonna stick to console as the interface for a while.

Fayrik

  • Bay Watcher
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #35 on: April 12, 2011, 10:47:49 pm »

>oh GOD the code it generates for the form is BIZZARE
Spoiler (click to show/hide)
Looks perfectly normal to me!
Logged
So THIS is how migrations start.
"Hey, dude, there's this crazy bastard digging in the ground for stuff. Let's go watch."

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #36 on: April 12, 2011, 10:59:11 pm »

>oh GOD the code it generates for the form is BIZZARE
Spoiler (click to show/hide)
Looks perfectly normal to me!

I don't think he is used to the operational overloading. VB doesn't have that, does it?

bowdown2q

  • Bay Watcher
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #37 on: April 12, 2011, 11:01:40 pm »

>oh GOD the code it generates for the form is BIZZARE
Spoiler (click to show/hide)
Looks perfectly normal to me!

I don't think he is used to the operational overloading. VB doesn't have that, does it?

Yeah, thats it. In VB, forms have the code
Code: [Select]
Public Class Form1

End Class

Fayrik

  • Bay Watcher
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #38 on: April 12, 2011, 11:07:41 pm »

Uh, if I'm right, what you have so far is designer code - you don't touch that.
If it's not given you any other files, you'll need a child class to enter your code. At least, that's how it works in C#.

I think you want a new file along the lines of:
Code: [Select]
   public ref class rgrg1 : public rgrg
   {
   public:
      rgrg1(void)
      {
         InitializeComponent();
         //
         //TODO: Add the constructor code here
         //
      }
   }
Then build your class from there. I've probably missed a lot out here, but hopefully that's enough to get you on your way.
Logged
So THIS is how migrations start.
"Hey, dude, there's this crazy bastard digging in the ground for stuff. Let's go watch."

bowdown2q

  • Bay Watcher
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #39 on: April 12, 2011, 11:18:46 pm »

Uh, if I'm right, what you have so far is designer code - you don't touch that.
If it's not given you any other files, you'll need a child class to enter your code. At least, that's how it works in C#.

I think you want a new file along the lines of:
Code: [Select]
   public ref class rgrg1 : public rgrg
   {
   public:
      rgrg1(void)
      {
         InitializeComponent();
         //
         //TODO: Add the constructor code here
         //
      }
   }
Then build your class from there. I've probably missed a lot out here, but hopefully that's enough to get you on your way.

Actually, the designer has this wonderful way of adding the necessary code to create whatever you drop on the form (drag-n'-drop controls on the form, is really easy), then all you have to do is add code for whatever you want that control to do; e.g. if I add a button...
Code: [Select]
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    End Sub
So then whatever code inside that gets executed when that button gets pressed.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #40 on: April 12, 2011, 11:32:19 pm »

Remind me, visual studio c++ works the same way as it does for just about every other language right? Because I'm thinking I must have missed something for there to be this level of confusion. You graphically make a form, then double click it to make a listener, then link your listener to your model (Or your control, and link your control to your model).

bowdown2q

  • Bay Watcher
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #41 on: April 12, 2011, 11:35:57 pm »

Remind me, visual studio c++ works the same way as it does for just about every other language right? Because I'm thinking I must have missed something for there to be this level of confusion. You graphically make a form, then double click it to make a listener, then link your listener to your model (Or your control, and link your control to your model).

Double clicking the control/form opens the code for that form file, where you can edit it. I'm not sure what you mean by 'listener'?

Also... anybody know how to change Visual Studio 2010 from VB setup to C++? I remember it asked me about that when I installed it, but I can't seem to find a way to change it now?

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #42 on: April 12, 2011, 11:40:29 pm »

The set up that it asked you about didn't have anything to do with your system config, but rather what layout you want your controls in. So basicaly where you want your tools to appear while you program. I'm used to the standard c++ set up, and use it for all languages in visual studio, but if your used to the VB set up you should keep it that way.

A listener is like a function that is fired off when you click a button, or move the mouse, or anything that causes something to happen.

bowdown2q

  • Bay Watcher
    • View Profile
Re: DagronQwest - my first attempt at coding in VB.
« Reply #43 on: April 12, 2011, 11:43:48 pm »

The set up that it asked you about didn't have anything to do with your system config, but rather what layout you want your controls in. So basicaly where you want your tools to appear while you program. I'm used to the standard c++ set up, and use it for all languages in visual studio, but if your used to the VB set up you should keep it that way.

A listener is like a function that is fired off when you click a button, or move the mouse, or anything that causes something to happen.

Ah. Thanks for that.

Okay, yeah, that's it then. When you double-click, it creates the code for that listener. Whatever the default behavior is for that control (e.g. click for buttons).

bowdown2q

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

Alright, well. C++ is WAY harder to learn/use than VB. By a LONG shot.

That aside, I think I'm making more progress this time through. I figured out how to make a class - and the critterID does return a beautiful "1" to the console.

So, I've decided that I need to read "critterstats.csv" into the program as a 2d array. Now, if anybody knows a good way to search this array (I only need to search the first field of each line), then I can skip the part where I pull the first index of each line into a separate 1-d array, which I can then search for matching strings. Then I can take the index of the matching value and pull the row of data from the 2d array and feed it into the constructor for a new critter.

This seems overly complex. I suppose I could just... enumerate a master list of all critters, such that
Code: [Select]
"crittername"= [index in csv]And save a step. I could even pop that out into its own file for easy editing if new critters are added to the list.

Uh. Anybody have any suggestions?

Also: how does one fill an array from a file? a csv?
Alsoalso: i dont think i can, but is it possible to define the array's size by first checking the number of lines in the CSV file, then
Code: [Select]
const int nBestiarySize = [check #lines in CSV];
a_sBestary[nBestiarySize][nCritterFields];
(where nCritterFields is a hardcoded const)?
If not... well, I'm a little intimidated by memory pointers :|

Also^3: do I need to have
Code: [Select]
#include <string> or whatever
in every header? Do i need it in every .cpp? if I have it in a header does it need to be in the .cpp? vice versa? Why does my IDE yell at me when I don't include "stdafx.h" in every .cpp and reciprocal?

Addendum: I think I may be biting off more than I can chew, but, hey, at least I'm learning something. Any help would be appreciated.

Addendum to Addendum: my IDE is now MS Visual Studio Prof. 2010 (dreamspark, despite an AWFUL dl speed, is a pretty good idea)

(I'm sorry if I'm... well, dumb. Teaching yourself is HARD, and I haven't been able to pick up any books. The websites are helpful, but only to a point. I seriously appreciate everyone who's helping me out here, even if it's just "hey, this sounds cool!" You're all getting into the 'special thanks to' section of the credits when this finally gets done. Thanks guys, seriously.)
Pages: 1 2 [3] 4