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 / can someone tell me what i'm doing wrong?

Author
Message
haliop
User Banned
Posted: 4th Sep 2008 16:06
i want to create a new box , during a the main program , in game creation, so in the main loop i have an if mouse point at XY vatibales then well i'll copy it:

while ( LoopGDK ( ) )
{
if ( dbEscapeKey ( ) )
return;

//buttons menu \ifs
if ( (dbMouseX() <=75) && (dbMouseX() >=30) && (dbMouseY() <= 40) && (dbMouseY() >= 20) && (dbMouseClick() == 1) && menu_mouse == 0 )
//(dbMouseX()== dbSpriteX(ButtonSprite)) && (dbMouseY()== dbSpriteY(ButtonSprite)) && (dbMouseX() <= dbSpriteWidth(ButtonSprite)) && (dbMouseY() <= dbSpriteHeight(ButtonSprite)))
{
menu_mouse = 1;
//Buttons();
edit_mode = true;
Box_Creator();

}

CameraPositions();
// update the screen
dbSync ( );
}

// return back to windows
return;
}

void Box_Creator(void)
{
dbMakeObjectCube(NewBox,10);
dbPositionObject(NewBox,0,0,-5);
while (edit_mode = true)
{
if (dbReturnKey () ) edit_mode = false;
if (dbLeftKey () ) dbPositionObject(NewBox, -10,0,-5);
}

}

so as you can see , there is the main loop which direct the second if to the box creator, editing mode.

now , if i destry the box creator while , the box shows and everything is working just that i can't move it , like in an ordinary edit mode, but if the while remains , then the game pause all oprations.

something i'm doing wrong..
ive also tried

if (dbReturnKey () = 1 ) edit_mode = false;
if (dbLeftKey () = 1) dbPositionObject(NewBox, -10,0,-5);

and the same result.

anyone?
ty for your time.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Sep 2008 16:48
Quote: "can someone tell me what i'm doing wrong?"

1. You aren't using the code tags
2. You are using assignment (a single '=') in your if/while commands when you should be using comparison ('==').

This: while (edit_mode = true)

Should be this: while (edit_mode == true)

haliop
User Banned
Posted: 4th Sep 2008 19:22
ok , i'll check it.
ty.
haliop
User Banned
Posted: 4th Sep 2008 19:27
i get this in the debug log , after changing it to ==
warning C4553: '==' : operator has no effect; did you intend '='?


i learned from the tutorials , but nothing..
i'm trying to figure it out.
..
hmmmm
still not working
and you said something abou the code tags, how do i use them?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 5th Sep 2008 03:48 Edited at: 5th Sep 2008 03:48
You've changed an operator on a line where you probably intended to do an assignment rather than a comparison.

Quote: "and you said something abou the code tags, how do i use them? "

Select your code in the edit box and hit the 'code' button.

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 12th Sep 2008 13:20 Edited at: 12th Sep 2008 13:32
you would need to add a dbSync(); into you while loop....thats the basic problem with why it wont work when it draws... essentially what a "while..do" loop does, is it tells your program to STOP COMPLETELY UNITL.. the condition the while loop is evaluating becomes true... this means that only the code inside that while loop is executing, every time you use a while loop, you need to ensure that you include an exit condition that can become true from code inside the while loop itself(which you have done, i think it was just the assignment operator in the while conditional you got mixed up)....

you while loop would look like this..



also, the value edit_mode, i assume is a boolean, declared somewhere in you program, for instance :

bool edit_mode;

otherwise if its an integer or something, the if and while statements would need to use logic operator "==" thats 2 equal signs... as oppsoed to the asignment operator "=" thats 1 equal sign... difference is that the logic operator evaluates the values on the left against the one on the right to be either true or false... the assignment operator will assign the value on the right of the operator, to the variable on the left of the operator( its saying make whats on the left of the equal sign the same as whats on the right)

Also you would need to be careful with long logic checks like you are doing with the mouse position, sometimes they might not return the result that you are expecting them too, read up on the Visual c++ compiler's operator precedence to find out how it evaluates logic operators, and making a few more checks that are slighly smaller may help

Lastly, im not sure if you missed it or its declared globally, the object number that you pass to create your objects in the function boxcreator would need to be defined and incremented each time the function is called if its called more than once.


Note: The code tags are HTML code tags that you can use to make the little "code snippet" clicky thingies(technical term there ).. the start code one is a set of square braces with the word "code" inside it, then the code snippet, then another set of square brackets with "/code" between them(without the quotations).. press the button at the top of the post message dialog that says code... then past in your code snippet, then click that button again. that button will put the html code tags down for you.

If it ain't broke.... DONT FIX IT !!!

Login to post a reply

Server time is: 2024-09-30 05:34:24
Your offset time is: 2024-09-30 05:34:24