Edit: A few things I noticed about Head First C#:
I just looked at a few code samples.
I'm surprised it starts out with GUI programs from the beginning. In my opinion it's easier to use a console application for the basics because the control flow (the way the different parts of code interact) is much simpler. It's also much easier to debug and retry.
That's just my opinion though, go ahead with the book if it works for you.
There's a small thing you shouldn't do however: In the code from the website many controls seem to be named button1 and so on. That's horrible style because it's impossible to know what the button does without looking into the method.
The book also doesn't seem to teach WPF, a much nicer but unfortunately not cross-platform alternative to Windows Forms.
If there's no explanation of the console you also really need to learn that. It's very easy compared to a GUI though.
[QUOTE=PredGD;40846033]Why is C++ more widely used than C# by the way? If C# is "easier" to use, then why would people move over to a harder language when a person can accomplish the same things with a easier language?[/QUOTE]
Because existing code costs time to rewrite with no visible changes. It's the equivalent of your company going 'we're going to release nothing for the next year'
[QUOTE=PredGD;40840009]Oh wow, I never saw that the line had been put into the code, I thought he told me to add it somewhere but didn't say where. :v:
Thanks.
[editline]Wut[/editline]
[/IMG]
How can I solve this?[/QUOTE]
I did not actually do that part of the book (we skipped some stuff for our class), but it appears that it might work if you put
[code]
this.Upgrade();
[/code]
Just above the line that errors.
Also if that doesn't work you can go ahead and skip this, the book doesn't do an awful lot with databases anyway. And when you do reach that part I'll provide you with a Database class file that can connect to a local database without problems :v:
[editline]31st May 2013[/editline]
[QUOTE=Tamschi;40846394]
If there's no explanation of the console you also really need to learn that. It's very easy compared to a GUI though.[/QUOTE]
I know the book does teach you this though, it's further down the line for some reason.
And fortunately it does tell you to change control names.
[QUOTE=MakeR;40825356]You are wrong about not using the this pointer resulting in accessing uninitialized objects/memory. My post wasn't directed at quincy18 and thus wasn't intended to help him, I was just pointing out to you and others who may be reading that what you said is, in fact, incorrect.
[editline]29th May 2013[/editline]
We don't want people doing things that are unnecessary because of something that isn't correct.
[editline]29th May 2013[/editline]
The dumb rating was because of the "bitchy" response.[/QUOTE]
While I find it cool that it works with "this->" why do I need it ? I really never ever had to use it before.
Working in Unity right now, coding in UnityScript. I need help making this simple 2D spring code work. So far I made one that works for one object, but if I attach the script to multiple objects, it breaks down and they all start flying to the left. Help, please!
[CODE]#pragma strict
var targets : GameObject[];
var SpringConstant : float;
var SpringDamping : float;
var SpringLength : float;
var totalVelocity : Vector3
function Update () {
totalVelocity = Vector3.zero;
for (var target : GameObject in targets){
F_SpringX = SpringConstant * (target.transform.position.x-transform.position.x)-SpringLength
F_DamperX = SpringDamping * (rigidbody.velocity.x-target.rigidbody.velocity.x);
F_SpringY = SpringConstant * (target.transform.position.y-transform.position.y)-SpringLength
F_DamperY = SpringDamping * (rigidbody.velocity.y-target.rigidbody.velocity.y);
totalVelocity += Vector3((F_SpringX+F_DamperX)/rigidbody.mass,(F_SpringY+F_DamperY)/rigidbody.mass,0);
Debug.DrawLine(pransform.position,target.transform.position,Color.cyan);
}
rigidbody.AddForce(totalVelocity*Time.deltaTime);
}
[/CODE]
Just attach it to some spheres or something, make sure they've got rigidbodies, and give them something to fall on. Best to freeze they Z positions, too.
Screw it, this code is crap. Could someone point me at a super easy to follow way to handle spring physics between multiple nodes in either 2d or 3d, preferably in JavaScript or UnityScript?
god dammit fuck segmentation faults i hate this world and everyone in it why god why asdfjkl;.
[QUOTE=Shotgunz;40863245]god dammit fuck segmentation faults i hate this world and everyone in it why god why asdfjkl;.[/QUOTE]
debugger
I have a cylinder tube mesh with a repeating texture going along it. I'm using the current distance along the tube to tile the texture along the tube. The problem with that is that for a really long tube, the texture coord ends up being a really high value which causes the texture to distort slightly. I don't see a way to wrap the values around so the values never end up reaching high values.
Does anyone know an IDE for javascript which will show errors, like visual studio? It's so hard having bits just not work and having to dig the error out myself.
-snip-
[QUOTE=layla;40864871]I have a cylinder tube mesh with a repeating texture going along it. I'm using the current distance along the tube to tile the texture along the tube. The problem with that is that for a really long tube, the texture coord ends up being a really high value which causes the texture to distort slightly. I don't see a way to wrap the values around so the values never end up reaching high values.[/QUOTE]
[code]glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );[/code]
You don't have to set the texcoords high up.
I was wondering if the only point in wrapping a c++ pointer to be used as a random access iterator is for extra type safety or something else i'm missing?
Where do I find the Slick game engine for java?
How I can achieve this alternating edge thingy for my mesh generation. So far it looks like the left square of the image below, but I want it to look like the other one on the right side.
[IMG]http://imgur.com/mz170Ob.png[/IMG]
[editline]2nd June 2013[/editline]
Nevermind, I already found a solution.
[code]
void Planet::build()
{
int buildinginput=-1;
std::cout << "Building menu initiated on planet " << name << "." << std::endl;
DisplayBuildings();
for(int ii=0; ii < MaxBuildingSelection; ii++)
std::cout << "To build " << BLDGID(ii) << ", " << "please type in \"" << ii << "\"." << std::endl;
std::cout << "To exit the building menu, please type in 0." << std::endl;
while(buildinginput!=0)
{
std::cin >> buildinginput;
if (buildinginput>9000)
{
DisplayBuildings();
for(int iii=0; iii < MaxBuildingSelection; iii++)
std::cout << "To build " << BLDGID(iii) << ", " << "please type in \"" << iii << "\"." << std::endl;
}
else if (buildinginput>0&&buildinginput<MaxBuildingSelection)
{
if (building[buildinginput]!=NONE)
{
BuildingBuilt(buildinginput);
}
else
{
BuildTimerStruct* tempBLDGTIMER = new BuildTimerStruct;
tempBLDGTIMER->TotalTime=(BLDGTIME(buildinginput));
tempBLDGTIMER->timelefttimer=&timeleft;
tempBLDGTIMER->buildingid=buildinginput;
std::thread foo(&Planet::BuildingTimer, *tempBLDGTIMER);
foo.detach();
buildinginput=0;
break; //to skip the rest of the junk
}
}
else
std::cout <<"No building or invalid number selected, ";
std::cout << "please enter a meaningful number to build or 0 to exit building menu." << std::endl;
std::cout << "To display building menu, type a number over 9000." << std::endl;
buildinginput=-1;
}
}
[/code]
std::thread does not like functions taking in more than 1 argument, so I made a class (so I can use "delete this;") to pass on arguments. A few things need to be pointers to allow the separate thread/function to change variables as it works.
Code for "Planet" class:
[code] class Planet
{
public:
Planet();
~Planet();
void build();
void DisplayStats();
int PlanetID;
static int globalplanets;
void BuildingBuilt(int buildingtype);
void DisplayBuildings();
void Planet::BuildingTimer (BuildTimerStruct);
void Planet::TimeUntilCompleteion(const int , const std::string );
private:
std::string name;
buildingstatus *building;
int timeleft;
friend class GameSystem;
};
[/code]
Code for the struct like class:
[code]
class BuildTimerStruct
{
public:
int TotalTime;
int* timelefttimer;
int buildingid;
BuildTimerStruct();
~BuildTimerStruct();
};
BuildTimerStruct::~BuildTimerStruct()
{
delete this;
}
[/code]
Code for the timer that std::thread is trying to work with:
[code]
void Planet::BuildingTimer (BuildTimerStruct Specials)
{
this->building[Specials.buildingid]=BUILDING;
this->timeleft=Specials.TotalTime;
int InitialTime=clock();
while(Specials.timelefttimer>0)
{
this->timeleft=this->timeleft-(clock()-InitialTime)/CLOCKS_PER_SEC;
}
this->building[Specials.buildingid]=BUILT;
if (DebugMode==true)
std::cout << BLDGID(Specials.buildingid) <<" has been built on " << name << "." <<std::endl;
}
[/code]
When I try to compile this program, it gives me this error:
[quote]Error 1 error C2064: term does not evaluate to a function taking 1 arguments c:\program files (x86)\microsoft visual studio 11.0\vc\include\functional 1152 1 [/quote]
which is this:
[code]_VARIADIC_EXPAND_0X(_CLASS_BIND, , , , )[/code]
I'm clueless. (This is my second C++ program FYI)
Any help?
Afaik MSVC is a bit behind on implementing C++11. std::thread actually does support passing on a couple of arguments.
You shouldn't do delete this;. Use a std::unique_ptr.
I also see you're using buildingstatus *building as an array - anything wrong with std::vector?
You could perhaps try GCC (or Clang if it works on Windows yet).
[editline]2nd June 2013[/editline]
Actually is seems that this unhelpful error-message is due to BuildingTimer being a member function and you not providing enough/the correct arguments - you need to pass this along (which is a hidden/implicit function parameter for member-functions).
I am compiling LLVM (Well actually I am compiling Rust but part of the compilation of that is compiling LLVM) and this one file has taken about 2 -3 hours and I don't know if it is doing anything or not, should I cancel and start the compilation over?
[img]http://puu.sh/36RwK.png[/img]
[QUOTE=ZeekyHBomb;40874413]Afaik MSVC is a bit behind on implementing C++11. std::thread actually does support passing on a couple of arguments.
You shouldn't do delete this;. Use a std::unique_ptr.
I also see you're using buildingstatus *building as an array - anything wrong with std::vector?
You could perhaps try GCC (or Clang if it works on Windows yet).
[editline]2nd June 2013[/editline]
Actually is seems that this unhelpful error-message is due to BuildingTimer being a member function and you not providing enough/the correct arguments - you need to pass this along (which is a hidden/implicit function parameter for member-functions).[/QUOTE]
The "this" pointer fixed it.
Replaced the "delete this" with a class that's allocated then given to the unique_ptr.
I've gotten rid of all the vectors in my code now due to it's immense want to free/delete all the memory I allocated. Unfortunately, this brings me back to good old pointer issues.
[code] Planet* GameSystemDirectory= new Planet[NumPlanets]; [/code]
Looks harmless ya?
Class definition of planet:
[code]
class Planet
{
public:
Planet();
~Planet();
void build();
void DisplayStats();
int PlanetID;
static int globalplanets;
void BuildingBuilt(int buildingtype);
void DisplayBuildings();
void Planet::BuildingTimer (BuildTimerStruct);
void Planet::TimeUntilCompleteion(const int , const std::string );
std::string name;
private:
buildingstatus *building;
int timeleft;
friend class GameSystem;
};
Planet::Planet()
{
building = new buildingstatus[MaxBuildingSelection];
timeleft = 0;
PlanetID = PlanetIDGenerator.requestID();
std::cout << "Please enter the name of the planet" << std::endl;
if (TestMode || LazyMode)
{
name = "AUTONAME " + std::to_string (PlanetID);
std::cout << "ID: " << PlanetID << std::endl;
}
else
std::cin >> name;
if (DebugMode==true)
std::cout << "name set: " << name << std::endl;
globalplanets++;
}
GameSystem::~GameSystem()
{
SystemIDGenerator.removeID(SystemIDnum);
totalsystems--;
delete GameSystemDirectory;
}
[/code]
But, when I get here from a different function call, the entire GameSystemDirectory is inaccessible. Gives me an error when I try to dereference it.
[code]Planet* GameSystem::PlanetSelect()
{
int SelectorInput=0;
std::cout << "Please select one of the following planets:" << std::endl;
if(DebugMode==true)
for(int ii=0;ii<NumPlanets;ii++)
{
std::cout << "Planet ID: ";
std::cout << this->GameSystemDirectory[ii].PlanetID;
std::cout << std::endl << ii << ": ";
std::cout << this->GameSystemDirectory[ii].name;
}
else
for(int ii=0;ii<GameSystem::totalsystems;ii++)
{
std::cout << ii << ": ";
std::cout << GameSystemDirectory[ii].name << std::endl;
}
std::cout << "Planet " << GameSystemDirectory[SelectorInput].name << " selected." << std::endl;
return &(GameSystemDirectory[SelectorInput]);
}[/code]
Any ideas why GameSystemDirectory would decide to undo itself?
I'm making a simple web server in Python but I'm stuck.
I've found out how to write data to the document using "wfile.write()"
How do I change something after I write it?
[QUOTE=cody8295;40881050]I'm making a simple web server in Python but I'm stuck.
I've found out how to write data to the document using "wfile.write()"
How do I change something after I write it?[/QUOTE]
You mean to the "file" that is sent to the client? You don't.
[QUOTE=Tamschi;40881273]You mean to the "file" that is sent to the client? You don't.[/QUOTE]
Soo, dynamic webpages with python are impossible?
[QUOTE=cody8295;40881329]Soo, dynamic webpages with python are impossible?[/QUOTE]
No, you're just supposed to decide what you send [I]before[/I] you send it.
[QUOTE=Tamschi;40881564]No, you're just supposed to decide what you send [I]before[/I] you send it.[/QUOTE]
Yeah but I need that content to be constantly changing... Without refreshing the page.
[QUOTE=cody8295;40881637]Yeah but I need that content to be constantly changing... Without refreshing the page.[/QUOTE]
You use Javascript for this.
[QUOTE=esalaka;40881672]You use Javascript for this.[/QUOTE]
Oh, I was trying to make it entirely Python/HTML, but alright.
[QUOTE=cody8295;40881697]Oh, I was trying to make it entirely Python/HTML, but alright.[/QUOTE]
As long as you generate HTML only on the server, it's essentially static content.
I need help deciding a language to learn. Any language that is easy to learn with lots of information about it? Not interested in web development languages like HTML.
How should I learn that language? Youtube videos? Reading a book?
Say I have a bunch of objects deriving from an Entity class.
Can I add these to a single list and call a method on each instead of a list for each type?
I know this is possible.
[code]
IList<Entity> List = new List<Entity>;
List.Add(new PlayerEntity);//These all derive from Entity.
List.Add(new BoxEntity);
List.Add(new GroundEntity);
foreach(Entity ent in List)
{
ent.Draw();
}
[/code]
But say I override the draw method in PlayerEntity, it will still use the base Draw method here. Not to mention everything else that is removed from PlayerEntity.
I have a feeling that it isn't possible but I though I might as well ask.
You need to declare Draw() virtual in the base Entity class.
Assuming C++,
[cpp]// In Entity
public:
virtual void Draw() { } // For a virtual function which does nothing
virtual void Draw() = 0; // For an abstract method, which has to be implemented[/cpp]
[cpp]// In PlayerEntity
public:
void Draw() { } // Once virtual, always virtual. The keyword is optional.[/cpp]
[editline]3rd June 2013[/editline]
Just noticed the foreach so it's probably not C++.
Sorry, you need to Log In to post a reply to this thread.