I would like to make my c++ projects more organized, so I decided to seperate them into individual files.
I looked on google how I would do this, and found some answers.
They want me to include the file into my main.cpp, which is all good, but then they go ahead and tell me I should declare a prototype of my function in main.cpp. I thought the point of splitting your project was to not have the main.cpp cluttered with all the declarations.
Isn't there any way in which I can just have all my functions in seperate files and use them in main.cpp without declaring them anywhere.
You declare classes and function prototypes in header files, and #include them in the source files that need them.
So foo.hpp would declare the classes and functions that are implemented in foo.cpp, and main.cpp would #include "foo.hpp" to get access to them.
I tried implementing AngelScript in my engine, as an alternative to lua, but I'm getting the following error
[code]
main.cpp:28:97: error: expected ‘;’ before ‘msg’
[/code]
[url=http://openpaste.org/73794b3D]source file[/url]
[editline]28th June 2011[/editline]
Yes, I did change USE_AS_NAMESPACE to AS_USE_NAMESPACE
[QUOTE=xxxkiller;30761554]I would like to make my c++ projects more organized, so I decided to seperate them into individual files.
I looked on google how I would do this, and found some answers.
They want me to include the file into my main.cpp, which is all good, but then they go ahead and tell me I should declare a prototype of my function in main.cpp. I thought the point of splitting your project was to not have the main.cpp cluttered with all the declarations.
Isn't there any way in which I can just have all my functions in seperate files and use them in main.cpp without declaring them anywhere.[/QUOTE]
You prototype in headers and then include the headers in main.cpp
[editline]28th June 2011[/editline]
I'm always late because of all these tabs :saddowns:
Ahh, ok. I guess I just misread .cpp and .hpp. As long as all this stuff is not cluttering my main.cpp file i'm happy, thanks.
Anyone know if its possible to install stuff onto VS2010 without having to reinstall it all?
I dodnt install some features when i first installed VS as i didnt think i would need them but now I do
I'm trying to create 1D value noise with [url=http://freespace.virgin.net/hugo.elias/models/m_perlin.htm]this[/url] tutorial but I don't get 1 part.
[code]
function Noise(integer x)
x = (x<<13) ^ x;
return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 7fffffff) / 1073741824.0);
end function
function SmoothedNoise_1(float x)
return Noise(x)/2 + Noise(x-1)/4 + Noise(x+1)/4
end function
[/code]
Why SmoothedNoise_1 method is calling Noise method with float values when Noise only accepts integers?
[QUOTE=Frugle;30764727]I'm trying to create 1D value noise with [url=http://freespace.virgin.net/hugo.elias/models/m_perlin.htm]this[/url] tutorial but I don't get 1 part.
[code]
function Noise(integer x)
x = (x<<13) ^ x;
return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 7fffffff) / 1073741824.0);
end function
function SmoothedNoise_1(float x)
return Noise(x)/2 + Noise(x-1)/4 + Noise(x+1)/4
end function
[/code]
Why SmoothedNoise_1 method is calling Noise method with float values when Noise only accepts integers?[/QUOTE]
Do not follow that tutorial.
Is there a better tutorial?
Anyone ever use SFML in C#? I'm having trouble even figuring it out because all the tutorials are in C++
I recently decided to start 3d development with XNA game studio, but I seem to have run into a problem. I was following the tutorials in the book "Microsoft XNA game studio creator's guide, second edition", and the default shader it has in the program that it uses for a base for all the beginning programs simply doesn't work. Here it is, help is appreciated;
[code]//------------------------------------------------------------
// Microsoft® XNA Game Studio Creator's Guide, Second Edition
// by Stephen Cawood and Pat McGee
// Copyright (c) McGraw-Hill/Osborne. All rights reserved.
// [url]https://www.mhprofessional.com/product.php?isbn=0071614060[/url]
//------------------------------------------------------------
float4x4 wvpMatrix : WORLDVIEWPROJ;
struct VSinput
{
float4 position : POSITION0;
float4 color : COLOR0;
};
struct VStoPS
{
float4 position : POSITION0;
float4 color : COLOR0;
};
struct PSoutput
{
float4 color : COLOR0;
};
// alter vertex inputs
void VertexShader(in VSinput IN, out VStoPS OUT)
{
// transform vertex
OUT.position = mul(IN.position, wvpMatrix);
OUT.color = IN.color;
}
// alter vs color output
void PixelShader(in VStoPS IN, out PSoutput OUT)
{
float4 color = IN.color;
OUT.color = clamp(color, 0, 1); // range between 0 and 1
}
// the shader starts here
technique BasicShader
{
pass p0
{
// declare & initialize ps & vs
vertexshader = compile vs_1_1 VertexShader();
pixelshader = compile ps_1_1 PixelShader();
}
}
[/code]
It returns the error
[code]Error 1 Errors compiling C:\Users\Administrator\Documents\Visual Studio 2010\Projects\XNA_project_1\Content\Shaders\PositionColor.fx:
C:\Users\Administrator\Documents\Visual Studio 2010\Projects\XNA_project_1\Content\Shaders\PositionColor.fx(27,6): error X3000: syntax error: unexpected token 'VertexShader' C:\Users\Administrator\Documents\Visual Studio 2010\Projects\XNA_project_1\Content\Shaders\PositionColor.fx 27 6 MGHWinBaseCode[/code]
[QUOTE=Quark:;30769627]Anyone ever use SFML in C#? I'm having trouble even figuring it out because all the tutorials are in C++[/QUOTE]
I don't see why you would need tutorials for SFML for anything other than setting it up, and since this is C#, not C++, setting up is not an issue.
Quick question here, for collision detection in a platformer if the player is touching ground what should I have it do? I know how to do collision detection I just want to make sure that I don't make any highly unoptimized code for it. My current thought is to just continuously redirect the players X/Y coordinates to the location of the wall so the player could never pass through it. Just wondering if that's a bad method.
[QUOTE=Quark:;30769627]Anyone ever use SFML in C#? I'm having trouble even figuring it out because all the tutorials are in C++[/QUOTE]
If you need help add me on Steam
Anyone have any experience with multi-level arrays in SourcePawn?
Posted this in WAYWO, but it really belongs more in this thread:
I've been doing so much low-level assembly programming lately, writing small and isolated programs, that I've become rusty on higher-level programming. So I'm going to start on a pretty simple network-based, real-time (as opposed to turn-based) 2D game to brush up on my Java.
Does anyone have any good ideas for how to structure a project like this efficiently, classwise and filewise? Good ideas/links for managing game states (menus for servers/clients, pausing, game over/round over, etc.)? And finally, any interesting (and most importantly well-documented) 2D libraries for some fancy particles/effects?
What is a good up to date book for xna game studio? The creators guide is sharply outdated.
[QUOTE=T3hGamerDK;30761959]I tried implementing AngelScript in my engine, as an alternative to lua, but I'm getting the following error
[code]
main.cpp:28:97: error: expected ‘;’ before ‘msg’
[/code]
[url=http://openpaste.org/73794b3D]source file[/url]
[editline]28th June 2011[/editline]
Yes, I did change USE_AS_NAMESPACE to AS_USE_NAMESPACE[/QUOTE]
Anyone? I haven't got the slightest clue what is wrong.
Try ripping stuff out until it works.
[QUOTE=ZeekyHBomb;30800953]Try ripping stuff out until it works.[/QUOTE]
That's what I did. It errors in the beginning.
Hey guys, I'm "working" on a physics-based puzzle game where you control a ball which can change materials to complete different puzzles, however I'm looking for an free engine with a built-in physics engine and some kind of scripting/coding system to ease up the development process since I'm not that good with C++ yet to consider using something like Ogre3D.
I'm taking a look at Panda3D, but I can't seem to find if it's free for any kind of use. I've bought a license for Torque a few years back, but that wont help too much since it doesn't have built-in physics and, being honest, it looks like ass.
tl;dr: looking for a game engine which is free for commercial use with built-in physics engine because I suck at C++
Start with something like
[cpp]#define AS_USE_NAMESPACE
#include <angelscript.h>
#include <scriptstdstring/scriptstdstring.h>
#include <scriptbuilder/scriptbuilder.h>
namespace as = AngelScript;
void MessageCallback( const as::asSMessageInfo *msg ){}[/cpp]
Then take out the namespace as = AngleScript;. Get rid of the headers you don't need. Then take out the AS_USE_NAMESPACE. Leave the header, but remove the parameter. ect.
[editline]30th June 2011[/editline]
[QUOTE=Samuka97;30801377]Hey guys, I'm "working" on a physics-based puzzle game where you control a ball which can change materials to complete different puzzles, however I'm looking for an free engine with a built-in physics engine and some kind of scripting/coding system to ease up the development process since I'm not that good with C++ yet to consider using something like Ogre3D.
I'm taking a look at Panda3D, but I can't seem to find if it's free for any kind of use. I've bought a license for Torque a few years back, but that wont help too much since it doesn't have built-in physics and, being honest, it looks like ass.[/QUOTE]
[url]http://www.panda3d.org/license.php[/url]
Didn't the guys who worked on Torque go bankrupt or something?
[QUOTE=Samuka97;30801377]tl;dr: looking for a game engine which is free for commercial use with built-in physics engine because I suck at C++[/QUOTE]
Sounds like a bad idea IMO. Learn C++.
[QUOTE=ZeekyHBomb;30801400]http://www.panda3d.org/license.php
Didn't the guys who worked on Torque go bankrupt or something?
Sounds like a bad idea IMO. Learn C++.[/QUOTE]
Oh, thanks. I didn't notice the menu transformed the links below it. Also I'm not really sure, the last time I went there was about 3 years ago or so. Also I am trying to learn C++, but Ogre3D seems too complicated for me to use (not really the Ogre part, more the setting-up and configurating), Irrlicht seems to have too little functionality and documentation and everything else is either paid or falls into one of those categories.
[QUOTE=ZeekyHBomb;30801400]Start with something like
[cpp](code)[/cpp]
Then take out the namespace as = AngleScript;. Get rid of the headers you don't need. Then take out the AS_USE_NAMESPACE. Leave the header, but remove the parameter. ect.[/QUOTE]
Holy shit. I was just about to do this, when I read the error again for the 100th time. Line 28 isn't where I thought it was, I had missed out a single "<<" at the end of the std::cout line!
Thanks anyway, I'll keep in mind to do those things the next time something goes wrong though, but I better doublecheck the line numers more often.
[QUOTE=Samuka97;30801509]Oh, thanks. I didn't notice the menu transformed the links below it. Also I'm not really sure, the last time I went there was about 3 years ago or so. Also I am trying to learn C++, but Ogre3D seems too complicated for me to use (not really the Ogre part, more the setting-up and configurating), Irrlicht seems to have too little functionality and documentation and everything else is either paid or falls into one of those categories.[/QUOTE]
I mean learn C++, not learn Ogre or Irrlicht.
You can learn and apply C++ without Game- or Graphic-libraries and I would recommend doing that before using a library ((parts of) the C++ standard library being the exception).
[QUOTE=ZeekyHBomb;30801614]I mean learn C++, not learn Ogre or Irrlicht.
You can learn and apply C++ without Game- or Graphic-libraries and I would recommend doing that before using a library ((parts of) the C++ standard library being the exception).[/QUOTE]
...what? As I have previously stated, I am learning C++. I'm more than halfway through C++ Primer Plus (5th Edition) and I have some prior "experience" from making simple games with SFML (pong, tic-tac-toe). From what I understood from that, you're telling me not to use any game or graphic libraries and program the rendering on my own? Since that's insane, at least for someone like me, I'm gonna assume I didn't understand what you said exactly.
[b]Edit:[/b] And once again, I do have prior experience to using C++ to make console applications. That's what I've been doing for the last 2 years while I used Game Maker to make my actual "games".
[b]Edit 2:[/b] Also, as I said, my problem with Ogre3D and Irrlicht isn't really the coding itself, it's setting my compiler up, compiling project files and fixing errors which I've never seen before that make it hard. I'm looking for something like Panda3D or Unity because I can code, but there's no complicated, poorly documented "setting up" involved with it.
[QUOTE=T3hGamerDK;30799199]Anyone? I haven't got the slightest clue what is wrong.[/QUOTE]
You seem to be missing a "<<" in this line before msg->message:
[code]std::cout << msg->section << "(" << msg->row << ", " << msg->col << ") : " << type << " : " msg->message << std::endl;[/code]
Edit:
Herp, I left facepunch open in the background and didn't think of refreshing it.
-snip, broken merge. also he already figured it out-
[QUOTE=Samuka97;30802753]...what? As I have previously stated, I am learning C++. I'm more than halfway through C++ Primer Plus (5th Edition) and I have some prior "experience" from making simple games with SFML (pong, tic-tac-toe). From what I understood from that, you're telling me not to use any game or graphic libraries and program the rendering on my own? Since that's insane, at least for someone like me, I'm gonna assume I didn't understand what you said exactly.
[b]Edit:[/b] And once again, I do have prior experience to using C++ to make console applications. That's what I've been doing for the last 2 years while I used Game Maker to make my actual "games".[/QUOTE]
You did not state that you are learning (pure) C++. You said you suck at it, and whether you are still learning or not, if you don't yet feel comfortable with the language itself then I think you should not move on already.
I am not suggesting that you should write your own renderer. I am suggesting that you don't write game requiring graphics yet.
If you feel you have a grip on C++, but somehow not on the big libraries, then work through a tutorial instead of creating your own thing from the ground up.
[editline]30th June 2011[/editline]
[QUOTE=Samuka97;30802753][b]Edit 2:[/b] Also, as I said, my problem with Ogre3D and Irrlicht isn't really the coding itself, it's setting my compiler up, compiling project files and fixing errors which I've never seen before that make it hard. I'm looking for something like Panda3D or Unity because I can code, but there's no complicated, poorly documented "setting up" involved with it.[/QUOTE]
Setting your build environment up for libraries is something, that you will probably encounter for many projects.
If you ask on the respective forums, or if you're too lazy to make an account right here, someone will surely know how to help you.
Understanding errors and knowing how to fix them is quite handy.
[QUOTE=ZeekyHBomb;30802863][b]If you feel you have a grip on C++, but somehow not on the big libraries, then work through a tutorial instead of creating your own thing from the ground up.[/b]
[editline]30th June 2011[/editline]
[b]If you ask on the respective forums, or if you're too lazy to make an account right here, someone will surely know how to help you. Understanding errors and knowing how to fix them is quite handy.[/b][/QUOTE]
Those are the two things I'm talking about. They're what's holding me back from wanting to use C++ and Ogre3D and instead making me lean towards pre-built engines such as Panda3D. The lack of proper documentation for say, the addons of certain libraries, the small userbase that barely ever awnsers people on their respective forums...
But since Panda3D already has been suggested (or did I suggest it myself in the first place?), I'm just gonna consider this question "awnsered" and stop clogging up the thread. (meant to say I should stop clogging up the thread, worded it wrongly)
Sorry, you need to Log In to post a reply to this thread.