• What do you need help with? Version 1
    5,001 replies, posted
Ok, so let's say that I'm making a game. This game uses a Screen object based state machine. The idea is: Screen - Contains a container full of game components such as a player object, some enemy objects and so on. Has a BlocksUpdate and BlocksDraw property ScreenManager - Has a stack/list of screens that are used as states. When the each frame, the manager calls Update on every screen (going backwards through the stack/list) until one is found where BlocksUpdate is set to true. Same idea with drawing Now, here's the issue. ScreenManager must obviously know about Screen so that it can have a stack/list of them. But Screen must also know about ScreenManager so it can push new screens onto the stack (for example the game screen might need to push a "Game Over" screen onto the stack. How would I let each object know about the other without having circular inclusions in C++? Sorry if this is worded badly, I can't think straight today
[QUOTE=Chris220;24637647]Ok, so let's say that I'm making a game. This game uses a Screen object based state machine. The idea is: Screen - Contains a container full of game components such as a player object, some enemy objects and so on. Has a BlocksUpdate and BlocksDraw property ScreenManager - Has a stack/list of screens that are used as states. When the each frame, the manager calls Update on every screen (going backwards through the stack/list) until one is found where BlocksUpdate is set to true. Same idea with drawing Now, here's the issue. ScreenManager must obviously know about Screen so that it can have a stack/list of them. But Screen must also know about ScreenManager so it can push new screens onto the stack (for example the game screen might need to push a "Game Over" screen onto the stack. How would I let each object know about the other without having circular inclusions in C++? Sorry if this is worded badly, I can't think straight today[/QUOTE] Answer: use only references or pointers to the other class in either of these two, and just forward-declare the class. Done like this, there won't be a circular dependency in the headers, and the source files can just include every header they need without any fear of such a thing happening.
Sounds like it should work, thank you muchly
[QUOTE=noctune9;24636201]The amount of platforms isn't what is really important, the amount of supported computers is and mono supports the huge majority of them.[/QUOTE] C# support is lesser than C++ support, so by your definition, C++ would be better in that regard.
[QUOTE=gparent;24640789]C# support is lesser than C++ support, so by your definition, C++ would be better in that regard.[/QUOTE] Why can't we have gold stars and zings any more :frown:
[QUOTE=esalaka;24640804]Why can't we have gold stars and zings any more :frown:[/QUOTE] The point wasn't to 'zing' him, so agree is just as appropriate.
[QUOTE=gparent;24640789]C# support is lesser than C++ support, so by your definition, C++ would be better in that regard.[/QUOTE] I never said C++ had worse support. I said that the amount of computers not supporting mono and supporting C++ is negligible in most cases. Unless you're doing something low-level of course.
I'm making a pong game and I want some advice. I have 2 different solutions for making the ball move: 1. Make a relative movement vector and each step move the ball accordingly. To bounce just negate movement for that axis. 2. Using angles with trig to make the ball bounce. Even though 1. is much easier, the ball has only 4 directions to move in and the game won't be so dynamic. The 2. option is much more flexible and allows the ball move at any angle, but it requires some maths. I haven't learned trig at school so 2. option might be a little hard. I know how to use sin and cos to move something some amount at some angle though.
[QUOTE=sim642;24644151]I'm making a pong game and I want some advice. I have 2 different solutions for making the ball move: 1. Make a relative movement vector and each step move the ball accordingly. To bounce just negate movement for that axis. 2. Using angles with trig to make the ball bounce. Even though 1. is much easier, the ball has only 4 directions to move in and the game won't be so dynamic. The 2. option is much more flexible and allows the ball move at any angle, but it requires some maths. I haven't learned trig at school so 2. option might be a little hard. I know how to use sin and cos to move something some amount at some angle though.[/QUOTE] Vectors definitely, but you seem to have misunderstood something: A vector can be in any direction too.
[QUOTE=noctune9;24644262]Vectors definitely, but you seem to have misunderstood something: A vector can be in any direction too.[/QUOTE] This. However, saying "vector" is a little vague. A vector can be represented in both rectangular coordinates like <2.5, -4.0> or polar coordinates (magnitude and angle) like 10.0&#8736;45°. Use rectangular coords because they are faster in your main movement loop. Trig functions are very expensive. [editline]07:12PM[/editline] Ignore what I said before, after googling a bit it seems that "vector" exclusively refers to values in the <x, y> (or however many dimensions) Euclidean space.
I seem to remember Beat Hazard was made in C# and XNA and i wanted to know if anyone has found any tutorials about how to use songs in games (or programs for that matter)
[QUOTE=Richy19;24647265]I seem to remember Beat Hazard was made in C# and XNA and i wanted to know if anyone has found any tutorials about how to use songs in games (or programs for that matter)[/QUOTE] If I remember correctly, there was a article posted earlier but it was pretty heavy on math.
[QUOTE=sim642;24644151]I'm making a pong game and I want some advice. I have 2 different solutions for making the ball move: 1. Make a relative movement vector and each step move the ball accordingly. To bounce just negate movement for that axis. 2. Using angles with trig to make the ball bounce. Even though 1. is much easier, the ball has only 4 directions to move in and the game won't be so dynamic. The 2. option is much more flexible and allows the ball move at any angle, but it requires some maths. I haven't learned trig at school so 2. option might be a little hard. I know how to use sin and cos to move something some amount at some angle though.[/QUOTE] Use 1 but to make the game more dynamic. Work like this Xball = Xball + Xacc * deltaframetime Yball = Yball + Yacc * deltaframetime Yacc = Yacc + ( Ypaddel - Yball) [img]http://img441.imageshack.us/img441/8691/ss20100906221848r.png[/img]
[QUOTE=noctune9;24647752]If I remember correctly, there was a article posted earlier but it was pretty heavy on math.[/QUOTE] Dont suppose you remember more or less where it was posted? :P
[QUOTE=Richy19;24648447]Dont suppose you remember more or less where it was posted? :P[/QUOTE] [url=http://www.gamedev.net/reference/programming/features/beatdetection/]It's this article I think[/url].
Anyone have any ideas as to what I should move onto after reading the book "Beginning C++ through Game Programming" and completing it's tasks?
[QUOTE='[ApS] Elf;24661382']Anyone have any ideas as to what I should move onto after reading the book "Beginning C++ through Game Programming" and completing it's tasks?[/QUOTE] Look into SFML or one of those libraries
Anyone know how 3d mesh files (no specific format) that aren't plain text are generally stored? My teacher suggested matrices but I just don't get it yet. New person here. :buddy:
[QUOTE=DOG-GY;24664795]Anyone know how 3d mesh files (no specific format) that aren't plain text are generally stored? My teacher suggested matrices but I just don't get it yet. New person here. :buddy:[/QUOTE] You have a lump full of vertex information (position, color, normal, texcoord), then lists of vertex indexes which are usually rendered as triangle strips. If there's skeletal animation data, then each vertex also has information on what bones it's attached to and weighting information for each. Bones will be arranged in some sort of hierarchy and contain an offset from the parent bone and orientations stored as quaternions (effectively a 4D vector ai + bj + ck + d, where i, j, and k are the imaginary units, which forms a double cover of every possible rotation), but matrices are also possible (though unlikely). Quaternions are more popular because they require fewer values to represent a rotation (four for quats as opposed to the nine or sixteen for matrices) and they greatly simplify operations like spherical linear interpolation. Multiplying quaternions is generally faster than multiplying matrixces, as well. There will also be a lump of texture paths somewhere in the file.
in XNA is it possible to rotate an image by 90 degrees when drawing it? The only SpriteEffects are Flip Horizontally and vertically but i want to rotate it by 90 degrees? Is it possible or will i just have to rotate the image in GIMP ?
[QUOTE=Richy19;24665426]in XNA is it possible to rotate an image by 90 degrees when drawing it? The only SpriteEffects are Flip Horizontally and vertically but i want to rotate it by 90 degrees? Is it possible or will i just have to rotate the image in GIMP ?[/QUOTE] There are 7 overloads of SpriteBatch.Draw(), 3 of which allow you to pass in a rotation argument: [code] SpriteBatch.Draw (Texture2D, Rectangle, Nullable<Rectangle>, Color, Single, Vector2, SpriteEffects, Single) SpriteBatch.Draw (Texture2D, Vector2, Nullable<Rectangle>, Color, Single, Vector2, Single, SpriteEffects, Single) SpriteBatch.Draw (Texture2D, Vector2, Nullable<Rectangle>, Color, Single, Vector2, Vector2, SpriteEffects, Single) [/code] If you scroll through the options with intellisense, you'll find them. A 90 degree clockwise rotation would be MathHelper.PiOver2, a counterclockwise rotation would be -MathHelper.PiOver2.
[QUOTE=ROBO_DONUT;24665205](effectively a 4D vector ai + bj + ck + d, where i, j, and k are the imaginary units, which forms a double cover of every possible rotation)[/QUOTE] I thought i, j and k were the unit vectors in three dimensions?
[QUOTE=esalaka;24667096]I thought i, j and k were the unit vectors in three dimensions?[/QUOTE] As far as I understand, they're unit vectors in three dimensions [i]and[/i] they're imaginary. That's where all the weird mathematical properties come from.
[QUOTE=NovembrDobby;24666842]There are 7 overloads of SpriteBatch.Draw(), 3 of which allow you to pass in a rotation argument: [code] SpriteBatch.Draw (Texture2D, Rectangle, Nullable<Rectangle>, Color, Single, Vector2, SpriteEffects, Single) SpriteBatch.Draw (Texture2D, Vector2, Nullable<Rectangle>, Color, Single, Vector2, Single, SpriteEffects, Single) SpriteBatch.Draw (Texture2D, Vector2, Nullable<Rectangle>, Color, Single, Vector2, Vector2, SpriteEffects, Single) [/code] If you scroll through the options with intellisense, you'll find them. A 90 degree clockwise rotation would be MathHelper.PiOver2, a counterclockwise rotation would be -MathHelper.PiOver2.[/QUOTE] Im doing that to rotate it with left and right but it didnt work anyway i just did it the easy way and rotated the picture its self
Can someone please explain to me just what the hell resources are and how they work in C++? I'm learning windows programming and I want to add a standard menu to the top of my blank window, but the only way to add it is using resources. I want to code the resources myself by the way, not use a resource editor.
[QUOTE=ScreenNamesSuck;24672079]what the hell resources are and how they work in C++?[/QUOTE] I can't answer your question, but I'd like to point out that "resources" are not a part of the C++ language (not that I'm aware of, at least). It sounds like WinAPI tomfoolery.
[QUOTE=ROBO_DONUT;24672153]I can't answer your question, but I'd like to point out that "resources" are not a part of the C++ language (not that I'm aware of, at least). It sounds like WinAPI tomfoolery.[/QUOTE] That's what I thought, they're written in some weird way that has nothing to do with C++. But apparently many WinAPI features use them so I'm kind of stuck.
[QUOTE=ROBO_DONUT;24665205]You have a lump full of vertex information (position, color, normal, texcoord), then lists of vertex indexes which are usually rendered as triangle strips. If there's skeletal animation data, then each vertex also has information on what bones it's attached to and weighting information for each. Bones will be arranged in some sort of hierarchy and contain an offset from the parent bone and orientations stored as quaternions (effectively a 4D vector ai + bj + ck + d, where i, j, and k are the imaginary units, which forms a double cover of every possible rotation), but matrices are also possible (though unlikely). Quaternions are more popular because they require fewer values to represent a rotation (four for quats as opposed to the nine or sixteen for matrices) and they greatly simplify operations like spherical linear interpolation. Multiplying quaternions is generally faster than multiplying matrixces, as well. There will also be a lump of texture paths somewhere in the file.[/QUOTE] Holy shit! Thanks! Funny that I never even considered normals, colour, and all that other information. I feel really stupid since I do 3d erryday.
I need help with an odd problem concerning virtual functions. I am trying to implement a factory system in my rough game framework. I've already gotten a list of Entity pointers that called proper virtual Think() functions from the derived class, but for some a similar system for the factory (calling a method called Create()) always calls the base function. They are pointers, and I've used a identical way to call Think in the update function. What could be wrong? Do you need code or is my description sufficient?
A resource file is something that ends in ".rc" and basically lists the type and filename of a resource (such as an icon) here's a small example if you want a custom icon [code] 1 ICON icon.ico [/code] You then number and name the path (relative to the RC file!) of each resource you would like embedded in your app or library. Add it to your visual studio project and it'll handle it for you (If you are using mingw, you'll need to run a tool called "windres" and output it to an object file, then link it in with the rest of your application)
Sorry, you need to Log In to post a reply to this thread.