If you don't separate them the compiler interprets them as the >> operator.
[cpp]
class map
{
int x, y;
std::vector<std::vector<char> > levelvector( 160, std::vector<char>( 480, 0 ));
public:
void open(std::string levelname);
void draw();
void set_values (int,int);
int area (void);
};[/cpp]
See for your self.
[code]1>c:\users\koen\documents\visual studio 2010\projects\platformer\platformer\main.cpp(26): error C2059: syntax error : 'constant'
1>c:\users\koen\documents\visual studio 2010\projects\platformer\platformer\main.cpp(26): error C2059: syntax error : ')'
1>c:\users\koen\documents\visual studio 2010\projects\platformer\platformer\main.cpp(26): error C2143: syntax error : missing ')' before ';'[/code]
[QUOTE=Z_guy;25315484]If you don't separate them the compiler interprets them as the >> operator.[/QUOTE]
C++0x should fix that : [url]http://en.wikipedia.org/wiki/C%2B%2B0x#Angle_bracket[/url] :D
[QUOTE=ColdFusion;25315531][cpp]
class map
{
int x, y;
std::vector<std::vector<char> > levelvector( 160, std::vector<char>( 480, 0 ));
public:
void open(std::string levelname);
void draw();
void set_values (int,int);
int area (void);
};[/cpp]
See for your self.[/QUOTE]
Initializations are not allowed in that scope. Use an initializer list:
[cpp]
class map
{
int x, y;
std::vector<std::vector<char> > levelvector;
public:
map() : levelvector( 160, std::vector<char>( 480, 0 ))
{
}
void open(std::string levelname);
void draw();
void set_values (int,int);
int area (void);
};[/cpp]
[QUOTE=ColdFusion;25315531][cpp]
class map
{
int x, y;
std::vector<std::vector<char> > levelvector( 160, std::vector<char>( 480, 0 ));
public:
void open(std::string levelname);
void draw();
void set_values (int,int);
int area (void);
};[/cpp]
See for your self.
[code]1>c:\users\koen\documents\visual studio 2010\projects\platformer\platformer\main.cpp(26): error C2059: syntax error : 'constant'
1>c:\users\koen\documents\visual studio 2010\projects\platformer\platformer\main.cpp(26): error C2059: syntax error : ')'
1>c:\users\koen\documents\visual studio 2010\projects\platformer\platformer\main.cpp(26): error C2143: syntax error : missing ')' before ';'[/code][/QUOTE]
Initialize stuff in the constructor.
This would work for variable definitions, but not declarations.
[editline]03:35PM[/editline]
:ninja:
Facepunch is lagging :|
[editline]03:37PM[/editline]
:ninja:
Facepunch is lagging :|
Its stupid how i din't noticed that i was not allowed to that.
Thanks to everybody who tried to help me :)
Hey guys,
I'm practicing Java and I have a question. Basically I'm trying to write a program that accepts input for 5 numbers, then displays the biggest and smallest numbers. I've already created a Scanner and 5 int variables.
Now how would I go about displaying the largest and smallest after the user inputs the numbers? I know I can use a billion if statements to do it but I'm wondering what's the easiest and cleanest way.
-snip-
It double posted for some reason, sorry.
I need help with choosing my first language. I started with Java not a couple of hours ago and I really enjoy it. But I wonder if Java is a good start.
[QUOTE=W00tbeer1;25318073]Hey guys,
I'm practicing Java and I have a question. Basically I'm trying to write a program that accepts input for 5 numbers, then displays the biggest and smallest numbers. I've already created a Scanner and 5 int variables.
Now how would I go about displaying the largest and smallest after the user inputs the numbers? I know I can use a billion if statements to do it but I'm wondering what's the easiest and cleanest way.[/QUOTE]
The cleanest way would be having an int for the biggest, an int for the smallest and one for the input.
The biggest is set to the lowest integer value (Integer.MIN_VALUE or something) and the smallest is set to the biggest integer value.
Then you take input, compare the input to those two and set them if appropriate.
[QUOTE=eXiv2;25318175]I need help with choosing my first language. I started with Java not a couple of hours ago and I really enjoy it. But I wonder if Java is a good start.[/QUOTE]
You've already started with Java, so go with Java.
Any reasonably modern language is a good start, and Java fits the bill.
[QUOTE=jA_cOp;25314176]DLLExp wouldn't be able to read all that information from the exported symbol if extern "C" had really been working there - it'd just be "GetClientInterface". And if it was, GetProcAddress wouldn't return null on you.
First I'd try without stdcall, I think it's possible they get decorated with a minimum amount of parameter info - an "@" follows the function name, followed by the total amount of bytes required for the parameters.
Otherwise, just because it will show you a more descriptive error on failure, try using a .def file instead:
[code]
LIBRARY "YourLibrary"
EXPORTS
GetClientInterface
[/code][/QUOTE]
Odd, the .def file worked
[QUOTE=eXeC64;25315214]Why are you hooking the source engine? At least thats what the interface looks like.[/QUOTE]
I'm not.
What order of translations and rotations would I use to rotate around the origin of a shape, for example: I have a square that is 128 pixels wide and high, it's origin is 54 pixels to the right and down, making the origin at the center of the Square. I now want to rotate the object 45 degrees to the right.
What I have so far:
[cpp]
glTranslatef( Offset.X, Offset.Y, 0 );
glRotatef( (float)Rotation.D, 0, 0, 1 );
glTranslatef( Position.X, Position.Y, 0 );
[/cpp]
Figured it out:
1. Translate by Position.
2. Rotate.
3. Translate by Negative Offset.
So I am trying to pass an object to a constructor by reference in C++. I have a Deck object that I am trying pass to Hand's constructor. Looks kind of like this:
[code]
//passing in int main
Hand hand(deck)
//constuctor
Hand(Deck &cards)
{
shit
}
[/code]
When I go to compile I get the error
[code]/home/ben/codeblocks/BackToTheHood/main.cpp|10|error: no matching function for call to ‘Hand::Hand(Deck (&)())’|[/code]
What is a Deck (&)() I don't even
double post
[QUOTE=redonkulous;25324669]What is a Deck (&)() I don't even[/QUOTE]
It's a reference to a function that takes no parameters and returns a Deck.
I'm guessing you defined your "deck" variable in main() as:
[code]Deck deck();[/code]
That's not creating an instance using its default constructor, it's [i]declaring a function[/i], and then you're trying to pass that function to the Hand constructor. Remove the empty parentheses from the Deck line and it should work.
Okay, my texture mapping isn't working at all for my project. I posted about it before but I got no answer. Every time I bind the texture and plot it's coords to the Quad it only paints a general color from the image, and I don't even think it's the top-left pixel or anything. I really don't understand why this is happening, any help would be greatly appreciated.
I've never used glTexGen before, but from reading through the documentation and comparing it to the code you posted, it looks like you're leaving out the required coefficients.
Try adding something like:
[code]glTexGenfv(GL_S, GL_OBJECT_PLANE, {1.0, 0.0, 0.0, 0.0});
glTexGenfv(GL_T, GL_OBJECT_PLANE, {0.0, 1.0, 0.0, 0.0});
[/code]
[QUOTE=ROBO_DONUT;25325115]I've never used glTexGen before, but from reading through the documentation and comparing it to the code you posted, it looks like you're leaving out the required coefficients.
Try adding something like:
[code]glTexGenfv(GL_S, GL_OBJECT_PLANE, {1.0, 0.0, 0.0, 0.0});
glTexGenfv(GL_T, GL_OBJECT_PLANE, {0.0, 1.0, 0.0, 0.0});
[/code][/QUOTE]
Thanks for replying, I started plotting coords to the object. After shifting through god knows many source codes, it turned out I had to enable and disable GL_TEXTURE_2D before and after plotting the vertexs respectively, but now I can't get the auto generating texture coordinating to work
Hey guys, I'm trying to figure out 3D projection.
What's wrong with this code?
[cpp]
/// <summary>
/// Uses perspective projection to map a point in 3D space to a 2D plane
/// </summary>
/// <param name="A">The point in 3D space that is to be projected.</param>
/// <param name="C">The location of the camera.</param>
/// <param name="Theta">The rotation of the camera.</param>
/// <param name="E">The viewer's position relative to the display surface.</param>
/// <param name="w">Width of the display surface in pixels</param>
/// <param name="h">Height of the display surface in pixels</param>
/// <returns></returns>
PointF MapVertexToScreenPoint(Point3 A, Point3 C, Point3 Theta, Point3 E, int w, int h)
{
var dx = Math.Cos(Theta.X) * (
Math.Sin(Theta.Z) * (A.Y - C.Y) + Math.Cos(Theta.Z) * (A.X - C.X))
- Math.Sin(Theta.Y) * (A.Z - C.Z);
var dy = Math.Sin(Theta.X) * (
Math.Cos(Theta.Y) * (A.Z - C.Z) + Math.Sin(Theta.Y) * (
Math.Sin(Theta.Z) * (A.Y - C.Y) + Math.Cos(Theta.Z) * (A.X - C.X)
)
) + Math.Cos(Theta.X) * (Math.Cos(Theta.Z) * (A.Y - C.Y) - Math.Sin(Theta.Z) * (A.X - C.X));
var dz = Math.Sin(Theta.X) * (
Math.Cos(Theta.Y) * (A.Z - C.Z) + Math.Sin(Theta.Y) * (
Math.Sin(Theta.Z) * (A.Y - C.Y) + Math.Cos(Theta.Z) * (A.X - C.X)
)
) - Math.Cos(Theta.X) * (Math.Cos(Theta.Z) * (A.Y - C.Y) - Math.Sin(Theta.Z) * (A.X - C.X));
return new PointF((float)((dx - E.X) / (E.Z / dz)) * (float)w, (float)((dy - E.Y) / (E.Z / dz)) * (float)h);
}
Point3 triA = new Point3(1,1,1);
Point3 triB = new Point3(-1,-1,-1);
protected override void OnPaint(PaintEventArgs e)
{
var g = e.Graphics;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
var cam = new Point3(0, 0, -4);
var rot = new Point3(0, 0, 0);
var rel_surf = new Point3(0, 0, 4);
var pt1 = MapVertexToScreenPoint(triA, cam, rot, rel_surf, ClientSize.Width, ClientSize.Height);
var pt2 = MapVertexToScreenPoint(triB, cam, rot, rel_surf, ClientSize.Width, ClientSize.Height);
g.DrawLine(Pens.Black, pt1, pt2);
}
[/cpp]
I got the formulae in MapVertexToScreenPoint() from [url=http://en.wikipedia.org/wiki/3D_projection#Perspective_projection]this Wikipedia page[/url]:
[img]http://upload.wikimedia.org/math/1/c/8/1c89722619b756d05adb4ea38ee6f62b.png[/img]
That looks terribly convoluted.
I'd write some proper matrix/quaternion math routines and break things into parts instead of doing it all at once. The [url=http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml]OpenGL glFrustum page[/url] lists the formula that OGL uses for view frustum matrixes. All you need to do is multiply the coordinates by this frustum matrix (plus any translation/rotation matrixes) and do perspective division (divide the x-, y-, and z-components by the w-component).
[forums broke]
[QUOTE=ROBO_DONUT;25326541]That looks terribly convoluted.
I'd write some proper matrix/quaternion math routines and break things into parts instead of doing it all at once. The [url=http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml]OpenGL glFrustum page[/url] lists the formula that OGL uses for view frustum matrixes. All you need to do is multiply the coordinates by this frustum matrix (plus any translation/rotation matrixes) and do perspective division (divide the x-, y-, and z-components by the w-component).[/QUOTE]
I'm doing it this way because once I get it working, I'm going to port it to assembly and turn it into a bootloader.
I'll look into using matrices, there's no reason I couldn't use them I suppose.
[QUOTE=turb_;25326582]I'm doing it this way because once I get it working, I'm going to port it to assembly and turn it into a bootloader.[/QUOTE]
WAIT- WHAT. :science:
Also, if you're not writing a serious next-gen 3D game, I'm sure you could take some shortcuts. Like just divide your x and y coords by their depth.
Is there a way to make some static function accessible from outside the games assembly by another assembly without making that class and all the other classes that have their instances in that class public?
How can I, I don't know, say that some specific assembly is "friendly" and can access everything I can from the games assembly?
You can use the InternalsVisibleTo attribute, but I think that if you're having this issue, you have serious encapsulation problems that should be addressed rather than applying a band-aid patch.
[cpp]myType.GetMethod("myStaticPrivateFunction", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly);[/cpp]
No need for a friend-declaration.
[cpp]myType.GetMethod("myStaticPrivateFunction", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly);[/cpp]
No need for a friend-declaration.
[editline]02:02PM[/editline]
automerge? :S
[editline]02:02PM[/editline]
automerge? :S
I need help with [url=http://pastebin.com/7f11dg8q]this[/URL] code. The issue is that the application won't close when I press ^C. The loop stops and a new tab comes up in Visual Studio like [url=http://data.fuskbugg.se/skogsturken/-bug.png]this[/url]. And yes, this is C#.
[cpp]using System;
using System.Text;
using System.Threading;
class Program
{
static bool quit = false;
static void Main(string[] args)
{
Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);
Console.CursorVisible = false;
MainLoop();
}
static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
{
Console.WriteLine("{0} hit, qutting...", e.SpecialKey);
quit = true;
}
static void MainLoop()
{
const int INTERVAL = 500;
Console.WriteLine("Welcome to minidunge0n! You can press CTRL+C to quit the game at any time.");
while (quit != true)
{
Console.WriteLine("test");
Thread.Sleep(INTERVAL);
}
}
}[/cpp]
Sorry, you need to Log In to post a reply to this thread.