I'm trying to make a game called "Nyan Sniper", and whenever I play, this happens
[img]http://gyazo.com/7cc55b3750beb9f589b4bfc41f6c4a70.png[/img]
Help?
[QUOTE=S!nclair;30622837]I'm trying to make a game called "Nyan Sniper", and whenever I play, this happens
[img]http://gyazo.com/7cc55b3750beb9f589b4bfc41f6c4a70.png[/img]
Help?[/QUOTE]
I have to take a shot in the dark here but render the cat first, then then crosshair.
[csharp]
double angle = (float)this.Angle;
double orgX = 0.5;
double orgY = 0.5;
double pointX = this.MovementX;
double pointY = this.MovementY;
double itemX = pointX - orgX;
double itemY = pointY - orgY;
double itemX1 = itemX * Math.Cos(this.Angle) - itemY * Math.Sin(this.Angle);
double itemY1 = itemX * Math.Sin(this.Angle) + itemY * Math.Cos(this.Angle);
this.MovementX = itemX1 + orgX;
this.MovementY = itemY1 + orgY;
[/csharp]
This is the code I use in my game to calculate a new vector to move my units using, they are supposed to turn around a central point. Instead they are turning randomly.
Can anyone explain why this piece of code
[IMG]http://dl.dropbox.com/u/10995123/ProgrammingShit/FuckedUp.png[/IMG]
Gives me this error
[IMG]http://dl.dropbox.com/u/10995123/ProgrammingShit/Error.png[/IMG]
Visual Studio has been really pissing me off lately.
[QUOTE=IndianCurry;30624892]Can anyone explain why this piece of code
[IMG]http://dl.dropbox.com/u/10995123/ProgrammingShit/FuckedUp.png[/IMG]
Gives me this error
[IMG]http://dl.dropbox.com/u/10995123/ProgrammingShit/Error.png[/IMG]
Visual Studio has been really pissing me off lately.[/QUOTE]
Show us Bullet.h as well. Maybe you gave a constructor return type there.
[QUOTE=jrj996;30622767]Do bools ever return true or false in C++? I always get some random ass number whenever I have it print.
Is there any function similiar to 'tostring' or something of that nature?[/QUOTE]
The random number should be 0 for false and 1 for true.
You can output std:boolalpha before outputting the booleans to get the strings "false" and "true" instead.
[QUOTE=Wyzard;30620763]It's possible if you use [url=http://www.opengl.org/wiki/Vertex_Specification#Primitive_Restart]primitive restart[/url] or [url=http://www.gamedev.net/page/resources/_/reference/programming/sweet-snippets/concatenating-triangle-strips-r1871]degenerate triangles[/url], but
and is simpler and more elegant that way.[/QUOTE]
I'm using the geometry shader, so triangle fans are not an option. I guess I could emit two primitives, or use a degenerate triangle instead. Emitting two primitives is probably the simplest way right now.
Edit:
Or I could emit one of the hidden triangles.
[editline]22nd June 2011[/editline]
[QUOTE=IndianCurry;30624892]Can anyone explain why this piece of code
[IMG]http://dl.dropbox.com/u/10995123/ProgrammingShit/FuckedUp.png[/IMG]
Gives me this error
[IMG]http://dl.dropbox.com/u/10995123/ProgrammingShit/Error.png[/IMG]
Visual Studio has been really pissing me off lately.[/QUOTE]
Maybe your header contain a type at the last line.
That "ctor not allowed a return type" error is usually because you forgot the last semicolon on the class definition. Because it's common to define the constructor first, when the header is "pasted into" the implementation file you end up with something like this:
[code]class MyClass{ stuff }
MyClass::MyClass() { blah }[/code]
As there's no semicolon, it's equivalent to:
[code]class MyClass { stuff } MyClass::MyClass { blah }[/code]
Here, the "class MyClass{ stuff }" is acting as a return type on the ctor, something that isn't allowed.
To fix, just put a semicolon on the closing } of you class declaration.
Does anyone know how to use external python libraries?
I want to use OpenCV but I dont know what or where to download
[QUOTE=Richy19;30629596]Does anyone know how to use external python libraries?
I want to use OpenCV but I dont know what or where to download[/QUOTE]
[url]http://opencv.willowgarage.com/wiki/[/url]
-snip-
[QUOTE=foszor;30623742]I have to take a shot in the dark here but render the cat first, then then crosshair.[/QUOTE]
[img]http://gyazo.com/e4bde4b2192c7c35c6194e469f757c01.png[/img]
I :h: you
[QUOTE=slashsnemesis;30630609][url]http://opencv.willowgarage.com/wiki/[/url][/QUOTE]
Yea but what do I do with it?
I installed this [url]http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3/[/url] the win32 exe
and I have python 2.7 and 3.2 but none of the OpenCV samples work
How do I pass a object (A mysql object) to a thread?
Ive got a thread that is being run quite alot of times and so I cant start a connection to the SQL server in each thread...
Anyhelp would be really appreciated
[QUOTE=benjojo;30635043]How do I pass a object (A mysql object) to a thread?
Ive got a thread that is being run quite alot of times and so I cant start a connection to the SQL server in each thread...
Anyhelp would be really appreciated[/QUOTE]
Pass the open mysql object as a pointer, to the thread each time you catch it?
[QUOTE=T3hGamerDK;30635149]Pass the open mysql object as a pointer, to the thread each time you catch it?[/QUOTE]
Could you give me a example?
I cant find anything on doing that with pointers...
You have object.
Pass &object to the thread.
[editline]22nd June 2011[/editline]
And make sure it stays valid.
[QUOTE=esalaka;30636416]You have object.
Pass &object to the thread.
[editline]22nd June 2011[/editline]
And make sure it stays valid.[/QUOTE]
Can I do that with [i]lots[/i] of threads?
EG, give the same object to lots of threads?
Here is some background information on what I am trying to do:
At the begging of the application the application starts a connection to the MYSQL server, then it
boots up the threads, When one of the threads needs to submit information to the database it makes a query, but I don't want the connection to be made inside the threads because there are lots of them.
Yeah you can pass it to lots of threads. I dunno if using it from multiple threads at the same time is a good idea though, so you might want to put it in a critical section or something. Unless the docs say it's threadsafe.
I'm working on a simple system for loading lua files, and to ensure that they haven't been loaded twice, I'm putting the UUID's of each file into some sort of array or something. The latter is a bit loose on what I want, but the UUID thing seems pretty solid. My only concern is this: How do I use the UUID from boost to do something like this?
[code]
boost::uuids::string_generator gen(some_string);
boost::uuid::uuid u(gen);
// TODO: std::cout the variable 'u' somehow.
[/code]
But how do I output the u variable as a string (either std::string or char)?
[editline]22nd June 2011[/editline]
Note, the "some_string" is of type const char*
boost::uuid::uuid probably has a .str(), .c_str(), .string() or other similar method. Read the manual?
[editline]22nd June 2011[/editline]
uuids::uuid*
[editline]22nd June 2011[/editline]
[url]http://www.boost.org/doc/libs/1_42_0/libs/uuid/uuid.html#Input%20and%20Output[/url]
[cpp]std::ostream& operator<<(std::ostream &stream, const boost::uuids::uuid &uuid)
{
for(const auto value : uuid) //C++98: for(boost::uuids::uuid::const_iterator iter = u.begin(); iter != u.end(); ++iter ) and use *iter instead of value
stream << value;
return stream;
}
//std::cout << someUuid; should now work[/cpp]
[editline]22nd June 2011[/editline]
meh
[QUOTE=sim642;30625467]Show us Bullet.h as well. Maybe you gave a constructor return type there.[/QUOTE]
Sorry for wasting your time, I am an idiot. I forgot to put a semi-colon after the ending bracket of the class. I've recently picked up programming again and keep forgetting the little things.
Fun fact: GCC gives a warning about that nowadays
[editline]23rd June 2011[/editline]
Probably picked up from clang but damn it's useful.
So I've been meaning to really bog down and learn c++ for serious now for about a year now and all I've got to show for it is being about 3/4 through learncpp.com
Tutorials are stupid because they're always written by someone very experienced which means what they write makes perfect sense to them so they tend to be vague about things and make stupid analogies.
I'm tired of tutorials because there's no end to it, I wanna start making things and learning by doing.
Is there someone who'd like to add me on steam that I can bother with questions? I'll try not to be annoying, promise.
How would I go about a pathfinding system without it being tilebased in flash as2?
I believe you can use A* for Nodes too, garry did it in the WAYO thread with one of his HTML tests.
Yeah, grids are a special kind of a graph. A* works for all weighed graphs. In a grid almost every node has exactly 4 edges, and edges in a grid are generally thought to be bidirectional.
A* doesn't require this - one node can have as many edges as it needs, and the graph can be directed.
Note that by "edge" I don't mean an edge that separates two tiles. I mean an edge that connects two tiles or nodes; a way between them.
[editline]23rd June 2011[/editline]
And also - in a grid, the weighing is usually thought to be a property of the nodes. If some tile in the grid requires longer to cross, then it's because the tile represents slower terrain. But in waypoint graphs, the weighing is thought to be a property of the edges - the weight is mainly affected by the edge's length, and there can be multiple different edges connecting the two nodes, each with a different weight.
Something's up with my SFML + OpenGL, it was working before, and I don't know what I did to break it but it is.
When the game is initialized:
[code]
void mvContext::Initialized()
{
//set up opengl
rw->SetActive(true);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable( GL_BLEND );
glOrtho(0.0f, static_cast<float>(rw->GetWidth()), static_cast<float>(rw->GetHeight()), 0.0f, -1.0, 1.0f);
...
code
}
[/code]
Every frame draw:
[code]
void mvContext::Draw()
{
State::Draw();
rw->Clear();
rw->SaveGLStates();
{
...
code
}
rw->RestoreGLStates();
//draw particles
for(int i = 0; i < parts.size(); i++)
{
float halfsize = parts[i].Size / 2.0f;
glBegin(GL_QUADS);
glColor4f(parts[i].Color.R, parts[i].Color.G, parts[i].Color.B, parts[i].Color.A);
glVertex2f(parts[i].Position.x - halfsize, parts[i].Position.y - halfsize);
glVertex2f(parts[i].Position.x + halfsize, parts[i].Position.y - halfsize);
glVertex2f(parts[i].Position.x + halfsize, parts[i].Position.y + halfsize);
glVertex2f(parts[i].Position.x - halfsize, parts[i].Position.y + halfsize);
glEnd();
}
rw->SaveGLStates();
{
...
code
}
rw->RestoreGLStates();
rw->Display();
}
[/code]
There are no compile-time errors, everything seems fine. But the glBegin(GL_QUADS); in the Draw will not draw.
It is called with every particle, and every particle seems to be in the correct positions and all.
In the Draw, all of the "... code" is just SFML drawing so it shouldn't be breaking it (It wasn't before).
Any hints as to what the problem is?
before it looked something like this (when it was working)
[quote][img]http://filesmelt.com/dl/idkau21.png[/img][/quote]
now it looks like this
[quote][img]http://filesmelt.com/dl/a49.png[/img][/quote]
I don't really know but quads are deprecated from at least 3.0 onwards - if you're using a newer version of OpenGL, they're not required to work. If it doesn't work with triangles, the problem's something else.
And I'd suggest you to call glBegin and glEnd outside of the for-loop
[editline]23rd June 2011[/editline]
but glbegin and glend are deprecated too from 3.0 onwards, so who cares
Sorry, you need to Log In to post a reply to this thread.