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 / Coding Help

Author
Message
Terrestrial Productions
15
Years of Service
User Offline
Joined: 23rd Jul 2009
Location:
Posted: 30th Nov 2009 00:16
Hi I need help with a script for two objects has a certain number and one with the highest wings but i want it to be able to fit any objects not just the two i'm using. Any help here?


Terrestrial Productions
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 30th Nov 2009 01:37 Edited at: 30th Nov 2009 01:37
Could you explain it a little more im having trouble understanding.

Do you mean wins? not wings?
Terrestrial Productions
15
Years of Service
User Offline
Joined: 23rd Jul 2009
Location:
Posted: 30th Nov 2009 03:12
Sorry I was rushed to write that. Here is the code that I have so far.
Quote: "
#include "DarkGDK.h"

void DarkGDK ( void )
{
int RandomNumber = dbRND ( 4 );

int ObjectOneAttack = 2;
int ObjectOneDefense = 2;
int ObjectOneStrength = 2;
int ObjectOneFight = ObjectOneAttack * RandomNumber + ObjectOneStrength * RandomNumber / RandomNumber;
int ObjectOneDefend = ObjectOneDefense * RandomNumber + ObjectOneStrength * RandomNumber / RandomNumber;

int ObjectTwoAttack = 2;
int ObjectTwoDefense = 2;
int ObjectTwoStrength = 2;
int ObjectTwoDefend = ObjectTwoDefense * RandomNumber + ObjectTwoStrength * RandomNumber / RandomNumber;
int ObjectTwoFight = ObjectTwoAttack * RandomNumber + ObjectTwoStrength * RandomNumber / RandomNumber;

int Offense = ObjectOneFight && ObjectTwoFight;
int Defense = ObjectTwoDefend && ObjectOneDefend;

int Loser = ;

dbSyncOn ( );
dbSyncRate ( 60 );

dbMakeObjectBox ( 1, 2, 8, 2 );

dbMakeObjectBox ( 2, 4, 4, 4 );
dbPositionObject ( 2, 0, 7, 0 );

dbPositionCamera ( 0, 5, -15 );

while ( LoopGDK ( ) )
{
dbSync ( );

if ( dbKeyState ( 17 ) )
dbPitchCameraUp ( 1 );
else if ( dbKeyState ( 31 ) )
dbPitchCameraDown ( 1 );
if ( dbKeyState ( 30 ) )
dbRollCameraLeft ( 1 );
else if ( dbKeyState ( 32 ) )
dbRollCameraRight ( 1 );
if ( dbUpKey ( ) )
dbPositionCamera ( dbCameraPositionX ( ), dbCameraPositionY ( )+1, dbCameraPositionZ ( ) );
else if ( dbDownKey ( ) )
dbPositionCamera ( dbCameraPositionX ( ), dbCameraPositionY ( )-1, dbCameraPositionZ ( ) );
if ( dbLeftKey ( ) )
dbMoveCameraLeft ( 0, 1 );
else if ( dbRightKey ( ) )
dbMoveCameraRight ( 0, 1 );
if ( dbKeyState ( 19 ) )
dbPositionCamera ( 0, 2.5, -15 );

if ( dbControlKey ( ) )
if ( Offense < Defense )
Offense = Loser;
else if ( Offense > Defense )
Defense = Loser;

if ( Offense ( ) = Loser )
dbDeleteObject ( Loser );
else if ( Defense ( ) = Loser )
dbDeleteObject ( Loser );

}
return;
}"

I'm trying to make it so that you have a random attack/defend stat and if you lost than you take damage or delete the object which is what i'm doing up there.


Terrestrial Productions
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 30th Nov 2009 06:52


the variables Offense and Defence are being used as functions here(thats what it looks like)


the && operator is a check. it will return 1 or 0. so your saying Offense = ObjectOneFight > 0 and ObjectTwoFight > 0

which would probably return 1. so Offense and defence are always 1 because i don't see a way that your ObjectFight variables can be 0 or negative

New Site! Check it out \/
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 30th Nov 2009 16:36
Quote: "if ( Offense ( ) = Loser )
"


I don't believe you can set a function call as an lvalue. Did you mean to use == instead of = ?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 1st Dec 2009 00:48 Edited at: 1st Dec 2009 00:48
Offense is a variable. there is no definition of a function called Offense()

New Site! Check it out \/
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 2nd Dec 2009 00:24 Edited at: 2nd Dec 2009 00:25
@Terrestrial Productions
1) If Offense is a variable, why do you have () after it???
2) '=' is the assignment character in C++, '==' is the comparison operator.

Terrestrial Productions
15
Years of Service
User Offline
Joined: 23rd Jul 2009
Location:
Posted: 7th Dec 2009 00:51
Sorry guys but i haven't had time to get good at coding. Thanks for all the help I'll put up the new code sometime later when i update it. Thanks alot!!


Terrestrial Productions
Terrestrial Productions
15
Years of Service
User Offline
Joined: 23rd Jul 2009
Location:
Posted: 7th Dec 2009 01:11
How would I put text on the screen like the characters health?
Heres the code
Quote: "int ObjectOneHealth = 10;

//the main loop now

dbText ( 0, 0, ObjectOneHealth );
"

when I do that it has error. What would i put in there to show the variable?


Terrestrial Productions
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 7th Dec 2009 02:18
You could use dbStr (ObjectOneHealth); but you'd have to de-allocate the memory yourself.
Freedom Fighters
14
Years of Service
User Offline
Joined: 2nd Nov 2009
Location:
Posted: 7th Dec 2009 02:34
you have to string the variable
use


Problem Solution That Never Fails: "Build A Bridge And Get Over It"
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 7th Dec 2009 03:11
Or how about you use it safely:



Your_Health = (My_Mood == HAPPY) ? 100 : NULL;
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 7th Dec 2009 13:02
@ bran flakes: do you need to do the same thing when you use sprintf instead of dbStr?

Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 7th Dec 2009 20:52
No, not unless you allocate memory yourself.

Without allocating memory:



With allocating memory:



Your_Health = (My_Mood == HAPPY) ? 100 : NULL;
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 8th Dec 2009 12:59
oh, i see, thanks.

Login to post a reply

Server time is: 2024-10-01 18:37:03
Your offset time is: 2024-10-01 18:37:03