I use VB 2010.
C# Programming in multiple tabs using classes
Page 1 of 112 Replies - 1372 Views - Last Post: 26 November 2011 - 11:13 AM
#1
C# Programming in multiple tabs using classes
Posted 19 November 2011 - 12:10 PM
I use VB 2010.
Replies To: C# Programming in multiple tabs using classes
#2
Re: C# Programming in multiple tabs using classes
Posted 19 November 2011 - 12:32 PM
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.
#3
Re: C# Programming in multiple tabs using classes
Posted 19 November 2011 - 12:47 PM
#4
Re: C# Programming in multiple tabs using classes
Posted 19 November 2011 - 01:06 PM
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.
#5
Re: C# Programming in multiple tabs using classes
Posted 19 November 2011 - 02:15 PM
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.
#6
Re: C# Programming in multiple tabs using classes
Posted 19 November 2011 - 02:43 PM
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 :)
#7
Re: C# Programming in multiple tabs using classes
Posted 19 November 2011 - 02:50 PM
#8
Re: C# Programming in multiple tabs using classes
Posted 20 November 2011 - 01:42 PM
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 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
- 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
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
#9
Re: C# Programming in multiple tabs using classes
Posted 20 November 2011 - 02:04 PM
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
#10
Re: C# Programming in multiple tabs using classes
Posted 26 November 2011 - 09:22 AM
#11
Re: C# Programming in multiple tabs using classes
Posted 26 November 2011 - 09:38 AM
#12
Re: C# Programming in multiple tabs using classes
Posted 26 November 2011 - 10:01 AM
Paepay, on 26 November 2011 - 10:22 AM, said:
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.
#13
Re: C# Programming in multiple tabs using classes
Posted 26 November 2011 - 11:13 AM
If you are interested in the game I can upload a .exe to Mediafire or something.
tlhIn`toq, on 26 November 2011 - 10:01 AM, said:
Paepay, on 26 November 2011 - 10:22 AM, said:
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.
|
|

New Topic/Question
Reply



MultiQuote





|