12 Replies - 2579 Views - Last Post: 26 November 2011 - 11:13 AM Rate Topic: -----

#1 Paepay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-November 11

C# Programming in multiple tabs using classes

Posted 19 November 2011 - 12:10 PM

I need help with programming in multiple tabs using Classes. We never learned this in class and I need to learn how to do this as soon as possible. Any help would be greatly appreciated :)

I use VB 2010.
Is This A Good Question/Topic? 0
  • +

Replies To: C# Programming in multiple tabs using classes

#2 Paepay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-November 11

Re: C# Programming in multiple tabs using classes

Posted 19 November 2011 - 12:32 PM

More background on this "project":

I started making a game around 2 months ago. Currently it has around 1400 lines of code on a single page. Adding new parts to this game is very tedious when I have to scroll through over a thousand lines of code. Last year in my CS1110 class we didn't learn anything about classes or I wouldn't be seeking help.

If anyone would like to view my game on Teamviewer or Screen share via Skype I'd be more than happy to show you.
Was This Post Helpful? 0
  • +
  • -

#3 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,691
  • Joined: 13-March 10

Re: C# Programming in multiple tabs using classes

Posted 19 November 2011 - 12:47 PM

How the hell can you start making a game without knowing what a Class is? Its the most fundamental building block of OO languages. I would open any intro book to the language and read firs 5 chapters.
Was This Post Helpful? 0
  • +
  • -

#4 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • Posts: 3,002
  • Joined: 30-January 11

Re: C# Programming in multiple tabs using classes

Posted 19 November 2011 - 01:06 PM

I agree with darek9576. With over 1400 lines of code in one file for a project of this type points out that you are not yet familiar with modularising your code.

You are taking this way too fast. You have been making a game without knowing the fundamental concepts behind object oriented design. This is of no use whatsoever.

Go back to the basics. Start from scratch. Before you dive in to making games and what not you should actually have some idea of what you are doing.

It may sound harsh but its for your own benefit. You are jumping into the deep end without knowing how to swim. Take a step back. Read up about classes and objects. Do some simple projects. Then when you have some more knowledge go back to these projects. Try even re - coding to current badly designed game into something more flexibility with the use of OOP and other design concepts.

Good luck.
Was This Post Helpful? 0
  • +
  • -

#5 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,691
  • Joined: 13-March 10

Re: C# Programming in multiple tabs using classes

Posted 19 November 2011 - 02:15 PM

I have never programmed a game in my life, but if i was to do it, there would be 1 thing i would immediately do:


1) Create a Player class, Environment class, Board class. - these classes might not be needed depending on the game but it just shows you, a nice way to break your code into modules. If it was a team of you coding the game, how would you expect other memebers to contribute to the one stream of code you have at the moment. Not possible.
Was This Post Helpful? 1
  • +
  • -

#6 Paepay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-November 11

Re: C# Programming in multiple tabs using classes

Posted 19 November 2011 - 02:43 PM

I know how to make classes. I'm trying to program in different "tabs" though to make it much easier to program.

I know how to make and call to classes if they are on the same page.

Sorry for any misunderstanding.

I currently have 8 tabs in my program.

1 being the main class and the other ones are for other classes I need for the game.

I want to call to each one of these classes specifically when I need them.

To put it simply. When I'm playing the game and choose the "C" option I want the program to go to the tab of code that I have for that particular choice. If any of you can talk to me on MSN I'd greatly appreciate it.

With Teamviewer this wouldn't take more than 5 minutes.


<removed contact details>

This post has been edited by CodingSup3rnatur@l-360: 19 November 2011 - 02:50 PM
Reason for edit:: Please try to keep discussion in this thread :)

Was This Post Helpful? 0
  • +
  • -

#7 Paepay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-November 11

Re: C# Programming in multiple tabs using classes

Posted 19 November 2011 - 02:50 PM

I'm sorry if that is not in the rules, but I'd like for someone to use Teamviewer with me so they can see what I'm talking about
Was This Post Helpful? 0
  • +
  • -

#8 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5535
  • View blog
  • Posts: 11,857
  • Joined: 02-June 10

Re: C# Programming in multiple tabs using classes

Posted 20 November 2011 - 01:42 PM

I'm sorry to say this; and as others have said I'm sorry if this seems harsh but...

You really don't sound like you have a grasp on understanding the basics. You've run off an started cutting wood and hammered together planks to build a house - before ever sitting down and making a blueprint. You've got 1400 lines of ... what? If you had no idea where you were going what did you code?

Quote

I know how to make classes. I'm trying to program in different "tabs" though to make it much easier to program.

I know how to make and call to classes if they are on the same page.

Sorry for any misunderstanding.

I currently have 8 tabs in my program.

1 being the main class and the other ones are for other classes I need for the game.

I want to call to each one of these classes specifically when I need them.


You said you wanted to make tabs because it would be easier to code. You have 8 tabs already. So... did it make the coding any easier?

I'm not sure why you think that having tabs will make this project easier to write. Tabs are just GUI. They might make interface easier to use for the player. But they really don't change much from the point of view of the programmer. You still make objects, whether they are players, treasure, weapons... You track them... they interact with each other... they raise events and they react to events... None of which have anything to do with which tabpage data is displayed on. The score can be shown on tab1 or tab8 or the statusbar. Your code doesn't care and isn't affected by that.

You sound like you think it has to be 1 tab to 1 class. That's just not the case. Take for example a tab that is going to be your map of the game environment. It would show lots of information that comes from other objects/classes: Trees, rocks, other players and so on.

There is no direct or implied relationship between tabs and organized code. Just because you have 20 code files doesn't mean 20 tabs. And having 8 tabs doesn't magically break up your one code file into lots of desecrate bits of organized classes. You have to do that. You have to design and organize your code. You have to envision the game, the pieces (objects), the interactions and code it accordingly. You have do the engineering of your software: That's why the job title is "Software engineer".

Quote

When I'm playing the game and choose the "C" option I want the program to go to the tab of code that I have for that particular choice.

  • On your form, set the KeyPreview to true.
  • Create a handler for the .KeyDown event. In your event handler you check which key was down and set the TabControl's .SelectedTab to the one in question.

Please don't be offended but this is basic. If you don't know how to do this, then you aren't ready to try to archetect something as complex as a game. Your course didn't teach you a LOT of things. Honestly, most of us don't hold college programming courses in high regard. They suck. They are designed on purpose to teach slowly so they get 4 years of tuition from you. You can learn more in 60 days with a good self-teaching book than a year in a college course.

The stages of asking for homework help on a forum

Quote

I have a little C# experience but I need to write ...


You need to start there. I can't say "I have little experience in speaking Russian, but I have been assigned to write a mystery novel in Russian. Can you help me?"

We can help you by saying "First learn basic programming and the language of C#. Then take on assignments." Could someone here write this program for you? Sure. Could someone here map out all the processes you need to follow and do the Software Design part of this in the slim hope you could code it from there? Sure. But we don't volunteer to do the job that you're either getting paid for, or getting a grade for. You may want to read this.

For now, just work on the lessons. Do a self-teaching book from cover to cover. Then consider writing a program.

Don't try to create a useful working program to fit a need of yours (or a for-pay contract) as your introduction to coding project. When you are learning to code you don't know enough to code a program, let alone know how to engineer the architecture of a program. It would be like saying "I don't know how to read sheet music, or play an instrument. I think I'll write a 3 act opera as my first learning experience."

I don't say this to be mean. We've seen lots of new coders take this approach and we know it doesn't work. Trying to design your own programs before you understand the basics of the code language you've chosen just leads to problems, frustrations, and 'swiss-cheese' education (lots of holes).


Resources, references and suggestions for new programmers. - Updated Oct 2011
Spoiler

Was This Post Helpful? 0
  • +
  • -

#9 Paepay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-November 11

Re: C# Programming in multiple tabs using classes

Posted 20 November 2011 - 02:04 PM

I really do appreciate that response and did put somethings into perspective for me.

I have made the game into Classes on a single page and it is working just fine. I'm having a few simple errors here and there but I should be able to do it.

Just to throw it out there, my game is VERY simple. It's 2D with ASCII graphics and is purely something I'm doing for fun, nothing else. I have a lot of interest in Computer Science and this is something I do on my free time.

If you want to help me with a few things I'd greatly appreciate it. Message me on here since posting my MSN is against the rules :P
Was This Post Helpful? 0
  • +
  • -

#10 Paepay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-November 11

Re: C# Programming in multiple tabs using classes

Posted 26 November 2011 - 09:22 AM

I have since resolved this issue and my game is over 8000 lines now :)
Was This Post Helpful? 0
  • +
  • -

#11 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,691
  • Joined: 13-March 10

Re: C# Programming in multiple tabs using classes

Posted 26 November 2011 - 09:38 AM

Number of lines has no indication about the program itself. I dont get the point.
Was This Post Helpful? 0
  • +
  • -

#12 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5535
  • View blog
  • Posts: 11,857
  • Joined: 02-June 10

Re: C# Programming in multiple tabs using classes

Posted 26 November 2011 - 10:01 AM

View PostPaepay, on 26 November 2011 - 10:22 AM, said:

I have since resolved this issue and my game is over 8000 lines now :)


Are they still all in one file?

The goal generally is not to see how big you can grow the application, but how small. Its like golf; the person with the lowest score wins.

The fact that it has grown from 1400 to 8000 lines in a couple weeks makes me think there is a LOT of code redundancy/duplication. Its easy to grow the program by having a lot of duplicate code via copy/paste the same method(s) amongst several classes like: Player, ogre, goblin and so on.
Was This Post Helpful? 0
  • +
  • -

#13 Paepay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-November 11

Re: C# Programming in multiple tabs using classes

Posted 26 November 2011 - 11:13 AM

There are at least 15 different classes and some of the code is copy and pasted, but it has come a LONG way since learning more about classes.

If you are interested in the game I can upload a .exe to Mediafire or something.

View PosttlhIn`toq, on 26 November 2011 - 10:01 AM, said:

View PostPaepay, on 26 November 2011 - 10:22 AM, said:

I have since resolved this issue and my game is over 8000 lines now :)


Are they still all in one file?

The goal generally is not to see how big you can grow the application, but how small. Its like golf; the person with the lowest score wins.

The fact that it has grown from 1400 to 8000 lines in a couple weeks makes me think there is a LOT of code redundancy/duplication. Its easy to grow the program by having a lot of duplicate code via copy/paste the same method(s) amongst several classes like: Player, ogre, goblin and so on.


I add code to this game everyday when possible. I added a few skills and simple 2D animations. Working inventory and shops. A few NPCs for combat as well.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1