4 Replies - 164 Views - Last Post: 02 July 2012 - 07:17 AM Rate Topic: -----

#1 digitaldevelopment  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 168
  • Joined: 30-April 12

problem with the creation of levels

Posted 02 July 2012 - 03:09 AM

I know this is gonna sound totally like a noob to you guys, but please bear with me as I really am one.
I am making a library for use with some of my games. so far it includes 3 classes:
-level
-character
-attack
well, I think the names speak for themselves, now the problem I have is that I would like to use level as sort of template for all levels. like
level lvl1 = new level();


which works, but when I put it in the program.cs to run it like this,
level lvl1 = new level();
Application.Run(lvl1());


this throws an error:

Error 1 'lvl1' is a 'variable' but is used like a 'method'
does anyone knows what I am doing wrong?

Is This A Good Question/Topic? 0
  • +

Replies To: problem with the creation of levels

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 458
  • View blog
  • Posts: 4,222
  • Joined: 25-March 09

Re: problem with the creation of levels

Posted 02 July 2012 - 03:13 AM

well dont put () at the end of the lvl1 variable:
Application.Run(lvl1());
should be
Application.Run(lvl1);

Also have you thing of Inheritance this way you can use your level as a base class that will hold the basic information about your level. and in the class that Inheritance the level class you can make additional changes.

This post has been edited by raziel_: 02 July 2012 - 03:17 AM

Was This Post Helpful? 2
  • +
  • -

#3 strawhat89  Icon User is offline

  • The Watcher Outside Your Window


Reputation: 247
  • View blog
  • Posts: 1,784
  • Joined: 11-July 11

Re: problem with the creation of levels

Posted 02 July 2012 - 03:19 AM

Read the error. You can only end methods (functions) with the 2 parentheses '()'. So either you just do

 Application.Run(lvl1); 


or you write a method for the level class which you use with the 'lvl1' object like

 lvl1.MyMethod(); 

Was This Post Helpful? 1
  • +
  • -

#4 digitaldevelopment  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 168
  • Joined: 30-April 12

Re: problem with the creation of levels

Posted 02 July 2012 - 03:24 AM

wow really? the '()' did it? --' I have a lot to learn...
thanks a lot :) you were really helpfull :)

View Postraziel_, on 02 July 2012 - 11:13 AM, said:

well dont put () at the end of the lvl1 variable:
Also have you thing of Inheritance this way you can use your level as a base class that will hold the basic information about your level. and in the class that Inheritance the level class you can make additional changes.

thanks! I will learn about this to enchance my codes :) thanks a lot!
Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is offline

  • Closing in on 5,000
  • member icon

Reputation: 4927
  • View blog
  • Posts: 10,465
  • Joined: 02-June 10

Re: problem with the creation of levels

Posted 02 July 2012 - 07:17 AM

Based on your string of recent posts for things you would have learned in the first couple chapters of any "Learn C# in 30 days" book I'm going to repeat this suggestion:

Stop trying to architect a program while you are still learning the basics of C#. It just never works. Its like saying you are going to learn home architecting WHILE you hammer boards together without a blueprint, and try to learn both new skills at the same time.

First learn the language. Do a couple hundred tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.

Then later you can start architecting your own simple stuff. Build a calculator. Build a DVD library program. Etc. Stuff that doesn't involve the complexity of a game.

Then move up to games.



There are three routes people seem to take when learning programming.
  • Just start trying to create programs
  • Start taking apart other programs and try to figure out the language by reverse engineering
  • Follow a guided learning course (school or self-teaching books)


For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.

Quote

Where do I start?


You start by learning a coding language FIRST.
Learn to plan before you type.
THEN you start designing software with a purpose.


If this sounds like you

Newbie/Rookie said:

I have a little programming experience but I need to write ...
read this section
Spoiler


Otherwise, you can just jump to the resources here:
Some of the tutorials below are for C# or Java not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.



Resources, references and suggestions for new programmers. - Updated Mar 2012
Spoiler

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1