Skip to main content
gamedev.net
🔒 Locked

Function return value problem?

Started by twety94Gmail May 14, 2012 at 6:43 PM 3 replies 1.6k views
Original Post
twety94Gmail
twety94Gmail
Hello.
My problem is c++ related on my lack of knowlage.

I have a fT whic i use for Timed Movment. In function Main::ActionHandle() i call the calculation where problem ocures.
when i blit HeroCropF(float) and Position(float) should be same right? i use same calculations and values. But "Position" changes while "HeroCropF" stay 0.
il post whole code if this isent enought but i got just bacis SDL Event/Render only.


int Main::MainStart()
{
if(Init() == false || Load() == false)
{
Exit();
return -1;
}
SDL_Event ImpEvent;
while(Running)
{
oT = cT;
cT = SDL_GetTicks();
fT = (cT - oT) / 1000.0f;
FpsTimer = SDL_GetTicks();
while(SDL_PollEvent(&ImpEvent))
{
EventHandle(&ImpEvent);
}
ActionHandle();
RenderHandle();
if(1000.0f / Screen_FPS > (SDL_GetTicks() - FpsTimer))
SDL_Delay(1000.0f / Screen_FPS - (SDL_GetTicks()- FpsTimer));
}
Exit();
return 0;
}

float Main::ReturnfT()
{
return fT;
}

void Main::ActionHandle(
{
Hero::HeroControl.AnimateHero();
Position += 4.0f * fT;
}

void Hero::AnimateHero()
{
HeroCropF += 4.0f * Main::MainControl.ReturnfT();

}


Edit: Btw Position changes for 4 Pixels per second, so should the HeroCropF but it dosent... Ani value with Position works perfect.

Edit2: I changed this:

void Main::ActionHandle(
{
Hero::HeroControl.AnimateHero();
Position += 4.0f * fT;
}

TO THIS!!!:

void Main::ActionHandle(
{
Hero::HeroControl.HeroPosF += 4.0f * fT;
Position += 4.0f * fT;
}

And now it works. So the error is Passed "fT" value ? wtf can som1 explain the error there
alvaro
alvaro
You are missing a closing parenthesis in the definition of Main::ActionHandle. This probably means that this is not actually your code, but just a crappy copy. And since I can't understand your English either, I really think I can't help you.

If you want to program, you need to start paying attention to details, because details matter.
twety94Gmail
twety94Gmail

You are missing a closing parenthesis in the definition of Main::ActionHandle. This probably means that this is not actually your code, but just a crappy copy. And since I can't understand your English either, I really think I can't help you.

If you want to program, you need to start paying attention to details, because details matter.

Yes i noticed it now... i made error during pasting =,?.
Mhm i can send you File.zip? i dont see a "Attach File"
Project file is CodeBlock compiler mingw32 if it helps
i uploaded Karg.zip to Mediafire
Link: http://www.mediafire.com/?3r0421j883qld80

Sry for my ingrish. I have no class for it.
alvaro
alvaro
You have two Main' objects: a local variable in main()' and a static member Main::MainControl'. Hero::AnimateHero' is getting `fT' from the wrong one.

Your English seems fine to me, except for spelling. Your browser probably has a spell checker built in. Use it.
twety94Gmail
twety94Gmail

You have two Main' objects: a local variable in main()' and a static member Main::MainControl'. Hero::AnimateHero' is getting `fT' from the wrong one.

Your English seems fine to me, except for spelling. Your browser probably has a spell checker built in. Use it.

i am grabbing "fT" from "Main::MainControl.ReturnfT()" and as you say its incorrect since it does not work.
i tried making "fT" public in Main Class. and grabing it with "Main::MainControl.fT" did not work.

I do not want to trouble you with this anymore.
What area of C++ should i look intro to fix this problem?
what would you recommend?

I never figured what are the red underlines for until now =,=

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.