Beginner C++ programmer here. What are pointers useful for? As I understand it they are just "shortcuts" to already existing variables, so what's the point? Should I just not worry about them for now?
[QUOTE=a-k-t-w;33021840]Beginner C++ programmer here. What are pointers useful for? As I understand it they are just "shortcuts" to already existing variables, so what's the point? Should I just not worry about them for now?[/QUOTE]
Pointers are quite hard to understand for beginners. You should know about them, but they're not very important to beginners. If you learn about more complex stuff like classes and such then pointers get a better purpose.
[QUOTE=a-k-t-w;33021840]Beginner C++ programmer here. What are pointers useful for? As I understand it they are just "shortcuts" to already existing variables, so what's the point? Should I just not worry about them for now?[/QUOTE]
I understand what you mean when you think pointer's aren't useful, but in the future you'll realize that a great deal of things use pointers and heap allocation.
How do you do NOT in python 3?
as in:
blah = false;
if([B]![/B]blah)
{
...
}
scrap thaat, python just uses the [B]not[/B] keyword
[QUOTE=a-k-t-w;33021840]Beginner C++ programmer here. What are pointers useful for? As I understand it they are just "shortcuts" to already existing variables, so what's the point? Should I just not worry about them for now?[/QUOTE]
Dynamic arrays are one example. If you don't know the size of the array you need to allocate, you would initialise a pointer then use the 'new' keyword to allocate the size that you want.
What am I doing wrong? This is my shunting yard algo in java:
[code]
for(int I=0;I<tokens.length;I++){
String token=tokens[I];
if(operators.containsKey(token)){
Operator O1=Operator.fromOperator(token);
Operator O2;
if(stack.size()!=0)
while((O2=Operator.fromOperator(stack.get(stack.size()-1)))!= null)
if((O1.isRightToLeft&&O1.precedence<O2.precedence)||(!O1.isRightToLeft&&O1.precedence<=O2.precedence)){
output+=O2.operator+" ";
stack.remove(stack.size()-1);
}
stack.add(token);
}else if(token.equals("(")){
stack.add(token);
}else if(token.equals(")")){
String tkn="";
while(!(tkn=stack.get(stack.size()-1)).equals("(")){
stack.remove(stack.size()-1);
output+=tkn+" ";
}
stack.remove(stack.size()-1);
}else{
output+=token+" ";
}
}
[/code]
[QUOTE=ThePuska;33011028]No, it's the ceiling. You have the wrong value for log10(34).[/QUOTE]
I see my mistake - I assumed the function for log base 10 in the gnome calculator was "log10", it is in fact "log".. using "log10" takes the value of log and adds 1 to it, presumably from the implicit multiplication of the 10 and the item inside the brackets.
I want to make a GUI that will work with various different resolutions and aspect ratios.
Would I be able to do it giving the position/size a value of 0.0 - 1.0 and then just times it with the height/width of the window?
I'm trying to create an isometric game. I got the positioning sorted out on the X, Y, and Z axis and have stored them in a 3D array.
My problem is draw order. They correctly draw based on their position inside the array but if I try to move an entity, that's where I have a problem.
Should I move the reference of the entity to the changed index so it can draw accordingly or is there some way to draw based on a class member (in this case a Vector3). OR should I keep track of some type of depth variable inside each block?
Thanks for any help you guys can provide.
Can anyone with some JSonCpp experience help me out?
How do you add values to the json root?
I tried:
[code]
void WindowSettings::remakeDefault()
{
root["WindowWidth"] = WindowWidth;
root["WindowHeight"] = WindowHeight;
root["FullScreen"] = FullScreen;
root["AntiAliasing"] = AntiAliasing;
root["VSync"] = VSync;
root["FrameRateLimit"] = FrameRateLimit;
root["AspectRatio"] = AspectRatio;
root["Resolution"] = Resolution;
saveToFile("conf.json");
}[/code]
but when I exit I get a runtime error:
runtime error pure virtual function call
and its back again
Is anyone good at making a smooth camera? I'm trying to add one into my game but can't figure it out.
gamew and gameh are width and height of window
pos is the players position
[code]
void UpdateCameraPos()
{
difference.X = Math.Abs(pos.X - prevpos.X);
difference.Y = Math.Abs(pos.Y - prevpos.Y);
if (camera.pos.X < pos.X - gamew * .65f) { camera.pos.X += difference.X; }
if (camera.pos.X > pos.X - gamew * .35f) { camera.pos.X += -difference.X; }
if (camera.pos.Y < pos.Y - gameh * .65f) { camera.pos.Y += difference.Y; }
if (camera.pos.Y > pos.Y - gameh * .35f) { camera.pos.Y += -difference.Y; }
//keep camera inside the map
if (camera.pos.X < 0)
{
camera.pos.X = 0;
}
if (camera.pos.X > tilewidth * 32 - gamew)
{
camera.pos.X = tilewidth * 32 - gamew;
}
if (camera.pos.Y < 0)
{
camera.pos.Y = 0;
}
if (camera.pos.Y > tileheight * 32 - gameh)
{
camera.pos.Y = tileheight * 32 - gameh;
}
prevpos = pos;
}
[/code]
How do you control movement by angle/radians in XNA?
[QUOTE=Mr. Smartass;33042432]How do you control movement by angle/radians in XNA?[/QUOTE]
More specifically?
To move something in a direction, use:
[code]
pos.X += (float)Math.cos(angleRads);
pos.Y += (float)Math.sin(angleRads);
[/code]
and you can convert between degs and rads with:
[code]
MathHelper.ToDegrees(radians);
MathHelper.ToRadians(degrees);
[/code]
Anybody have any experience with rrdtool?
Right now, I have graivity be applied when the character is not grounded. However, I have run into a problem in that the character is considered grounded one frame, and not grounded the next because the collision is fixed and the player is no longer collided with the floor. While this may seem ok at first, it screwed up moving tiles because the character has his yvelocity set to the tile one frame and to zero the next. I was thinking of just constantly applying gravity, however that seems counterproductive. Any suggestions?
I'm having some difficulty with static classes in C++, I'd appreciate it if I could get some help!
test.h:
[CODE]class process {
public:
static void Start();
};[/CODE]
main.cpp:
[CODE]#include "test.h"
int main(int argc, char** argv) {
process::Start();
return 0;
}[/CODE]
In main.cpp, I get the compile error: undefined reference to `process::Start()'. I'm using MinGW and Code::Blocks, if that's of any significance. Help would be greatly appreciated; this has been bothering me for quite some time (there's probably a very simple solution, too!).
You don't have the code part for the Start() method, only a declaration.
Oh, haha, I forgot to post this too:
test.cpp:
[CODE]
#include "test.h"
void process::Start(void) {
if(state != Uninitialized)
return;
state = Running;
while(state == Running) {
Loop();
}
}
[/code]
You forgot the ending bracket.
No, actually, I just forgot to include it. Sorry, again!
Well Start() wouldn't compile as there's no variable named state, nor does it have a Loop() method.
These were not included for simplicity's sake.
[QUOTE=Jookia;33048488]Well Start() wouldn't compile as there's no variable named state, nor does it have a Loop() method.[/QUOTE]
That wouldn't explain his error, though.
"undefined reference to `process::Start()'"
If you're not going to actually show your problem and instead post snippets of code that doesn't work, then I'm not going to bother helping.
Either post your code, recreate the error in the minimum code and upload it, or get out.
[QUOTE=Jookia;33048532]If you're not going to actually show your problem and instead post snippets of code that doesn't work, then I'm not going to bother helping.
Either post your code, recreate the error in the minimum code and upload it, or get out.[/QUOTE]
Calm down. I was simply avoiding pasting a bunch of irrelevant code, and instead focusing on the code that was actually generating the error. But if you want the full code, here:
test.h
[CODE]
#ifndef TEST_H_INCLUDED
#define TEST_H_INCLUDED
class process {
public:
static void Start();
private:
static void Loop();
enum processState {
Uninitialized, Paused, Running, Exiting, Stopped};
static processState state;
};
#endif
[/CODE]
test.cpp
[CODE]
#include <iostream>
void process::Start(void) {
if(state != Uninitialized)
return;
state = Running;
while(state == Running) {
Loop();
}
}
void process::Loop() {
cout << "Test";
}
process::processState process::state = Uninitialized;
// enum member variable
[/CODE]
main.cpp
[CODE]
#include "test.h"
int main(int argc, char** argv) {
process::Start();
return 0;
}
[/CODE]
test.cpp doesn't include test.h.
Ok, thank you for spotting that one. The compiler didn't say anything about that. Unfortunately, doesn't solve my original problem:
undefined reference to `process::Start()'
in main.cpp, line 4
What's your makefile contents?
Edit: After downloading the code and manually compiling and linking it, I find no problems with it and can run it fine.
[QUOTE=Jookia;33049025]What's your makefile contents?
[/QUOTE]
I'm not quite sure how to answer this question. Do you mean this?
[IMG]http://dl.dropbox.com/u/10657252/Makefile.PNG[/IMG]
Ah, codeblocks I see. Have you added test.cpp to the project?
Sorry, you need to Log In to post a reply to this thread.