Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Simple problem with if then statements - C++

Author
Message
Seppuku Arts
Moderator
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 24th Nov 2007 20:53 Edited at: 24th Nov 2007 21:01
It seems previous use of C# may have gotten me a little bit confused with how I'm attempting my if then statements.

What I am trying is the DarkGDK C++ equivalent of DBPro's

if Upkey() = 1 and walking = 0 then walking = 1

I should really look this up, but I don't have the time to delve into the depths of the internet looking for the solution. (As really I'm just gradually converting my DBP code over to DGDK)

What I did was:



It runs, but the result isn't quite the same as I get in DBP:

I'll do the whole code if it helps:

DBP:


DarkSDK:



What I am doing is making the animation play as the player moves forward and the animation not to plat when its not moving forward. I DBP it works, in DarkGDK the models in stuck on one frame when walking (presumably the last frame) and a different frame when not (The first frame)

I love Nancy DrewG, but not insert brain here
Roxas
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 24th Nov 2007 21:02 Edited at: 24th Nov 2007 21:03
Never mind.. Dint see your edit

Let me read your post again!


Click For Details!

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 24th Nov 2007 21:02 Edited at: 24th Nov 2007 21:06
You mean like:



?

[edit]

Seems dbUpKey() returns an integer. Maybe better to do dbUpKey() == 1, just incase.

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Seppuku Arts
Moderator
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 24th Nov 2007 21:27
Zotoast, that works better (the values are returned, so that line of the code works fine), but my animation still doesn't play - though in DBP it does. But I'll look into it later myself (Not coding right now)...unless somebody is capable of providing a better version of my code.


In the background when the character is not walking I use these commands, when I remove the first 'if then' below, the 'walking' animation will loop, when I have it, it sticks to a single frame.

if ( dbUpKey () == 0 )
dbLoopObject ( 1, 1, 1 );
if ( dbUpkey () == 0 )
walking = 0;

Sorry if any of this looks slightly sloppy, I've just typed it out into the browser as my laptop connects to the internet here and not my programming PC.

Cheers.

I love Nancy DrewG, but not insert brain here
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Nov 2007 21:37
This is a straight conversion of your original code:


If the function names and parameters are wrong, it's because they were wrong in your code

Any non-zero value is 'true' and zero is 'false', ! operates on the true/false value as a NOT, and && is a logical AND (ie, it also operates on true/false values).

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Seppuku Arts
Moderator
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 24th Nov 2007 21:55 Edited at: 24th Nov 2007 21:56
That code works too (and looks much tidier, thanks) but it seems more or less that the if, then statements are working fine now as well as the variable 'walking', but the problem is getting the object to animate - it seems obvious that I must have missed something from my original code (I did use instances to do with the downkey as well - though I wouldn't think it would make a difference, but I'll try that when I get back)

For really this is the last I'll look on it tonight, I really don't have much time.

I love Nancy DrewG, but not insert brain here
Hayer
19
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 24th Nov 2007 23:55
if ( dbUpKey () )
{
if ( walking == 0)
walking = 1;
}

shouldn't it be

if ( dbUpKey ( ) == 1 && walking == 0 )
{
walking = 1;
}

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Nov 2007 17:49
They are actually equivalent. Remember that in C and C++, a non-zero value counts as 'true', and that a nested 'if' is equivalent to a logical AND.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code

Login to post a reply

Server time is: 2024-11-16 22:09:58
Your offset time is: 2024-11-16 22:09:58