• What do you need help with? V. 3.0
    4,884 replies, posted
Odd, are the x and y values you use for position calculating unwanted values? Perhaps it's just drawing off-screen. [editline]25th December 2011[/editline] [QUOTE=NovembrDobby;33893894]Maybe you need to set all those little things like the scale and colour and stuff (although I'd think they'd be 1/white by default)[/QUOTE] They are defaulted. [editline]25th December 2011[/editline] Also, I noticed you're drawing the background image after drawing the "Planet".
[QUOTE=ief014;33893898]Odd, are the x and y values you use for position calculating unwanted values? Perhaps it's just drawing off-screen. [editline]25th December 2011[/editline] They are defaulted. [editline]25th December 2011[/editline] Also, I noticed you're drawing the background image after drawing the "Planet".[/QUOTE]Good idea, and also, I wanted to just get the sprite on the screen. I'll look into it. [editline]25th December 2011[/editline] If you look at the code, near the end ( where the x and y equations are ) that's how the position is set. Should I be setting it earlier? [editline]25th December 2011[/editline] Oh, and putting the planet before the background still hasn't made the circle draw.
[QUOTE=Meatpuppet;33893964]If you look at the code, near the end ( where the x and y equations are ) that's how the position is set. Should I be setting it earlier?[/QUOTE] Yes, so long as your modifications to the sprite are done before it is drawn
[QUOTE=ief014;33894010]Yes, so long as your modifications to the sprite are done before it is drawn[/QUOTE] Same for the circle? [editline]25th December 2011[/editline] [cpp]// ship sprite Spaceship ship1("Ship one", 2000, 1000, 86400); ship1.ShipLoadImage("sprite.png"); ship1.GetShipImage().SetPosition(0 ,-250);[/cpp] Adding line 4 didn't help.
You shouldn't have to add that. Check if these lines are doing what you want. [cpp] y = -(accelfactory * (Time * Time) + (velocityY * Time)) + initialY; x = (accelfactorx * (Time * Time) + (velocityX * Time)) + initialX; [/cpp] Perhaps print their values in the console.
I always print velocityX and velocityY in the console, they're both working fine. [editline]25th December 2011[/editline] Got it. For some reason the negative I put in the initialY wasn't registering right.
Im trying to make an animation class, I have this code: [cpp] class Animator { sf::Sprite *sprite; int frames; float currFrame; int startFrame; int finalCurrFrame; sf::Vector2f frameSize; sf::Vector2i currVecPos; sf::Vector2i amountOfFrames; public: Animator(sf::Sprite &spr); ~Animator(); void setFrames(int fram, sf::Vector2f eFrameSize); void ChangeFrames(int minFrame, int maxFrame); void Update(float delta); }; #include "./Animator.hpp" #include <iostream> Animator::Animator(sf::Sprite &spr) { sprite = &spr; } Animator::~Animator() { } void Animator::setFrames(int fram, sf::Vector2f eFrameSize,const sf::Texture *img) { frames = fram; frameSize = eFrameSize; amountOfFrames.x = img->GetWidth() / frameSize.x; amountOfFrames.y = img->GetHeight() / frameSize.y; } void Animator::ChangeFrames(int minFrame, int maxFrame) { startFrame = minFrame; finalCurrFrame = maxFrame; currFrame = startFrame; } void Animator::Update(float delta) { currFrame += delta * 3; int cF = (int)(currFrame); if(cF > finalCurrFrame) currFrame = startFrame; currVecPos.x = cF % amountOfFrames.x; currVecPos.y = cF / amountOfFrames.y; sprite->SetSubRect(sf::IntRect(currVecPos.x * frameSize.x,currVecPos.y * frameSize.y,frameSize.x, frameSize.y) ); } [/cpp] and im using this image: [img]http://i.imgur.com/GsLN8.png[/img] with these settings: [code] anim.setFrames(12, sf::Vector2f(32,32), sprite.GetTexture()); anim.ChangeFrames(1,3); [/code] but it seems to be doing frames 1 - 2 - 7 Can anyone see any fault in my logic?
Can someone tell me how to use vector2 ( T ) within a function like SetPosition() in SFML?
[QUOTE=Meatpuppet;33898541]Can someone tell me how to use vector2 ( T ) within a function like SetPosition() in SFML?[/QUOTE] [code] sf::Vector2f pos; pos.x = 5.0f; pos.y = 10.0f; spr.SetPosition(pos); [/code] or [code] spr.SetPosition(sf::Vector2f(5.0f, 10.0f)); [/code]
How do you re-load a DirectX 10 shader during runtime? I'm originally loading the shader/technique via: [cpp] HR(D3DX10CreateEffectFromFileA( filePath, NULL, NULL, "fx_4_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, m_pD3DDevice, NULL, NULL, &m_pBasicEffect, &pErrors, NULL)); m_pBasicTechnique = m_pBasicEffect->GetTechniqueByName("VertexLitGeneric"); [/cpp] And then later calling that. However the new/updated (just swapped out the pixel shader's lines to test) shader never takes over. What step am I missing here?
[QUOTE=ief014;33898677][code] sf::Vector2f pos; pos.x = 5.0f; pos.y = 10.0f; spr.SetPosition(pos); [/code] or [code] spr.SetPosition(sf::Vector2f(5.0f, 10.0f)); [/code][/QUOTE] Thanks.
How would you go about drawing a tile based map from a 2d array in XNA? Thought of going through a loop drawing every tile according to the value in the array but it doesn't work like that.
Should I try to make my own engine or start with Unity? I want my senior project (far out) to be an evolution simulation in a 3D environment. I'll need hills, caves, & dynamically generated shapes. Should I write my own engine for this or go through unity?
Unity.
I have exercises in my book called "Programming Priciples and Practice Using C++" by Bjarne Stroustrup, great book. I'm trying to do all the exercises and with this one, I am having problems. I need to put the integers in growing order. [CODE]int main() { int val1; int val2; int val3; int sv = 0; //smallest value int mv = 0; //medium value int bv = 0; //biggest value cout << "PLEASE ENTER THREE INTEGERS: " << endl; cin >> val1 >> val2 >> val3; if(val1>val2, val2>val3) bv=val1, mv=val2, sv=val3; if(val1>val3, val3>val2) bv=val1, mv=val3, sv=val2; if(val2>val1, val1>val3) bv=val2, mv=val1, sv=val3; if(val2>val3, val3>val1) bv=val2, mv=val3, sv=val1; if(val3>val1, val1>val2) bv=val3, mv=val1, sv=val2; if(val3>val2, val2>val1) bv=val3, mv=val2, sv=val1; cout <<sv<<", "<<mv<<", "<<bv<<endl<<endl; keep_window_open(); }[/CODE] Language is C++ For some reason, it does not assign the right values to my variables sv, mv, bv. It outputs the values wrong. (e.g. 2 3 1 comes out 2, 3, 1) I know I could do this same exercise with an extra variable, but why does this not work? PS keep_window_open() is defined by a library.
Does anything happen if you switch the comma to the OR operator ||?
3 2 1 still outputs as 2, 3, 1 Operator && worked though and with every input I give. How does comma exactly work? EDIT:Found a definition for comma: [QUOTE]The comma operator (,) is used to separate two or more expressions that are included where only one expression is expected. When the set of expressions has to be evaluated for a value, only the rightmost expression is considered.[/QUOTE] [url]http://www.cplusplus.com/doc/tutorial/operators/[/url]
The comma separate two expressions. Although I have no idea what happens when you put it into an if statement like that.
Yes, both inequalities had to be true. But with comma separating them, only one of them had to be true to get an end output.
Currently i'm trying to make a simple 2D rts in XNA and got this for movement in my Unit Class [code] public override void Update(GameTime gameTime) { base.Update(gameTime); movePosition = targetPosition - center; if (movePosition != Vector2.Zero) { movePosition.Normalize(); position += movePosition * speed; } }[/code] targetPosition is the vector2 to where the unit has to move to (where i leftclick my mouse) movePosition is the vector2 to move the position vector2. The base class is Sprite.cs for simple spritedrawing. The problem with it however is that when it moves to fast and it reaches the targetPosition vector it goes to far and wants to go back, goes to back to far, want to go the other side agian and goes to far, etc: it wobbles. I won't want to cheat with a MathHelper.smoothstep because you can't use a speed variable to have a constant speed.
[QUOTE=Swebonny;33903327]The comma separate two expressions. Although I have no idea what happens when you put it into an if statement like that.[/QUOTE] Left side of the comma is evaluated, but it's returned value is not used anywhere. Right side is also evaluated and it's returned value is returned from the comma operator, so that the if statement will only take right side's value into count.
[QUOTE=ToXiCsoldier;33903482]Currently i'm trying to make a simple 2D rts in XNA and got this for movement in my Unit Class [code] public override void Update(GameTime gameTime) { base.Update(gameTime); movePosition = targetPosition - center; if (movePosition != Vector2.Zero) { movePosition.Normalize(); position += movePosition * speed; } }[/code] targetPosition is the vector2 to where the unit has to move to (where i leftclick my mouse) movePosition is the vector2 to move the position vector2. The base class is Sprite.cs for simple spritedrawing. The problem with it however is that when it moves to fast and it reaches the targetPosition vector it goes to far and wants to go back, goes to back to far, want to go the other side agian and goes to far, etc: it wobbles. I won't want to cheat with a MathHelper.smoothstep because you can't use a speed variable to have a constant speed.[/QUOTE] Before normalizing the movePosition vector, get its length. If the length is smaller than the speed variable, do not normalize and scale the vector. [editline]26th December 2011[/editline] e.g. something like [cpp]if (movePosition != Vector2.Zero) { if (movePosition.Length() > speed) { movePosition.Normalize(); movePosition *= speed; } position += movePosition; }[/cpp]
Is there any good articles on how to do dynamic pathfinding in a 3d enviroment with a flying object? Think a flying object in gmod, trying to find its way around player built structures as well as the static map.
[QUOTE=AtomiCasd;33905419]Is there any good articles on how to do dynamic pathfinding in a 3d enviroment with a flying object? Think a flying object in gmod, trying to find its way around player built structures as well as the static map.[/QUOTE] There's a shitload of work in that.
[QUOTE=Lord Ned;33898788]How do you re-load a DirectX 10 shader during runtime? I'm originally loading the shader/technique via: HR(D3DX10CreateEffectFromFileA( filePath, NULL, NULL, "fx_4_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, m_pD3DDevice, NULL, NULL, &m_pBasicEffect, &pErrors, NULL)); m_pBasicTechnique = m_pBasicEffect->GetTechniqueByName("VertexLitGeneric"); And then later calling that. However the new/updated (just swapped out the pixel shader's lines to test) shader never takes over. What step am I missing here?[/QUOTE] I'm not really familiar with effects and D3DX but it can't be so different to base D3D10, so there's probably a release method for the effect that you have to call to delete it then you can recreate it, probably should set the pointer to null too. Not sure what your HR function does but it will also be helpful later to get back the error result from D3DX. Just a side note though, recreating a shader generally isn't something you need to do, even with different code (which should probably be another shader anyway).
[QUOTE=Philly c;33907230]I'm not really familiar with effects and D3DX but it can't be so different to base D3D10, so there's probably a release method for the effect that you have to call to delete it then you can recreate it, probably should set the pointer to null too. Not sure what your HR function does but it will also be helpful later to get back the error result from D3DX. Just a side note though, recreating a shader generally isn't something you need to do, even with different code (which should probably be another shader anyway).[/QUOTE] I didn't think about releasing the previous shader. I'll try that now. The HR is just a macro that pops up a dialog box with the HRESULT the DX function return.s I know the shader's wouldn't like it if I changed the variables it asked for or other misc. things that it can change, but when I'm working with pixel-shader/hlsl specific operations, it'd be nice to iteratively develop that didn't involve reloading application every time. Unfortunately releasing the effect doesn't make it change either. [editline]26th December 2011[/editline] Actually maybe it did make it change. It threw a breakpoint in the background that I didn't notice, saying my EffectVar's are out of date. That's good news. I think. [b]Edit:[/b] Attempting to fix that by re-assigning the effect var's didn't work either.
[QUOTE=Lord Ned;33907735]I know the shader's wouldn't like it if I changed the variables it asked for or other misc. things that it can change, but when I'm working with pixel-shader/hlsl specific operations, it'd be nice to iteratively develop that didn't involve reloading application every time.[/QUOTE] Yeah that's a good idea, I didn't think of that when I said it. Sorry I can't really help any further with effects. I just use regular shaders.
[QUOTE=Philly c;33907915]Yeah that's a good idea, I didn't think of that when I said it. Sorry I can't really help any further with effects. I just use regular shaders.[/QUOTE] I'm going to beat this thing to death until it works, even if it kills me. I've tried re-creating the InputLayout, I've tried re-creating all the buffers, etc. I've tried pretty much everything but shutting the renderer down entirely and re-creating it. I'll find a way eventually. Thanks for your help though, you kept me going.
[QUOTE=ThePuska;33906900]There's a shitload of work in that.[/QUOTE] Oh okay thanks you've been really helpful
[QUOTE=T3hGamerDK;33852756]I get a segmentation fault when running this project: [url]https://github.com/mastersrp/hacktheplanet[/url] (it requires this: [url=https://github.com/mastersrp/libscript]libscript[/url] which may cause the segmentation fault, although I'm not sure why)[/QUOTE] No one? I've narrowed it down to being the libscript part though, more specifically in the files state.cpp or state.h or script.hpp. I've merged them into one and posted it here: [url]http://pastebin.sabayon.org/pastie/7875[/url] Please note that the script/config.hpp file looks like this: [cpp] #define SCRIPT_USE_LUA //#define SCRIPT_USE_AS [/cpp] But the error lies in what code is above. I just don't know where. It builds fine, but when I run: [cpp] script::state* g_scriptState; g_scriptState->CreateState(); [/cpp] The program crashes at the second line.
Sorry, you need to Log In to post a reply to this thread.